:root { --bg:#14161a; --fg:#eceff4; --dim:#8a93a3; --cell:#242932; --open:#2f3642; --hl:#3b4a63; --cur:#f2c14e;
        --ghost:#8e7cf0; --good:#5cc98a; --bad:#ee6b6b;
        --sat:env(safe-area-inset-top,0px); --sab:env(safe-area-inset-bottom,0px);
        --sal:env(safe-area-inset-left,0px); --sar:env(safe-area-inset-right,0px); }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html { -webkit-text-size-adjust:100%; touch-action:manipulation; overscroll-behavior:none; background:var(--bg); }
body { margin:0; background:var(--bg); color:var(--fg); font:16px/1.35 -apple-system,system-ui,sans-serif;
       -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
#app { max-width:520px; margin:0 auto; min-height:100vh; min-height:100dvh;
       padding:calc(10px + var(--sat)) calc(12px + var(--sar)) calc(14px + var(--sab)) calc(12px + var(--sal)); }
h1 { font-size:22px; margin:6px 0; } h2 { font-size:16px; margin:10px 0 4px; }
button { font:inherit; color:var(--fg); background:#2b3240; border:0; border-radius:10px; padding:0 14px; min-height:44px;
         touch-action:manipulation; -webkit-appearance:none; appearance:none; }
button:active { filter:brightness(1.35); transform:scale(.97); }
button.primary { background:#3d6df0; min-height:54px; font-weight:600; flex:1; } button:disabled { opacity:.4; }
.row { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0; } .row > button { flex:1; }
.dim { color:var(--dim); font-size:13px; }
.ahead { color:var(--good); } .behind { color:var(--bad); }
.card { background:var(--cell); border-radius:12px; padding:12px; margin:10px 0; }
.big { font-size:28px; font-weight:700; }
.timer { font-variant-numeric:tabular-nums; font-size:24px; font-weight:700; }
.splits { font-variant-numeric:tabular-nums; width:100%; border-collapse:collapse; }
.splits td, .splits th { padding:4px 6px; text-align:right; } .splits td:first-child, .splits th:first-child { text-align:left; }

/* play screen: fixed to the visible viewport; grid takes the leftover height; keyboard pinned to the bottom */
.play { position:fixed; inset:0; display:flex; flex-direction:column; gap:6px; overflow:hidden;
        padding:calc(8px + var(--sat)) calc(10px + var(--sar)) calc(8px + var(--sab)) calc(10px + var(--sal));
        max-width:520px; margin:0 auto; }
.top { display:flex; justify-content:space-between; align-items:baseline; gap:8px; }
.top .dim { text-align:right; }
.bars { display:grid; gap:3px; }
.bar { height:8px; background:#2a2f39; border-radius:4px; overflow:hidden; }
.bar i { display:block; height:100%; transition:width .35s ease-out; }
.bar.you i { background:var(--cur); } .bar.ghost i { background:var(--ghost); }
.lead { font-size:13px; font-weight:600; min-height:18px; }
.gridwrap { flex:1 1 0; min-height:0; display:flex; align-items:center; justify-content:center; container-type:size; }
.grid { display:grid; gap:3px; width:100%; max-width:100%; aspect-ratio:1/1; width:min(100%,100cqh); container-type:inline-size; }
.cell { position:relative; background:var(--open); border-radius:5px; display:flex; align-items:center; justify-content:center;
        font-size:clamp(20px,9vw,40px); font-size:clamp(20px,calc(100cqw / 9),44px); font-weight:600; transition:background .12s; }
.cell.block { background:#0b0c0e; }
.cell .num { position:absolute; top:2px; left:4px; font-size:11px; font-weight:500; color:var(--dim); }
.cell.hl { background:var(--hl); } .cell.cur { background:var(--cur); color:#111; } .cell.cur .num { color:#4a3d12; }
.cell.wrong { color:var(--bad); }
.cell .gdot { position:absolute; right:4px; bottom:4px; width:10px; height:10px; border-radius:50%; background:var(--ghost);
              animation:pop .25s ease-out; }
@keyframes pop { from { transform:scale(0); } 60% { transform:scale(1.5); } to { transform:scale(1); } }
.cell.gcur { box-shadow:inset 0 0 0 3px var(--ghost); }
.clue { display:flex; align-items:stretch; gap:6px; }
.clue .txt { flex:1; background:var(--cell); border-radius:10px; padding:6px 10px; min-height:48px; display:flex; align-items:center; }
.clue button { width:48px; padding:0; font-size:20px; }
.actions { display:flex; gap:6px; } .actions button { flex:1; min-height:40px; font-size:14px; padding:0 4px; }
.msg { min-height:16px; }
.kbd { display:grid; gap:6px; }
.kbd .krow { display:flex; gap:5px; justify-content:center; }
.kbd button { flex:0 0 calc((100% - 45px) / 10); min-height:48px; padding:0; font-size:19px; font-weight:600; }
.kbd button.wide { flex:0 0 calc((100% - 45px) / 10 * 1.5 + 2.5px); }
.sheet { display:none; position:fixed; inset:0; z-index:5; background:var(--bg); overflow-y:auto; -webkit-overflow-scrolling:touch;
         padding:calc(10px + var(--sat)) calc(12px + var(--sar)) calc(14px + var(--sab)) calc(12px + var(--sal)); }
.sheet.open { display:block; }
.cluelist { display:grid; gap:4px; font-size:15px; }
.cluelist div.item { padding:10px 8px; border-radius:8px; background:var(--cell); } .cluelist div.act { background:var(--hl); }
.sheet .close { position:sticky; bottom:0; width:100%; margin-top:10px; }
