/* SPDX-License-Identifier: Apache-2.0 | Copyright 2026 alvations (Melon Lab) */
:root{
  --bg:#14151c; --panel:#1d1f2a; --cell:#262938; --ink:#ecebf1; --mute:#9a9bb0; --accent:#f2b84b; --line:#33364a;
  --gap:10px; --anim:110ms;
}
@media (max-width:520px){ :root{ --gap:7px; } }
*{ box-sizing:border-box; }
html,body{ margin:0; background:var(--bg); color:var(--ink);
  font:16px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
body{ min-height:100dvh; display:flex; justify-content:center;
  padding:max(16px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom)); }
#app{ width:100%; max-width:480px; position:relative; }
header{ display:flex; justify-content:space-between; align-items:flex-end; gap:12px; margin-bottom:12px; flex-wrap:wrap; }
h1{ margin:0; font-size:2rem; letter-spacing:.02em; color:var(--accent); }
.sub{ margin:0; color:var(--mute); font-size:.85rem; } .sub a{ color:var(--mute); white-space:nowrap; }
.stats{ display:flex; gap:8px; }
.stat{ background:var(--panel); border-radius:10px; padding:6px 12px; min-width:64px; text-align:center; }
.stat span{ display:block; font-size:.68rem; text-transform:uppercase; letter-spacing:.08em; color:var(--mute); }
.stat b{ font-size:1.1rem; font-variant-numeric:tabular-nums; } .stat b.none{ color:var(--mute); font-weight:400; }
.tray{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:6px; }
.pw{ position:relative; background:var(--panel); color:var(--ink); border:1px solid #33364a; border-radius:10px;
  padding:8px 4px; font:inherit; font-size:.85rem; cursor:pointer; white-space:nowrap; }
.pw:disabled{ opacity:.35; cursor:default; }
.pw.armed{ border-color:var(--accent); box-shadow:0 0 0 2px var(--accent) inset; }
.pw i{ font-style:normal; margin-left:6px; background:var(--accent); color:#1b1b22; border-radius:99px;
  padding:0 7px; font-weight:700; font-size:.78rem; }
@media (max-width:380px){ .pw{ font-size:.78rem; } .pw i{ margin-left:3px; padding:0 5px; } }
/* a slot that cannot act now is aria-disabled + .empty (never disabled): a tap explains it */
.pw.empty{ opacity:.45; } .pw.empty:hover{ opacity:.6; }
.hint{ min-height:1.4em; margin:0 0 8px; color:var(--accent); font-size:.85rem; text-align:center; }
.board{ position:relative; width:100%; aspect-ratio:1; background:var(--panel); border-radius:14px; padding:var(--gap);
  touch-action:none; user-select:none; -webkit-user-select:none; outline:none; container-type:size; }
.board.targeting{ cursor:crosshair; box-shadow:0 0 0 2px var(--accent); }
.cells,.tiles{ position:absolute; inset:var(--gap); }
.cells{ display:grid; grid-template-columns:repeat(4,1fr); gap:var(--gap); }
.cells div{ background:var(--cell); border-radius:8px; }
/* targeting: a picked cell is solid gold; the keyboard cursor is a dashed light ring (drawn on the tile too) */
.cells div.sel,.tile.sel{ outline:3px solid var(--accent); outline-offset:-3px; }
.cells div.cur,.tile.cur{ outline:3px dashed var(--ink); outline-offset:-3px; }
.cells div.sel.cur,.tile.sel.cur{ outline:3px solid var(--accent); box-shadow:inset 0 0 0 6px var(--ink); }
.tile{ position:absolute; left:0; top:0; display:flex; align-items:center; justify-content:center;
  width:calc((100% - 3*var(--gap))/4); height:calc((100% - 3*var(--gap))/4); border-radius:8px; font-weight:800;
  background:hsl(var(--h) 62% 60%); color:#15151d;
  transform:translate(calc(var(--c)*(100% + var(--gap))),calc(var(--r)*(100% + var(--gap))));
  transition:transform var(--anim) ease-out; font-size:9cqw; font-variant-numeric:tabular-nums; }
