:root {
  --ink: #17322c;
  --cream: #f5f0e5;
  --paper: #fffdf7;
  --lime: #d7f43b;
  --orange: #ff6b35;
  --blue: #5cc8ff;
  --line: #c8c5b9;
  --tile-size: min(58px, 5.6vh, calc((100vw - 46px) / 8));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--cream); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }

.topbar { height: 60px; padding: 0 max(18px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--ink); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-size: 20px; letter-spacing: .025em; font-weight: 950; }
.brand b { color: var(--orange); }
.brand-mark { display: grid; grid-template-columns: repeat(2, 22px); gap: 2px; transform: rotate(-3deg); }
.brand-mark i { display: grid; place-items: center; height: 25px; background: var(--ink); color: white; font-style: normal; font-size: 13px; }
.brand-mark i:last-child { background: var(--orange); }
.top-actions { display: flex; gap: 8px; }
.leaderboard-button { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border: 2px solid var(--ink); background: var(--lime); color: var(--ink); font: inherit; font-size: 11px; font-weight: 950; cursor: pointer; }
.leaderboard-button:hover { background: var(--orange); }
.stats-button { color: var(--orange); }
.icon-button { width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); font-weight: 900; font-size: 16px; cursor: pointer; }
.icon-button:hover { background: var(--lime); }

