/* Word Tangle — letter tiles and woven strands.
   Visual styles live in the variables below; layout follows. See docs/ART_GUIDE.md. */

:root {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 16px;
  --gap: 12px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --shift-ms: 520ms;
}

:root, [data-theme="light"] {
  --bg: #f6efe2;
  --bg-strand-a: rgba(229, 72, 59, .10);
  --bg-strand-b: rgba(18, 134, 127, .10);
  --surface: #fffaf2;
  --surface-2: #f1e7d5;
  --ink: #241d45;
  --ink-2: #4f4870;
  --muted: #6f6890;
  --line: #e0d3bc;
  --board: #e9dcc4;
  --tile: #fffdf8;
  --tile-ink: #241d45;
  --tile-edge: #cdbb9b;
  --accent: #e0463a;
  --accent-soft: #fbd9d3;
  --accent-ink: #ffffff;
  --teal: #0f7f78;
  --teal-soft: #cdeeea;
  --gold: #b8790a;
  --good: #1d7f47;
  --bad: #c0352b;
  --dup: #a96a0c;
  --shadow: 0 1px 2px rgba(36, 29, 69, .08), 0 6px 18px rgba(36, 29, 69, .08);
}

[data-theme="dark"] {
  --bg: #15112b;
  --bg-strand-a: rgba(255, 107, 90, .10);
  --bg-strand-b: rgba(56, 201, 191, .09);
  --surface: #211b45;
  --surface-2: #2b2458;
  --ink: #f5f0ff;
  --ink-2: #d2c9f0;
  --muted: #a9a0d0;
  --line: #3b336f;
  --board: #0f0c22;
  --tile: #f6ecd8;
  --tile-ink: #1f1840;
  --tile-edge: #b4a382;
  --accent: #ff6b5a;
  --accent-soft: #5a2a3a;
  --accent-ink: #ffffff;
  --teal: #38c9bf;
  --teal-soft: #173f4a;
  --gold: #f2b233;
  --good: #4cd98a;
  --bad: #ff7b70;
  --dup: #f2b233;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
}

[data-contrast="high"] {
  --muted: var(--ink-2);
  --line: var(--ink-2);
  --tile-edge: var(--tile-ink);
}
[data-contrast="high"][data-theme="light"] { --bg: #ffffff; --surface: #ffffff; --ink-2: #1a1433; --accent: #b3261e; }
[data-contrast="high"][data-theme="dark"] { --bg: #000000; --surface: #0d0b1c; --ink-2: #ffffff; --tile: #ffffff; --tile-ink: #000000; }
[data-text="large"] { font-size: 118%; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520' viewBox='0 0 520 520'%3E%3Cpath d='M-20 120 C 120 20, 220 220, 360 110 S 560 60, 600 160' fill='none' stroke='%23888' stroke-opacity='.10' stroke-width='3'/%3E%3Cpath d='M-20 380 C 100 300, 260 470, 380 360 S 540 300, 600 400' fill='none' stroke='%23888' stroke-opacity='.08' stroke-width='3'/%3E%3C/svg%3E"),
    radial-gradient(1200px 600px at 10% -10%, var(--bg-strand-a), transparent 60%),
    radial-gradient(900px 600px at 110% 20%, var(--bg-strand-b), transparent 60%);
  background-attachment: fixed;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--ink-2); }
p { margin: 0 0 .6em; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--teal); }
code { font-family: var(--mono); font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.center { text-align: center; }
.fine { color: var(--muted); font-size: .88rem; }
.lead { font-size: 1.1rem; font-weight: 700; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 800; color: var(--muted); margin-bottom: .3em; }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 8px; }

