:root {
  /* arcade-neon palette: player = orange, rival = cyan, on deep charcoal */
  --bg: #0a0c12;
  --panel: rgba(20, 24, 34, 0.82);
  --line: #2a3142;
  --text: #eef2fb;
  --muted: #8b96ad;
  --player: #ff7a18;     /* you */
  --player-2: #ffb056;
  --rival: #22d3ee;      /* the machine */
  --rival-2: #67e8f9;
  --ok: #34d399;
  --danger: #ff5a5f;
  --radius: 16px;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(800px 500px at 12% -8%, rgba(255, 122, 24, 0.16), transparent 60%),
    radial-gradient(760px 520px at 110% 8%, rgba(34, 211, 238, 0.16), transparent 55%),
    radial-gradient(700px 700px at 50% 120%, rgba(255, 122, 24, 0.06), transparent 60%);
}

.stage { width: min(94vw, 760px); display: flex; flex-direction: column; gap: 14px; padding: 18px 0; }
.topbar { display: flex; align-items: baseline; gap: 12px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.4px; }
.logo { font-size: 20px; }
.tagline { color: var(--muted); font-size: 14px; }

/* board + overlays */
.board-wrap { position: relative; aspect-ratio: 1 / 1; width: 100%; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(255,255,255,0.02); }
#game { display: block; width: 100%; height: 100%; background:
  linear-gradient(180deg, #0c0f17, #0a0c12); image-rendering: pixelated; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px;
  background: rgba(8, 10, 16, 0.55); backdrop-filter: blur(6px); animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.hidden { display: none !important; }

.panel { width: min(100%, 440px); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 26px; text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); animation: rise .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }

.title { font-family: var(--font-display); font-weight: 700; margin: 0 0 8px; font-size: 44px; letter-spacing: 2px;
  background: linear-gradient(90deg, var(--player), var(--rival)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 18px rgba(255,122,24,0.25)); }
.title.sm { font-size: 28px; }
.subtitle { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0 0 20px; }

.modes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.btn { font-family: var(--font-ui); font-size: 15px; font-weight: 600; color: var(--text);
  background: #1b2130; border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; cursor: pointer;
  transition: transform .08s ease, background .15s, border-color .15s, filter .15s; }
.btn:hover { background: #232b3d; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--player-2), var(--player)); border-color: transparent; color: #2a1500;
  box-shadow: 0 10px 26px rgba(255,122,24,0.3); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: #161b27; }

.diffs { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.diff-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; width: 100%; margin-bottom: 4px; }
.chip { font-size: 13px; font-weight: 600; color: var(--muted); background: #161b27; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: .15s; }
.chip:hover { color: var(--text); }
.chip.on { color: var(--rival); border-color: var(--rival); box-shadow: 0 0 0 3px rgba(34,211,238,0.12); }

.scaffold-note { margin-top: 18px; color: var(--muted); font-size: 12px; opacity: .7; }

/* HUD */
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; pointer-events: none; }
.hud-side { display: flex; flex-direction: column; line-height: 1.1; }
.hud-side.rival { text-align: right; }
.hud-name { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); }
.hud-score { font-family: var(--font-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-side.you .hud-score { color: var(--player-2); }
.hud-side.rival .hud-score { color: var(--rival-2); }
.hud-center { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted);
  background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }

.footnote { text-align: center; color: var(--muted); font-size: 12px; }

/* mute button */
.icon-btn { margin-left: auto; background: transparent; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; width: 40px; height: 40px; font-size: 17px; cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: #161b27; }

/* pre-round countdown */
.countdown { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(72px, 18vw, 150px); color: #fff;
  text-shadow: 0 0 34px rgba(255, 122, 24, 0.55), 0 0 12px rgba(34, 211, 238, 0.4); }
.countdown.flash { animation: cd .55s ease-out; }
@keyframes cd {
  0% { opacity: 0; transform: scale(0.5); }
  30% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.45); }
}

/* score pop on change */
.hud-score.pop { animation: pop .26s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.38); } 100% { transform: scale(1); } }

/* best-score lines (menu + game over) */
.best-line { margin-top: 16px; color: var(--muted); font-size: 13px; }

/* active power-up indicator */
.power-tag { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); z-index: 4;
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  background: rgba(167, 139, 250, 0.16); color: #c4b5fd; border: 1px solid #a78bfa;
  border-radius: 999px; padding: 4px 12px; pointer-events: none; }

/* start-menu item legend */
.items-key { width: fit-content; margin: 16px auto 2px; display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px; color: var(--muted); text-align: left; }
.items-key .ik { display: flex; align-items: center; gap: 9px; }
.ik-dot { width: 13px; height: 13px; flex: none; }
.ik-dot.food { background: var(--ok); border-radius: 50%; }
.ik-dot.portal { border: 2.5px solid #a78bfa; border-radius: 50%; }
.ik-dot.bonus { background: #ffd24a; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }

@media (max-width: 520px) {
  .title { font-size: 34px; }
  .tagline { display: none; }
}