main { max-width: 1120px; margin: auto; padding: 15px 18px 18px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 62px; }
.eyebrow { font-size: 10px; font-weight: 950; letter-spacing: .065em; margin: 0 0 5px; color: #46625b; }
.hero h1 { font-size: clamp(27px, 3.6vw, 43px); line-height: .98; letter-spacing: -.045em; margin: 0; }
.hero h1 br { display: block; }
.hero h1 em { font-style: normal; color: var(--orange); }
.timer-card { border: 2px solid var(--ink); background: var(--paper); padding: 7px 13px; min-width: 105px; box-shadow: 3px 3px 0 var(--ink); }
.timer-card span { display: block; font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.timer-card strong { font-variant-numeric: tabular-nums; font-size: 23px; }

.mode-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 10px; border-bottom: 2px solid var(--ink); }
.mode-tab { padding: 9px 21px; border: 0; background: transparent; font-weight: 850; color: #6f7d79; cursor: pointer; font-size: 14px; }
.mode-tab.active { background: var(--ink); color: white; }
.mode-tab span { font-size: 7px; color: var(--orange); vertical-align: middle; margin-left: 3px; }
.mode-tab.versus-tab { color: #6a3d78; }
.mode-tab.versus-tab.active { color: white; background: #6a3d78; }

.game-shell { display: grid; grid-template-columns: calc(var(--tile-size) * 8 + 13px) minmax(245px, 1fr); grid-template-areas: "status status" "board rack" "board actions"; align-items: start; justify-content: center; column-gap: clamp(22px, 5vw, 74px); row-gap: 12px; background: var(--paper); border: 2px solid var(--ink); border-top: 0; padding: 13px 20px 15px; }
.status-row { grid-area: status; display: flex; justify-content: space-between; gap: 16px; font-size: 12px; min-height: 18px; }
.completed-share { border: 0; border-bottom: 2px solid var(--orange); padding: 0 0 2px; background: transparent; color: var(--ink); font: inherit; font-size: 12px; font-weight: 900; cursor: pointer; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 7px; }
.board-wrap { grid-area: board; display: flex; justify-content: center; padding: 0; }
.board { width: calc(var(--tile-size) * 8 + 13px); height: calc(var(--tile-size) * 8 + 13px); display: grid; grid-template-columns: repeat(8, var(--tile-size)); grid-template-rows: repeat(8, var(--tile-size)); background: var(--ink); border: 2px solid var(--ink); gap: 1px; padding: 1px; touch-action: manipulation; }
.cell { width: var(--tile-size); height: var(--tile-size); border: 0; background: var(--paper); position: relative; display: grid; place-items: center; padding: 0; cursor: pointer; }
.cell.bonus { --bonus-colour: #ffd6a2; background: var(--bonus-colour); box-shadow: inset 0 0 0 2px rgba(23,50,44,.36); }
.cell.bonus-2 { --bonus-colour: #ffd6a2; }
.cell.bonus-3 { --bonus-colour: #ffad66; }
.cell.bonus-4 { --bonus-colour: #f77845; }
.cell.bonus::after { content: attr(data-bonus); position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; color: var(--ink); font-size: calc(var(--tile-size) * .27); font-weight: 950; line-height: 1; pointer-events: none; }
.cell.bonus.filled::after { inset: auto 2px 2px auto; min-width: 22px; height: 16px; padding: 0 3px; border-radius: 8px; background: var(--ink); color: white; font-size: 8px; box-shadow: 0 0 0 1px var(--paper); }
.cell:hover { background: #f1eee5; }
.cell:focus-visible { outline: 3px solid var(--blue); z-index: 2; }
.cell.filled { background: var(--lime); }

.tile { width: var(--tile-size); height: var(--tile-size); min-width: var(--tile-size); min-height: var(--tile-size); border: 2px solid var(--ink); background: var(--lime); color: var(--ink); display: grid; place-items: center; padding: 0; font-size: calc(var(--tile-size) * .48); line-height: 1; font-weight: 950; box-shadow: 3px 3px 0 var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; cursor: grab; }
.tile:active { cursor: grabbing; }
.tile.selected { outline: 4px solid var(--orange); outline-offset: -5px; }
.tile.vowel { background: var(--blue); }
.cell .tile { width: 100%; height: 100%; min-width: 100%; min-height: 100%; border: 0; box-shadow: none; }
.cell.bonus .tile { position: relative; z-index: 2; background: var(--bonus-colour); }
.cell.invalid .tile { background: #ff9d88; animation: shake .3s; }
.cell.drag-target { outline: 4px solid var(--orange); outline-offset: -4px; }
.drag-ghost { position: fixed; z-index: 9999; pointer-events: none; opacity: .88; transform: rotate(4deg) scale(1.04); box-shadow: 6px 7px 0 rgba(23,50,44,.45); }

.rack-section { grid-area: rack; align-self: end; justify-self: center; border: 0; padding: 0; width: max-content; }
.rack-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; font-weight: 900; font-size: 11px; letter-spacing: .07em; }
.rack-wrap { position: relative; width: max-content; }
.rack { display: grid; grid-template-columns: repeat(4, var(--tile-size)); grid-auto-rows: var(--tile-size); gap: 6px; width: calc(var(--tile-size) * 4 + 30px); min-height: calc(var(--tile-size) * 4 + 30px); padding: 6px; border: 1px dashed var(--line); background: #faf7ef; }
.rack.xl { grid-template-columns: repeat(6, var(--tile-size)); width: calc(var(--tile-size) * 6 + 42px); }
.rack.concealed .tile { color: transparent; background: #d8d7d1; border-color: #a7aaa4; box-shadow: 3px 3px 0 #a7aaa4; pointer-events: none; }
.shuffle-button { border: 0; border-bottom: 2px solid var(--orange); padding: 2px 0; background: transparent; color: var(--ink); font: inherit; font-size: 11px; font-weight: 900; cursor: pointer; }
.shuffle-button:hover:not(:disabled) { color: var(--orange); }
.shuffle-button:disabled { opacity: .35; cursor: not-allowed; }
.reveal-button { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 150px; background: var(--ink); color: white; box-shadow: 4px 4px 0 var(--orange); }
.reveal-button.hidden { display: none; }
.game-actions { grid-area: actions; align-self: start; display: flex; justify-content: center; gap: 9px; }
.game-shell.completed { grid-template-columns: calc(var(--tile-size) * 8 + 13px); grid-template-areas: "status" "board"; justify-content: center; }
.game-shell.completed .status-row { width: calc(var(--tile-size) * 8 + 13px); align-items: center; }
.game-shell.completed .rack-section, .game-shell.completed .game-actions { display: none; }
.game-shell.completed .cell .tile { background: #287653; color: white; pointer-events: none; }
.game-shell.completed .cell.filled { background: #287653; }
.game-shell.completed .status-dot { background: #287653; }
.button { min-height: 42px; padding: 0 17px; border: 2px solid var(--ink); font: inherit; font-size: 13px; font-weight: 900; cursor: pointer; }
.button.primary { background: var(--ink); color: white; box-shadow: 3px 3px 0 var(--orange); }
.button.primary:hover:not(:disabled) { background: #285247; }
.button.ghost { background: transparent; color: var(--ink); }
.button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

.result-panel { text-align: center; background: var(--paper); border: 2px solid var(--ink); border-top: 0; padding: 35px 22px; }
.hidden { display: none; }

.saved-name-note { display: block; margin-top: 6px; color: #58706a; font-size: 11px; font-weight: 700; }
input[readonly] { background: #eef3ef; color: var(--ink); cursor: default; }
.leaderboard-profile { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding: 14px; border: 2px solid var(--ink); background: #f5f2e9; }
.leaderboard-profile div { display: grid; gap: 4px; }
.leaderboard-profile span { color: #58706a; font-size: 12px; line-height: 1.45; }
.profile-dialog { width: min(520px, calc(100vw - 24px)); }
.profile-dialog h2 { margin-bottom: 8px; }
.profile-choice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.profile-name-form { display: grid; gap: 13px; margin-top: 20px; }
.profile-name-form label { display: grid; gap: 5px; }
.profile-name-form label span { color: #58706a; font-size: 12px; line-height: 1.4; }
.profile-name-form input { min-height: 48px; border: 2px solid var(--ink); padding: 0 12px; background: white; color: var(--ink); font: inherit; font-weight: 800; }
.permanent-warning { margin: 0; padding: 11px; border-left: 5px solid var(--orange); background: #fff0e9; font-size: 13px; line-height: 1.45; }
.text-button { justify-self: start; border: 0; border-bottom: 2px solid var(--orange); padding: 2px 0; background: transparent; color: var(--ink); font: inherit; font-size: 12px; font-weight: 900; cursor: pointer; }
.profile-status { min-height: 20px; color: #9b3427; font-size: 13px; font-weight: 800; }
@media (max-width: 560px) {
  .leaderboard-profile { align-items: stretch; flex-direction: column; }
  .profile-choice-actions { flex-direction: column; }
}
.result-burst { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--lime); border: 2px solid var(--ink); font-size: 27px; box-shadow: 4px 4px 0 var(--ink); }
.result-panel h2 { font-size: clamp(54px, 9vw, 85px); letter-spacing: -.06em; margin: 0; font-variant-numeric: tabular-nums; }
.result-copy { color: #5a6965; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
.share-status { min-height: 20px; color: #58706a; font-size: 13px; }
.bonus-summary { display: inline-block; margin: 2px auto 8px; padding: 7px 12px; border: 2px solid var(--ink); background: #fff0e9; color: var(--orange); font-weight: 950; }
.daily-summary { max-width: 720px; margin: 24px auto 0; }
.daily-headline-stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--ink); }
.daily-headline-stats > div { padding: 13px 8px; border-right: 1px solid var(--ink); background: var(--cream); }
.daily-headline-stats > div:last-child { border-right: 0; }
.daily-headline-stats strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.daily-headline-stats span { font-size: 10px; font-weight: 850; color: #5a6965; }
.achievement-unlocks { max-width: 720px; margin: 14px auto 0; padding: 14px; border-left: 5px solid var(--orange); background: #fff0e9; text-align: left; }
.achievement-unlocks h3 { margin: 0 0 6px; font-size: 15px; }
.achievement-unlocks p { margin: 4px 0; font-size: 12px; }
.leaderboard-entry { max-width: 720px; margin: 18px auto 0; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) auto; align-items: center; gap: 10px; padding: 14px; border: 2px solid var(--ink); background: #f2f9cc; text-align: left; }
.leaderboard-entry > div b, .leaderboard-entry > div span { display: block; }
.leaderboard-entry > div span { margin-top: 3px; color: #5a6965; font-size: 11px; }
.leaderboard-entry input { min-height: 42px; width: 100%; border: 2px solid var(--ink); border-radius: 0; padding: 8px 10px; background: white; color: var(--ink); font: inherit; font-weight: 800; }
.leaderboard-entry .button { min-width: 120px; }
.leaderboard-entry p { grid-column: 1 / -1; min-height: 0; margin: 0; color: #52635e; font-size: 12px; }
.rules-strip { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--ink); border-top: 0; }
.rules-strip > div { display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 75px; padding: 9px 16px; text-align: center; background: var(--cream); border-right: 1px solid var(--ink); }
.rules-strip > div:last-child { border-right: 0; }
.rules-strip span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); font-family: Georgia, serif; font-size: 12px; font-weight: 800; }
.rules-strip p { margin: 0; font-size: 11px; line-height: 1.35; }

dialog { max-width: 520px; width: calc(100% - 30px); border: 2px solid var(--ink); padding: 30px; background: var(--paper); color: var(--ink); box-shadow: 10px 10px 0 var(--ink); }
dialog::backdrop { background: rgba(12,28,24,.58); }
dialog h2 { font-size: 31px; line-height: 1.05; margin: 0 40px 20px 0; }
dialog ol { padding-left: 22px; line-height: 1.5; }
dialog li { margin: 9px 0; }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; font-size: 30px; cursor: pointer; }
.dialog-note { padding: 13px; background: var(--cream); font-size: 13px; line-height: 1.45; border-left: 4px solid var(--orange); }
dialog .button { width: 100%; margin-top: 8px; }
.stats-dialog { max-width: 720px; }
.stats-dialog h3 { margin: 24px 0 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 2px solid var(--ink); }
.stat-box { min-height: 82px; display: grid; place-items: center; align-content: center; padding: 8px; text-align: center; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--cream); }
.stat-box:nth-child(4n) { border-right: 0; }
.stat-box:nth-last-child(-n+4) { border-bottom: 0; }
.stat-box strong { font-size: 25px; line-height: 1; }
.stat-box span { margin-top: 6px; font-size: 10px; font-weight: 850; color: #5a6965; }
.achievement-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.achievement-card { display: grid; grid-template-columns: 38px 1fr; gap: 9px; align-items: center; padding: 11px; border: 2px solid var(--line); background: #f1eee5; opacity: .55; }
.achievement-card.unlocked { border-color: var(--ink); background: var(--lime); opacity: 1; box-shadow: 2px 2px 0 var(--ink); }
.achievement-card i { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: white; font-style: normal; }
.achievement-card b, .achievement-card small { display: block; }
.achievement-card small { margin-top: 2px; color: #52635e; }
.score-distribution { display: grid; gap: 7px; text-align: left; }
.score-band { display: grid; grid-template-columns: 80px 1fr 72px; gap: 10px; align-items: center; font-size: 11px; font-weight: 850; }
.score-band-label { white-space: nowrap; }
.score-band-track { height: 18px; overflow: hidden; border: 1px solid var(--ink); background: #e5e1d7; }
.score-band-fill { display: block; width: var(--band-width); height: 100%; min-width: 0; background: var(--band-colour, var(--orange)); transition: width .3s ease; }
.score-band-value { text-align: right; font-variant-numeric: tabular-nums; }
.daily-summary .score-distribution { margin-top: 12px; padding: 14px; border: 2px solid var(--ink); background: var(--paper); }
.daily-summary .score-distribution::before { content: "YOUR SCORE RANGES"; grid-column: 1 / -1; margin-bottom: 3px; font-size: 10px; letter-spacing: .08em; color: #5a6965; }
.leaderboard-dialog { max-width: 680px; }
.leaderboard-tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 2px solid var(--ink); }
.leaderboard-tabs button { min-height: 42px; border: 0; background: var(--cream); color: var(--ink); font: inherit; font-size: 12px; font-weight: 900; cursor: pointer; }
.leaderboard-tabs button.active { background: var(--ink); color: white; }
.leaderboard-period { min-height: 18px; margin: 12px 0; color: #5a6965; font-size: 12px; font-weight: 800; }
.leaderboard-list { display: grid; gap: 7px; max-height: min(55vh, 520px); overflow: auto; }
.leaderboard-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 48px; padding: 8px 11px; border: 2px solid var(--ink); background: var(--cream); }
.leaderboard-row:first-child { background: var(--lime); box-shadow: 3px 3px 0 var(--ink); }
.leaderboard-rank { font-size: 18px; font-weight: 950; text-align: center; }
.leaderboard-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.leaderboard-date { color: #66746f; font-size: 11px; white-space: nowrap; }
.leaderboard-time { min-width: 58px; font-size: 18px; font-weight: 950; font-variant-numeric: tabular-nums; text-align: right; }
.leaderboard-empty { padding: 28px 14px; border: 2px dashed var(--line); color: #65736f; text-align: center; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.proof-round { margin: -4px 0 10px; color: #52635e; font-size: 12px; font-weight: 950; letter-spacing: .12em; }
.proof-scoreboard { width: min(390px, 86vw); margin: 14px auto 0; }
.multiplayer-panel { min-height: 525px; padding: clamp(22px, 4vw, 46px); border: 2px solid var(--ink); border-top: 0; background: var(--paper); }
.lobby-intro { max-width: 850px; margin: auto; }
.lobby-intro > h2, .room-lobby h2 { margin: 0 0 8px; font-size: clamp(31px, 5vw, 52px); letter-spacing: -.04em; }
.lobby-intro > p { max-width: 680px; color: #566a64; line-height: 1.55; }
.lobby-choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 24px; }
.lobby-card { position: relative; display: grid; align-content: start; gap: 14px; padding: 25px; border: 2px solid var(--ink); background: var(--cream); box-shadow: 5px 5px 0 var(--ink); }
.lobby-card.join-card { background: #eef8fd; }
.lobby-card h3 { margin: 0; font-size: 24px; }
.lobby-number { position: absolute; right: 16px; top: 14px; font-family: Georgia, serif; font-size: 18px; font-weight: 900; color: var(--orange); }
.lobby-card label, .room-controls label { display: grid; gap: 6px; font-size: 11px; font-weight: 900; letter-spacing: .035em; }
.lobby-card input:not([type=range]), .lobby-card select, .room-controls select { width: 100%; min-height: 43px; border: 2px solid var(--ink); border-radius: 0; background: white; color: var(--ink); padding: 8px 10px; font: inherit; font-weight: 800; }
input[type=range] { width: 100%; accent-color: var(--orange); }
.room-code-input { text-transform: uppercase; letter-spacing: .26em; font-size: 20px !important; }
.connection-message { min-height: 20px; color: var(--orange) !important; font-weight: 850; }
.room-lobby { max-width: 800px; margin: auto; }
.room-header { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.button.compact { min-height: 36px; padding: 0 12px; }
.room-code { border: 0; border-bottom: 5px solid var(--orange); background: transparent; color: inherit; font: inherit; cursor: pointer; letter-spacing: .08em; }
.player-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 24px 0; }
.player-card { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 10px 13px; border: 2px solid var(--ink); background: var(--cream); }
.player-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--player-color); box-shadow: 0 0 0 2px var(--ink); }
.player-card b { font-size: 14px; }
.player-card small { color: #66746f; }
.room-controls { display: grid; grid-template-columns: 1fr 160px 180px; align-items: end; gap: 15px; padding: 18px; border: 2px solid var(--ink); background: #eef8fd; }
.waiting-copy { color: #5a6965; font-weight: 800; }

.match-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 20px; background: rgba(15,31,27,.88); color: var(--paper); }
.match-overlay.hidden { display: none; }
.countdown { font-size: min(42vw, 240px); font-weight: 950; line-height: 1; color: var(--lime); text-shadow: 9px 9px 0 var(--orange); }
.winner-proof, .score-popup { width: min(600px, 100%); padding: 28px; border: 3px solid var(--paper); background: var(--ink); text-align: center; box-shadow: 9px 9px 0 var(--orange); }
.winner-proof h2, .score-popup h2 { margin: 0 0 18px; font-size: clamp(30px, 7vw, 55px); }
.proof-grid { width: min(360px, 76vw); aspect-ratio: 1; margin: auto; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); gap: 1px; padding: 2px; background: #0d211c; }
.proof-cell { display: grid; place-items: center; background: #fffdf7; color: transparent; font-weight: 950; }
.proof-cell.filled { background: var(--lime); color: var(--ink); }
.match-scoreboard { display: grid; gap: 7px; }
.score-row { display: grid; grid-template-columns: 15px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; background: var(--paper); color: var(--ink); text-align: left; }
.score-row .player-dot { background: var(--player-color); }
.final-match-actions { margin-top: 16px; }

@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

@media (max-width: 700px) {
  :root { --tile-size: min(54px, 5.25vh, calc((100vw - 32px) / 8)); }
  .topbar { height: 54px; padding: 0 12px; }
  .brand { font-size: 15px; }
  .brand-mark { grid-template-columns: repeat(2, 19px); }
  .brand-mark i { height: 22px; }
  .leaderboard-button { width: 32px; min-height: 32px; justify-content: center; padding: 0; }
  .leaderboard-button b { display: none; }
  .icon-button { width: 32px; height: 32px; }
  main { padding: 9px 8px 10px; }
  .hero { min-height: 54px; }
  .hero h1 { font-size: clamp(23px, 7vw, 33px); }
  .timer-card { min-width: 90px; padding: 5px 9px; box-shadow: 2px 2px 0 var(--ink); }
  .timer-card strong { font-size: 19px; }
  .mode-tabs { margin-top: 6px; }
  .mode-tabs { grid-template-columns: repeat(2, 1fr); }
  .mode-tab { padding: 7px 5px; font-size: 12px; }
  .game-shell { grid-template-columns: 1fr; grid-template-areas: "status" "board" "rack" "actions"; justify-items: center; gap: 8px; padding: 9px 6px 10px; }
  .status-row { width: 100%; font-size: 10px; }
  .rack-section { min-width: 0; width: calc(var(--tile-size) * 8 + 7px); }
  .rack-heading { margin-bottom: 4px; }
  .rack-heading > span { display: none; }
  .rack, .rack.xl { grid-template-columns: repeat(8, var(--tile-size)); grid-auto-rows: var(--tile-size); gap: 1px; width: calc(var(--tile-size) * 8 + 7px); min-height: calc(var(--tile-size) * 2 + 1px); padding: 0; border: 0; background: transparent; }
  .rack .tile { box-shadow: none; }
  .game-actions { width: 100%; }
  .game-actions .button { flex: 1; min-height: 37px; }
  .rules-strip { display: none; }
  .result-actions { flex-direction: column; }
  .result-actions .button { width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .daily-headline-stats { grid-template-columns: repeat(3, 1fr); }
  .score-band { grid-template-columns: 68px 1fr 58px; gap: 6px; font-size: 9px; }
  .stat-box:nth-child(2n) { border-right: 0; }
  .stat-box:nth-last-child(-n+4) { border-bottom: 1px solid var(--ink); }
  .stat-box:nth-last-child(-n+2) { border-bottom: 0; }
  .achievement-grid, .lobby-choice-grid, .player-list { grid-template-columns: 1fr; }
  .leaderboard-entry { grid-template-columns: 1fr; text-align: center; }
  .leaderboard-entry p { grid-column: 1; }
  .leaderboard-row { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px; padding-inline: 8px; }
  .leaderboard-date { grid-column: 2; grid-row: 2; }
  .leaderboard-time { grid-column: 3; grid-row: 1 / span 2; }
  .leaderboard-dialog { padding: 22px 15px; }
  .multiplayer-panel { min-height: 0; padding: 18px 10px; }
  .lobby-intro > h2, .room-lobby h2 { font-size: clamp(27px, 9vw, 38px); }
  .lobby-intro > p { font-size: 13px; }
  .lobby-choice-grid { margin-top: 16px; gap: 12px; }
  .lobby-card { padding: 16px; box-shadow: 3px 3px 0 var(--ink); }
  .room-controls { grid-template-columns: 1fr; }
  .room-header { align-items: center; }
  .player-list { margin: 16px 0; }
  .winner-proof, .score-popup { max-height: calc(100dvh - 20px); overflow: auto; padding: 18px 12px; box-shadow: 5px 5px 0 var(--orange); }
  .winner-proof h2, .score-popup h2 { margin-bottom: 10px; font-size: clamp(25px, 8vw, 38px); }
  .proof-grid { width: min(84vw, 42dvh, 320px); }
  .proof-scoreboard { width: 100%; margin-top: 9px; }
  .score-row { padding: 7px 9px; }
}

@media (min-width: 701px) and (max-width: 980px) {
  :root { --tile-size: min(49px, 4.8vh, calc((100vw - 42px) / 8)); }
  main { padding: 11px 14px 14px; }
  .hero { min-height: 56px; }
  .hero h1 { font-size: clamp(27px, 4.8vw, 37px); }
  .game-shell { grid-template-columns: 1fr; grid-template-areas: "status" "board" "rack" "actions"; justify-items: center; gap: 8px; padding: 10px 12px 12px; }
  .status-row { width: min(100%, calc(var(--tile-size) * 8 + 13px)); }
  .rack-section { min-width: 0; width: calc(var(--tile-size) * 8 + 7px); }
  .rack, .rack.xl { grid-template-columns: repeat(8, var(--tile-size)); grid-auto-rows: var(--tile-size); gap: 1px; width: calc(var(--tile-size) * 8 + 7px); min-height: calc(var(--tile-size) * 2 + 1px); padding: 0; border: 0; background: transparent; }
  .rack .tile { box-shadow: none; }
  .game-actions { width: calc(var(--tile-size) * 8 + 13px); }
  .game-actions .button { flex: 1; }
  .rules-strip { display: none; }
  .multiplayer-panel { min-height: 0; padding: 25px 22px; }
  .room-controls { grid-template-columns: 1fr 130px 160px; gap: 10px; padding: 14px; }
  .winner-proof, .score-popup { max-height: calc(100dvh - 28px); overflow: auto; }
  .proof-grid { width: min(350px, 52dvh); }
}

@media (max-height: 720px) and (min-width: 701px) {
  main { padding-top: 9px; }
  .hero { min-height: 52px; }
  .mode-tabs { margin-top: 5px; }
  .rules-strip > div { min-height: 62px; padding-block: 6px; }
}

.hidden { display: none !important; }
