/* ─── SHELL ─── */
body {
  min-height: 100vh;
  --font-body: "DM Sans", sans-serif;
}

.game-shell {
  min-height: 100vh;
  padding: 7.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Single source of truth for the play screen's canvas+HUD width, so they
     scale up together on big screens instead of staying capped at 400px.
     100% -> mobile is unchanged (bounded by .game-screen's own 640px cap);
     640px -> desktop ceiling, matching .game-screen's existing max-width;
     100vh - 18rem -> leaves room for the fixed nav + HUD + padding above/
     below the canvas so it never overflows on short viewports. 18rem is a
     tunable estimate of that fixed vertical chrome, same spirit as the
     other tunable constants in app.js (initialTimeMs, regenEveryStreak). */
  --canvas-size: min(100%, 640px, calc(100vh - 18rem));
}

.hidden { display: none !important; }

.game-screen {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.game-logo {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 8vw, 4rem);
  letter-spacing: 0.05em;
  color: var(--text);
  text-align: center;
  line-height: 1;
  margin: 0;
}

.game-logo span { color: var(--accent); }
.game-logo.small { font-size: clamp(1.8rem, 6vw, 2.6rem); margin-bottom: 0.5rem; }

.game-tagline {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-top: 0.6rem;
  margin-bottom: 2.5rem;
}

/* ─── SHARED BUTTON STYLES ───
   .btn-primary / .btn-ghost normally live in index.css, but this page only
   loads shared.css - duplicated here so game.html doesn't need to pull in
   the rest of index.css just for two button styles. */
.btn-primary {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.9rem 2rem;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: none;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent2);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.btn-primary:hover::before { transform: translateX(0); }
.btn-primary span { position: relative; z-index: 1; }

.btn-ghost {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.9rem 2rem;
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  cursor: none;
  transition: border-color 0.2s, color 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ─── MODE GRID ─── */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  width: 100%;
}

.mode-card {
  background: var(--bg);
  border: none;
  padding: 1.6rem 1.4rem;
  text-align: left;
  color: var(--text);
  cursor: none;
  font-family: var(--font-body);
  transition: background 0.2s;
  position: relative;
}

.mode-card:hover:not(.disabled) { background: var(--surface); }
.mode-card:hover:not(.disabled) .mode-icon { color: var(--accent); }

.mode-card.disabled { opacity: 0.35; cursor: not-allowed; }

.mode-icon {
  width: 26px;
  height: 26px;
  color: var(--muted);
  transition: color 0.2s;
  margin-bottom: 0.7rem;
}

.mode-icon-glyph {
  display: inline-block;
  font-size: 1.4rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.mode-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.04em;
}

.mode-tag {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--accent3);
  text-transform: uppercase;
  margin-left: 0.3rem;
}

.mode-badge {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  margin-left: 0.4rem;
}

.mode-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.4rem;
  line-height: 1.5;
}

.mode-best {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-top: 0.6rem;
  min-height: 1em;
}

/* ─── MENU ACTIONS / SHARED BUTTONS ─── */
.menu-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── HUD ─── */
.game-hud {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: var(--canvas-size);
  justify-content: center;
  position: relative;
}

.hud-item { text-align: center; }

.hud-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent);
  line-height: 1.1;
}

#hud-lives { letter-spacing: 0.15em; color: var(--accent2); }

.btn-icon {
  position: absolute;
  right: 0;
  top: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  cursor: none;
  transition: border-color 0.2s, color 0.2s;
}

.btn-icon:hover { border-color: var(--accent2); color: var(--accent2); }

/* ─── CANVAS ─── */
.canvas-wrap {
  position: relative;
  width: var(--canvas-size);
  aspect-ratio: 1 / 1;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  touch-action: none;
  cursor: none;
}

.game-bonus-flash {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translate(-50%, -6px);
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #22ff88;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(34, 255, 136, 0.6);
}

.game-bonus-flash.flash-active {
  animation: bonusPop 0.9s ease forwards;
}

@keyframes bonusPop {
  0% { opacity: 0; transform: translate(-50%, 4px); }
  20% { opacity: 1; transform: translate(-50%, -10px); }
  80% { opacity: 1; transform: translate(-50%, -14px); }
  100% { opacity: 0; transform: translate(-50%, -20px); }
}

/* ─── GAME OVER ─── */
.gameover-score {
  font-family: var(--font-display);
  font-size: clamp(4rem, 16vw, 7rem);
  color: var(--accent);
  line-height: 1;
  margin-top: 1rem;
}

.gameover-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.3rem;
}

.gameover-reason {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-top: 0.8rem;
  min-height: 1em;
}

.gameover-accuracy {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 0.5rem;
  min-height: 1em;
}

.gameover-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 1.2rem;
  text-align: center;
  min-height: 1.4em;
}

/* ─── LEADERBOARD ─── */
.leaderboard-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.lb-select {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.8rem;
  cursor: none;
}

.lb-scope-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.lb-scope-tab {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: none;
  transition: border-color 0.2s, color 0.2s;
}

.lb-scope-tab:hover:not(.disabled) { color: var(--text); }
.lb-scope-tab.active { border-color: var(--accent); color: var(--accent); }
.lb-scope-tab.disabled { opacity: 0.35; cursor: not-allowed; }

.leaderboard-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  margin-bottom: 1.5rem;
  min-height: 120px;
}

.lb-row {
  background: var(--bg);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lb-rank {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  width: 2.2rem;
}

.lb-name { flex: 1; font-size: 0.85rem; }

.lb-meta {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
}

.lb-score {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.lb-loading, .lb-empty {
  background: var(--bg);
  padding: 2rem 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── SETTINGS ─── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  max-width: 340px;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.toggle-switch {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  cursor: none;
  transition: border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.toggle-switch.is-on { border-color: var(--accent); background: rgba(0, 229, 255, 0.08); }
.toggle-switch.is-on .toggle-knob { background: var(--accent); transform: translateX(18px); }

.tile-color-picker {
  width: 42px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: none;
  padding: 0;
  flex-shrink: 0;
}
.tile-color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.tile-color-picker::-webkit-color-swatch { border: none; border-radius: 4px; }
.tile-color-picker::-moz-color-swatch { border: none; border-radius: 4px; }

/* ─── AD SLOT ─── */
.game-ad-slot {
  max-width: 640px;
  margin: 2rem auto 0;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 480px) {
  .game-hud { gap: 1.2rem; }
  .hud-value { font-size: 1.5rem; }
}
