/* ================================================================
   GAME SHELL — shared chrome for all arcade games
   Each game sets:  :root { --cr: R,G,B; }  (accent colour as RGB)
   ================================================================ */

:root {
  --modal-btn-secondary: rgba(255,255,255,0.62);
}

/* ── PAGE RESET + BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-1);
  font-family: 'Syne', sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #fff;
}

/* ── APP CONTAINER ───────────────────────────────────────────── */
#app {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

/* ── PAGE BACKGROUND ─────────────────────────────────────────── */
#page-bg {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at 50% 28%,
    var(--bg-3) 0%, var(--bg-2) 44%, var(--bg-1) 100%);
}
#page-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 32%, rgba(0,0,0,0.75) 100%);
}

/* ── GRAIN + AMBIENT ─────────────────────────────────────────── */
#grain {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 200; opacity: 0.038;
}

#amb-cvs {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none; opacity: 0.42;
}

/* ── GAME FRAME ──────────────────────────────────────────────── */
#game-frame {
  position: relative; z-index: 2;
  width: 100%; height: 100%; overflow: hidden;
}
@media (min-width: 768px) {
  #game-frame {
    width: 420px;
    height: min(900px, 96dvh);
    border-radius: 25px;
    background: var(--bg-1);
    box-shadow:
      0 0 0 1px rgba(255,255,255,0.052),
      0 0 90px rgba(0,0,0,0.92),
      0 0 160px rgba(var(--cr),0.07);
  }
}

/* ── GAME CANVAS ─────────────────────────────────────────────── */
#game-cvs { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ── START SCREEN DEFAULTS ───────────────────────────────────── */
#start-screen {
  justify-content: space-between;
  padding: max(52px, env(safe-area-inset-top)) 28px max(40px, env(safe-area-inset-bottom));
}

.start-bot .gbtn { padding-top: 8px; padding-bottom: 8px; color: rgba(255,255,255,0.42); }

/* ── OVERLAY + GLASS PANEL ───────────────────────────────────── */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  transition: opacity 0.26s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.glass-panel {
  width: 100%; max-width: 328px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 24px; padding: 28px 24px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.09),
    0 24px 80px rgba(0,0,0,0.68);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
}

.panel-title {
  font-weight: 800; font-size: 19px;
  letter-spacing: 0.1em; text-transform: uppercase;
  text-align: center; margin-bottom: 20px;
}
.panel-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.6; letter-spacing: 0.04em;
  color: rgba(255,255,255,0.42); text-align: center;
  margin-top: -12px; margin-bottom: 20px;
}

/* ── GLASS BUTTONS ───────────────────────────────────────────── */
.gbtn {
  padding: 15px 26px;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px;
  background: rgba(255,255,255,0.042);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: #fff;
  font-family: 'JetBrains Mono', monospace; font-weight: 500;
  font-size: 13.5px; letter-spacing: 0.15em; text-transform: uppercase;
  cursor: pointer; outline: none; position: relative; overflow: hidden;
  transition: background 0.2s, border-color 0.2s, transform 0.16s, box-shadow 0.2s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 4px 18px rgba(0,0,0,0.3);
}
.gbtn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(175deg, rgba(255,255,255,0.07) 0%, transparent 50%);
  pointer-events: none;
}
.gbtn:hover:not(:disabled) {
  background: rgba(255,255,255,0.085); border-color: rgba(255,255,255,0.17);
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 10px 30px rgba(0,0,0,0.48),
    0 0 20px rgba(var(--cr),0.16);
}
.gbtn:active:not(:disabled) { transform: translateY(0); }
.gbtn:disabled { opacity: 0.26; cursor: not-allowed; }