.tile[data-len="3"]{ font-size:7.6cqw; } .tile[data-len="4"]{ font-size:6.4cqw; }
.tile[data-len="5"]{ font-size:5.2cqw; } .tile[data-len="6"]{ font-size:4.4cqw; }
.tile sup{ font-size:.55em; margin-left:1px; }
.tile.lo{ background:hsl(40 25% 88%); } .tile.lo2{ background:hsl(38 40% 82%); }
.tile.pop{ animation:pop 140ms ease-out; } .tile.new{ animation:appear 160ms ease-out; }
@keyframes pop{ 50%{ transform:translate(calc(var(--c)*(100% + var(--gap))),calc(var(--r)*(100% + var(--gap)))) scale(1.14); } }
@keyframes appear{ from{ opacity:0; scale:.6; } }
.over{ position:absolute; inset:0; border-radius:14px; background:rgba(20,21,28,.985); z-index:3; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:10px; text-align:center; padding:20px; }
.over[hidden]{ display:none; } .over h2{ margin:0; font-size:clamp(1.2rem, 5.6vw, 1.6rem); line-height:1.2; text-wrap:balance; }
.over p{ margin:0; color:var(--mute); text-wrap:balance; } .over .best{ color:var(--accent); font-weight:700; }
.row{ display:flex; justify-content:center; margin:14px 0 6px; }
.btn{ background:var(--panel); color:var(--ink); border:1px solid #33364a; border-radius:10px; padding:9px 18px; font:inherit; cursor:pointer; }
.btn.primary{ background:var(--accent); color:#1b1b22; border-color:var(--accent); font-weight:700; }
/* hover and press feedback (desktop), no movement */
.btn:hover:not(:disabled),.pw:hover:not(:disabled){ background:#262a3a; border-color:#4b4f6a; }
.btn:active:not(:disabled),.pw:active:not(:disabled){ background:#2f3349; }
.btn.primary:hover:not(:disabled){ background:#f5c46a; border-color:#f5c46a; } .btn.primary:active:not(:disabled){ background:#e0a93f; }
a:hover{ color:var(--ink); }
.btn:focus-visible,.pw:focus-visible,.board:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
a:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:6px; }
.how a{ color:var(--mute); }
.how{ color:var(--mute); font-size:.82rem; text-align:center; margin:8px 0; }
/* toast at the top of the screen, never over the games row; .bad is the neutral warning/loss variant */
.toast{ position:fixed; left:50%; top:max(12px,env(safe-area-inset-top)); transform:translateX(-50%); background:var(--accent);
  color:#1b1b22; padding:5px 14px; font-size:.9rem; line-height:1.35; border-radius:99px; font-weight:700; opacity:0; pointer-events:none; transition:opacity 200ms;
  width:max-content; max-width:calc(100vw - 32px); text-align:center; z-index:5; box-shadow:0 4px 18px rgba(0,0,0,.45); }
.toast.on{ opacity:1; }
.toast.bad{ background:var(--panel); color:var(--ink); border:1px solid #ff6b6b; font-weight:600; }
.toast.info{ background:var(--panel); color:var(--ink); border:1px solid var(--line); font-weight:600; }
@media (prefers-reduced-motion:reduce){
  :root{ --anim:0ms; }
  .tile.pop,.tile.new{ animation:none; }
  /* opacity is not motion: the toast still fades */
  .toast{ transition:opacity 200ms; }
}
.games{ display:flex; flex-wrap:wrap; justify-content:center; gap:6px 10px; margin:10px 0 4px; font-size:.82rem; }
.games a{ color:var(--mute); } .games a[aria-current="page"]{ color:var(--accent); text-decoration:none; }
.games.detail{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:14px 0 4px; font-size:.82rem; }
.games.detail a{ display:block; text-decoration:none; background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:8px 10px; color:var(--mute); line-height:1.3; }
.games.detail a b{ display:block; color:var(--ink); font-size:.95rem; } .games.detail a:hover{ border-color:#4b4f6a; }
@media (max-width:340px){ .games.detail{ grid-template-columns:1fr; } }
.pw.empty:focus-visible{ opacity:1; }
.games.detail a b .vs{ font-style:normal; font-weight:600; font-size:.66rem; letter-spacing:.06em; text-transform:uppercase; color:var(--cool); margin-left:6px; vertical-align:1px; }
.stat b.none,.stat .none{ color:var(--mute); font-weight:600; font-size:1.1rem; }
/* Round 3 end card: See the board beside New game */
.over .row{ margin:4px 0 0; gap:8px; flex-wrap:wrap; }
