/* Quint in the future's style: paper tiles edged in blue on the grainy sky.
   Correct is the theme's blue, present its gold, absent its muted ink. High
   contrast swaps them for vermilion and vivid blue, like Wordle's orange and blue. */
.quint-page {
  --w-correct: var(--blue);
  --w-present: var(--gold);
  --w-absent: var(--fmute);
  --w-mark-ink: var(--paper);
  --w-gap: clamp(4px, 1.2vw, 6px);
  --w-chrome: 400px;                    /* height of everything but the board */
}
.quint-page.contrast { --w-correct: var(--verm); --w-present: var(--blue); }

.quint-page .f-main.quint {
  width: min(520px, 100%);
  padding-top: 0; padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: clamp(10px, 2.2vh, 20px);
  min-height: calc(100svh - 72px);
}

/* ---------- title row ---------- */
.w-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
          padding: 14px 16px; background: var(--paper); border: var(--edge); box-shadow: var(--lift); }
.w-title { min-width: 0; }
.w-title .eyebrow { margin-bottom: 6px; white-space: nowrap; }
.w-timer { font-variant-numeric: tabular-nums; color: var(--blue); }
.w-timer::before { content: "·"; margin: 0 .55em 0 .25em; color: var(--fmute); }
.w-title h1[data-dots].small { font-size: clamp(30px, 8vw, 44px); line-height: 1.05; }
.w-tools { display: flex; gap: 6px; flex-shrink: 0; }
.w-icon { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; cursor: pointer;
          color: var(--blue); background: var(--paper); border: var(--edge); border-radius: 0;
          transition: background-color .15s, color .15s; }
.w-icon:hover { background: var(--blue); color: var(--paper); }
.w-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: square; }
.w-icon svg .dot { fill: currentColor; }

/* ---------- board ---------- */
.w-board-wrap { position: relative; flex: 1 1 auto; display: grid; place-items: center; min-height: 0; }
.w-board { display: grid; grid-template-rows: repeat(6, 1fr); gap: var(--w-gap);
           width: min(330px, 100%, calc((100svh - var(--w-chrome)) * 5 / 6)); min-width: 220px; aspect-ratio: 5 / 6; }
.w-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--w-gap); }

.w-tile { display: grid; place-items: center; aspect-ratio: 1; min-width: 0;
        font: 600 clamp(24px, 7vw, 32px)/1 var(--futura); text-transform: uppercase; color: var(--fink);
        background: rgba(247, 247, 230, .82); border: 1.5px solid rgba(31, 43, 255, .32); user-select: none; }
.w-tile[data-filled] { background: var(--paper); border-color: var(--blue); animation: w-pop .1s ease-out; }
.w-tile[data-state] { color: var(--w-mark-ink); border-color: transparent; }
.w-tile[data-state="correct"] { background: var(--w-correct); }
.w-tile[data-state="present"] { background: var(--w-present); }
.w-tile[data-state="absent"]  { background: var(--w-absent); }
.w-tile.flip { animation: w-flip .5s ease-in both; }
.w-tile.win { animation: w-bounce 1s ease both; }
.w-row.shake { animation: w-shake .6s; }

@keyframes w-pop { from { transform: scale(.82); } 40% { transform: scale(1.1); } to { transform: scale(1); } }
@keyframes w-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }
@keyframes w-shake {
  10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); }
}
@keyframes w-bounce {
  0%, 20% { transform: translateY(0); } 40% { transform: translateY(-30px); } 50% { transform: translateY(5px); }
  60% { transform: translateY(-15px); } 80% { transform: translateY(2px); } 100% { transform: translateY(0); }
}

/* ---------- messages ---------- */
.w-toasts { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 5; pointer-events: none;
            display: flex; flex-direction: column; align-items: center; gap: 6px; }
.w-toast { width: max-content; max-width: min(340px, calc(100vw - 48px)); padding: 12px 16px; text-align: center;
           font: 600 14px/1.3 var(--futura); letter-spacing: .04em;
           color: var(--paper); background: var(--fink); box-shadow: var(--lift); transition: opacity .3s; }
.w-toast.fade { opacity: 0; }
.w-dialog .w-toasts { top: 12px; }

/* ---------- keyboard ---------- */
.w-keyboard { display: flex; flex-direction: column; gap: 8px; width: 100%; user-select: none; touch-action: manipulation; }
.w-keys { display: flex; gap: 6px; justify-content: center; }
.w-keys .half { flex: .5; }
.w-key { flex: 1; min-width: 0; height: clamp(48px, 7.5vh, 58px); padding: 0; cursor: pointer;
         font: 600 clamp(13px, 3.6vw, 16px)/1 var(--futura); text-transform: uppercase; color: var(--blue);
         background: var(--paper); border: var(--edge); border-radius: 0; -webkit-tap-highlight-color: transparent;
         transition: background-color .15s, color .15s; }
