/* Astro Blast — mobile-first styles.
 * System theme via prefers-color-scheme (no JS toggle), plus
 * color-scheme so form controls follow the OS theme too.
 * Banner reserve: anchored adaptive banners are up to 90dp tall on
 * phones (Michelle 2026-11-12) — body padding-bottom reserves it and
 * fixed overlays (toast, sheet) carry their own --banner-h offset.
 * The whole game view fits above the banner with no scrolling:
 * topbar + HUD + canvas + controls = 100dvh minus the banner reserve.
 */
:root {
  color-scheme: light dark;
  --banner-h: 0px;
  --bg: #e9eef4;
  --surface: #ffffff;
  --surface-2: #dfe7f0;
  --ink: #101820;
  --ink-2: #46525e;
  --ink-3: #76828e;
  --line: #c9d3dd;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #dbeafe;
  --danger: #b3261e;
  --warn: #8a5a00;
  --good: #1d4ed8;
  --radius: 16px;
  --canvas-bg: #d7e2ee;
  --stroke: #101820;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #05070d;
    --surface: #121826;
    --surface-2: #1b2334;
    --ink: #eef2f8;
    --ink-2: #b9c4d4;
    --ink-3: #7e8ba0;
    --line: #2a3448;
    --accent: #7db4ff;
    --accent-ink: #06101f;
    --accent-soft: #16263f;
    --danger: #ff8a80;
    --warn: #ffcf7d;
    --good: #7db4ff;
    --canvas-bg: #05070d;
    --stroke: #ffffff;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--banner-h);
  overflow: hidden;
}
body, button, input { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button { touch-action: manipulation; }
button, a { -webkit-touch-callout: none; user-select: none; }

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding-top: 6px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); display: block; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-word { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.brand-word span { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.about-button {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer;
}
.icon-button {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 20px;
}

/* ---- HUD ---- */
.hud {
  display: flex; align-items: center; gap: 14px;
  min-height: 34px; flex-shrink: 0;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3);
}
.hud-item strong { color: var(--ink); font-size: 15px; letter-spacing: 0; }
.hud-lives { margin-left: auto; display: flex; gap: 4px; font-size: 16px; color: var(--accent); }
.hud-lives .lost { opacity: 0.25; }

/* ---- stage / canvas ---- */
.stage {
  flex: 1; min-height: 0;
  border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; background: var(--canvas-bg);
}
#game { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---- controls: thumb-sized, clear of the 90px banner zone.
 * Row height is fixed so the bottom edge sits a tight 6px above
 * the banner zone (BlockDrop T24 pattern). */
.controls {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 0 6px;
  min-height: 90px;
  touch-action: none; /* drags on the controls area never scroll/zoom (vc3, correction 26) */
}
.controls-left, .controls-right { display: flex; align-items: center; gap: 10px; }
.ctl-btn {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 26px; font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
.ctl-btn:active, .ctl-btn.held { background: var(--accent-soft); border-color: var(--accent); }
.ctl-fire {
  width: 76px; height: 76px; font-size: 17px; letter-spacing: 0.04em;
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.ctl-fire:active, .ctl-fire.held { filter: brightness(1.15); }

/* ---- buttons ---- */
.button {
  min-height: 52px; border-radius: 12px; border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; font-size: 16px; cursor: pointer; padding: 0 16px;
  width: 100%; margin-top: 10px; white-space: nowrap;
}
.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* ---- sheets ---- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-center { align-items: center; }
.sheet-card {
  background: var(--surface); color: var(--ink);
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + var(--banner-h));
  width: 100%; max-width: 560px; max-height: 82dvh; overflow-y: auto;
}
.sheet-center .sheet-card { border-radius: 20px; margin: 16px; padding-bottom: 20px; text-align: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-card h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.menu-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.menu-best { margin: 10px 0 0; font-weight: 700; color: var(--accent); }
.menu-help { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); }
.about-body { font-size: 14px; color: var(--ink-2); }
.about-meta { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; }
.footer-link {
  background: none; border: 0; padding: 10px 4px; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0;
}
/* Identity is shown on the leaderboard sheet; the switch is a hint, not a
   logout — Play Games v2 has no sign-out API, so it opens the Play Games app.
   Left inset matches the avatar + gap above so it reads as a sub-line. */
.pg-switch { display: block; padding: 6px 0 0 40px; text-align: left; font-size: 12px; }

/* ---- leaderboard (vc5) ---- */
.lb-rows { margin: 12px 0 0; display: flex; flex-direction: column; gap: 2px; }
.lb-row {
  display: flex; align-items: center; gap: 10px;
  min-height: 30px; padding: 2px 4px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.lb-rank { width: 36px; flex-shrink: 0; font-weight: 800; color: var(--ink-3); }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; }
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.lb-you { margin: 12px 0 0; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 8px; }
/* Your own rank: highlighted in place when it is already in the top 10, and
 * pinned under the list (after a ⋯ divider) when it is not — the server ranks
 * against the whole board, so a player far below the visible page still gets a
 * real number here. */
.lb-gap { margin: 2px 0; text-align: center; color: var(--ink-3); font-weight: 800; line-height: 16px; }
.lb-row--you {
  background: var(--accent-soft);
  border-bottom-color: transparent;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.lb-row--you .lb-rank { color: var(--accent); }
.lb-you-tag {
  flex-shrink: 0; font-size: 10px; font-weight: 900; letter-spacing: 0.06em;
  padding: 2px 6px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
}
.lb-name-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.lb-name-row input {
  flex: 1; min-width: 0; min-height: 48px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink);
  font: inherit; padding: 0 12px;
}

/* ---- toast: pointer-events none so it never eats taps (BlockDrop
 * T26); anchored ABOVE the controls + banner, never overlapping
 * them (Solitaire correction). */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--banner-h) + 90px + 16px);
  z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
