:root {
  --bg: #0a0a1a; --panel: #14142e; --ink: #e8ecff; --dim: #99a2d0;
  --accent: #00e5ff; --pink: #ff4d6d; --gold: #ffb703;
  --sw: 100%; /* actual stage width, kept in sync by app.js */
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: radial-gradient(circle at 50% 0, #1a1a40, var(--bg) 60%); color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 16px; overscroll-behavior: none; }
[hidden] { display: none !important; }

.app { height: 100dvh; display: grid; gap: 8px;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "hud" "play" "status" "bar";
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.hud, .bar, .status { justify-self: center; width: var(--sw); }
.hud { grid-area: hud; display: flex; gap: 8px; }
.play { grid-area: play; min-height: 0; container-type: size; display: grid; place-items: center; }
.status { grid-area: status; display: flex; gap: 8px; justify-content: center; }
.bar { grid-area: bar; display: flex; gap: 8px; }
.bar button { flex: 1; padding-inline: 8px; }

.stat { flex: 1; background: var(--panel); border: 1px solid #2a2a58; border-radius: 8px; padding: 4px 8px; text-align: center; }
.stat span { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.stat b { font-size: clamp(16px, 4vw, 20px); color: var(--accent); }
#lives { color: var(--pink); letter-spacing: 2px; }

/* Stage keeps the true 480:640 ratio and is centred inside whatever space is left. */
.stage { position: relative; width: min(100cqw, 75cqh); aspect-ratio: 3 / 4; border-radius: 10px;
  border: 2px solid var(--accent); box-shadow: 0 0 24px rgba(0, 229, 255, .35); overflow: hidden; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; background: #07071a; touch-action: none; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 16px; background: rgba(7, 7, 26, .84); backdrop-filter: blur(3px); overflow: auto; }
.overlay h1 { margin: 0; font-size: clamp(26px, 8vw, 44px); letter-spacing: .1em; color: var(--accent); text-shadow: 0 0 18px var(--accent); }
.overlay p { margin: 0; font-size: 16px; }
.overlay .hint { color: var(--dim); font-size: 14px; line-height: 1.6; }
button { font: inherit; font-size: 16px; color: var(--ink); background: var(--panel); border: 1px solid #3a3a78; border-radius: 8px; padding: 10px 16px; cursor: pointer; min-height: 44px; }
button:hover, button:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: #04121a; font-weight: 700; border: 0; padding: 12px 28px; }
.chip { font-size: 14px; padding: 4px 12px; min-height: 0; border-radius: 999px; background: var(--panel); border: 1px solid var(--gold); color: var(--gold); }

/* Short, wide screens (phones in landscape): board on the left, HUD and controls in a side column. */
@media (orientation: landscape) and (max-height: 560px) {
  .app { grid-template-columns: minmax(0, 1fr) minmax(150px, 220px); grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "play hud" "play status" "play ." "play bar"; justify-content: stretch; column-gap: 12px; }
  .hud, .bar, .status { justify-self: stretch; width: auto; }
  .hud { flex-wrap: wrap; } .stat { flex: 1 1 40%; }
  .bar { flex-direction: column; }
  .status { flex-direction: column; align-items: stretch; text-align: center; }
  .overlay .hint { display: none; }
  .overlay { gap: 6px; padding: 8px; }
}
