/* One screen, one board. The controls only reserve the space they need. */
:root {
  color-scheme:light;
  --bg:#f4f5f7;
  --ink:#273244;
  --muted:#758091;
  --border:#dce1e8;
  --inset-top:max(8px,env(safe-area-inset-top));
  --inset-right:max(8px,env(safe-area-inset-right));
  --inset-bottom:max(8px,env(safe-area-inset-bottom));
  --inset-left:max(8px,env(safe-area-inset-left));
  --board-size:min(calc(100vw - var(--inset-left) - var(--inset-right)),calc(100dvh - var(--inset-top) - var(--inset-bottom) - 52px));
  font-family:"Microsoft YaHei","PingFang SC",system-ui,sans-serif;
  font-synthesis:none;
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html,body { width:100%; height:100%; margin:0; overflow:hidden; }
body { color:var(--ink); background:var(--bg); overscroll-behavior:none; }
button { font:inherit; color:inherit; cursor:pointer; -webkit-tap-highlight-color:transparent; }
button:disabled { cursor:default; opacity:.4; }
button:focus-visible { outline:2px solid #657fa7; outline-offset:2px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.app { height:100dvh; padding:var(--inset-top) var(--inset-right) var(--inset-bottom) var(--inset-left); display:grid; place-items:center; }
.game-shell { width:var(--board-size); display:grid; grid-template-areas:"hud" "arena"; grid-template-columns:minmax(0,1fr); gap:8px; }
.game-hud { grid-area:hud; display:flex; align-items:center; justify-content:space-between; gap:16px; height:44px; min-width:0; }
.brand { font-size:17px; font-weight:700; letter-spacing:.02em; white-space:nowrap; }
.score-stat { display:flex; align-items:baseline; gap:8px; white-space:nowrap; }
.stat-label { font-size:11px; font-weight:400; color:var(--muted); white-space:nowrap; }
#score { min-width:94px; font:600 27px/1 "Segoe UI",sans-serif; font-variant-numeric:tabular-nums; letter-spacing:.02em; }
.next-stat { display:flex; align-items:center; gap:6px; }
#next { display:block; width:56px; height:auto; aspect-ratio:1.44; }
.toolbar-buttons { display:flex; gap:4px; }
.toolbar-buttons button { min-width:44px; height:44px; padding:0 8px; border:0; border-radius:5px; background:transparent; font-size:12px; white-space:nowrap; }
.toolbar-buttons button:hover:not(:disabled) { background:#e6eaf0; }
#sound { font-size:20px; }
.arena { grid-area:arena; width:var(--board-size); height:var(--board-size); outline:none; min-width:0; }
.stage { position:relative; width:100%; height:100%; overflow:hidden; isolation:isolate; border:1px solid #303b50; border-radius:3px; background:#171e2c; }
#game { display:block; width:100%; height:100%; touch-action:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; }
.overlay { position:absolute; inset:0; z-index:5; display:grid; place-items:center; padding:16px; background:rgba(16,22,33,.38); }
.overlay-content { width:min(300px,100%); padding:22px; border:1px solid #dee3e9; border-radius:8px; background:#f7f8fa; text-align:center; }
.overlay h1 { margin:0 0 12px; font-size:24px; line-height:1.25; font-weight:650; }
.overlay p { margin:0 0 18px; font-size:12px; line-height:1.8; color:#627084; }
.overlay-actions { display:flex; justify-content:center; flex-wrap:wrap; gap:8px; }
.overlay-actions button { min-height:44px; padding:10px 18px; border-radius:5px; font-size:13px; }
.button-primary { min-width:126px; border:1px solid #273244; background:#273244; color:#fff; }
.button-primary:hover { background:#3c4c63; }
.button-secondary { border:1px solid var(--border); background:transparent; color:#56657b; }
.results { color:var(--ink) !important; font-weight:600; font-variant-numeric:tabular-nums; }
.toast { position:absolute; z-index:6; left:50%; bottom:20px; transform:translateX(-50%); width:max-content; max-width:90%; padding:8px 12px; border:1px solid #d9e0e9; border-radius:5px; background:#f7f8fa; font-size:12px; line-height:1.5; text-align:center; }
.touch-hint,.touch-controls { display:none; }
.touch-hint { grid-area:hint; margin:0; color:var(--muted); font-size:10px; line-height:14px; text-align:center; white-space:nowrap; }
.touch-controls { grid-area:controls; grid-template-columns:repeat(5,minmax(0,1fr)); gap:6px; }
.touch-controls button { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; min-width:0; height:56px; padding:4px; border:1px solid var(--border); border-radius:6px; background:#fff; touch-action:none; user-select:none; -webkit-user-select:none; }
.touch-controls button:active:not(:disabled) { background:#e3e9f2; border-color:#9dadc3; }
.touch-controls button > span { font:24px/1 "Segoe UI",sans-serif; }
.touch-controls small { font-size:10px; line-height:12px; }
.touch-controls .drop-button { border-color:#b8c4d5; background:#e5ebf4; }
.noscript { position:fixed; inset:0; display:grid; place-items:center; margin:0; background:var(--bg); }
@media (max-width:640px),(hover:none) and (pointer:coarse) {
  :root { --board-size:min(calc(100vw - var(--inset-left) - var(--inset-right)),calc(100dvh - var(--inset-top) - var(--inset-bottom) - 138px)); }
  .game-shell { grid-template-areas:"hud" "arena" "hint" "controls"; }
  .game-hud { gap:8px; }
  .brand { font-size:14px; letter-spacing:0; }
  .score-stat { gap:0; }
  .score-stat > .stat-label { display:none; }
  #score { min-width:70px; font-size:22px; letter-spacing:0; }
  .next-stat { display:grid; justify-items:center; gap:0; }
  .next-stat > .stat-label { font-size:9px; line-height:12px; }
  #next { width:40px; }
  .toolbar-buttons button { padding:0 4px; font-size:11px; }
  #sound { font-size:18px; }
  .touch-hint { display:block; }
  .touch-controls { display:grid; }
  .overlay-content { padding:18px; }
  .overlay h1 { font-size:22px; }
}
@media (max-height:600px) and (min-aspect-ratio:6/5) {
  :root { --board-size:min(calc(100dvh - var(--inset-top) - var(--inset-bottom)),calc(100vw - var(--inset-left) - var(--inset-right) - 190px)); }
  .game-shell { width:auto; grid-template-areas:"hud arena controls"; grid-template-columns:110px var(--board-size) 64px; gap:8px; align-items:center; }
  .game-hud { height:auto; display:grid; justify-content:center; justify-items:center; gap:16px; }
  .brand { font-size:14px; }
  .score-stat { display:grid; justify-items:center; gap:5px; }
  .score-stat > .stat-label { display:block; }
  #score { min-width:0; font-size:24px; }
  .next-stat { display:grid; justify-items:center; gap:3px; }
  #next { width:64px; }
  .toolbar-buttons { display:grid; grid-template-columns:44px 44px; gap:4px; }
  #sound { grid-column:1/-1; justify-self:center; }
  .touch-hint { display:none; }
  .touch-controls { display:grid; grid-template-columns:minmax(0,1fr); }
  .touch-controls button { height:52px; }
  .overlay-content { padding:16px; }
  .overlay h1 { font-size:21px; }
}