.gbtn.primary {
  font-size: 22px; letter-spacing: 0.22em;
  border-color: rgba(var(--cr),0.52);
  background:   rgba(var(--cr),0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 4px 22px rgba(var(--cr),0.28),
    0 0 40px rgba(var(--cr),0.12);
}
.gbtn.primary:hover:not(:disabled) {
  background:   rgba(var(--cr),0.24);
  border-color: rgba(var(--cr),0.68);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 10px 36px rgba(var(--cr),0.36),
    0 0 60px rgba(var(--cr),0.18);
}

/* Amber destructive-action button — use on confirm/delete actions */
.gbtn.danger {
  border-color: rgba(255,182,39,0.52);
  background:   rgba(255,182,39,0.16);
  color: rgba(255,182,39,0.95);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 4px 22px rgba(255,182,39,0.28),
    0 0 40px rgba(255,182,39,0.12);
}
.gbtn.danger:hover:not(:disabled) {
  background:   rgba(255,182,39,0.24);
  border-color: rgba(255,182,39,0.68);
  color: rgba(255,182,39,1);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 10px 36px rgba(255,182,39,0.36),
    0 0 60px rgba(255,182,39,0.18);
}

.gbtn.mode { flex: 1; padding: 8px 10px; font-size: 13.5px; color: rgba(255,255,255,0.42); }
.gbtn.mode.active {
  border-color: rgba(45,212,255,0.52); background: rgba(45,212,255,0.12);
  color: rgba(45,212,255,0.95);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 0 24px rgba(45,212,255,0.18);
}
.gbtn.mode.active:hover:not(:disabled) {
  background: rgba(45,212,255,0.20); border-color: rgba(45,212,255,0.68);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 30px rgba(0,0,0,0.48), 0 0 28px rgba(45,212,255,0.28);
}

/* ── DIFFICULTY BUTTONS (always same colours across all games) ── */
#diff-easy-btn.active   { border-color:rgba(45,255,170,0.52); background:rgba(45,255,170,0.12); color:rgba(45,255,170,0.95); box-shadow:inset 0 1px 0 rgba(255,255,255,0.12),0 0 24px rgba(45,255,170,0.18); }
#diff-normal-btn.active { border-color:rgba(255,182,39,0.52); background:rgba(255,182,39,0.12); color:rgba(255,182,39,0.95); box-shadow:inset 0 1px 0 rgba(255,255,255,0.12),0 0 24px rgba(255,182,39,0.18); }
#diff-hard-btn.active   { border-color:rgba(255,59,111,0.52); background:rgba(255,59,111,0.12); color:rgba(255,59,111,0.95); box-shadow:inset 0 1px 0 rgba(255,255,255,0.12),0 0 24px rgba(255,59,111,0.18); }
#diff-easy-btn.active:hover:not(:disabled)   { background:rgba(45,255,170,0.20); border-color:rgba(45,255,170,0.68); box-shadow:inset 0 1px 0 rgba(255,255,255,0.14),0 10px 30px rgba(0,0,0,0.48),0 0 28px rgba(45,255,170,0.28); }
#diff-normal-btn.active:hover:not(:disabled) { background:rgba(255,182,39,0.20); border-color:rgba(255,182,39,0.68); box-shadow:inset 0 1px 0 rgba(255,255,255,0.14),0 10px 30px rgba(0,0,0,0.48),0 0 28px rgba(255,182,39,0.28); }
#diff-hard-btn.active:hover:not(:disabled)   { background:rgba(255,59,111,0.20); border-color:rgba(255,59,111,0.68); box-shadow:inset 0 1px 0 rgba(255,255,255,0.14),0 10px 30px rgba(0,0,0,0.48),0 0 28px rgba(255,59,111,0.28); }
#diff-easy-btn:active:not(:disabled)   { background:rgba(45,255,170,0.20); border-color:rgba(45,255,170,0.68); color:rgba(45,255,170,0.95); }
#diff-normal-btn:active:not(:disabled) { background:rgba(255,182,39,0.20); border-color:rgba(255,182,39,0.68); color:rgba(255,182,39,0.95); }
#diff-hard-btn:active:not(:disabled)   { background:rgba(255,59,111,0.20); border-color:rgba(255,59,111,0.68); color:rgba(255,59,111,0.95); }

/* ── HUD ─────────────────────────────────────────────────────── */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  display: flex; align-items: center; gap: 10px;
}
#hud.hidden { display: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 15px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.6); cursor: pointer; outline: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;                     /* emoji icon size (BLOCKS) */
  transition: background 0.17s, transform 0.14s;
}
.icon-btn svg { width: 18px; height: 18px; } /* SVG icon size (PRISM) — overrides HTML attributes */
.icon-btn:hover { background: rgba(255,255,255,0.10); transform: scale(1.06); }

