/* =====================================================================
   Asteroids — fixed "deep space neon" theme.
   Like the other arcade canvas games (Flappy, Timberman, Neon Dash), this
   page deliberately ignores the center's light/dark mode and its shared
   glass chrome (no glass.css, no mode bootstrap). Every colour is a hard
   copy of the game's own canvas palette: void navy, ion-cyan ship glow,
   plasma-magenta hazards, ion-gold saucer, violet rock rim.
   The whole c-* chrome block lives here (it is NOT inherited).
   ===================================================================== */
:root {
  --as-void:   #060812;   /* deep space base */
  --as-void2:  #0d1226;
  --as-panel:  #131a34;
  --as-cyan:   #4de8ff;   /* ship / primary glow */
  --as-cyan2:  #17b6d6;
  --as-violet: #8b93ff;   /* asteroid rim */
  --as-mag:    #ff5fa2;   /* hazard / secondary accent */
  --as-gold:   #ffd166;   /* saucer / highlight text */
  --as-line:   rgba(120, 150, 220, .28);
  --as-text:   #dfe7ff;
  --as-muted:  #97a3cc;
}

html, body { height: 100%; }
body.as-page {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--as-void2) 0%, var(--as-void) 70%);
  color: var(--as-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.as-page *,
body.as-page *::before,
body.as-page *::after { box-sizing: border-box; }

/* ---------- App frame ---------- */
.c-app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.c-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 12px clamp(12px, 3vw, 28px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(13, 18, 38, .62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--as-cyan2);
  z-index: 20;
}
.c-bar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.c-bar__brand svg { filter: drop-shadow(0 0 6px rgba(77, 232, 255, .5)); }
.c-bar__title {
  margin: 0;
  font-size: clamp(19px, 3.4vw, 26px);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--as-cyan);
  text-shadow: 0 0 12px rgba(77, 232, 255, .6), 0 0 30px rgba(77, 232, 255, .3);
}
.c-bar__stats { display: flex; align-items: center; gap: 8px 18px; margin-left: auto; }
.c-bar__controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat { font-size: 14px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; color: var(--as-muted); }
.stat b { color: var(--as-cyan); font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- Buttons (neon outline chips) ---------- */
.c-btn {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  padding: 9px 16px;
  border-radius: 12px;
  border: 2px solid var(--as-line);
  background: rgba(19, 26, 52, .7);
  color: var(--as-text);
  box-shadow: 0 3px 0 rgba(4, 6, 16, .55);
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.c-btn:hover { background: rgba(30, 40, 74, .9); border-color: var(--as-cyan2); }
.c-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(4, 6, 16, .55); }
.c-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(77, 232, 255, .45); }
.c-btn--primary {
  background: linear-gradient(140deg, var(--as-cyan), var(--as-cyan2));
  border-color: rgba(77, 232, 255, .8);
  color: #04121a;
  text-shadow: none;
  box-shadow: 0 3px 0 rgba(4, 6, 16, .55), 0 0 18px rgba(77, 232, 255, .4);
}
.c-btn--primary:hover { background: linear-gradient(140deg, #6cf0ff, var(--as-cyan)); }

/* ---------- Table / stage ---------- */
.c-table {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2.4vh, 22px);
}
.as-stage {
  position: relative;
  /* near-square play field, capped by the viewport height minus chrome */
  width: min(94vw, calc((100vh - 150px) * 1.05), 620px);
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 40%, #0c1226 0%, #05070f 80%);
  border: 2px solid var(--as-cyan2);
  box-shadow: 0 0 26px rgba(23, 182, 214, .35), inset 0 0 60px rgba(3, 6, 16, .8);
  touch-action: none;
  cursor: crosshair;
}
#screen {
  display: block; width: 100%; height: 100%;
  touch-action: none;
}