/* ---- logo ---- */
.logo { display: block; width: 220px; height: auto; margin: 0 auto; overflow: visible; }
.logo.big { width: 260px; }
.logo.hero { width: min(420px, 88vw); }
.logo.huge { width: min(640px, 40vw); }
.lg-strand.a { stroke: var(--accent); opacity: .85; }
.lg-strand.b { stroke: var(--teal); opacity: .85; }
.lg-text { font-family: var(--font); font-weight: 900; font-size: 34px; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 7px; letter-spacing: .5px; }
.mark { width: 30px; height: 30px; flex: none; }
.mk-bg { fill: var(--surface-2); }
.mk-a { stroke: var(--accent); }
.mk-b { stroke: var(--teal); }

/* ---- buttons, inputs ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 800; cursor: pointer; text-decoration: none;
  transition: transform .12s var(--ease), background .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: .92rem; }
.btn.big { min-height: 54px; font-size: 1.1rem; padding: 0 28px; }
.icon-btn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink);
  display: inline-grid; place-items: center; font-weight: 900; font-size: 1.05rem; cursor: pointer; padding: 0 8px;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: var(--surface-2); }
.host-btn { font-size: .85rem; border: 2px solid var(--teal); color: var(--teal); border-radius: 999px; height: 36px; }
input[type="text"], input[type="number"], input:not([type]), select {
  min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); padding: 0 12px; width: 100%;
}
input:focus, select:focus { border-color: var(--teal); outline: none; }
.code-input { text-transform: uppercase; letter-spacing: .4em; font-weight: 900; font-size: 1.4rem; text-align: center; font-family: var(--mono); }

.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { transform: translateX(22px); }
.switch input:focus-visible + i { outline: 3px solid var(--teal); outline-offset: 2px; }

.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; min-height: 40px; min-width: 44px; padding: 0 12px; font-weight: 800; cursor: pointer; }
.seg button.on { background: var(--teal); color: #fff; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 14px; }
.tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); }
.tag.muted { background: var(--surface-2); color: var(--muted); }

/* ---- loading, toasts, sheets ---- */
.loading { min-height: 60dvh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); font-weight: 700; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 800; box-shadow: var(--shadow); animation: toast-in .25s var(--ease); text-align: center; }
.toast.good { background: var(--good); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
dialog.sheet {
  border: 0; padding: 0; width: min(640px, 100vw); max-width: 100vw; max-height: min(92dvh, 900px); border-radius: 22px 22px 0 0; margin: auto auto 0;
  background: var(--surface); color: var(--ink); box-shadow: 0 -10px 40px rgba(0,0,0,.3); overflow: auto;
}
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog.sheet::backdrop { background: rgba(10, 6, 30, .55); }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; }
dialog.sheet > :not(.sheet-head) { padding: 14px 18px 22px; }
.prefs { display: grid; gap: 4px; }
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.host-menu { display: grid; gap: 10px; }
.qr-sheet { display: grid; justify-items: center; gap: 8px; }
.qr { width: min(280px, 70vw); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 10px; }

/* ---- home ---- */
.home { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; }
.home-top { display: flex; }
.home-hero { text-align: center; padding: 8px 0 18px; }
.tagline { font-size: 1.15rem; font-weight: 700; color: var(--ink-2); }
.home-forms { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 14px; }
.home-card { display: grid; gap: 8px; align-content: start; }
.home-card label { font-weight: 800; font-size: .9rem; margin-top: 4px; }
.home-card .btn { margin-top: 8px; }
.form-error { color: var(--bad); font-weight: 800; text-align: center; min-height: 1.2em; }
.how ol { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }

/* ---- phone shell ---- */
.phone { max-width: 600px; margin: 0 auto; padding: 0 12px calc(24px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 6px; padding: 8px 0; background: linear-gradient(var(--bg) 70%, transparent); }
.round-label { font-weight: 900; font-size: .95rem; margin-left: 4px; }
.status-pill:empty { display: none; }
.status-pill { font-size: .75rem; font-weight: 800; color: #fff; background: var(--dup); padding: 3px 10px; border-radius: 99px; }
.status-pill[data-status="failed"] { background: var(--bad); }
.phone-main { min-height: 70dvh; }

/* players */
.players { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.players li { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; border-radius: 12px; background: var(--surface-2); }
.players li.away { opacity: .55; }
.players li.me { outline: 2px solid var(--teal); }
.players .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 900; font-size: .9rem; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: -1px; flex: none; }

/* lobby, preview */
.invite { text-align: center; }
.code { font-family: var(--mono); font-weight: 900; font-size: 3rem; letter-spacing: .25em; margin: 0 0 8px; padding-left: .25em; }
.invite-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.waiting { color: var(--muted); font-weight: 800; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; } }
.big-count { text-align: center; font-size: 5rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent); }
.big-count.small-text { font-size: 1.3rem; color: var(--ink-2); line-height: 1.3; }

/* round card */
.round-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.round-card-title { font-size: 1.3rem; }
.facts { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.facts li { background: var(--surface-2); border-radius: 12px; padding: 8px 4px; text-align: center; display: grid; }
.facts b { font-size: 1.15rem; }
.facts span { font-size: .75rem; color: var(--muted); font-weight: 700; }
.card-cols { display: grid; gap: 14px; }
@media (min-width: 700px) { .card-cols { grid-template-columns: 1fr 1fr; } }
.score-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.score-table td { padding: 5px 2px; border-bottom: 1px dashed var(--line); }
.bonus-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bonus-list li { display: flex; gap: 10px; align-items: flex-start; }
.bonus-list li > div { display: grid; }
.bonus-list span { font-size: .9rem; color: var(--ink-2); }
.icon { width: 26px; height: 26px; flex: none; color: var(--teal); }

/* setup editor */
.setup h2 { margin-top: 0; }
.setup-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.field { display: grid; gap: 6px; font-weight: 800; font-size: .92rem; }
.field.inline { display: flex; justify-content: space-between; align-items: center; }
.field output { color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.bonus-grid { display: grid; gap: 10px; }
@media (min-width: 640px) { .bonus-grid { grid-template-columns: 1fr 1fr; } }
.bonus-card { border: 2px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface); transition: border-color .2s, background .2s; }
.bonus-card.on { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 8%, var(--surface)); }
.bonus-head { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.bonus-head b { flex: 1; }
.bonus-rule { font-size: .88rem; color: var(--ink-2); margin: 8px 0; }
.bonus-params { display: none; gap: 8px; }
.bonus-card.on .bonus-params { display: grid; }
.bonus-params label { display: grid; grid-template-columns: 1fr 120px; gap: 8px; align-items: center; font-size: .88rem; font-weight: 700; }
.setup-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 12px 0 4px; background: var(--surface); }

