@font-face { font-family: Inter; src: url("/web/inter.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: Nunito; src: url("/web/nunito.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  color-scheme: dark;
  --paper: #15142c;
  --surface: #24213e;
  --raised: #302b4e;
  --line: #514a70;
  --well: #1b1931;
  --ink: #f9f6ff;
  --muted: #c4bdd4;
  --tile-ink: #1d1732;
  --mint: #93e7b8;
  --lemon: #ffda78;
  --lilac: #c8b4ff;
  --ember: #ffad94;
  --sky: #95ddeb;
  --ruby: #ffb5c6;
  --gem: #ffe0e7;
  --heading: Nunito, system-ui, sans-serif;
}
[data-theme="forest"] { --paper: #14271f; --surface: #203b2f; --raised: #2f4d3c; --line: #587762; --well: #182e24; }
[data-theme="ocean"] { --paper: #101f2e; --surface: #193347; --raised: #26485d; --line: #4b7488; --well: #14293b; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.5 Inter, sans-serif; }
h1, h2, h3, strong { font-family: var(--heading); font-weight: 800; }
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--lilac); text-underline-offset: .2em; }
:where(a, button, input, select):focus-visible { outline: 2px solid var(--lemon); outline-offset: 3px; }
.masthead { border-bottom: 1px solid var(--line); background: var(--well); }
.masthead-inner, .layout, .footer { width: min(100% - 2.5rem, 65rem); margin-inline: auto; }
.masthead-inner { min-height: 4.15rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { text-decoration: none; color: var(--ink); font: 800 1.5rem var(--heading); display: flex; align-items: center; gap: .65rem; }
.brand img { border-radius: .65rem; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem; }
.top-actions button, .text-button { min-height: 44px; padding: .45rem .75rem; background: transparent; border: 0; border-radius: .65rem; font-size: .875rem; color: var(--muted); }
.top-actions button:hover, .text-button:hover { background: var(--raised); color: var(--ink); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 20rem); gap: 1.25rem; padding-block: 1.65rem 1.25rem; align-items: start; }
.game-panel, .sidebar-card { background: var(--surface); border: 1px solid var(--line); border-radius: 1.5rem; }
.game-panel { padding: clamp(.85rem, 3.2vw, 1.65rem); min-width: 0; box-shadow: 0 18px 45px #08071745; }
.rankings .signature { justify-content: flex-start; }
.rankings h1 { font-size: clamp(1.85rem, 5vw, 2.6rem); line-height: 1.1; margin-bottom: .95rem; }
.ranking-tabs, .ranking-periods { display: grid; gap: .25rem; padding: .25rem; background: var(--well); border-radius: .8rem; }
.ranking-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ranking-periods { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ranking-tabs button, .ranking-periods button { min-height: 44px; padding: .35rem .2rem; border: 1px solid transparent; border-radius: .65rem; background: transparent; color: var(--muted); font: 800 .88rem/1.2 var(--heading); overflow-wrap: anywhere; }
.ranking-tabs button { min-height: 48px; }
.ranking-tabs button:hover, .ranking-periods button:hover { background: var(--raised); }
.ranking-tabs button[aria-selected="true"] { background: var(--lilac); color: var(--tile-ink); }
.ranking-periods button[aria-pressed="true"] { background: var(--mint); color: var(--tile-ink); }
.rank-window { margin: .8rem 0 .6rem; color: var(--lilac); font-size: .82rem; font-weight: 600; }
.rank-message, .rank-personal { margin-block: .65rem; font-size: .875rem; }
.rank-message { color: var(--muted); }
.rank-personal { color: var(--mint); }
.rank-message:empty, #solo-message:empty { display: none; }
.rank-rows { margin-top: .45rem; }
.rank-row, .rank-record { display: grid; align-items: center; gap: .6rem; overflow-wrap: anywhere; }
.rank-row { grid-template-columns: auto minmax(0, 1fr) auto; min-height: 48px; border-bottom: 1px solid var(--line); }
.rank-number { display: grid; place-items: center; min-width: 2rem; min-height: 2rem; padding-inline: .28rem; border-radius: .55rem; color: var(--lilac); background: var(--well); font: 800 .88rem var(--heading); }
.rank-number[data-rank="1"] { background: var(--lemon); color: var(--tile-ink); }
.rank-number[data-rank="2"] { background: var(--sky); color: var(--tile-ink); }
.rank-number[data-rank="3"] { background: var(--ember); color: var(--tile-ink); }
.rank-name { font: 800 1rem/1.25 var(--heading); }
button.rank-name { justify-self: start; max-width: 100%; min-height: 44px; border: 0; background: transparent; padding: .25rem 0; text-align: left; }
button.rank-name:hover { color: var(--lilac); text-decoration: underline; }
.rank-name small { margin-left: .35rem; color: var(--lilac); }
.rank-score { text-align: right; color: var(--mint); font-variant-numeric: tabular-nums; }
.rank-record { grid-template-columns: minmax(0, 1fr) auto; margin-block: .55rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--well); }
.rank-record-detail span { display: block; color: var(--lemon); font-size: .78rem; }
.rank-record-detail strong { display: block; }
.rank-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .4rem; }
.rank-controls .text-button { padding-inline: .25rem; color: var(--mint); }
.rank-controls .primary { margin-top: .35rem; }
.rank-controls .score-pages { flex: 1 1 100%; margin-top: .25rem; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.game-header h1 { font-size: clamp(1.6rem, 4vw, 2.15rem); line-height: 1.1; }
.game-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-bottom: .85rem; }
.stat { padding: .5rem .35rem .45rem; min-height: 3.65rem; text-align: center; background: var(--well); border-radius: .85rem; }
.stat span { display: block; color: var(--muted); font-size: .75rem; }
.stat strong { display: block; color: var(--mint); font-size: clamp(1.15rem, 4vw, 1.65rem); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat:last-child strong { color: var(--lilac); }
.timer strong { color: var(--lemon); }
.timer .urgent { color: var(--ruby); }

.board-area { position: relative; min-height: 15.25rem; display: grid; align-items: center; padding: .7rem; background: var(--well); border-radius: 1.05rem; isolation: isolate; }
.board-area:not(.covered) { min-height: 0; }
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(.25rem, 1.15vw, .65rem); }
.column { display: grid; gap: .3rem; min-width: 0; padding: .18rem; border-radius: .75rem; }
.column:nth-child(1), .signature :nth-child(1) { --column: var(--mint); }
.column:nth-child(2), .signature :nth-child(2) { --column: var(--lemon); }
.column:nth-child(3), .signature :nth-child(3) { --column: var(--lilac); }
.column:nth-child(4), .signature :nth-child(4) { --column: var(--ember); }
.column:nth-child(5), .signature :nth-child(5) { --column: var(--sky); }
.column.boosted { box-shadow: inset 0 0 0 1px var(--lemon); background: color-mix(in srgb, var(--lemon) 12%, transparent); }
.boost { color: var(--lemon); font: 800 .72rem var(--heading); text-align: center; min-height: 1rem; white-space: nowrap; }
.tile { position: relative; display: grid; place-items: center; background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: .55rem; height: clamp(2rem, 5vw, 2.7rem); font: 800 clamp(1rem, 3.8vw, 1.65rem)/1 var(--heading); }
.tile:not(.playable):nth-of-type(1) { opacity: .48; }
.tile:not(.playable):nth-of-type(2) { opacity: .68; }
.tile:not(.playable):nth-of-type(3) { opacity: .84; }
.tile.playable { min-height: 44px; width: 100%; height: clamp(44px, 6.6vw, 3.55rem); border: 0; font-size: clamp(1.25rem, 4.8vw, 2rem); background: var(--playable); color: var(--tile-ink); box-shadow: inset 0 -3px 0 #201b391a; }
.tile.playable[aria-disabled="false"]:hover { filter: brightness(1.12); transform: translateY(-1px); }
.tile.playable[aria-disabled="false"]:active { transform: translateY(2px); }
.column:nth-child(1) { --playable: #9bf8b9; }
.column:nth-child(2) { --playable: #ffe071; }
.column:nth-child(3) { --playable: #d2baff; }
.column:nth-child(4) { --playable: #ffaf95; }
.column:nth-child(5) { --playable: #9aedff; }
.tile.gem { background: #49243d; border-color: #ff6c88; opacity: 1; }
.tile.playable.gem { background: var(--gem); color: #7b1631; }
.tile-value { position: absolute; right: .25rem; bottom: .25rem; color: inherit; font: 800 clamp(.59rem, 1.6vw, .7rem)/1 var(--heading); }
.tile-gem { position: absolute; top: .2rem; left: .2rem; }
.chosen-gem { vertical-align: -.25rem; }
.column.drop .tile { animation: drop .16s ease-out; }
.column.rise .tile { animation: rise .16s ease-out; }
@keyframes drop { from { translate: 0 -.65rem; } to { translate: 0 0; } }
@keyframes rise { from { translate: 0 .65rem; } to { translate: 0 0; } }
.board-area.covered .board { opacity: .26; filter: blur(2px); pointer-events: none; }
.board-area > * { grid-area: 1 / 1; }
.board-overlay { position: relative; display: grid; place-items: center; padding: .35rem; }
.overlay-card { width: min(100%, 24rem); padding: 1.3rem 1rem; text-align: center; border: 1px solid var(--line); border-radius: 1.2rem; background: var(--surface); box-shadow: 0 10px 36px #09081970; }
.signature { display: flex; justify-content: center; gap: .25rem; margin-bottom: .55rem; }
.signature span { width: 1.12rem; height: .23rem; border-radius: 1rem; background: var(--column); }
.overlay-card h2 { line-height: 1.12; font-size: clamp(1.3rem, 3.8vw, 1.85rem); }
.overlay-card p { margin: .5rem auto .9rem; color: var(--muted); font-size: .875rem; max-width: 27ch; }
.overlay-card .button { width: min(100%, 14rem); }
.overlay-card .button + .button:not([hidden]) { margin-top: .4rem; }

.tray { margin-bottom: .65rem; padding: .55rem .8rem .65rem; min-height: 4.15rem; background: var(--well); border-radius: .85rem; }
.tray-label { color: var(--muted); display: flex; justify-content: space-between; font-size: .78rem; }
#word-value { color: var(--mint); }
.word { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; align-items: center; min-height: 1.45rem; }
.word > span { color: var(--muted); font-size: .88rem; }
.word .chosen { min-width: 1.5rem; text-align: center; color: var(--ink); background: var(--raised); border-radius: .3rem; font: 800 1.12rem/1.5 var(--heading); }
.word .chosen.boosted { color: var(--lemon); }
.word .chosen.gem { background: var(--gem); color: #7b1631; }
.main-actions, .tools { display: grid; gap: .55rem; margin-top: .55rem; }
.main-actions { grid-template-columns: 1fr 1fr 1.4fr; }
.tools { grid-template-columns: minmax(0, 1fr) minmax(min-content, 6.65rem); }
.button { border: 1px solid transparent; min-height: 44px; padding: .45rem .7rem; border-radius: .75rem; font: 800 .97rem/1.25 var(--heading); }
.button span { margin-left: .25em; }
.button:not(:disabled, [aria-disabled="true"]):hover { filter: brightness(1.12); }
.button:not(:disabled, [aria-disabled="true"]):active { translate: 0 1px; }
.primary { color: var(--tile-ink); background: var(--mint); }
.burn { color: var(--tile-ink); background: var(--ember); }
.secondary { background: var(--raised); border-color: var(--line); }
.danger { background: var(--ruby); color: #40202c; }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: default; }
#bank:disabled { background: var(--raised); color: var(--muted); border-color: var(--line); opacity: 1; }
.tools .button { min-height: 60px; padding: .45rem; background: var(--well); }
.tools .button:disabled { opacity: 1; color: var(--muted); }
.tools .button span { margin-left: 0; }
.blank-tool { display: flex; align-items: center; gap: .5rem; text-align: left; }
.blank-icon { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: .75rem; background: var(--lilac); color: var(--tile-ink); font: 800 1.5rem var(--heading); }
.blank-tool:disabled .blank-icon { background: var(--raised); color: var(--muted); }
.tool-label { display: grid; gap: .13rem; }
.tools strong { font: 700 .75rem Inter, sans-serif; text-transform: uppercase; }
.tools small { display: block; color: var(--muted); font: 400 .72rem Inter, sans-serif; }
.shuffle-tool { display: grid; align-content: center; justify-items: center; gap: .2rem; }
.shuffle-label { display: flex; align-items: center; gap: .3rem; color: var(--mint); }
.shuffle-tool:disabled .shuffle-label { color: var(--muted); }
.shuffle-icon { flex: none; width: 16px; height: 16px; }
.setting-toggle { display: flex; gap: .55rem; align-items: center; min-height: 44px; cursor: pointer; }
dialog .setting-toggle input { width: 1.1rem; min-height: 0; height: 1.1rem; margin: 0; accent-color: var(--mint); }
.feedback { min-height: 1.25em; margin-top: .4rem; color: var(--mint); font-size: .83rem; }
.feedback.error { color: var(--ruby); }

.sidebar { display: grid; gap: 1rem; }
.sidebar-card { padding: 1.05rem; }
.sidebar-card h2 { font-size: 1.16rem; margin-bottom: .65rem; }
.sidebar-card p { color: var(--muted); font-size: .875rem; }
.mode { display: grid; width: 100%; grid-template-columns: 2.3rem minmax(0, 1fr) auto; align-items: center; gap: .65rem; min-height: 3.6rem; text-align: left; padding: .5rem .6rem; background: var(--well); border: 1px solid transparent; border-radius: .8rem; }
.mode + .mode { margin-top: .45rem; }
.mode:hover { background: var(--raised); }
.mode strong, .mode small { display: block; }
.mode strong { font-size: 1rem; line-height: 1.18; }
.mode small { margin-top: .15rem; color: var(--muted); font-size: .72rem; }
.solo { --mode: var(--lilac); }
.multi { --mode: var(--sky); }
.mode-icon { display: grid; width: 2.15rem; height: 2.15rem; place-items: center; border-radius: .55rem; background: var(--mode); color: var(--tile-ink); font: 800 1.2rem var(--heading); }
.mode-arrow { color: var(--mode); font-size: 1.35rem; }
.round-rows { max-height: 12.5rem; overflow-y: auto; scrollbar-gutter: stable; }
.row { display: flex; align-items: center; justify-content: space-between; min-height: 2rem; gap: .5rem; padding: .35rem 0; font-size: .87rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.row strong { flex-shrink: 0; color: var(--mint); font-variant-numeric: tabular-nums; }
.row button { text-align: left; padding: 0; border: 0; min-height: 44px; background: transparent; color: var(--lilac); text-decoration: underline; text-underline-offset: .18em; overflow-wrap: anywhere; }
.keyboard-card dl { display: grid; gap: .48rem; font-size: .83rem; color: var(--muted); }
.keyboard-card dl div { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
kbd { background: var(--well); color: var(--ink); border: 1px solid var(--line); border-radius: .3rem; padding: .08em .35em; }
.footer { display: flex; flex-wrap: wrap; gap: .5rem 1.3rem; padding-bottom: 1.35rem; font-size: .8rem; }
.footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }

dialog { max-width: min(28rem, 100% - 1.2rem); width: 100%; max-height: min(88dvh, 42rem); overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 1.25rem; padding: 1.15rem; }
dialog::backdrop { background: #0b081ad0; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: .7rem; }
.dialog-heading h2 { font-size: 1.5rem; line-height: 1.15; overflow-wrap: anywhere; }
.dialog-heading button { width: 44px; min-height: 44px; border-radius: .7rem; background: var(--raised); border: 1px solid var(--line); font-size: 1.35rem; flex-shrink: 0; }
dialog p, dialog form, dialog .field, dialog .score-pages, dialog > .button { margin-block: .65rem; }
dialog p, dialog small { color: var(--muted); }
dialog p:empty { display: none; }
dialog form .button { margin-top: .55rem; }
dialog input, dialog select { background: var(--well); color: var(--ink); border: 1px solid var(--line); border-radius: .6rem; min-height: 44px; width: 100%; padding: .45rem .65rem; }
.field { display: grid; gap: .3rem; }
.score-pages { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
.friend-request { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .25rem .6rem; border-top: 1px solid var(--line); }
.rules { padding-left: 1.4rem; color: var(--muted); }
.rules li + li { margin-top: .65rem; }
.alphabet { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: .28rem; }
.alphabet button { min-width: 44px; padding-inline: .3rem; }

@media (max-width: 48rem) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 38rem; padding-top: 1.15rem; }
  .sidebar { grid-template-columns: 1fr 1fr; }
  .keyboard-card { grid-column: 1 / -1; }
}
@media (max-width: 32rem) {
  .masthead-inner, .layout, .footer { width: calc(100% - 1rem); }
  .masthead-inner { flex-wrap: wrap; gap: .1rem .4rem; padding: .4rem .2rem; }
  .brand { min-height: 44px; font-size: 1.2rem; }
  .brand img { width: 30px; height: 30px; }
  .top-actions { gap: 0; }
  .top-actions button { padding-inline: .45rem; font-size: .8rem; }
  .sidebar { grid-template-columns: minmax(0, 1fr); }
  .board-area { padding: .35rem; }
  .column { padding-inline: 0; }
  .board { gap: .28rem; }
  .tile { border-radius: .42rem; }
}
@media (hover: none) and (pointer: coarse) { .keyboard-card { display: none; } }
@media (prefers-reduced-motion: reduce) { .column .tile { animation: none !important; } }