/* ---------- Ready / pause / game-over overlays ---------- */
.as-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(4, 6, 16, .62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  touch-action: manipulation;
}
.as-overlay[hidden] { display: none; }
.as-card {
  max-width: 320px;
  text-align: center;
  padding: 22px 24px 20px;
  border-radius: 16px;
  background: linear-gradient(160deg, var(--as-panel), #0c1124);
  border: 2px solid var(--as-cyan2);
  box-shadow: 0 0 30px rgba(23, 182, 214, .3), 0 22px 50px rgba(0, 0, 0, .6);
  color: var(--as-text);
  animation: asPop .3s ease;
  touch-action: manipulation;
}
@keyframes asPop { from { transform: scale(.88); opacity: 0; } }
.as-card__big { font-size: 40px; line-height: 1.1; }
.as-card__big svg { width: 84px; height: 84px; display: block; margin: 0 auto; filter: drop-shadow(0 0 8px rgba(77,232,255,.4)); }
.as-card__big svg[hidden] { display: none; }
.as-card h2 {
  margin: 6px 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--as-cyan);
  text-shadow: 0 0 12px rgba(77, 232, 255, .5);
}
.as-card p { margin: 0 0 14px; color: var(--as-muted); font-size: 13.5px; line-height: 1.55; }
.as-card p b { color: var(--as-gold); }
.as-card .c-btn { font-size: 14px; }
.as-card kbd, .c-modal kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin: 0 1px;
  font: 700 12px/1.5 ui-monospace, "Segoe UI", monospace;
  text-align: center;
  color: var(--as-cyan);
  background: rgba(77, 232, 255, .1);
  border: 1px solid var(--as-cyan2);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(4, 6, 16, .5);
}
.c-win__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Touch pads (coarse pointers only) ---------- */
.as-touch { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.as-touch[hidden] { display: none; }
.as-pad {
  position: absolute;
  pointer-events: auto;
  width: 76px; height: 76px;
  border-radius: 50%;
  border: 2px solid var(--as-cyan2);
  background: rgba(19, 26, 52, .5);
  color: var(--as-cyan);
  font-size: 30px;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  opacity: .8;
}
.as-pad:active { background: rgba(77, 232, 255, .28); opacity: 1; }
.as-pad--left   { left: 14px;  bottom: 18px; }
.as-pad--right  { left: 104px; bottom: 18px; }
.as-pad--thrust { right: 104px; bottom: 18px; color: var(--as-gold); border-color: var(--as-gold); }
.as-pad--fire   { right: 14px;  bottom: 18px; color: var(--as-mag); border-color: var(--as-mag); }
@media (hover: hover) and (pointer: fine) {
  /* desktop: keep them hidden — the JS also gates on touch support */
  .as-touch { display: none; }
}

/* ---------- Rules modal ----------
   The full-screen overlay itself scrolls, never the card, so no scrollbar
   gutter ever sits inside the panel (see AGENTS.md). */
.c-modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed; inset: 0;
  background: rgba(3, 5, 14, .68);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.c-modal__panel {
  position: relative; z-index: 1;
  margin: auto;                    /* centres, and a too-tall card scrolls in from the top */
  width: min(92vw, 480px);
  background: linear-gradient(160deg, var(--as-panel), #0a0f20);
  color: var(--as-text);
  border-radius: 16px;
  border: 2px solid var(--as-cyan2);
  box-shadow: 0 0 30px rgba(23, 182, 214, .3), 0 24px 60px rgba(0, 0, 0, .65);
}
.c-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--as-line);
}
.c-modal__head h2 {
  margin: 0; font-size: 18px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--as-cyan); text-shadow: 0 0 10px rgba(77, 232, 255, .5);
}
.c-modal__x {
  appearance: none; border: 0; background: none;
  color: var(--as-muted); font-size: 26px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.c-modal__x:hover { color: var(--as-gold); }
.c-modal__body { padding: 8px 20px 4px; font-size: 14px; line-height: 1.55; }
.c-modal__body h3 {
  margin: 16px 0 6px; font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--as-gold);
}
.c-modal__body ul { margin: 0; padding-left: 20px; }
.c-modal__body li { margin: 4px 0; }
.c-modal__body b { color: var(--as-gold); }
.c-modal__lead { margin: 12px 0; }
.c-modal__note {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(139, 147, 255, .1);
  border: 1px solid var(--as-line);
  font-size: 13px;
  color: var(--as-muted);
}
.c-modal__foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }
.c-modal .c-btn { border-color: var(--as-line); box-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.c-modal .c-btn--primary { border-color: rgba(77, 232, 255, .8); }

/* ---------- Responsive ---------- */
@media (max-width: 700px), (max-height: 560px) {
  .c-bar { gap: 5px 12px; padding: 7px clamp(10px, 3vw, 18px); padding-top: max(7px, env(safe-area-inset-top)); }
  .c-bar__brand { gap: 8px; }
  .c-bar__title { font-size: 16px; letter-spacing: .08em; }
  .c-bar__stats { gap: 4px 12px; margin-left: auto; }
  .stat { font-size: 12px; }
  .stat b { font-size: 13px; }
  .c-btn { padding: 8px 10px; font-size: 12px; }
  .c-bar__controls { gap: 6px; }
  .c-bar__controls .c-btn { padding: 9px 10px; white-space: nowrap; }
  .as-stage { width: min(96vw, calc((100vh - 120px) * 1.05)); }
}
@media (max-width: 700px) {
  .c-bar__controls { flex: 1 1 100%; flex-wrap: nowrap; }
  .c-bar__controls .c-btn { flex: 1 1 auto; min-width: 0; padding: 9px 6px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 380px) {
  .c-bar { gap: 5px 8px; }
  .c-bar__title { font-size: 15px; }
  .stat { font-size: 11px; }
  .stat b { font-size: 12px; }
  .c-bar__controls { gap: 4px; }
  .c-bar__controls .c-btn { font-size: clamp(10px, 3.2vw, 12px); padding: 9px 4px; letter-spacing: .01em; }
  .as-pad { width: 62px; height: 62px; font-size: 24px; }
  .as-pad--right { left: 84px; }
  .as-pad--thrust { right: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .c-btn, .as-card { transition: none; animation: none; }
}
