/* TileQuiz · Split-flap design system · phones, tablets, desktops and TVs */
:root {
  --bg: #0D1017; --panel: #151A23; --panel-2: #1B2130; --line: #262D3A; --line-2: #343C4B;
  --cream: #F1E8D6; --cream-2: #E4D9C3; --ink: #111418;
  --amber: #F5A524; --green: #33D18F; --red: #EF4B4B; --muted: #8B95A7;
  --mono: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
  --display: 'Bebas Neue', 'Oswald', Impact, 'Arial Narrow', sans-serif;
  --radius: 6px;
  --shell: 480px;
  --pad: 16px;
  --flap-w: 30px; --flap-h: 40px; --flap-fs: 28px;
  color-scheme: dark;
}
@media (min-width: 640px) { :root { --shell: 640px; --pad: 24px; --flap-w: 36px; --flap-h: 48px; --flap-fs: 34px; } }
@media (min-width: 1024px) { :root { --shell: 960px; --pad: 32px; --flap-w: 42px; --flap-h: 56px; --flap-fs: 40px; } }
@media (min-width: 1600px) { :root { --shell: 1100px; } }

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--mono); color: var(--cream); background: var(--bg); line-height: 1.4; min-height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
a { color: var(--amber); }
a:hover { color: var(--cream); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.bebas { font-family: var(--display); font-weight: 400; letter-spacing: .03em; text-transform: uppercase; }
.label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.amber { color: var(--amber); }
.green { color: var(--green); }
.red { color: var(--red); }

/* shell */
.screen { max-width: var(--shell); margin: 0 auto; min-height: 100dvh; padding: var(--pad) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 10px; }
.topbar .wordmark { display: flex; align-items: center; gap: 10px; font-size: 26px; line-height: 1; text-decoration: none; color: var(--cream); }
.topbar .wordmark svg.mark { width: 24px; height: 24px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.iconbtn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: var(--radius); }
.iconbtn:hover { color: var(--cream); background: var(--panel); }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }

/* two-column layouts on wide screens: hero | main, with actions under the hero */
.cols { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.cols > .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 7fr); grid-template-rows: auto 1fr; column-gap: 48px; row-gap: 24px; align-items: start; }
  .cols > .col.hero { grid-column: 1; grid-row: 1; }
  .cols > .col.main { grid-column: 2; grid-row: 1 / span 2; }
  .cols > .col.actions { grid-column: 1; grid-row: 2; }
  .cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* flaps */
.flap { position: relative; overflow: hidden; border-radius: var(--radius); background: var(--cream); color: var(--ink); }
.flap::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 50%; background: rgba(255, 255, 255, 0.08); pointer-events: none; }
.flap::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, 0.38); pointer-events: none; }
.flap.dark { background: var(--panel); color: var(--cream); border: 1px solid var(--line); }
.flap.amber { background: var(--amber); color: var(--ink); }
.flap.green { background: var(--green); color: var(--ink); }
.flap.red { background: var(--red); color: var(--cream); }
.flapword { display: flex; flex-wrap: wrap; gap: 4px; }
.flapword .gap { width: 10px; }
.flapword .ch { width: var(--flap-w); height: var(--flap-h); font-size: var(--flap-fs); display: flex; align-items: center; justify-content: center; }
.flapword.lg .ch { width: calc(var(--flap-w) * 1.5); height: calc(var(--flap-h) * 1.5); font-size: calc(var(--flap-fs) * 1.55); }
.flapword.xl .ch { width: calc(var(--flap-w) * 1.8); height: calc(var(--flap-h) * 1.85); font-size: calc(var(--flap-fs) * 2.1); }
.flapword .sep { font-size: calc(var(--flap-fs) * 1.5); align-self: flex-end; padding: 0 2px 8px; }
.flapword.xl .sep { font-size: calc(var(--flap-fs) * 2); }

/* buttons */
.btn { height: 54px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: var(--radius); font-family: var(--display); font-size: 22px; letter-spacing: .04em; text-transform: uppercase; text-decoration: none; user-select: none; transition: transform .08s ease, filter .12s ease; width: 100%; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--amber); color: var(--ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border: 1px solid var(--cream); color: var(--cream); }
.btn.ghost:hover { background: rgba(241, 232, 214, 0.06); }
.btn.quiet { border: 1px solid var(--line); color: var(--muted); }
.btn.quiet:hover { color: var(--cream); border-color: var(--line-2); }
.btn.sm { height: 40px; font-size: 18px; padding: 0 14px; width: auto; }
.btn.xs { height: 34px; font-size: 11px; font-family: var(--mono); letter-spacing: .1em; padding: 0 12px; width: auto; border: 1px solid var(--cream); border-radius: 4px; }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }

/* home */
.headline { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.tagline { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.today { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--cream); }
.today:hover { border-color: var(--line-2); color: var(--cream); }
.today .num { font-size: 34px; line-height: 1; color: var(--amber); }
.today .txt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.today .txt .t { font-size: 20px; line-height: 1; }
.today .txt .s { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.today.done .num { color: var(--green); }
.list { border-top: 1px solid var(--line); }
.list .item { display: flex; align-items: center; gap: 14px; height: 50px; border-bottom: 1px solid var(--line); color: var(--cream); text-decoration: none; width: 100%; text-align: left; }
.list .item:hover { background: rgba(255, 255, 255, 0.02); }
.list .item .icon { color: var(--muted); }
.list .item .name { font-size: 22px; line-height: 1; }
.list .item .meta { margin-left: auto; font-size: 11px; letter-spacing: .1em; color: var(--muted); display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.list .item .meta .pct { color: var(--cream); min-width: 3ch; text-align: right; }
.list .item .meta .pct.none { color: var(--line-2); }
.modes { display: flex; gap: 8px; }
.modes .mode { flex: 1; height: 54px; display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--display); font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.modes .mode .icon { width: 18px; height: 18px; }
.modes .mode.on { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.sticky-bottom { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); margin-top: auto; padding-top: 12px; background: linear-gradient(180deg, rgba(13, 16, 23, 0) 0%, var(--bg) 30%); }
.sticky-bottom .label, .sticky-bottom .note { display: none; }
@media (min-width: 900px) { .sticky-bottom { position: static; margin-top: 0; padding-top: 0; background: none; } .sticky-bottom .label, .sticky-bottom .note { display: block; } .screen.play .play-wrap { max-width: 720px; width: 100%; margin: 0 auto; } }
.kbd-hint { display: none; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
@media (hover: hover) and (pointer: fine) and (min-width: 640px) { .kbd-hint { display: block; } }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.hint { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hint .h { padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); line-height: 1.5; }
.hint .h b { display: block; color: var(--cream); font-family: var(--display); font-size: 20px; letter-spacing: .03em; font-weight: 400; }

/* HUD */
.hud { padding: 12px 14px 0; }
.hud .big { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.hud .big > div { min-width: 0; }
.hud .big .v { font-size: 40px; line-height: 1; }
.hud .small { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 11px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.hud .small b { color: var(--cream); font-weight: 500; }
.lives { display: inline-flex; gap: 5px; vertical-align: middle; margin-left: 6px; }
.lives i { width: 12px; height: 12px; border-radius: 2px; background: var(--line); display: block; transition: background .2s; }
.lives i.on { background: var(--amber); }
.lives i.lost { animation: lose .4s ease; }
.track { margin: 12px -14px 0; height: 3px; background: var(--line); overflow: hidden; border-radius: 0 0 8px 8px; }
.track .fill { height: 100%; width: 100%; background: var(--amber); transform-origin: left; }
.track .fill.low { background: var(--red); }

/* board: portrait stacks, short landscape puts the board beside the HUD */
.play-wrap { display: grid; grid-template-areas: "hud" "prompt" "grid" "msg" "players"; gap: 14px; flex: 1; align-content: start; }
.play-wrap > .hud { grid-area: hud; }
.play-wrap > .prompt-block { grid-area: prompt; }
.play-wrap > .grid-block { grid-area: grid; position: relative; width: 100%; }
.play-wrap > .msg { grid-area: msg; }
.play-wrap > .players { grid-area: players; }
.grid-block { max-width: 680px; margin: 0 auto; }
.grid-block.cols-2 { max-width: 460px; }
.grid-block.cols-3 { max-width: 580px; }
.prompt { font-size: clamp(28px, 7.5vw, 40px); line-height: 1; margin: 4px 0 0; }
.prompt.boss { color: var(--amber); }
.sub { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 8px; }
.tile { --tile-fs: 12px; --fs-scale: 1; position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-family: var(--mono); font-size: calc(var(--tile-fs) * var(--fs-scale)); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; line-height: 1.2; word-break: break-word; hyphens: auto; transition: transform .08s ease, filter .12s ease; -webkit-tap-highlight-color: transparent; }
.tile:active:not([disabled]) { transform: scale(.96); }
.grid.cols-2 .tile { --tile-fs: 20px; aspect-ratio: 1.25; }
.grid.cols-3 .tile { --tile-fs: 15px; }
.tile.emoji { --fs-scale: 2.4; text-transform: none; letter-spacing: 0; line-height: 1; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif; }
.tile.emoji.emoji-wide { --fs-scale: 1.5; }
.tile.long { --fs-scale: .85; }
.tile.xlong { --fs-scale: .72; }
.tile.xxlong { --fs-scale: .62; }
.tile.is-found { background: var(--green); color: var(--ink); animation: flip .35s ease-out; }
.tile.is-wrong { background: var(--red); color: var(--cream); animation: flip .35s ease-out; }
.tile.is-revealed { background: var(--amber); color: var(--ink); animation: flip .35s ease-out; }
.tile.is-belongs { background: var(--cream-2); color: var(--muted); }
.tile[disabled] { cursor: default; }
.tile .by { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 3px; background: var(--ink); color: var(--cream); font-size: 9px; display: flex; align-items: center; justify-content: center; letter-spacing: 0; }
.tile .state { position: absolute; bottom: 3px; right: 4px; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: rgba(0, 0, 0, 0.55); }
.tile .state .icon { width: 13px; height: 13px; stroke-width: 3; }
.tile.is-wrong .state { color: rgba(255, 255, 255, 0.9); }
.tile.is-revealed .state { color: rgba(0, 0, 0, 0.45); }
.tvscreen .tile .state { width: 2vw; height: 2vw; bottom: .8vmin; right: .8vmin; }
.tvscreen .tile .state .icon { width: 1.7vw; height: 1.7vw; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--amber); color: var(--ink); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
.tile .key { position: absolute; bottom: 4px; left: 6px; font-size: 9px; color: rgba(0, 0, 0, 0.45); letter-spacing: 0; display: none; }
.msg { min-height: 20px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; text-align: center; color: var(--amber); }
.msg.bad { color: var(--red); }
.msg.good { color: var(--green); }
.msg.plain { color: var(--muted); }
.banner { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 2; }
.banner .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px 28px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); animation: rise .3s ease-out; min-width: 220px; }
.banner .card .t { font-size: 44px; line-height: 1; }
.banner .card .s { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.banner .card .p { font-size: 30px; line-height: 1; color: var(--amber); margin-top: 6px; }
.grid.dim .tile:not(.is-found):not(.is-wrong):not(.is-revealed) { opacity: .55; }
@media (hover: hover) and (pointer: fine) {
  .tile:not([disabled]):hover { transform: translateY(-2px); filter: brightness(1.04); }
  .tile .state { position: absolute; bottom: 3px; right: 4px; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; color: rgba(0, 0, 0, 0.55); }
.tile .state .icon { width: 13px; height: 13px; stroke-width: 3; }
.tile.is-wrong .state { color: rgba(255, 255, 255, 0.9); }
.tile.is-revealed .state { color: rgba(0, 0, 0, 0.45); }
.tvscreen .tile .state { width: 2vw; height: 2vw; bottom: .8vmin; right: .8vmin; }
.tvscreen .tile .state .icon { width: 1.7vw; height: 1.7vw; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--amber); color: var(--ink); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
.tile .key { display: block; }
}
@media (min-width: 640px) {
  .tile { --tile-fs: 14px; }
  .grid.cols-3 .tile { --tile-fs: 17px; }
  .grid.cols-2 .tile { --tile-fs: 22px; }
  .grid { gap: 10px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .screen.play { min-height: 0; }
  .play-wrap { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); grid-template-areas: "hud grid" "prompt grid" "msg grid" "players grid" "spacer grid"; grid-template-rows: auto auto auto auto 1fr; column-gap: 20px; }
  .grid-block { max-width: none; }
  .tile { aspect-ratio: 1.6; --tile-fs: 12px; }
  .grid.cols-3 .tile { aspect-ratio: 1.6; --tile-fs: 13px; }
  .grid.cols-2 .tile { aspect-ratio: 1.8; --tile-fs: 18px; }
  .prompt { font-size: clamp(24px, 4vw, 34px); }
  .hud .big .v { font-size: 32px; }
  .players { flex-direction: column; }
  .players .pl { flex: none; height: 40px; }
}

.tile.is-picked { box-shadow: inset 0 0 0 3px var(--amber); }
.tile.is-picked.other { box-shadow: inset 0 0 0 3px var(--muted); }
.tile.flash-wrong { animation: wrongflash .6s ease; }
@keyframes wrongflash { 0%, 100% { background: var(--cream); color: var(--ink); } 40% { background: var(--red); color: var(--cream); } }
.tile .rank { position: absolute; top: 4px; left: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--cream); font-size: 10px; display: flex; align-items: center; justify-content: center; letter-spacing: 0; }
.tile.is-found .rank { background: var(--ink); }
.tvscreen .tile .rank { min-width: 2.4vw; height: 2.4vw; font-size: 1.2vw; border-radius: 1.2vw; top: .8vmin; left: .8vmin; }
.tvscreen .tile.is-picked { box-shadow: inset 0 0 0 .5vmin var(--amber); }
.typechip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); }
.tvscreen .typechip { height: 3.2vmin; font-size: 1.1vw; padding: 0 1vw; }

/* image tiles (flags) */
.tile.has-img { padding: 0; background: var(--panel-2); color: var(--cream); }
.tile.has-img > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.grid.has-img .tile { aspect-ratio: 4 / 3; }
.grid.has-img.cols-2 .tile { aspect-ratio: 4 / 3; }
.tile.has-img .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 22px 3px 6px; font-size: 10px; letter-spacing: .04em; background: rgba(17, 20, 24, 0.82); color: var(--cream); display: none; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.tile.has-img.is-found .cap, .tile.has-img.is-wrong .cap, .tile.has-img.is-revealed .cap, .tile.has-img.is-belongs .cap { display: block; }
.tile.has-img.is-found { box-shadow: inset 0 0 0 4px var(--green); }
.tile.has-img.is-wrong { box-shadow: inset 0 0 0 4px var(--red); }
.tile.has-img.is-revealed { box-shadow: inset 0 0 0 4px var(--amber); }
.tile.has-img.is-belongs { box-shadow: inset 0 0 0 4px var(--cream-2); }
.tile.has-img.is-picked { box-shadow: inset 0 0 0 4px var(--amber); }
.tile.has-img .state { background: rgba(17, 20, 24, 0.7); color: var(--cream); border-radius: 3px; z-index: 2; }
.tile.has-img .by, .tile.has-img .rank, .tile.has-img .key { z-index: 2; }
.tile.has-img .key { color: rgba(255, 255, 255, 0.85); text-shadow: 0 0 3px rgba(0, 0, 0, 0.9); }
.tile.has-img::after { z-index: 1; background: rgba(0, 0, 0, 0.22); }
.tile.has-img::before { z-index: 1; background: rgba(255, 255, 255, 0.05); }
.promptimg { width: 108px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; display: block; margin: 8px 0 6px; box-shadow: 0 0 0 1px var(--line-2); }
.tvscreen .promptimg { width: 16vw; margin: 1vmin 0; }
.tvscreen .tile.has-img .cap { font-size: 1.3vw; padding: .6vmin 3vw .6vmin 1vw; }
.tvscreen .tile.has-img.is-found, .tvscreen .tile.has-img.is-wrong, .tvscreen .tile.has-img.is-revealed, .tvscreen .tile.has-img.is-picked { box-shadow: inset 0 0 0 .7vmin var(--green); }
.tvscreen .tile.has-img.is-wrong { box-shadow: inset 0 0 0 .7vmin var(--red); }
.tvscreen .tile.has-img.is-revealed { box-shadow: inset 0 0 0 .7vmin var(--amber); }
.tvscreen .tile.has-img.is-picked { box-shadow: inset 0 0 0 .7vmin var(--amber); }
.share .sg i.img { background: var(--cream); }

/* players */
.players { display: flex; gap: 8px; flex-wrap: wrap; }
.players .pl { flex: 1 1 calc(33% - 8px); min-width: 100px; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
.players .pl .n { font-size: 20px; line-height: 1; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.players .pl .n .host { font-size: 9px; letter-spacing: .1em; color: var(--amber); font-family: var(--mono); }
.players .pl .n.me { color: var(--amber); }
.players .pl .c { font-size: 24px; line-height: 1; color: var(--amber); display: flex; align-items: center; gap: 8px; }
.players .pl .c .lv { display: inline-flex; gap: 3px; }
.players .pl .c .lv i { width: 8px; height: 8px; border-radius: 2px; background: var(--line-2); display: block; }
.players .pl .c .lv i.on { background: var(--green); }
.players .pl.off { opacity: .45; }
.players .pl.out .c { color: var(--red); }

/* results */
.rows { border-top: 1px solid var(--line); }
.rows .r { display: flex; justify-content: space-between; align-items: center; height: 46px; border-bottom: 1px solid var(--line); }
.rows .r .k { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.rows .r .v { font-size: 26px; line-height: 1; }
.share { display: flex; gap: 14px; align-items: center; }
.share .sg { display: grid; grid-template-columns: repeat(var(--cols, 4), 22px); gap: 4px; }
.share .sg i { width: 22px; height: 22px; border-radius: 3px; display: block; background: var(--cream); }
.share .sg i.f { background: var(--green); }
.share .sg i.w { background: var(--red); }
.share .sg i.m { background: var(--amber); }
.share .sg i.o { background: var(--cream); opacity: .35; }
.share .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.share .txt .t { font-size: 20px; line-height: 1; }
.share .txt .s { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; position: relative; margin-top: 8px; }
.bar .f { height: 100%; background: var(--amber); transition: width .8s ease; }
.bar .d { position: absolute; top: 0; height: 100%; background: var(--cream); }
.kn { display: flex; justify-content: space-between; align-items: baseline; }
.kn .v { font-size: 26px; line-height: 1; color: var(--amber); }
.rows .r.lesson { height: auto; min-height: 40px; padding: 8px 0; gap: 12px; align-items: flex-start; }
.rows .r.lesson .k { flex: none; width: 58px; padding-top: 3px; }
.rows .r.lesson .k.wrong { color: var(--red); }
.rows .r.lesson .k.missed { color: var(--amber); }
.rows .r.lesson .v { font-family: var(--mono); font-size: 13px; line-height: 1.4; text-align: left; flex: 1; color: var(--cream); }
.standings .r .v { display: flex; align-items: center; gap: 10px; }
.standings .r .k { color: var(--cream); font-size: 20px; font-family: var(--display); letter-spacing: .03em; display: flex; align-items: center; gap: 8px; }
.standings .r .k .pos { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* lobby */
.code { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input { height: 50px; padding: 0 14px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); color: var(--cream); font-family: var(--mono); font-size: 16px; text-transform: none; width: 100%; }
.field input.code { text-transform: uppercase; letter-spacing: .3em; font-family: var(--display); font-size: 28px; }
.field input:focus { outline: 2px solid var(--amber); border-color: var(--amber); }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.tvrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius); }
.tvrow .icon { color: var(--amber); }
.tvrow .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tvrow .txt .t { font-size: 18px; line-height: 1; }
.tvrow .txt .s { font-size: 11px; color: var(--muted); word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--cream); color: var(--ink); padding: 10px 16px; border-radius: var(--radius); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; z-index: 20; animation: rise .25s ease-out; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); white-space: nowrap; }
.error { padding: 10px 12px; border: 1px solid var(--red); color: var(--red); border-radius: var(--radius); font-size: 12px; }

/* animations */
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes lose { 0% { transform: scale(1.6); background: var(--red); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.shake { animation: shake .3s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------------
   TV display (/tv/CODE): 16:9, read from across the room, no pointer.
   Overscan-safe padding, everything sized in viewport units. */
body.tv { overflow: hidden; cursor: none; }
body.tv .toast { font-size: 1.4vw; }
.tvscreen { width: 100vw; height: 100vh; height: 100dvh; padding: 4vmin 5vmin; display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); column-gap: 4vmin; }
.tvscreen .board-col { display: flex; flex-direction: column; gap: 2.4vmin; min-width: 0; min-height: 0; }
.tvscreen .side-col { display: flex; flex-direction: column; gap: 2.4vmin; min-width: 0; min-height: 0; }
.tvscreen .label { font-size: 1.3vw; }
.tvscreen .prompt { font-size: clamp(32px, 4.6vw, 96px); margin: 0; }
.tvscreen .sub { font-size: 1.3vw; margin-top: .6vmin; }
.tvscreen .grid-block { max-width: none; margin: 0; flex: 1; min-height: 0; position: relative; }
.tvscreen .grid { gap: 1.2vmin; height: 100%; grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr)); }
.tvscreen .tile { aspect-ratio: auto; height: 100%; --tile-fs: clamp(16px, 1.9vw, 40px); padding: 1vmin; border-radius: 1vmin; }
.tvscreen .grid.cols-3 .tile { --tile-fs: clamp(18px, 2.3vw, 48px); }
.tvscreen .grid.cols-2 .tile { --tile-fs: clamp(22px, 3vw, 60px); }
.tvscreen .tile .by { width: 2.4vw; height: 2.4vw; font-size: 1.1vw; top: .8vmin; right: .8vmin; border-radius: .5vmin; }
.tvscreen .msg { font-size: 1.6vw; min-height: 2.2vw; }
.tvscreen .banner .card { padding: 3vmin 5vmin; border-radius: 1.5vmin; }
.tvscreen .banner .card .t { font-size: 6vw; }
.tvscreen .banner .card .s { font-size: 1.6vw; }
.tvscreen .banner .card .p { font-size: 3.6vw; }
.tvscreen .hud { padding: 1.6vmin 2vmin 0; border-radius: 1.2vmin; }
.tvscreen .hud .big .v { font-size: 4.2vw; }
.tvscreen .hud .small { font-size: 1.2vw; margin-top: 1.2vmin; }
.tvscreen .lives i { width: 1.2vw; height: 1.2vw; }
.tvscreen .lives { gap: .5vw; }
.tvscreen .track { margin: 1.4vmin -2vmin 0; height: .5vmin; border-radius: 0 0 1.2vmin 1.2vmin; }
.tvscreen .codebox { display: flex; flex-direction: column; gap: 1.2vmin; }
.tvscreen .flapword { gap: .6vmin; }
.tvscreen .flapword .ch { width: 5.2vw; height: 6.8vw; font-size: 5.4vw; border-radius: .8vmin; }
.tvscreen .flapword.big .ch { width: 8vw; height: 10.4vw; font-size: 8.4vw; }
.tvscreen .flapword .gap { width: 2vw; }
.tvscreen .flapword .sep { font-size: 5vw; padding-bottom: 1vw; }
.tvscreen .joinat { font-size: 1.8vw; line-height: 1.3; }
.tvscreen .joinat b { color: var(--amber); font-weight: 500; }
.tvscreen .players { flex-direction: column; gap: 1vmin; overflow: hidden; }
.tvscreen .players .pl { flex: none; height: 5.2vmin; padding: 0 1.6vmin; border-radius: .8vmin; }
.tvscreen .players .pl .n { font-size: 2.2vw; }
.tvscreen .players .pl .n .host { font-size: 1vw; }
.tvscreen .players .pl .c { font-size: 2.4vw; }
.tvscreen .players .pl .c .lv i { width: .9vw; height: .9vw; }
.tvscreen .rows .r { height: 5vmin; }
.tvscreen .rows .r .k { font-size: 1.3vw; }
.tvscreen .rows .r .v { font-size: 2.8vw; }
.tvscreen .standings .r .k { font-size: 2.4vw; }
.tvscreen .standings .r .k .pos { font-size: 1.2vw; }
.tvscreen .note { font-size: 1.4vw; }
.tvscreen .waiting { animation: pulse 2s ease-in-out infinite; }
.tvscreen .center { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 3vmin; }
.tvscreen .center .flapword { justify-content: center; }
.tvscreen .center .players { flex-direction: row; justify-content: center; flex-wrap: wrap; width: 100%; }
.tvscreen .center .players .pl { flex: 0 0 auto; min-width: 16vw; }
.tvscreen .wordmark { display: flex; align-items: center; gap: 1vmin; font-size: 2.4vw; line-height: 1; }
.tvscreen .wordmark svg.mark { width: 2.2vw; height: 2.2vw; }
.tvscreen .topline { display: flex; align-items: center; justify-content: space-between; }
.tvscreen .field input { height: 8vmin; font-size: 3vw; }
.tvscreen .field input.code { font-size: 5vw; }
.tvscreen .btn { height: 8vmin; font-size: 2.6vw; }
@media (orientation: portrait) { .tvscreen { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); } .tvscreen .side-col { order: -1; } }