.w-key.wide { flex: 1.5; font-size: 11px; letter-spacing: .14em; }
.w-key svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; vertical-align: middle; }
.w-key:hover { background: #fffff6; }
.w-key:active { background: var(--blue); color: var(--paper); }
.w-key[data-state] { color: var(--w-mark-ink); border-color: transparent; }
.w-key[data-state="correct"] { background: var(--w-correct); }
.w-key[data-state="present"] { background: var(--w-present); }
.w-key[data-state="absent"]  { background: var(--w-absent); opacity: .85; }

/* ---------- dialogs ---------- */
.w-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100svh - 48px); overflow: auto;
            padding: clamp(22px, 5vw, 32px); color: var(--fink); background: var(--paper);
            border: var(--edge); border-radius: 0; box-shadow: var(--lift); }
.w-dialog:focus { outline: none; }
.w-dialog::backdrop { background: rgba(20, 42, 107, .4); }
.w-dialog[open] { animation: w-rise .2s ease-out; }
@keyframes w-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.w-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0; cursor: pointer;
           font: 400 26px/1 var(--futura); color: var(--blue); background: none; border: 0; }
.w-close:hover { color: var(--fink); }
.w-dialog h2 { margin: 0 0 12px; font: 600 24px/1.2 var(--futura); color: var(--blue); }
.w-dialog ul { margin: 0 0 18px; padding-left: 20px; }
.w-dialog li { margin: 4px 0; }
.w-dialog p { margin: 6px 0 0; }
.w-help-label { font: 600 14px/1 var(--futura); margin-top: 14px !important; }
.w-example { display: flex; gap: 4px; margin-top: 14px; }
.w-example .w-tile { width: 38px; font-size: 20px; border-color: var(--blue); background: var(--paper); }
.w-example .w-tile[data-state] { border-color: transparent; }
.w-example .w-tile[data-state="correct"] { background: var(--w-correct); }
.w-example .w-tile[data-state="present"] { background: var(--w-present); }
.w-example .w-tile[data-state="absent"] { background: var(--w-absent); }
.w-help-foot { margin-top: 20px !important; padding-top: 14px; border-top: 1px solid rgba(31, 43, 255, .2); color: var(--fmute); }

.w-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 24px; text-align: center; }
.w-stats div { display: flex; flex-direction: column-reverse; }
.w-stats dd { margin: 0; font: 600 34px/1.1 var(--futura); color: var(--blue); font-variant-numeric: tabular-nums; }
.w-stats dt { font-size: 11px; line-height: 1.25; color: var(--fmute); }

.w-dist { display: grid; gap: 4px; }
.w-bar { display: grid; grid-template-columns: 14px 1fr; gap: 6px; align-items: center; font: 600 13px/1 var(--futura); }
.w-bar span { justify-self: start; min-width: 22px; padding: 4px 7px; text-align: right; color: var(--paper); background: var(--w-absent);
              font-variant-numeric: tabular-nums; }
.w-bar.current span { background: var(--w-correct); }

.w-today { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px !important;
           font-weight: 600; font-variant-numeric: tabular-nums; }
.w-today[hidden] { display: none; }
.w-today-gold { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); }
.w-points { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px;
            padding: 10px 14px; font-size: 14px; text-decoration: none; color: var(--blue) !important;
            border: var(--edge); transition: background-color .15s, color .15s; }
.w-points strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.w-points:hover { background: var(--blue); color: var(--paper) !important; }
.w-settings-foot { margin-top: 14px !important; font-size: 13px; color: var(--fmute); }

/* Until the server has sent the board, the keys wait. */
.w-keyboard.waiting { opacity: .55; pointer-events: none; }

.w-next { display: flex; align-items: center; justify-content: space-between; gap: 16px;
          margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(31, 43, 255, .2); }
.w-next[hidden] { display: none; }
.w-next .eyebrow { margin-bottom: 8px; }
.w-clock { margin: 0 !important; font: 600 30px/1 var(--futura); color: var(--blue); font-variant-numeric: tabular-nums; }
.w-next .btn { min-width: 132px; min-height: 48px; }

.w-setting { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; cursor: pointer;
             border-bottom: 1px solid rgba(31, 43, 255, .2); }
.w-setting:last-child { border-bottom: 0; }
.w-setting strong { display: block; font-weight: 600; }
.w-setting small { display: block; font-size: 12px; color: var(--fmute); }
/* A square switch in the theme's blue. */
.w-setting input[type=checkbox] { appearance: none; flex-shrink: 0; position: relative; width: 40px !important; height: 22px !important;
                                  margin: 0; cursor: pointer; background: rgba(79, 95, 143, .35); border: var(--edge); transition: background-color .15s; }
.w-setting input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
                                         background: var(--paper); transition: transform .15s; }
.w-setting input[type=checkbox]:checked { background: var(--blue); }
.w-setting input[type=checkbox]:checked::after { transform: translateX(18px); }
.w-setting input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }

/* Phones: the header wraps to two rows, so the board gives up the room. */
@media (max-width: 620px) {
  .quint-page { --w-chrome: 430px; }
  .quint-page .f-main.quint { min-height: 0; }
  .w-head { padding: 10px 12px; }
  .w-key { height: 50px; }
  .w-keyboard { gap: 6px; }
  .w-keys { gap: 5px; }
}
@media (max-height: 640px) {
  .w-head { padding: 10px 12px; }
  .w-title .eyebrow { display: none; }
  .w-key { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .w-tile[data-filled], .w-tile.flip, .w-tile.win, .w-row.shake, .w-dialog[open] { animation: none; }
}