/* ── SCREENS ─────────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.36s ease, transform 0.36s ease;
}
.screen.hidden { opacity: 0; pointer-events: none; transform: scale(0.965); }

/* ── START SCREEN LAYOUT ─────────────────────────────────────── */
.start-logo { display: flex; flex-direction: column; align-items: center; width: 100%; margin-top: 18%; }
.start-play { display: flex; flex-direction: column; align-items: center; width: 100%; }
.start-mid  { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.start-bot  { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }

.hs-display {
  position: absolute;
  top: max(16px, env(safe-area-inset-top)); right: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.hs-display .hs-label { color: rgba(255,255,255,0.28); }
.hs-display .hs-diff  { color: rgba(255,255,255,0.42); }

.arcade-back {
  display: block; margin-top: 10px; text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(255,255,255,0.32); text-decoration: none;
  transition: color 0.2s; padding: 6px 0;
}
.arcade-back:hover { color: rgba(255,255,255,0.65); }

.logo-wrap { text-align: center; width: 100%; overflow: hidden; }

/*
 * .logo-glow must NEVER use filter — any ancestor filter breaks background-clip:text
 * on the .logo child, leaking the full gradient rectangle.
 * Glow is faked with a blurred ::before pseudo-element, which is a SIBLING
 * of .logo in the render tree, not an ancestor.
 */
.logo-glow { position: relative; z-index: 0; display: block; }
.logo-glow::before {
  content: '';
  position: absolute; inset: -14px -28px;
  background: radial-gradient(ellipse at center, rgba(var(--cr), 0.30) 0%, transparent 68%);
  filter: blur(20px);
  pointer-events: none; z-index: -1;
}

.tagline {
  font-family: 'Instrument Serif', serif; font-style: italic;
  font-size: clamp(12px, 3.4vw, 16px);
  color: rgba(255,255,255,0.38); letter-spacing: 0.04em; margin-top: 7px;
}

.menu-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 268px; }
.mode-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}
.mode-row { display: flex; gap: 10px; width: 100%; max-width: 268px; }

/* ── HOW TO PLAY ─────────────────────────────────────────────── */
.rules { list-style: none; display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.rule  { display: flex; gap: 12px; align-items: flex-start; }
.rule-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: rgba(var(--cr),0.13); border: 1px solid rgba(var(--cr),0.26);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.rule-text { font-size: 12.5px; line-height: 1.55; color: rgba(255,255,255,0.66); font-weight: 500; }
.rule-key {
  display: inline-block; padding: 1px 6px; margin: 0 2px;
  border-radius: 5px; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
}

/* ── GAME OVER ───────────────────────────────────────────────── */
#new-best {
  display: none; margin: 0 auto 12px; width: fit-content;
  padding: 3px 14px; border-radius: 20px;
  background: rgba(255,182,39,0.12); border: 1px solid rgba(255,182,39,0.36);
  color: var(--amber); font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.24em; text-transform: uppercase;
  animation: badgeGlow 1.4s ease-in-out infinite alternate;
}
@keyframes badgeGlow {
  from { box-shadow: 0 0 6px  rgba(255,182,39,0.16); }
  to   { box-shadow: 0 0 26px rgba(255,182,39,0.50); }
}
.modal-btns { display: flex; flex-direction: column; gap: 12px; margin: 20px auto 0; max-width: 268px; }
.modal-btns .gbtn:not(.primary):not(.danger) { font-size: 15.5px; padding-top: 11px; padding-bottom: 11px; color: var(--modal-btn-secondary); }

.go-score-lbl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; letter-spacing: 0.24em; text-transform: uppercase;
  color: rgba(255,255,255,0.28); text-align: center; margin-bottom: 4px;
}
