:root {
    color-scheme: light;
    --ts-page: #f7f5ed;
    --ts-panel: #fffdf7;
    --ts-field: #f5f1e6;
    --ts-hover: #ece9db;
    --ts-field-line: #b9b8a8;
    --ts-accent-fill: #f6dfca;
    --ts-accent-ink: #8e3827;
    --ts-primary-ink: #fff;
    --ts-ink: #1b3440;
    --ts-muted: #56646a;
    --ts-line: #d9d8c9;
    --ts-accent: #a2402c;
    --ts-type: "DM Sans", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    --face: #f8ecd5;
    --edge: #aa9e86;
}
html, body { background: var(--ts-page); }
body::before { content: none; }
.typestack {
    min-height: 100vh;
    color: var(--ts-ink);
    background: var(--ts-page);
    font: 500 15px/1.45 var(--ts-type);
    -webkit-font-smoothing: antialiased;
}
.typestack [hidden] { display: none !important; }
.typestack h1, .typestack h2, .typestack h3 { color: inherit; font-family: inherit; overflow-wrap: normal; }
.typestack :is(button, input, select) { font: inherit; color: inherit; }
.typestack button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.typestack button:disabled { cursor: default; }
.typestack :is(button, input, select):focus-visible { outline: 3px solid var(--ts-accent); outline-offset: 3px; }
.gamebar { background: var(--ts-panel); border-bottom: 1px solid var(--ts-line); }
/* iOS applies its scroll-edge blur beyond the reported safe area. */
.ios-standalone {
    --ts-top-edge: calc(env(safe-area-inset-top, 0px) + 32px);
    scroll-padding-top: var(--ts-top-edge);
}
.ios-standalone .gamebar { padding-top: var(--ts-top-edge); }
.ios-standalone #milestone { top: calc(var(--ts-top-edge) + 8px); }
.ios-standalone .typestack dialog {
    top: var(--ts-top-edge);
    max-height: calc(100dvh - var(--ts-top-edge) - 30px);
}
.gamebar-inner {
    width: min(840px, calc(100% - 56px));
    min-height: 75px;
    margin: auto;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.gamebar h1 { flex: none; display: flex; align-items: center; gap: 9px; font-size: 30px; font-weight: 850; letter-spacing: -.07em; line-height: 1; }
.gamebar h1 img { display: block; border-radius: 8px; }
.gamebar nav { min-width: 0; }
.gamebar nav svg {
    width: 21px; height: 21px; fill: none; stroke: currentColor;
    stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.gamebar nav, .dialog-actions { display: flex; align-items: center; gap: 8px; }
.typestack .action, .typestack .close {
    display: inline-flex; justify-content: center; align-items: center; gap: 7px;
    min-height: 40px; border: 1px solid transparent; border-radius: 11px; padding: 8px 15px;
    font-size: 14px; line-height: 1; font-weight: 700; white-space: nowrap;
}
.typestack .primary { background: var(--ts-ink); color: var(--ts-primary-ink); box-shadow: inset 0 -2px 0 #06061945; }
.typestack .leaderboard-action { background: var(--ts-field); border-color: var(--ts-field-line); }
.typestack :is(.leaderboard-action, [data-standings]):disabled { color: var(--ts-muted); opacity: .4; }
.typestack .subtle, .typestack .close { background: transparent; }
.typestack .primary:disabled { opacity: .48; }
.primary > span { font-size: 21px; line-height: 14px; }
.help-icon { display: inline-grid; place-items: center; border: 1.6px solid currentColor; width: 16px; height: 16px; border-radius: 50%; font-size: 12px; }
.game-table { width: min(610px, calc(100% - 24px)); margin: auto; padding: clamp(22px, 4.2vh, 44px) 0 52px; }
.round-stats { display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: center; gap: 1px 12px; margin: 0 3px 3px; }
.score-caption { grid-column: 1 / -1; font-size: 12px; line-height: 1.2; color: var(--ts-muted); font-weight: 650; }
#score {
    font-size: clamp(40px, 4.6vw, 55px); line-height: .95; letter-spacing: -.075em;
    font-weight: 800; font-variant-numeric: tabular-nums; transform-origin: left bottom;
}
.score-line { display: flex; position: relative; align-items: center; width: fit-content; }
.score-comparison {
    margin: 14px 0;
    padding: 15px 16px 12px;
    border: 1px solid var(--ts-line);
    border-radius: 10px;
    background: var(--ts-panel);
}
section.score-comparison:has(figure[hidden]) { display: none; }
#score-gain { display: none; }
.personal-best { color: var(--ts-accent-ink); font-variant-numeric: tabular-nums; }
#milestone {
    position: fixed; z-index: 10; top: max(16px, env(safe-area-inset-top)); left: 50%;
    transform: translateX(-50%); pointer-events: none; width: max-content;
    --ticket: #dce9e8; --ticket-edge: #91a9a9; --ticket-ink: #23434b;
}
#milestone.record-ticket { --ticket: #ffe2a1; --ticket-edge: #d5ae65; --ticket-ink: #48331f; }
.score-ticket {
    display: flex; align-items: center; gap: 13px; padding: 10px 22px 10px 12px;
    border: 1px solid var(--ticket-ink); border-radius: 12px; color: var(--ticket-ink);
    background: var(--ticket); box-shadow: 0 3px var(--ticket-edge), 0 4px var(--ticket-ink), 0 9px 17px #20192c26;
    transform: rotate(-2deg);
}
.ticket-seal {
    display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
    background: var(--ticket-ink); color: var(--ticket); font: 38px/1 var(--ts-type);
}
.score-ticket > span + span { border-left: 1px dashed var(--ticket-edge); padding-left: 13px; }
#milestone-label { display: block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
#milestone-score { display: block; font-size: 29px; line-height: 1.05; letter-spacing: -.06em; }
.ticket-burst { display: none; }
@media (prefers-reduced-motion: no-preference) {
    [data-impact="match"] #score { animation: score-press 330ms ease-out; }
    [data-impact="match"] #score-gain {
        display: block; position: absolute; left: calc(100% + 10px); white-space: nowrap;
        padding: 2px 8px; border-radius: 6px; background: var(--ts-accent-fill); color: var(--ts-accent-ink);
        font-size: 14px; font-weight: 800; animation: score-gain 950ms ease-out both;
    }
    .stack[data-tile="wild"]:enabled .tile-face { overflow: hidden; }
    .stack[data-tile="wild"]:enabled .tile-face::after {
        content: ""; position: absolute; inset: -35% -50%; pointer-events: none;
        background: linear-gradient(110deg, transparent 39%, #fff8 48%, transparent 56%);
        animation: wild-foil 5.8s ease-in-out infinite;
    }
    .stack[data-tile="wild"][aria-pressed="true"] .glyph, .just-placed.from-wild .glyph {
        animation: wild-turn 350ms cubic-bezier(.2,.8,.2,1);
    }
    .score-ticket { animation: ticket-stamp 2.3s both; }
    .ticket-burst { display: block; position: absolute; inset: 66% 0 auto; }
    .ticket-burst i {
        position: absolute; left: calc(10% + var(--ray) * 7%); width: 5px; height: 11px;
        border-radius: 2px; background: #80a2a3; --angle: calc((var(--ray) - 5.5) * -14deg);
        animation: paper-burst 690ms cubic-bezier(.16,.72,.32,1) both;
    }
    .ticket-burst i:nth-child(3n + 1) { background: #efba61; height: 7px; }
    .ticket-burst i:nth-child(3n + 2) { background: #c58164; width: 4px; }
    @keyframes score-press { 35% { transform: scale(1.13); color: var(--ts-accent); } }
    @keyframes score-gain {
        0% { opacity: 0; transform: translate(-5px,6px) scale(.8); }
        22%, 65% { opacity: 1; transform: translate(0,0); }
        100% { opacity: 0; transform: translateY(-11px); }
    }
    @keyframes wild-foil { 0%, 75% { transform: translateX(-80%); } 100% { transform: translateX(80%); } }
    @keyframes wild-turn { from { transform: rotate(-30deg) scale(.6); } 65% { transform: rotate(7deg) scale(1.12); } }
    @keyframes ticket-stamp {
        0% { transform: translateY(-18px) rotate(5deg) scale(.82); }
        10% { opacity: 1; transform: translateY(3px) rotate(-4deg) scale(1.04); }
        17%, 87% { opacity: 1; transform: rotate(-2deg); }
        100% { opacity: 0; transform: translateY(-10px) rotate(-2deg); }
    }
    @keyframes paper-burst {
        from { opacity: 0; transform: rotate(var(--angle)) translateY(0) scale(.4); }
        20% { opacity: 1; }
        to { opacity: 0; transform: rotate(var(--angle)) translateY(60px) rotate(95deg); }
    }
}
#show-leaderboard, #show-player { min-width: 54px; min-height: 44px; padding-inline: 8px; }
.round-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.round-actions .action { flex: 0 0 auto; }
.round-divider { flex: 0 0 1px; height: 18px; margin-inline: 3px; background: var(--ts-line); }
#undo-label { flex: none; white-space: nowrap; overflow-wrap: normal; }
.round-actions .subtle { border-color: var(--ts-field-line); }
.round-actions .primary:disabled { white-space: normal; background: var(--ts-field); border-color: var(--ts-field-line); color: var(--ts-muted); opacity: .8; box-shadow: none; }

.road-count { margin: 8px 0; text-align: center; font-size: 13px; font-weight: 650; color: var(--ts-muted); }
[data-renderer="webgl"] .road-count, .personal-best:not([hidden]) + .score-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.word-board {
    display: grid; grid-template-columns: repeat(var(--slots, 5), minmax(0, 1fr)); gap: clamp(4px, 1vw, 7px);
    background: #234350; border: 1px solid #355561; border-bottom: 3px solid #172f39;
    padding: clamp(5px, 1.4vw, 8px); border-radius: 17px;
}
/* A single viewport holds the physical board from the first placement to street view. */
.view-caption { display: flex; align-items: baseline; justify-content: space-between; margin: 0 3px 7px; }
.view-caption span, .street-numbers { font: 650 12px/1.2 var(--ts-type); color: var(--ts-muted); }
.board-stage { position: relative; }
.game-table .board-stage { margin-inline: -8px; }
.field-width { position: absolute; inset: 0 0 auto; height: 0; visibility: hidden; pointer-events: none; }
.board-stage[data-renderer="webgl"] {
    aspect-ratio: var(--field-aspect, 1); overflow: hidden; border-radius: 16px;
    border: 1px solid #a6b9b8; background: #dbe5df; isolation: isolate;
    touch-action: pinch-zoom; overscroll-behavior: contain; user-select: none; -webkit-user-select: none;
}
.scene-viewport, .scene-viewport canvas { display: block; height: 100%; width: 100%; }
.scene-viewport { position: absolute; inset: 0; visibility: hidden; background: linear-gradient(158deg,#d7e7e8 0%,#e7eee8 55%,#f1eadc 100%); }
[data-renderer="webgl"] > .scene-viewport { visibility: visible; }
#skyline[tabindex="0"] { cursor: grab; touch-action: none; }
#skyline[tabindex="0"]:active { cursor: grabbing; }
#skyline:focus-visible { outline: 3px solid var(--ts-accent); outline-offset: -4px; }
.street-numbers { display: none; }
[data-finished="true"] .street-numbers {
    display: flex; align-items: center; gap: .7em; position: absolute; bottom: 7px; left: 50%;
    transform: translateX(-50%); padding: 3px 10px; border-radius: 8px;
    color: #354c53; background: #f5f4e9de; font-variant-numeric: tabular-nums; pointer-events: none;
}
[data-renderer="basic"] .scene-viewport canvas { display: none; }
[data-finished="true"] [data-renderer="basic"] { padding-bottom: 25px; }
[data-finished="true"] [data-renderer="basic"] .scene-viewport { visibility: visible; }
[data-finished="true"] .playing-area [data-renderer="webgl"] .word-board { visibility: hidden; }
.practice-stage[data-renderer="webgl"] { aspect-ratio: var(--field-aspect, 1.6); }
.typestack .slot {
    display: block; appearance: none; position: relative; min-width: 0; aspect-ratio: 1 / 1.02;
    background: #304f5b; border: 1px solid #54717b; border-radius: 10px;
    box-shadow: inset 0 2px 2px #373b6f0c; touch-action: manipulation;
}
/* Catch the tile over the facade while the finger is below the roof. */
.board-stage:has(.lifted) .word-board > button::before {
    content: ""; position: absolute; inset: -15% -2.1% -50%;
}
.slot[data-letter=""]::after {
    content: ""; position: absolute; inset: calc(50% - 5px) calc(50% - 5px);
    background: linear-gradient(#93aaa9, #93aaa9) center / 1px 100% no-repeat,
                linear-gradient(#93aaa9, #93aaa9) center / 100% 1px no-repeat;
}
.slot .tile-face { display: none; }
.tile-face, .tile-layer {
    position: absolute; display: grid; place-items: center; left: 0; right: 0; bottom: 0;
    width: 100%; aspect-ratio: 1; border: 1.6px solid var(--edge); border-radius: 9px;
    background: linear-gradient(160deg, #fff 18%, var(--face) 90%);
    color: var(--ts-ink); box-shadow: inset 0 1px 0 white, inset 0 -2px 0 #ddd2bb;
    pointer-events: none;
}
.tile-face .glyph { font: 800 clamp(27px, 4.4vw, 41px)/1 var(--ts-type); letter-spacing: -.045em; transform: translateY(1px); }
.tile-value {
    position: absolute; top: 5px; right: 6px; color: #515b58;
    font: 750 11px/1 var(--ts-type); font-variant-numeric: tabular-nums;
}
.slot[data-letter]:not([data-letter=""]) .tile-face {
    display: grid; height: 100%; top: -2px; left: -1px; right: -1px; width: calc(100% + 2px);
    border-color: #a59e89; box-shadow: inset 0 -3px 0 #ddcfb6, 0 3px 0 #a19580;
}
.slot .glyph { font-size: clamp(31px, 7.3vw, 56px); }
.slot .tile-value { font-size: clamp(11px, 1.3vw, 14px); top: 7px; right: 8px; }
.slot[data-armed="true"] { border-color: #d1a879; }
.typestack .slot.drop-target { background: #677577; outline: 3px solid #e8b473; outline-offset: -2px; }
.slot.drop-target .tile-face { border-color: var(--ts-accent); filter: brightness(.95); }
.playing-area { overflow-anchor: none; }
.feedback {
    display: flex; align-items: center; flex-wrap: wrap; column-gap: 6px;
    min-height: 40px; margin: 0 3px; padding-block: 8px;
    font-size: 13px; line-height: 1.3; color: var(--ts-muted);
}
[data-finished="true"] .feedback { min-height:0; margin:0; padding:0; }
[data-feedback="scored"] #message { color: var(--ts-accent-ink); font-weight: 750; }
.typestack #suggest-word {
    min-height: 24px; padding: 0; border: 0; background: none;
    font-weight: 750; text-decoration: underline; text-underline-offset: 3px;
}
.typestack .text-action { background: none; border: none; text-decoration: underline; font-weight: 700; padding: 2px 6px; }
.rack {
    background: #ece9dc; border: 1px solid #ceccbc;
    border-radius: 14px; padding: 17px clamp(12px, 3.5vw, 24px) 20px;
    box-shadow: inset 0 1px 0 #ffffffa6, 0 2px 0 #a7a28e44;
}
.view-caption h2, .log-head h2 { font-size: 16px; font-weight: 750; letter-spacing: -.035em; line-height: 1.2; }
#letters {
    --gap: clamp(6px, 1.5vw, 12px); --step: 3.5px;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px var(--gap);
}
.board-stage:not([data-renderer="webgl"]) #letters[data-columns="6"] {
    grid-template-columns:repeat(12,minmax(0,1fr));
}
.board-stage:not([data-renderer="webgl"]) #letters[data-columns="6"] .stack { grid-column:span 2; }
.board-stage:not([data-renderer="webgl"]) #letters[data-columns="6"] :is([data-tile="wild"], [data-tile="blank"]) { grid-column:6 / span 2; }
.board-stage:not([data-renderer="webgl"]) #letters[data-columns="6"] [data-tile="wild"]:has(+ [data-tile="blank"]) { grid-column:5 / span 2; }
.board-stage:not([data-renderer="webgl"]) #letters[data-columns="6"] [data-tile="wild"] + [data-tile="blank"] { grid-column:7 / span 2; }
.typestack .stack {
    position: relative; border: 0; border-radius: 9px; background: none; padding: 0; outline-offset: 3px;
    width: 100%;
    aspect-ratio: 1 / 1.24; min-width: 0;
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    cursor: grab;
}
.stack .tile-layer { transform: translateY(calc(-1 * var(--level) * var(--step))); background: #f1e9d7; box-shadow: inset 0 -1px 0 #dcd2bb, 0 1px 0 #a99e85; }
.stack .tile-face {
    transform: translateY(calc(-1 * var(--depth) * var(--step)));
    box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 #e0d4bb, 0 2px 0 #a99b80, 0 3px 4px #4b3e2418;
}
.stack[data-empty="true"] .tile-face {
    background: transparent; border: 1px dashed #b9b5a5; box-shadow: none; color: #65706a;
}
.stack[data-empty="true"] .tile-value { opacity: .65; }
.stack[aria-pressed="true"] .tile-face { outline: 3px solid var(--ts-accent); outline-offset: 1px; }
.stack.lifted .tile-face { opacity: .36; outline: 0; }
.stack:not([data-empty="true"]):disabled .tile-face { filter: saturate(.67); }
.tile-kind { position: absolute; bottom: 5px; font: 800 8px/1 var(--ts-type); letter-spacing: .06em; text-transform: uppercase; }
:is([data-tile="wild"], [data-practice-tile="wild"]) .tile-face, .slot.from-wild .tile-face, .tile-face.drag-ghost[data-tile="wild"] {
    background: linear-gradient(145deg, #ffdda4 3%, #f6c99d 38%, #f0bd96 69%, #edb5a5 100%);
    border-color: #b78360; box-shadow: inset 0 1px 0 #ffffffa1, inset 0 -2px 0 #d7a585, 0 2px 0 #b3876a;
}
:is([data-tile="blank"], [data-practice-tile="blank"]) .tile-face, .tile-face.drag-ghost[data-tile="blank"] {
    background: linear-gradient(145deg, #edfcff, #b9e2ee);
    border-color: #85b3c2; box-shadow: inset 0 1px 0 #fff9, inset 0 -2px 0 #b2d8e5, 0 2px 0 #90b5c4;
}
.stack[data-tile="wild"] .glyph, .stack[data-tile="blank"] .glyph,
.drag-ghost[data-tile="wild"] .glyph, .drag-ghost[data-tile="blank"] .glyph {
    font: 700 clamp(25px, 4vw, 38px)/1 var(--ts-type); letter-spacing: 0; transform: none;
}
.tile-face.drag-ghost { position: fixed; inset: 0 auto auto 0; z-index: 1500; opacity: .94; box-shadow: 0 13px 24px #22224540; margin: 0; }
.word-log { margin: 22px 3px 0; padding-top: 15px; border-top: 1px solid var(--ts-line); }
.log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
#word-count, .save-note { color: var(--ts-muted); font-size: 13px; }
.save-note { margin-top: 8px; }
#word-list { margin:10px 0 0; }
.word-chain { display:flex; flex-wrap:wrap; gap:6px; list-style:none; margin:0; padding:0; }
.word-chain + .word-chain { margin-top:8px; padding-top:8px; border-top:1px solid var(--ts-line); }
.word-chain li { position:relative; }
.word-chain li + li { margin-inline-start:14px; }
.word-arrow { position:absolute; left:-14px; width:13px; text-align:center; color:var(--ts-muted); font:400 12px/1 var(--ts-type); top:50%; transform:translateY(-50%); }

#word-list:empty { display: none; }
#word-list li { display: inline-flex; align-items: baseline; gap: 6px; background: var(--ts-hover); border-radius: 7px; padding: 4px 8px; font-size: 13px; }
#word-list .word-chain:first-child > li:first-child { color: var(--ts-accent-ink); background: var(--ts-accent-fill); }
#word-list b { font-weight: 750; }
#word-list span { font-size: 11px; font-weight: 600; }
.typestack dialog { margin: auto; width: min(405px, calc(100% - 28px)); max-height: calc(100dvh - 30px); padding: 22px; border: 1px solid var(--ts-line); border-radius: 18px; background: var(--ts-panel); color: var(--ts-ink); box-shadow: 0 25px 80px #2920463d; }
.typestack dialog::backdrop { background: #24243b70; }
.dialog-head, .lesson-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.dialog-head h2 { font-size: 26px; line-height: 1.08; letter-spacing: -.055em; font-weight: 800; }
.typestack .close { flex-shrink: 0; width: 36px; height: 36px; padding: 0; min-height: 36px; background: var(--ts-field); font-size: 24px; }
.typestack dialog p { font-size: 14px; line-height: 1.45; margin: 12px 0; }
#help { width: min(424px, calc(100% - 24px)); }
.lesson-head h2 { margin: 0; font-size: 15px; font-weight: 750; }
.lesson-skip { border: 0; background: transparent; min-height: 40px; padding: 4px; color: var(--ts-muted); }
.lesson-progress { display: flex; gap: 5px; margin: 8px 0 22px; }
.lesson-progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--ts-line); }
.lesson-progress i.filled { background: var(--ts-accent); }
#lesson-title { margin: 0; font-size: clamp(24px, 7vw, 32px); letter-spacing: -.05em; line-height: 1.12; }
#help #lesson-prompt { margin: 7px 0 16px; min-height: 2.9em; }
.practice-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 13px; color: var(--ts-muted); }
#practice-score { margin-left: 3px; font-size: 17px; color: var(--ts-ink); font-variant-numeric: tabular-nums; }
#practice-result { color: var(--ts-accent-ink); }
#practice-board .glyph { font-size: clamp(25px, 8vw, 37px); }
#practice-board .tile-value { font-size: 10px; top: 3px; right: 5px; }
.practice-stage:not([data-renderer="webgl"]) .lesson-target { outline: 3px solid var(--ts-accent); outline-offset: -2px; }
.practice-stage:not([data-renderer="webgl"]) [data-stock] { display: flex; justify-content: center; gap: 9px; margin: 15px 0; padding: 10px; background: var(--ts-field); border-radius: 12px; }
#practice-rack .stack { flex: 0 1 54px; aspect-ratio: 1; --depth: 0; --step: 0px; }
#practice-rack .glyph { font-size: 26px; }
#practice-rack .tile-value { font-size: 10px; top: 3px; right: 4px; }
#practice-rack .tile-kind { bottom: 2px; font-size: 7px; }
#practice-rack .stack:disabled { opacity: .52; }
#practice-rack .stack[data-spent="true"] { visibility: hidden; }
#practice-choices { margin: 16px auto; grid-template-columns: repeat(3, 48px); justify-content: center; }
#practice-finish { display: flex; margin: 18px auto; }
.lesson-reference { border-top: 1px solid var(--ts-line); }
.lesson-reference summary, #solution summary { padding: 10px 0; color: var(--ts-muted); font-size: 13px; cursor: pointer; }
#preferences:not(:empty) { padding-top: 8px; }
#mix .mix-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--ts-line); }
#mix :is(input, select) { width: 112px; min-height: 36px; padding: 6px; background: var(--ts-field); color: var(--ts-ink); border: 1px solid var(--ts-field-line); border-radius: 7px; }
@media (pointer: coarse) { #mix :is(input, select) { min-height: 44px; font-size: 16px; } }
.dialog-actions { margin-top: 15px; flex-wrap: wrap; }
.alphabet { display: grid; grid-template-columns: repeat(auto-fit,minmax(44px,1fr)); gap: 5px; }
.alphabet button { background: var(--ts-field); border: 1px solid var(--ts-field-line); border-bottom-width: 2px; border-radius: 7px; min-height: 42px; font-size: 22px; font-weight: 750; }
.alphabet button:disabled { opacity: .35; }
.laptop-hint, .slot-key { display: none; }

@media (any-pointer: fine) {
    .laptop-hint {
        display: block;
        margin: 8px 0 0;
        color: var(--ts-muted);
        font-size: 13px;
        text-align: center;
    }
    .slot[data-armed="true"] .slot-key, .slot.lesson-target .slot-key {
        position: absolute;
        left: 5%;
        bottom: 5%;
        display: grid;
        place-items: center;
        min-width: 1.6em;
        height: 1.6em;
        border: 1px solid #ffffffa6;
        border-radius: 4px;
        background: #213842;
        color: white;
        font: 750 11px/1 var(--ts-type);
        font-variant-numeric: tabular-nums;
        pointer-events: none;
    }
}

@media (hover: hover) {
    .typestack :is(.subtle, .leaderboard-action):not(:disabled):hover { background: var(--ts-hover); }
    .typestack .primary:hover { filter: brightness(.9); }
    .stack:not(:disabled):not(.lifted):hover .tile-face { border-color: var(--ts-accent); }
    .slot[data-armed="true"]:hover { outline: 2px solid #e8b473; outline-offset: -2px; }
    .alphabet button:not(:disabled):hover { background: var(--ts-accent-fill); }
}
@media (max-width: 580px) {
    .gamebar-inner { width: calc(100% - 28px); min-height: 60px; flex-wrap: wrap; gap: 4px 6px; padding-block: 6px; }
    .gamebar h1 { flex-shrink: 1; font-size: 25px; gap: 6px; }
    .gamebar h1 img { width: 31px; height: 31px; }
    .gamebar nav { flex-shrink: 0; margin-inline-start: auto; }
    .gamebar .action { padding: 7px 8px; font-size: 13px; }
    .gamebar #show-help { padding-inline: 10px 0; border: 0; }
    .gamebar .help-label { display: none; }
    .gamebar .help-icon { width: 19px; height: 19px; font-size: 14px; }
    .game-table { padding-top: 20px; }
    .round-actions .action { padding-inline: 10px; min-height: 42px; }
    .word-board { border-radius: 13px; }
    .typestack .slot { border-radius: 7px; }
    .feedback { font-size: 12px; }
    .rack { border-radius: 15px; padding: 13px 12px 15px; }
    #letters { --gap: 7px; --step: 3px; }
    .tile-face, .tile-layer { border-radius: 6px; }
    .tile-value { top: 3px; right: 4px; font-size: 9px; }
    .slot .tile-value { top: 4px; right: 5px; }
    .tile-kind { font-size: 6.5px; bottom: 3px; }
    .word-log { margin-top: 18px; padding-top: 12px; }
}
@media (max-width: 374px) {
    .round-stats { column-gap: 4px; }
    .round-actions { gap: 4px; }
    .round-divider { margin-inline: 2px; }
    .round-actions .action { font-size: 13px; gap: 4px; padding-inline: 6px; }
    #score { font-size: 36px; }
}
@media (max-width: 410px) {
    .gamebar-inner { width: calc(100% - 20px); }
    .gamebar h1 { font-size: 22px; }
    .gamebar h1 img { width: 27px; height: 27px; }
    .gamebar .primary > span { display: none; }
    .gamebar .action { font-size: 12px; padding-inline: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
    .slot.drop-target, .stack .tile-face { transition: outline-color 80ms, border-color 80ms; }
}

#solution { border-top: 1px solid var(--ts-line); padding-top: 10px; }
#solution summary { color: var(--ts-accent-ink); font-weight: 700; cursor: pointer; }
#solution-list { list-style-position: inside; font-size: 13px; padding: 0; }
#solution-list li { padding: 4px 0; border-bottom: 1px solid var(--ts-line); }
#solution-list b { float: right; letter-spacing: .04em; }

#next-day, .results-link, .results-page a { color: var(--ts-accent); font-weight: 650; }
.results-link { display: inline-block; margin: 16px 3px 0; font-size: 13px; }
#name-form { display: grid; gap: 12px; margin-top: 15px; }
#player-name { width: 100%; padding: 10px; background: var(--ts-field); border: 1px solid var(--ts-field-line); border-radius: 8px; font-size: 16px; }
#name-form button { justify-self: start; }
.typestack .daily-test { margin-top: 16px; color: var(--ts-accent); }
.results-page { padding: 32px max(16px, calc((100% - 760px) / 2)); }
.results-page h1 { margin: 18px 0; font-size: 32px; }
.results-scroll { overflow-x: auto; }
.results-page table { width: 100%; border-collapse: collapse; text-align: left; }
.results-page td, .results-page th { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--ts-line); }

#name-form .dialog-actions { margin-top: 2px; }
#leaderboard .standings-date { margin: 4px 0 15px; color: var(--ts-muted); }
#standings-status:empty { display: none; }
.standings-scroll { max-height: min(55dvh, 460px); overflow: auto; }
.standings { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.standings caption { text-align: left; font-size: 15px; font-weight: 750; padding-bottom: 4px; }
.standings th { position: sticky; top: 0; background: var(--ts-panel); color: var(--ts-muted); font-size: 12px; }
.standings :is(th, td) { padding: 9px 7px; border-bottom: 1px solid var(--ts-line); }
.standings :is(th, td):first-child { width: 3em; padding-left: 0; color: var(--ts-muted); }
.standings td:nth-child(2) { overflow-wrap: anywhere; }
.standings :is(th, td):last-child { text-align: right; padding-right: 0; }
.standings td:last-child { font-weight: 750; }

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --ts-page: #14252e; --ts-panel: #1c303a; --ts-field: #293e48;
        --ts-ink: #f4efe1; --ts-muted: #bdc9c8; --ts-line: #3c535b; --ts-field-line: #536970;
        --ts-accent: #f3b28c; --ts-hover: #324850; --ts-accent-fill: #503c32; --ts-accent-ink: #ffcfaa;
        --ts-primary-ink: #20333b; --face: #304850; --edge: #75898a;
    }
    .board-stage[data-renderer="webgl"] { border-color: #354e60; background: #101e32; }
    .scene-viewport { background: linear-gradient(180deg,#0a1428,#192c49 62%,#354359); }
    [data-renderer="basic"] .road-count {
        color: #ffebbd; padding: 5px; border-radius: 5px;
        background: radial-gradient(ellipse at 25% 0, #514238, transparent 48%),
            radial-gradient(ellipse at 75% 0, #514238, transparent 48%), #1b2c3c;
    }
    [data-finished="true"] .street-numbers { color: #dce7e5; background: #1a2e40ea; }
    .word-board { background: #203b48; border-color: #5b747c; border-bottom-color: #142b34; }
    .typestack .slot { background: #284653; border-color: #486772; box-shadow: inset 0 2px 4px #10101870; }
    .rack { background: #233841; border-color: #445b61; box-shadow: inset 0 1px 0 #62818050; }
    .tile-face, .tile-layer { background: linear-gradient(150deg, #3e5760, var(--face)); box-shadow: none; }
    .stack .tile-layer { background: #344a51; box-shadow: inset 0 -1px 0 #25373c, 0 1px 0 #11262e; }
    .stack .tile-face, .slot[data-letter]:not([data-letter=""]) .tile-face {
        border-color: var(--edge); box-shadow: inset 0 1px 0 #65787b, inset 0 -2px 0 #25373c, 0 2px 0 #12272e;
    }
    .tile-value { color: #d2dfda; }
    .stack[data-empty="true"] .tile-face { color: #a4b3af; background: transparent; border-color: #5c7276; box-shadow: none; }
    :is([data-tile="wild"], [data-practice-tile="wild"]) .tile-face, .slot.from-wild .tile-face, .tile-face.drag-ghost[data-tile="wild"] {
        background: linear-gradient(145deg, #825437, #7e533d 40%, #714e40 70%, #614a45);
        border-color: #bf9c7d; box-shadow: inset 0 -2px 0 #634836, 0 2px 0 #302b26;
    }
    :is([data-tile="blank"], [data-practice-tile="blank"]) .tile-face, .tile-face.drag-ghost[data-tile="blank"] {
        background: linear-gradient(145deg, #2f5868, #224553); border-color: #76a3b2;
        box-shadow: inset 0 -2px 0 #193743, 0 2px 0 #142b33;
    }
    .slot[data-armed="true"] { border-color: var(--ts-accent); }
    .typestack .slot.drop-target { background: #645a46; outline-color: var(--ts-accent); }
    .typestack dialog::backdrop { background: #0b0c16ae; }
}


.round-actions #undo:disabled { opacity: .55; }
.board-stage:not([data-renderer="webgl"]) .city-rack { margin-top: 10px; }
.board-stage[data-renderer="webgl"] .city-rack { display: contents; }
[data-renderer="webgl"] .word-board, [data-renderer="webgl"] [data-stock]:not([hidden]) {
    display: block; position: absolute; inset: 0; padding: 0; margin: 0; pointer-events: none;
    background: transparent; border: 0; box-shadow: none;
}
.typestack [data-renderer="webgl"] :is(.word-board, [data-stock]) > button {
    position: absolute; min-width: 0; padding: 0; aspect-ratio: auto; pointer-events: auto;
    transform: none; background: transparent; border: 0; box-shadow: none; outline: none;
}
[data-renderer="webgl"] :is(.tile-face, .layers), [data-renderer="webgl"] .slot::after { visibility: hidden; }
[data-finished="true"] .playing-area .city-rack { display: none; }

@media (min-width: 680px) {
    .game-table .board-stage { margin-inline: -24px; }
    .game-table {
        width: min(610px, max(430px, calc(82svh - 210px)), calc(100% - 24px));
        padding-top: clamp(14px, 2.25vh, 24px);
    }
    .gamebar-inner { min-height: 65px; }
}

/* Wait for this player’s issued tile faces before showing a new daily rack. */
.game-table[inert] .playing-area { visibility: hidden; }

/* Flat faces use the same letter rims and the lit appearance of the enamel roofs. */
:root { --enamel-roof: #f6faf9; --enamel-ink: #132d44; }
@media (prefers-color-scheme: dark) {
    :root { --enamel-roof: #484b4e; --enamel-ink: #f5f7ed; }
}
.stack:not([data-empty="true"]) .tile-face.enamel,
.slot[data-letter]:not([data-letter=""]) .tile-face.enamel,
.tile-face.drag-ghost.enamel {
    background: var(--enamel-roof); color: var(--enamel-ink); border-color: var(--letter-wall);
    box-shadow: inset 0 -2px 0 var(--letter-wall), 0 2px 0 var(--letter-wall);
}
.tile-face.enamel .tile-value { color: inherit; font-weight: 850; }

#share-controls:not([hidden]) { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:8px 14px; margin:0 0 16px; }

.result-totals:not([hidden]) { display:grid; grid-template-columns:repeat(3,1fr); width:100%; gap:5px; margin:0; padding:13px 8px; background:var(--ts-panel); color:var(--ts-ink); border:1px solid var(--ts-field-line); border-top:0; }
.result-totals div { display:flex; flex-direction:column-reverse; align-items:center; }
.result-totals dt { font:600 clamp(10px,2.8vw,13px)/1.25 var(--ts-type); text-align:center; }
.result-totals dd { margin:0 0 3px; font:800 22px/1.2 var(--ts-type); }
#share-result { width:100%; min-height:48px; display:flex; align-items:center; justify-content:center; gap:11px; background:#202020; color:#fff; border:1px solid #202020; border-radius:0 0 9px 9px; font:750 17px/1.2 var(--ts-type); cursor:pointer; }
#share-result:hover { background:#343434; }
.result-link-field { width:100%; padding:8px; font-size:16px; }
#share-totals + #share-result { margin-top:-8px; }
.copy-symbol { display:inline-block; position:relative; width:14px; height:16px; border:2px solid currentColor; border-radius:2px; }
.copy-symbol::before { content:""; position:absolute; width:9px; height:11px; border:2px solid currentColor; border-right:0; border-bottom:0; top:-6px; left:-6px; border-radius:2px 0 0 0; }
#game[data-finished="true"][data-table="classic"] .playing-area { margin-block-start:24px; }
#game[data-finished="true"][data-table="classic"] .playing-area .board-stage { margin-inline:0; background:var(--ts-panel); border:1px solid var(--ts-field-line); border-bottom:0; border-radius:9px 9px 0 0; }
#game[data-finished="true"][data-table="classic"] .playing-area [data-renderer="basic"] { aspect-ratio:var(--field-aspect, auto); align-content:center; }
#game[data-finished="true"][data-table="classic"] #skyline { background:var(--ts-panel); color:var(--ts-ink); }
.round-stats:has(#result-score-label:not([hidden])) { display:flex; flex-wrap:wrap; container:score-row / inline-size; }
.round-stats:has(#result-score-label:not([hidden])) .score-caption { width:100%; }
.round-stats:has(#result-score-label:not([hidden])) .round-actions { margin-inline-start:auto; }
.score-caption:has(#result-score-label:not([hidden])) :is(.personal-best, .score-label) { display:none; }
@container score-row (max-width:330px) {
    #score { font-size:36px; }
    .round-actions { gap:4px; }
    .round-divider { margin-inline:2px; }
    .round-actions .action { font-size:13px; gap:4px; padding-inline:6px; }
}
#result-picker {
    margin-top:24px; padding:8px 12px; background:var(--ts-panel);
    border:1px solid var(--ts-field-line); border-radius:9px 9px 0 0; border-bottom:0;
}
.result-segments {
    display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); max-width:320px; margin-inline:auto;
    padding:3px; border-radius:9px; background:var(--ts-field);
}
.result-segments button {
    min-height:44px; border:1px solid transparent; border-radius:7px;
    background:transparent; color:var(--ts-muted); font-size:14px; font-weight:600; font-variant-numeric:tabular-nums;
}
.result-segments button b { margin-inline-start:3px; }
.result-segments button[aria-pressed="true"] { background:var(--ts-panel); color:var(--ts-ink); border-color:var(--ts-field-line); }
.result-segments button:focus-visible { outline-offset:-3px; }
#game[data-finished="true"][data-table="classic"] #result-picker:not([hidden]) + .playing-area { margin-top:0; }
#game[data-finished="true"][data-table="classic"] #result-picker:not([hidden]) + .playing-area .board-stage { border-top:0; border-radius:0; }
@media (prefers-color-scheme: dark) {
    #share-result { background:var(--ts-field); color:var(--ts-ink); border-color:var(--ts-field-line); }
    #share-result:hover { background:var(--ts-hover); }
}
