:root {
  --bg: #0c0d10;
  --panel: #16181e;
  --ink: #ece7dc;
  --muted: #9a937f;
  --line: #2a2d36;
  --acid: #d6ff3d;
  --acid-ink: #12140a;
  --warn: #ff6b4a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--acid); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.brand { font-weight: 800; letter-spacing: -.03em; font-size: 20px; color: var(--ink); }
.brand span { color: var(--acid); }
nav { display: flex; gap: 16px; font-size: 14px; }
nav a { color: var(--muted); }
nav a:hover, nav a.on { color: var(--ink); text-decoration: none; }
h1 { font-size: 36px; letter-spacing: -.04em; margin: 0 0 8px; }
.lede { color: var(--muted); max-width: 62ch; margin: 0 0 28px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; min-height: 180px; display: flex; flex-direction: column;
}
.card h2 { margin: 0 0 8px; font-size: 20px; }
.card p { margin: 0 0 16px; color: var(--muted); flex: 1; font-size: 14px; }
.btn {
  display: inline-block; background: var(--acid); color: var(--acid-ink);
  font-weight: 700; border-radius: 999px; padding: 8px 14px; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.stage {
  background: #090a0c; border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; display: grid; place-items: center; overflow: hidden;
}
canvas, .board { touch-action: none; max-width: 100%; }
.hud {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  margin: 12px 0 16px; color: var(--muted); font-size: 14px;
}
.hud b { color: var(--ink); }
.note { color: var(--muted); font-size: 14px; max-width: 70ch; }
footer { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.legal { max-width: 72ch; }
.legal h1 { font-size: 28px; }
.legal p, .legal li { color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); padding: 10px 14px;
  border-radius: 10px; display: none;
}
@media (max-width: 640px) {
  h1 { font-size: 28px; }
  header { flex-wrap: wrap; gap: 10px; }
}

/* Keep intrinsic aspect ratios on narrow screens and provide real touch targets. */
canvas { display:block; width:100%; height:auto; outline-offset:4px; }
.game-page { max-width:800px; }
.game-page .stage { width:100%; max-width:546px; margin:0 auto; }
.game-page .lede { margin-bottom:14px; }
button { font:inherit; cursor:pointer; border:0; min-height:44px; touch-action:manipulation; }
button:disabled { cursor:default; opacity:.5; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline:2px solid #7ad7ff; outline-offset:3px; }
.controls { display:flex; flex-wrap:wrap; gap:8px; }
#status { min-height:24px; margin:12px 0; color:var(--acid); font-size:14px; }
.aim { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-bottom:14px; }
.aim input { flex:1; min-width:130px; accent-color:var(--acid); height:32px; }
.lane-controls { max-width:520px; display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px auto; }
.lane-controls button { padding:8px 4px; border-radius:10px; }
.lane-controls .closed { background:var(--warn); }
@media(max-width:540px) { .wrap { padding-left:12px; padding-right:12px; } .game-page h1 { font-size:24px; } .stage { padding:6px; } .lane-controls { gap:5px; font-size:13px; } }
/* Homepage player: a single active game, with controls beside the canvas. */
[hidden] { display:none !important; }
header { flex-wrap:wrap; gap:16px; padding:16px 0; margin-bottom:20px; }
.language-picker { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); }
select { color:var(--ink); background:var(--panel); border:1px solid var(--line); padding:8px 10px; border-radius:8px; min-height:44px; font:inherit; }
.game-tabs { display:flex; gap:10px; margin:20px 0; }
.game-tab { color:var(--muted); background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:12px 18px; flex:1; }
.game-tab[aria-selected="true"] { color:var(--acid-ink); background:var(--acid); border-color:var(--acid); font-weight:700; }
.game-panel { display:grid; grid-template-columns:minmax(250px,1fr) minmax(0,520px); gap:28px; align-items:start; }
.game-panel h2 { margin:0 0 12px; font-size:28px; }
.game-panel .lede { margin-bottom:12px; }
.game-play { min-width:0; }
.game-panel .stage { width:100%; max-width:520px; margin:auto; }
#game-gate .stage { max-width:420px; }
[data-role="status"] { min-height:44px; color:var(--acid); font-size:14px; }
.instructions { margin-top:20px; }
.instructions summary { cursor:pointer; color:var(--ink); font-weight:600; }
.pause-note { font-size:12px; }
.game-panel .aim { display:grid; grid-template-columns:1fr; gap:4px; }
.game-panel .aim input { width:100%; min-width:0; }
@media(max-width:760px) {
  .game-panel { grid-template-columns:1fr; gap:16px; }
  .game-info { display:contents; }
  .game-info > h2, .game-info > .lede { display:none; }
  .game-play { grid-row:4; }
  .game-panel .hud { margin:0; }
  .game-panel [data-role="status"] { margin:0; min-height:24px; }
  #game-grav .game-play { grid-row:5; }
  .instructions { margin-top:0; }
  .game-tab { padding:10px 6px; font-size:14px; }
  .game-tabs { gap:6px; margin:12px 0; }
  .language-picker { margin-left:auto; }
  h1 { font-size:26px; }
  .wrap > .lede { font-size:14px; margin-bottom:12px; }
}