/* ---- board ---- */
.board { position: relative; width: 100%; aspect-ratio: 1; container-type: inline-size; --n: 4; user-select: none; -webkit-user-select: none; }
.board-viewport { position: absolute; inset: 0; overflow: hidden; border-radius: clamp(10px, 3cqi, 22px); background: var(--board); box-shadow: inset 0 2px 6px rgba(0,0,0,.12); transition: box-shadow .3s; }
.board.interactive .board-viewport { touch-action: none; }
.board-stage { position: absolute; inset: 1.4cqi; transform-origin: 0 0; overflow: hidden; }
.tile { position: absolute; transition: left var(--shift-ms) var(--ease), top var(--shift-ms) var(--ease); cursor: pointer; outline: none; }
.tile::before {
  content: ""; position: absolute; inset: 6%; border-radius: 20%;
  background: var(--tile); box-shadow: 0 .45cqi 0 var(--tile-edge);
  transition: background .12s, transform .12s var(--ease);
}
.tile .face {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center;
  font-weight: 900; color: var(--tile-ink); font-size: calc(100cqi / var(--n) * .46); line-height: 1; letter-spacing: -.02em;
  transition: color .12s;
}
.tile.qu .face { font-size: calc(100cqi / var(--n) * .36); }
.tile.sel::before { background: var(--accent); transform: scale(.96); box-shadow: 0 .3cqi 0 color-mix(in srgb, var(--accent) 60%, #000); }
.tile.sel .face { color: var(--accent-ink); }
.tile.sel.last::before { box-shadow: 0 0 0 .7cqi color-mix(in srgb, var(--accent) 35%, transparent), 0 .3cqi 0 color-mix(in srgb, var(--accent) 60%, #000); }
.tile.hinge::after { content: ""; position: absolute; inset: 2%; z-index: 4; border-radius: 24%; border: max(2px, .6cqi) dashed var(--gold); pointer-events: none; }
.tile.trail::before { background: color-mix(in srgb, var(--trail) 70%, var(--tile)); }
.tile.trail .face { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.tile.kbd::before { box-shadow: 0 0 0 max(3px, .8cqi) var(--teal); }
.board:not(:focus-within) .tile.kbd::before { box-shadow: 0 .45cqi 0 var(--tile-edge); }
.board:not(:focus-within) .tile.sel.kbd::before { box-shadow: 0 .3cqi 0 color-mix(in srgb, var(--accent) 60%, #000); }
.tile.ghost { pointer-events: none; }
.tile.no-anim, .tile.no-anim::before { transition: none !important; }
.strands { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; transition: opacity .15s; }
.strands.fade { opacity: 0; }
.strands .s-outer { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.strands .s-inner { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: .14 .1; }
.sel-strand .s-outer { stroke: var(--accent); stroke-width: .3; opacity: .7; }
.sel-strand .s-inner { stroke: #fff; stroke-width: .06; opacity: .75; }
.sel-strand .s-knot { fill: #fff; opacity: .9; }
.trail-strand .s-outer { stroke: var(--c); stroke-width: .28; opacity: .75; }
.trail-strand .s-inner { stroke: #fff; stroke-width: .05; opacity: .7; }
.row-flash { position: absolute; left: 0; right: 0; z-index: 1; opacity: 0; pointer-events: none; border-radius: 12px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--teal) 45%, transparent), transparent); }
.row-flash.on { animation: row-flash 1.3s var(--ease); }
.row-flash-arrow { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0; }
@keyframes row-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }
.board.pulse-good .board-viewport { animation: pulse-good .6s var(--ease); }
.board.pulse-bad .board-viewport { animation: shake .4s; }
.board.pulse-dup .board-viewport { animation: pulse-dup .6s var(--ease); }
@keyframes pulse-good { 30% { box-shadow: 0 0 0 5px var(--good); } }
@keyframes pulse-dup { 30% { box-shadow: 0 0 0 5px var(--dup); } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.board.locked .tile { cursor: default; }
.board.zoomed .board-viewport { box-shadow: inset 0 0 0 3px var(--teal); }
.board-wrap { position: relative; }
.board-overlay { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; border-radius: 18px; font-size: 2rem; font-weight: 900;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.board-overlay.time { color: var(--accent); font-size: 3rem; animation: pop .4s var(--ease); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

/* ---- playing ---- */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.hud-time { display: flex; align-items: baseline; gap: 6px; }
.timer { font-size: 2.6rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.low { color: var(--accent); animation: breathe 1s ease-in-out infinite; }
.hud-sub { color: var(--muted); font-weight: 800; }
.shift-ring { position: relative; width: 62px; height: 62px; display: grid; place-items: center; }
.shift-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 3.5; }
.ring-fg { fill: none; stroke: var(--teal); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 94.25; transition: stroke-dashoffset .25s linear; }
.shift-ring.soon .ring-fg { stroke: var(--accent); }
.shift-ring.final .ring-fg { stroke: var(--muted); }
.shift-label { position: relative; font-weight: 900; font-size: .9rem; font-variant-numeric: tabular-nums; }
.shift-ring::after { content: "shift"; position: absolute; bottom: -14px; font-size: .62rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.bonus-chips { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bonus-chips li { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 800; padding: 3px 10px 3px 6px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); }
.bonus-chips .icon { width: 16px; height: 16px; }
.word-bar { min-height: 64px; display: grid; place-items: center; text-align: center; margin: 4px 0; }
.current-word { font-size: 2rem; font-weight: 900; letter-spacing: .08em; min-height: 1.2em; line-height: 1.2; color: var(--accent); word-break: break-all; }
.current-word.short { color: var(--muted); }
.current-word.missing { color: var(--muted); text-decoration: line-through; }
.hint { font-size: .9rem; font-weight: 800; min-height: 1.3em; color: var(--muted); }
.hint.good { color: var(--good); }
.hint.bad { color: var(--bad); }
.hint.dup { color: var(--dup); }
.controls { display: flex; gap: 8px; margin: 12px 0; align-items: center; }
.controls .type-input { flex: 1; min-width: 0; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; }
.controls .type-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 600; }
.zoom-btn { min-width: 44px; padding: 0; font-size: 1.3rem; }
.hinge-note { margin: 0 0 8px; }
.words-panel { margin-top: 10px; }
.my-count { margin-bottom: 8px; }
.my-words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-weight: 800; font-size: .88rem; letter-spacing: .04em; border: 0; }
.chip.new { animation: chip-in .45s var(--ease); background: var(--accent-soft); }
@keyframes chip-in { from { transform: scale(.4) translateY(-10px); opacity: 0; } }
button.chip { cursor: pointer; min-height: 36px; border: 2px solid var(--c); }
button.chip.shared { opacity: .7; border-style: dashed; }
.chain { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 4px; }
.chain-label { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--teal); }
.chain-words { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: .95rem; }
.chain-words i { color: var(--muted); font-style: normal; }
.goal { padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-top: 10px; }
.goal-text { font-weight: 800; font-size: .92rem; margin-bottom: 6px; }
.meter { height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); border-radius: inherit; transition: width .5s var(--ease); }
.goal.reached .meter i { background: var(--good); }
.goal.reached .goal-text { color: var(--good); }

@media (min-width: 900px) {
  .phone { max-width: 1100px; }
  .playing { display: grid; grid-template-columns: minmax(420px, 620px) minmax(280px, 1fr); grid-template-areas: "hud side" "chips side" "word side" "board side" "controls side"; column-gap: 28px; align-items: start; }
  .playing > .hud { grid-area: hud; }
  .playing > .bonus-chips { grid-area: chips; }
  .playing > .word-bar { grid-area: word; }
  .playing > .board-wrap { grid-area: board; }
  .playing > .controls { grid-area: controls; }
  .playing > .hinge-note, .playing > .goal, .playing > .chain, .playing > .words-panel { grid-column: 2; }
  .playing > .hinge-note { grid-row: 1; }
  .playing > .goal { grid-row: 2; }
  .playing > .chain { grid-row: 3; }
  .playing > .words-panel { grid-row: 4 / span 2; margin-top: 0; }
}
@media (max-height: 700px) and (max-width: 899px) { .word-bar { min-height: 48px; } .current-word { font-size: 1.6rem; } .timer { font-size: 2rem; } }

/* ---- results ---- */
.results-head { text-align: center; }
.score-big { text-align: center; margin: 0; }
.score-big b { font-size: 3.4rem; font-weight: 900; color: var(--accent); line-height: 1; }
.score-big span { color: var(--muted); font-weight: 800; }
.next-bar { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.next-label { font-weight: 800; color: var(--ink-2); flex-basis: 100%; text-align: center; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; overflow-x: auto; }
.tabs button { flex: 1; min-height: 40px; border: 0; background: transparent; border-radius: 10px; font-weight: 800; font-size: .88rem; cursor: pointer; white-space: nowrap; padding: 0 10px; }
.tabs button[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
.round-pick { text-align: right; }
.round-pick select { width: auto; }
.tally { display: flex; gap: 14px; justify-content: center; margin-bottom: 10px; color: var(--muted); font-weight: 700; }
.tally b { color: var(--ink); font-size: 1.2rem; }
.tally .total b { color: var(--accent); }
.awards { list-style: none; padding: 0; margin: 0 0 10px; }
.awards li { padding: 6px 10px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); font-weight: 800; }
.word-rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.wr { display: grid; grid-template-columns: 1fr auto 2.4em; grid-template-areas: "w badge pts" "bon bon bon"; gap: 2px 8px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.wr .w { grid-area: w; font-weight: 900; letter-spacing: .05em; }
.wr .badge { grid-area: badge; font-size: .72rem; font-weight: 800; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); }
.wr.shared .badge { background: var(--surface); color: var(--muted); }
.wr.shared .w { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.wr .pts { grid-area: pts; font-weight: 900; font-size: 1.1rem; }
.wr .bon { grid-area: bon; display: flex; flex-wrap: wrap; gap: 4px; }
.wr .bon:empty { display: none; }
.wr .bon i { font-style: normal; font-size: .75rem; font-weight: 800; color: var(--gold); }
.rejected { margin-top: 10px; color: var(--muted); }
.rejected summary { cursor: pointer; font-weight: 800; min-height: 32px; }
.rejected ul { margin: 4px 0; padding-left: 1.2em; }
.rejected .w { font-weight: 800; color: var(--ink-2); }
.leaderboard { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; }
.leaderboard li { display: grid; grid-template-columns: 1.8em auto 1fr auto 3em; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.leaderboard li.me { outline: 2px solid var(--teal); }
.leaderboard .rank { font-weight: 900; color: var(--muted); text-align: center; }
.leaderboard .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard .meta { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.leaderboard .total { font-weight: 900; font-size: 1.15rem; }
.table-wrap { overflow-x: auto; }
.match-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.match-table th, .match-table td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.match-table .left { text-align: left; white-space: nowrap; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }
.match-table th { font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.match-table .total { font-weight: 900; }
.match-table tr.me td { background: color-mix(in srgb, var(--teal) 10%, transparent); }
.player-words { border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; margin-bottom: 8px; background: var(--surface); }
.player-words summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; gap: 6px; }
.player-words .breakdown { margin-top: 8px; }
.podium { list-style: none; padding: 0; margin: 10px auto; display: flex; align-items: flex-end; justify-content: center; gap: 10px; max-width: 420px; }
.podium li { flex: 1; display: grid; justify-items: center; gap: 4px; }
.podium .name { font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .avatar { width: 44px; height: 44px; font-size: 1.2rem; }
.podium .step { width: 100%; display: grid; place-items: center; font-weight: 900; font-size: 1.5rem; color: #fff; border-radius: 12px 12px 4px 4px; background: var(--teal); }
.podium .place-1 .step { height: 92px; background: var(--accent); }
.podium .place-2 .step { height: 66px; }
.podium .place-3 .step { height: 46px; background: var(--gold); }
.replay { display: grid; gap: 10px; }
.replay .board { max-width: 420px; margin: 0 auto; }
.replay-controls { display: flex; gap: 8px; justify-content: center; }
.replay-caption { text-align: center; font-weight: 800; color: var(--ink-2); margin: 0; }
.replay-words { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.highlights { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.highlights li { display: grid; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.highlights span { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.closed, .spectator { padding-top: 10vh; }

/* ---- big screen ---- */
body[data-view="screen"] { overflow: hidden; }
.screen { position: relative; width: 100vw; height: 100dvh; overflow: hidden; font-size: clamp(15px, 1.2vw, 30px); }
.screen-corner { position: absolute; top: 10px; right: 10px; z-index: 5; opacity: .35; }
.screen-corner:hover, .screen-corner:focus-within { opacity: 1; }
.screen-body { height: 100%; padding: 3vh 3vw; display: grid; gap: 3vw; }
.screen h1 { font-size: 2.4em; }
.screen h2 { font-size: 1.5em; }
.tv-col { display: grid; align-content: center; gap: 2vh; min-height: 0; }
.tv-lobby { grid-template-columns: 1fr 1fr; text-align: center; }
.tv-join { font-size: 1.4em; font-weight: 700; }
.tv-code { font-family: var(--mono); font-size: 7em; font-weight: 900; letter-spacing: .2em; padding-left: .2em; margin: 0; line-height: 1; color: var(--accent); }
.tv-qr { width: min(30vh, 22vw); justify-self: center; }
.tv-players { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); gap: .5em; text-align: left; }
.tv-players li { display: flex; align-items: center; gap: .5em; font-weight: 800; padding: .3em .6em; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.tv-players li.away { opacity: .45; }
.tv-players .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-players .avatar { width: 1.8em; height: 1.8em; font-size: .9em; }
.tv-preview { grid-template-columns: 1fr 1.6fr; }
.tv-preview .tv-col.narrow { text-align: center; }
.tv-count { font-size: 9em; font-weight: 900; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.tv-count.small-text { font-size: 4em; color: var(--ink-2); }
.tv-card .round-card { font-size: 1.1em; }
.tv-playing { grid-template-columns: auto 1fr; align-items: center; }
.tv-board { position: relative; width: min(92dvh, 60vw); }
.tv-side { display: grid; gap: 2.2vh; align-content: center; min-width: 0; }
.tv-side .logo { margin: 0; width: 14em; }
.tv-timer { font-size: 7em; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.tv-timer.low { color: var(--accent); }
.tv-shift .label { font-size: 1.4em; font-weight: 800; display: block; margin-bottom: .4em; }
.tv-shift .meter { height: 16px; }
.tv-shift .meter i { transition: width .25s linear; }
.tv-shift.soon .label { color: var(--accent); }
.tv-goal .goal-text { font-size: 1.2em; }
.tv-side-players h3 { font-size: 1.2em; }
.tv-side-players .tv-players { grid-template-columns: repeat(auto-fill, minmax(8em, 1fr)); font-size: .85em; }
.tv-results { grid-template-columns: 1fr 1fr; align-items: start; overflow: hidden; }
.tv-results .leaderboard li { font-size: 1.05em; padding: .3em .6em; }
.tv-results .leaderboard { gap: .3em; }
.tv-results.final { align-items: center; }
.tv-results .podium { max-width: 30em; font-size: 1.3em; }
.tv-replay { display: grid; justify-items: center; }
.tv-replay .board { width: min(36vh, 22vw); }
.tv-next { font-size: 1.3em; font-weight: 800; text-align: center; color: var(--ink-2); }
.tv-closed { place-items: center; align-content: center; text-align: center; }
.board-tv .board-viewport { border-radius: 2.4cqi; }
@media (max-aspect-ratio: 1/1) {
  .screen { overflow: auto; height: auto; min-height: 100dvh; }
  body[data-view="screen"] { overflow: auto; }
  .tv-playing, .tv-lobby, .tv-preview, .tv-results { grid-template-columns: 1fr; }
  .tv-board { width: 100%; }
}

/* ---- motion ---- */
[data-motion="reduced"] *, [data-motion="reduced"] *::before, [data-motion="reduced"] *::after {
  animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important;
}
[data-motion="reduced"] .row-flash.on { animation: none; opacity: 1; transition: opacity 1.2s; }

/* TV sizing for shared components (rem-based sizes are too small at 3 m) */
.screen .match-table { font-size: 1.05em; }
.screen .match-table th { font-size: .75em; }
.screen .leaderboard .meta { font-size: .7em; }
.screen .goal-text { font-size: 1em; }
.replay-tv .replay-controls { display: none; }
.replay-tv .replay-caption { font-size: 1.1em; }
