/*
  path: shared-game-engine/engine/styles.css
  purpose: Shared responsive arcade shell styles for all standalone games.
  how it works: Product pages set CSS variables from theme config while this file owns layout, canvas scaling, controls, scoreboards, and story page structure.
  dependencies: HTML IDs/classes expected by createGame.
  change log: 2026-06-05 - extracted from Steam Punk Star Killer and parameterized with theme variables.
*/

/* -------------------------------------------------------------------------- */
/* 1. Design Tokens And Global Reset                                          */
/* -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #ffe0a4;
  --panel: rgba(60, 34, 12, 0.92);
  --panel-strong: rgba(78, 43, 14, 0.98);
  --line: rgba(255, 220, 128, 0.58);
  --hot: #ff8a3d;
  --gold: #ffd166;
  --aqua: #9de7d3;
  --green: #b9ffb0;
  --violet: #c28746;
  --radius: 8px;
  --game-primary: var(--gold);
  --game-secondary: #b86b2d;
  --game-danger: #ff3b3b;
  --game-background: #050712;
  --game-surface-dark: #10172f;
  --game-surface-low: #071b24;
  --game-page-glow-a: rgba(255, 209, 102, 0.2);
  --game-page-glow-b: rgba(180, 82, 28, 0.22);
  --game-page-veil: transparent;
  --game-frame-line: rgba(255, 220, 128, 0.34);
  --game-frame-shadow: rgba(255, 220, 128, 0.18);
  --game-text-warm: #fff0c4;
  --game-active-text: #1a0710;
  --game-hero-image: none;
  --game-aspect: 720 / 1080;
  --arcade-viewport-height: 100svh;
  --arcade-viewport-width: 100vw;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: contain;
  touch-action: manipulation;
}

.theme-steampunk {
  --panel: rgba(60, 34, 12, 0.92);
  --panel-strong: rgba(78, 43, 14, 0.98);
  --line: rgba(255, 220, 128, 0.58);
  --hot: #ff8a3d;
  --gold: #ffd166;
  --aqua: #9de7d3;
  --game-surface-dark: #10172f;
  --game-surface-low: #071b24;
  --game-page-glow-a: rgba(255, 209, 102, 0.2);
  --game-page-glow-b: rgba(180, 82, 28, 0.22);
  --game-page-veil: rgba(12, 7, 3, 0.18);
  --game-frame-line: rgba(255, 220, 128, 0.34);
  --game-frame-shadow: rgba(255, 220, 128, 0.18);
  --game-text-warm: #fff0c4;
  --game-active-text: #1a0710;
}

.theme-neon-apocalypse {
  --panel: rgba(15, 0, 28, 0.9);
  --panel-strong: rgba(28, 0, 48, 0.98);
  --line: rgba(0, 245, 255, 0.58);
  --hot: #ff003c;
  --gold: #ff2bd6;
  --aqua: #00f5ff;
  --game-surface-dark: #190030;
  --game-surface-low: #03000a;
  --game-page-glow-a: rgba(0, 245, 255, 0.18);
  --game-page-glow-b: rgba(255, 43, 214, 0.24);
  --game-page-veil: rgba(5, 0, 9, 0.05);
  --game-frame-line: rgba(0, 245, 255, 0.34);
  --game-frame-shadow: rgba(255, 43, 214, 0.22);
  --game-text-warm: #f8fbff;
  --game-active-text: #050009;
}

.theme-ai-drone-wars {
  --panel: rgba(3, 18, 28, 0.92);
  --panel-strong: rgba(5, 28, 44, 0.98);
  --line: rgba(110, 231, 255, 0.52);
  --hot: #ff496c;
  --gold: #6ee7ff;
  --aqua: #f8fbff;
  --game-surface-dark: #061827;
  --game-surface-low: #010409;
  --game-page-glow-a: rgba(110, 231, 255, 0.16);
  --game-page-glow-b: rgba(47, 128, 255, 0.2);
  --game-page-veil: rgba(1, 4, 9, 0.06);
  --game-frame-line: rgba(110, 231, 255, 0.32);
  --game-frame-shadow: rgba(110, 231, 255, 0.2);
  --game-text-warm: #f8fbff;
  --game-active-text: #010409;
}

.theme-olympus {
  --panel: rgba(12, 28, 46, 0.9);
  --panel-strong: rgba(18, 42, 68, 0.96);
  --line: rgba(246, 211, 107, 0.62);
  --hot: #e7354f;
  --gold: #f6d36b;
  --aqua: #4cb3ff;
  --game-surface-dark: #12395d;
  --game-surface-low: #02121f;
  --game-page-glow-a: rgba(246, 211, 107, 0.18);
  --game-page-glow-b: rgba(76, 179, 255, 0.22);
  --game-page-veil: rgba(2, 18, 31, 0.05);
  --game-frame-line: rgba(255, 249, 230, 0.32);
  --game-frame-shadow: rgba(246, 211, 107, 0.18);
  --game-text-warm: #fff9e6;
  --game-active-text: #07131f;
}

.theme-usa-2026-football-fest {
  --panel: rgba(4, 24, 32, 0.9);
  --panel-strong: rgba(6, 37, 50, 0.96);
  --line: rgba(255, 212, 71, 0.62);
  --hot: #ff4f5e;
  --gold: #ffd447;
  --aqua: #23c8ff;
  --game-surface-dark: #063243;
  --game-surface-low: #021016;
  --game-page-glow-a: rgba(255, 212, 71, 0.18);
  --game-page-glow-b: rgba(35, 200, 255, 0.22);
  --game-page-veil: rgba(2, 16, 22, 0.05);
  --game-frame-line: rgba(255, 255, 255, 0.3);
  --game-frame-shadow: rgba(255, 212, 71, 0.2);
  --game-text-warm: #fff7d6;
  --game-active-text: #041820;
}

.theme-neon-apocalypse::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.04), rgba(255,255,255,0.04) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: screen;
  opacity: .04;
}

.theme-ai-drone-wars::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  background:
    linear-gradient(rgba(110,231,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,231,255,.08) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .035;
}

.theme-olympus::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  background:
    radial-gradient(circle at 52% 8%, rgba(246, 211, 107, .18), transparent 18rem),
    linear-gradient(135deg, transparent 46%, rgba(76, 179, 255, .16) 47%, transparent 51%);
  opacity: .05;
}

html {
  min-height: 100svh;
  background: var(--game-background);
}

/* -------------------------------------------------------------------------- */
/* 2. Page Shell And Cabinet Layout                                           */
/* -------------------------------------------------------------------------- */

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 0%, var(--game-page-glow-a), transparent 38rem),
    radial-gradient(circle at 18% 14%, var(--game-page-glow-a), transparent 31rem),
    radial-gradient(circle at 82% 18%, var(--game-page-glow-b), transparent 28rem),
    linear-gradient(145deg, var(--game-background) 0%, var(--game-surface-dark) 47%, var(--game-surface-low) 100%);
  color: var(--ink);
  font-family: "Sora", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.story-page,
.story-page * {
  max-width: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 8px;
  z-index: 30;
  pointer-events: none;
  border: 2px solid var(--game-frame-line);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-secondary) 68%, transparent),
    0 0 38px color-mix(in srgb, var(--game-primary) 24%, transparent),
    0 0 0 10px rgba(20, 9, 2, 0.07) inset,
    0 0 34px color-mix(in srgb, var(--game-frame-shadow) 58%, transparent) inset;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

button {
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 54%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 22%, transparent), color-mix(in srgb, var(--game-secondary) 84%, rgba(0, 0, 0, 0.84))),
    color-mix(in srgb, var(--game-secondary) 80%, rgba(0, 0, 0, 0.8));
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 14%, transparent) inset, 0 10px 24px rgba(0, 0, 0, 0.28);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

input {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  font-size: 16px;
}

button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--game-text-warm) 82%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 34%, transparent), color-mix(in srgb, var(--game-secondary) 90%, rgba(0, 0, 0, 0.9))),
    color-mix(in srgb, var(--game-primary) 28%, var(--game-secondary));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 20%, transparent) inset, 0 0 24px color-mix(in srgb, var(--game-primary) 24%, transparent), 0 12px 28px rgba(0, 0, 0, 0.34);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--game-primary) 78%, transparent);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  grid-template-areas:
    "title stats"
    "canvas command"
    "canvas score"
    "canvas upgrades"
    "canvas perks";
  align-content: start;
  gap: 20px;
  width: min(1320px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  min-height: var(--arcade-viewport-height, 100svh);
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.stage-wrap,
.control-panel {
  min-width: 0;
}

.layout-title {
  grid-area: title;
}

.layout-run-stats {
  grid-area: stats;
}

.layout-canvas {
  grid-area: canvas;
}

.layout-score {
  grid-area: score;
}

.layout-upgrades {
  grid-area: upgrades;
}

.command-panel {
  grid-area: command;
}

.theme-identity-badge {
  display: grid;
  gap: 4px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 62%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-primary) 18%, transparent), transparent 62%),
    rgba(0, 0, 0, 0.24);
  box-shadow: 0 0 18px color-mix(in srgb, var(--game-primary) 20%, transparent) inset;
}

.theme-identity-badge span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-identity-badge strong {
  color: var(--ink);
  font-family: Orbitron, Sora, sans-serif;
  font-size: clamp(0.78rem, 2.6vw, 1rem);
  line-height: 1.1;
}

.product-promo {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 48%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-primary) 14%, transparent), transparent 58%),
    rgba(0, 0, 0, 0.3);
}

.product-promo[hidden] {
  display: none;
}

.product-promo h2 {
  margin: 2px 0 14px;
  color: var(--game-text-warm);
  font-size: clamp(1.15rem, 2.8vw, 1.85rem);
  line-height: 1.05;
}

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.product-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--game-primary) 42%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 14%, transparent), color-mix(in srgb, var(--game-surface-low) 82%, transparent)),
    rgba(0, 0, 0, 0.34);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
}

.product-card-directory {
  height: 100%;
  border-color: color-mix(in srgb, var(--game-text-warm) 34%, var(--game-primary));
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--game-primary) 18%, transparent), transparent 42%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), color-mix(in srgb, var(--game-surface-low) 88%, transparent));
}

.product-card-directory:nth-child(2) {
  --card-accent: #00f5ff;
}

.product-card-directory:nth-child(3) {
  --card-accent: #8ee6ff;
}

.product-card-directory:nth-child(4) {
  --card-accent: #ffd36b;
}

.product-card-media {
  position: relative;
  display: block;
  min-height: 118px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.38);
}

.product-card-media-poster {
  margin: -1px -1px 0;
  min-height: 292px;
  border-bottom: 1px solid color-mix(in srgb, var(--card-accent, var(--game-primary)) 36%, transparent);
}

.product-card-poster {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 292px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.08) contrast(1.05);
  transition: transform 180ms ease, filter 180ms ease;
}

.product-card-screenshot {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top center;
  transition: transform 180ms ease, filter 180ms ease;
}

.product-card-media-poster .product-card-screenshot {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: min(42%, 168px);
  border: 1px solid color-mix(in srgb, var(--card-accent, var(--game-primary)) 34%, rgba(0, 0, 0, 0.72));
  border-radius: 8px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(0, 0, 0, 0.62) inset;
}

.product-card-media:hover .product-card-screenshot,
.product-card-media:focus-visible .product-card-screenshot {
  filter: saturate(1.12) contrast(1.06);
  transform: scale(1.035);
}

.product-card-media:hover .product-card-poster,
.product-card-media:focus-visible .product-card-poster {
  filter: saturate(1.16) contrast(1.08);
  transform: scale(1.025);
}

.product-card-icon {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 42px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 62%, transparent);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.56);
  box-shadow: 0 0 18px color-mix(in srgb, var(--game-primary) 36%, transparent);
}

.product-card-play {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 54%, transparent);
  border-radius: 999px;
  color: var(--game-text-warm);
  background: rgba(0, 0, 0, 0.58);
  font-family: Orbitron, Sora, sans-serif;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.product-card-copy {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.product-card-directory .product-card-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.product-card h3 {
  margin: 0;
  color: var(--game-text-warm);
  font-size: 1rem;
  line-height: 1.15;
}

.product-card p {
  min-height: 2.8em;
  margin: 0;
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.45;
}

.product-card-directory p {
  min-height: 0;
}

.product-card-hook {
  color: color-mix(in srgb, var(--game-text-warm) 72%, white);
  font-size: 0.82rem;
}

.product-card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.product-card-features li {
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 40%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--game-text-warm) 86%, var(--game-primary));
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.1;
}

.product-card-action {
  align-self: end;
  margin-top: auto;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.arcade-account-chip {
  position: relative;
  width: 42px;
  min-width: 42px;
  height: 42px;
  margin-top: 8px;
  min-height: 42px;
  padding: 0;
  letter-spacing: 0;
  border-radius: 50%;
}

.arcade-account-chip[data-signed-in="true"] {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--green) 20%, transparent), color-mix(in srgb, var(--game-surface-dark) 88%, transparent)),
    color-mix(in srgb, var(--game-surface-dark) 82%, transparent);
  border-color: color-mix(in srgb, var(--green) 42%, var(--game-primary));
}

.arcade-account-chip[data-signed-in="true"]::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid color-mix(in srgb, var(--game-surface-dark) 88%, transparent);
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px color-mix(in srgb, var(--green) 70%, transparent);
}

.arcade-account-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
}

.arcade-account-icon::before,
.arcade-account-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.arcade-account-icon::before {
  top: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.arcade-account-icon::after {
  bottom: 1px;
  width: 16px;
  height: 8px;
  border-radius: 999px 999px 4px 4px;
}

.arcade-auth-prompt {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--game-primary) 30%, transparent);
}

.arcade-auth-prompt[hidden] {
  display: none;
}

.arcade-auth-prompt p {
  display: grid;
  gap: 3px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.35;
}

.arcade-auth-prompt strong {
  color: var(--game-text-warm);
  font-size: 0.94rem;
  font-weight: 950;
  text-transform: uppercase;
}

.arcade-auth-prompt span {
  color: color-mix(in srgb, var(--game-text-warm) 72%, var(--game-primary));
}

.arcade-auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.arcade-auth-actions .arcade-link {
  min-height: 42px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.arcade-auth-actions .arcade-link[hidden] {
  display: none;
}

.arcade-auth-secondary {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-text-warm) 12%, transparent), color-mix(in srgb, var(--game-surface-dark) 88%, transparent)),
    color-mix(in srgb, var(--game-surface-dark) 82%, transparent);
  border-color: color-mix(in srgb, var(--game-text-warm) 36%, var(--game-primary));
}

.scoreboard-claim-link {
  color: var(--game-primary);
  font-weight: 900;
}

.scoreboard-local-note {
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-weight: 800;
}

.earned-unlocks {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 44%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 14%, transparent), transparent),
    color-mix(in srgb, var(--game-surface-dark) 82%, transparent);
  box-shadow: 0 12px 28px color-mix(in srgb, #000 26%, transparent);
}

.earned-unlocks[hidden] {
  display: none;
}

.earned-unlocks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--game-text-warm);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.earned-unlocks-head a {
  color: var(--game-primary);
  font-size: 0.72rem;
  text-decoration: none;
}

.earned-unlocks-grid {
  display: grid;
  gap: 8px;
}

.earned-unlock-card {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.earned-unlock-card img {
  width: 70px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 38%, transparent);
  border-radius: 6px;
}

.earned-unlock-card div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.earned-unlock-card strong,
.earned-unlock-card span {
  overflow-wrap: anywhere;
}

.earned-unlock-card strong {
  color: var(--game-text-warm);
  font-size: 0.88rem;
  line-height: 1.18;
}

.earned-unlock-card span {
  color: color-mix(in srgb, var(--game-text-warm) 72%, var(--game-primary));
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.25;
}

.scoreboard .product-promo {
  margin-top: 14px;
  padding: 12px;
}

.scoreboard .product-card-grid,
.product-promo-gameover .product-card-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.scoreboard .product-card-media,
.product-promo-gameover .product-card-media {
  min-height: 86px;
}

.scoreboard .product-card p,
.product-promo-gameover .product-card p {
  display: none;
}

.product-directory-page {
  min-height: 100svh;
  overflow-x: hidden;
  overflow-y: auto;
}

.product-directory-shell {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom));
}

.product-directory-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(360px, 1.14fr);
  align-items: center;
  gap: clamp(18px, 4vw, 42px);
  min-height: min(680px, calc(100svh - 42px));
  padding: 38px 0 30px;
}

.product-directory-hero-copy {
  min-width: 0;
}

.product-directory-hero h1 {
  display: block;
  width: max-content;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  white-space: normal;
  text-align: left;
  margin: 0;
  color: var(--game-text-warm);
  font-size: clamp(2.1rem, 4.1vw, 3.9rem);
  line-height: 1.04;
  text-shadow: 0 0 18px color-mix(in srgb, var(--game-primary) 34%, transparent), 0 5px 0 rgba(30, 10, 2, 0.46);
}

.product-directory-hero h1 span {
  display: block;
  white-space: nowrap;
}

.product-directory-hero p {
  max-width: 720px;
  margin: 18px 0 0;
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 800;
  line-height: 1.55;
}

.product-directory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.product-directory-actions .arcade-link {
  width: auto;
  min-width: min(180px, 100%);
}

.arcade-link-secondary {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-surface-high) 76%, transparent), rgba(0, 0, 0, 0.3));
  color: var(--game-text-warm);
}

.product-directory-feature {
  position: relative;
  display: block;
  min-height: min(62svh, 560px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--game-primary) 46%, transparent);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.38);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.product-directory-feature-art {
  display: block;
  width: 100%;
  min-height: min(62svh, 560px);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.12) contrast(1.05);
}

.product-directory-feature::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 35%, rgba(0, 0, 0, 0.78)),
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), transparent 58%);
  pointer-events: none;
}

.product-directory-feature-copy {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 1;
  display: grid;
  gap: 6px;
  color: var(--game-text-warm);
}

.product-directory-feature-copy strong {
  font-family: Orbitron, Sora, sans-serif;
  font-size: clamp(1.25rem, 3vw, 2.3rem);
  line-height: 1;
}

.product-directory-feature-copy span:last-child {
  max-width: 620px;
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  font-weight: 800;
  line-height: 1.45;
}

.product-directory-showcase {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-directory-preview {
  position: relative;
  display: block;
  min-height: 128px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--game-primary) 48%, transparent);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.36);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.32);
}

.product-directory-preview:nth-child(2),
.product-directory-preview:nth-child(3) {
  transform: translateY(18px);
}

.product-directory-preview img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 128px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: top center;
  filter: saturate(1.08) contrast(1.04);
  transition: transform 180ms ease, filter 180ms ease;
}

.product-directory-preview:hover img,
.product-directory-preview:focus-visible img {
  filter: saturate(1.2) contrast(1.1);
  transform: scale(1.035);
}

.product-directory-preview span {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 42%, transparent);
  border-radius: 8px;
  color: var(--game-text-warm);
  background: rgba(0, 0, 0, 0.66);
  font-family: Orbitron, Sora, sans-serif;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.1;
}

.product-directory-highlights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.product-directory-highlights span {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 34%, transparent);
  border-radius: var(--radius);
  color: color-mix(in srgb, var(--game-text-warm) 84%, var(--game-primary));
  background: rgba(0, 0, 0, 0.24);
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.product-directory-highlights strong {
  color: var(--game-text-warm);
  font-family: Orbitron, Sora, sans-serif;
}

.product-directory-grid.product-promo {
  padding: 18px;
}

.product-directory-grid .product-card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.product-directory-grid .product-card-media {
  min-height: 156px;
}

.product-directory-grid .product-card-media-poster {
  min-height: clamp(240px, 28vw, 340px);
}

.product-directory-grid .product-card-poster {
  min-height: clamp(240px, 28vw, 340px);
}

.perks-panel {
  grid-area: perks;
}

.mobile-action-panel {
  grid-area: perks;
  display: none;
}

.mobile-action-button {
  appearance: none;
  min-width: 0;
  min-height: 68px;
  padding: 8px 6px 9px;
  display: grid;
  grid-template-rows: 23px minmax(14px, auto) minmax(10px, auto);
  align-content: center;
  align-items: center;
  justify-items: center;
  gap: 3px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 50%, var(--game-text-warm) 12%);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 70%, var(--game-primary) 18%), color-mix(in srgb, var(--panel) 88%, black 12%)),
    color-mix(in srgb, var(--panel) 92%, black);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 10%, transparent) inset,
    0 8px 22px rgba(0, 0, 0, 0.28);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.mobile-action-button span,
.mobile-action-button small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-action-button span {
  font-family: Orbitron, Sora, Inter, sans-serif;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mobile-action-button small {
  color: color-mix(in srgb, var(--game-text-warm) 86%, var(--game-primary));
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.mobile-action-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.mobile-action-button:disabled {
  cursor: default;
  opacity: 0.78;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-surface-dark) 78%, var(--game-primary) 12%), color-mix(in srgb, var(--game-surface-low) 84%, black 16%)),
    color-mix(in srgb, var(--game-surface-low) 90%, black);
}

.mobile-action-button:focus-visible {
  outline: 2px solid var(--game-text-warm);
  outline-offset: 3px;
}

.mobile-action-button:disabled small {
  color: color-mix(in srgb, var(--game-text-warm) 76%, var(--game-primary));
}

/* -------------------------------------------------------------------------- */
/* 3. Header Marquee And Stat Panels                                          */
/* -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: stretch;
  margin-bottom: 14px;
}

.title-block {
  min-width: 0;
  display: flex;
  align-items: stretch;
  width: 100%;
}

.eyebrow {
  margin: 0 0 5px;
  color: color-mix(in srgb, var(--game-primary) 72%, var(--game-text-warm));
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 10px color-mix(in srgb, var(--game-primary) 45%, transparent), 0 1px 8px rgba(0, 0, 0, 0.8);
}

h1,
h2 {
  margin: 0;
  line-height: 1;
  letter-spacing: 0;
}

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: none;
  width: 100%;
  min-height: 72px;
  padding: 9px 24px 11px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 62%, var(--game-text-warm) 12%);
  border-radius: 7px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 28%, transparent), color-mix(in srgb, var(--game-surface-dark) 86%, transparent) 46%, color-mix(in srgb, var(--game-surface-low) 94%, transparent));
  overflow-wrap: normal;
  white-space: nowrap;
  color: var(--game-text-warm);
  font-size: clamp(2.15rem, 3.8vw, 3.45rem);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 20%, transparent) inset,
    0 0 0 5px color-mix(in srgb, var(--game-surface-dark) 64%, transparent),
    0 18px 44px rgba(0, 0, 0, 0.34),
    0 0 32px color-mix(in srgb, var(--game-primary) 14%, transparent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.68), 0 0 20px color-mix(in srgb, var(--game-primary) 28%, transparent);
}

.title-full {
  display: inline;
}

.title-compact {
  display: none;
}

h2 {
  font-size: clamp(1.9rem, 5vw, 3.8rem);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 8px;
  grid-template-areas: "level balls";
  width: 100%;
  margin-bottom: 14px;
}

.stat,
.panel-section {
  border: 1px solid color-mix(in srgb, var(--game-primary) 58%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 26%, transparent), color-mix(in srgb, var(--game-surface-dark) 78%, transparent) 34%, color-mix(in srgb, var(--game-surface-low) 72%, transparent)),
    var(--panel);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 18%, transparent) inset,
    0 0 32px color-mix(in srgb, var(--game-primary) 14%, transparent),
    0 18px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

.stat {
  min-height: 72px;
  padding: 10px;
  overflow: hidden;
}

.stat-small:first-child {
  grid-area: level;
}

.stat-small:nth-child(2) {
  grid-area: balls;
}

.stat-coins {
  grid-area: auto;
}

.stat-score {
  grid-area: auto;
}

.stat span,
.angle-readout span {
  display: block;
  color: var(--game-text-warm);
  font-size: 0.76rem;
  font-weight: 700;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.stat strong,
.angle-readout strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.2rem, 2.6vw, 1.9rem);
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 0 14px color-mix(in srgb, var(--game-primary) 38%, transparent), 0 1px 10px rgba(0, 0, 0, 0.74);
}

.stat-display {
  min-height: 88px;
  border-color: color-mix(in srgb, var(--game-primary) 68%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 22%, transparent), rgba(0, 0, 0, 0.3)),
    rgba(8, 4, 0, 0.88);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 22%, transparent) inset, 0 0 30px color-mix(in srgb, var(--game-primary) 20%, transparent), 0 18px 60px rgba(0, 0, 0, 0.35);
}

.stat-display span {
  text-align: center;
  color: var(--game-primary);
}

.stat-display strong {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 7px 8px 5px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 26%, transparent);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--game-primary) 8%, transparent) 0 1px, transparent 1px 14px),
    linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(22, 7, 0, 0.92));
  color: var(--game-primary);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.55rem, 3.3vw, 2.65rem);
  font-weight: 900;
  letter-spacing: 0.045em;
  text-shadow: 0 0 6px color-mix(in srgb, var(--game-primary) 90%, transparent), 0 0 18px color-mix(in srgb, var(--game-danger) 60%, transparent);
}

.stat-score strong,
.stat-coins strong {
  font-size: clamp(1.45rem, 2.65vw, 2.25rem);
}

.score-panel {
  display: grid;
  gap: 10px;
}

/* -------------------------------------------------------------------------- */
/* 4. Canvas Frame And Game Overlay                                           */
/* -------------------------------------------------------------------------- */

.score-panel .stat-display {
  min-height: 96px;
}

.score-panel .stat-display strong {
  min-height: 56px;
}

.score-panel .stat-score strong,
.score-panel .stat-coins strong {
  font-size: clamp(1.48rem, 3.55vw, 2.22rem);
  letter-spacing: 0.035em;
}

.canvas-card {
  position: relative;
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--game-primary) 78%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 22%, transparent), color-mix(in srgb, var(--game-secondary) 70%, transparent)),
    var(--game-surface-low);
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--game-surface-low) 88%, rgba(0, 0, 0, 0.9)),
    0 0 0 10px color-mix(in srgb, var(--game-secondary) 72%, transparent),
    0 0 0 13px color-mix(in srgb, var(--game-primary) 18%, transparent),
    0 28px 90px rgba(0, 0, 0, 0.55),
    0 0 54px color-mix(in srgb, var(--game-primary) 22%, transparent),
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 38%, transparent) inset;
}

.canvas-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: calc(var(--radius) - 1px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 24%, transparent) inset,
    0 0 0 8px rgba(0, 0, 0, 0.08) inset,
    0 0 0 16px color-mix(in srgb, var(--game-primary) 3%, transparent) inset,
    0 0 42px color-mix(in srgb, var(--game-primary) 16%, transparent) inset;
}

canvas {
  display: block;
  width: min(100%, 640px);
  height: auto;
  aspect-ratio: var(--game-aspect);
  min-height: 0;
  margin-inline: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-background) 12%, transparent), color-mix(in srgb, var(--game-background) 72%, rgba(0, 0, 0, 0.68))),
    color-mix(in srgb, var(--game-primary) 8%, transparent);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.arcade-chain-coach {
  display: grid;
  gap: 4px;
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 36%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--game-primary) 12%, transparent), color-mix(in srgb, var(--game-secondary) 18%, transparent)),
    color-mix(in srgb, var(--game-surface-low) 78%, rgba(0, 0, 0, 0.5));
  box-shadow: 0 0 18px color-mix(in srgb, var(--game-primary) 12%, transparent) inset;
}

.arcade-chain-coach strong {
  color: var(--game-primary);
  font-family: Orbitron, Sora, Inter, sans-serif;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.arcade-chain-coach span {
  color: color-mix(in srgb, var(--game-text-warm) 88%, #ffffff);
  font-size: 0.86rem;
  line-height: 1.36;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.overlay-panel {
  width: min(560px, 100%);
  max-height: min(calc(100svh - 48px), calc(100% - 48px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 26px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 58%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 24%, transparent), color-mix(in srgb, var(--game-surface-dark) 88%, rgba(0, 0, 0, 0.88))),
    color-mix(in srgb, var(--game-surface-dark) 92%, rgba(0, 0, 0, 0.92));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

.overlay-art,
.scoreboard-art,
.rules-art {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--game-primary) 42%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 18%, transparent), rgba(0, 0, 0, 0.42)),
    var(--game-surface-dark);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34), 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 12%, transparent) inset;
}

.overlay-art {
  display: grid;
  grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 12px 0 14px;
  padding: 10px;
}

.overlay-art img,
.scoreboard-art img,
.rules-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay-art img {
  aspect-ratio: 16 / 10;
  border-radius: 6px;
}

.overlay-art p,
.scoreboard-art p,
.rules-art p {
  margin: 0;
  color: color-mix(in srgb, var(--game-text-warm) 88%, var(--game-primary));
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
}

.overlay-panel:has(.scoreboard:not([hidden])) > .overlay-art {
  display: none;
}

.overlay-panel p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.mode-select {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.mode-select[hidden] {
  display: none;
}

.mode-card {
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
  text-align: left;
  min-width: 0;
}

.mode-card span {
  color: #fff8dd;
  font-size: 1.02rem;
  font-weight: 950;
  white-space: nowrap;
}

.mode-card strong {
  color: #ffe0a4;
  font-size: 0.72rem;
  line-height: 1.25;
  white-space: nowrap;
}

.mode-card.is-active {
  border-color: color-mix(in srgb, var(--game-text-warm) 96%, transparent);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-danger) 86%, var(--game-secondary)), color-mix(in srgb, var(--game-primary) 94%, transparent));
  color: var(--game-active-text);
}

.mode-card.is-active span,
.mode-card.is-active strong {
  color: var(--game-active-text);
  text-shadow: none;
}

.scoreboard {
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 10px;
  overflow: hidden;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 66%, transparent);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 16% 8%, color-mix(in srgb, var(--game-text-warm) 32%, transparent), transparent 7rem),
    radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--game-primary) 28%, transparent), transparent 8rem),
    linear-gradient(180deg, rgba(5, 7, 18, 0.74), color-mix(in srgb, var(--game-surface-dark) 88%, rgba(0,0,0,.88)));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 18%, transparent) inset,
    0 0 34px color-mix(in srgb, var(--game-primary) 20%, transparent),
    0 18px 50px rgba(0, 0, 0, 0.44);
}

.scoreboard[hidden] {
  display: none;
}

.scoreboard::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 22%, transparent);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--game-primary) 6%, transparent) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 8%, transparent), rgba(0, 0, 0, 0.22));
  box-shadow: 0 0 36px color-mix(in srgb, var(--game-primary) 16%, transparent) inset;
}

.scoreboard-hero {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.58;
}

.scoreboard-gear {
  position: absolute;
  width: 84px;
  aspect-ratio: 1;
  border: 9px dotted color-mix(in srgb, var(--game-primary) 42%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--game-secondary) 44%, transparent) inset, 0 0 28px color-mix(in srgb, var(--game-primary) 24%, transparent);
}

.gear-one {
  right: -26px;
  top: -30px;
}

.gear-two {
  left: -30px;
  bottom: 18px;
  width: 58px;
}

.scoreboard-orbit {
  position: absolute;
  right: 34px;
  bottom: 30px;
  width: 100px;
  aspect-ratio: 1;
  border: 1px solid rgba(157, 231, 211, 0.34);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(157, 231, 211, 0.14);
}

.scoreboard-art {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 74px;
  padding: 8px;
}

.scoreboard-art img {
  aspect-ratio: 1;
  border-radius: 6px;
}

.scoreboard .product-promo {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--game-primary) 24%, transparent);
}

.scoreboard .product-promo .eyebrow,
.scoreboard .product-promo h2 {
  display: none;
}

.scoreboard-entry {
  display: grid;
  gap: 8px;
}

.scoreboard-entry label {
  color: #fff1bc;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.74);
}

.scoreboard-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.scoreboard-entry input {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 62%, transparent);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.86), color-mix(in srgb, var(--game-surface-low) 92%, rgba(0, 0, 0, 0.9)));
  color: var(--game-primary);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 14%, transparent) inset;
}

.scoreboard-entry p {
  min-height: 20px;
  margin: 0;
  color: #b9ffb0;
  font-size: 0.8rem;
  font-weight: 900;
}

.score-invite-form {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding-top: 9px;
  border-top: 1px solid color-mix(in srgb, var(--game-primary) 28%, transparent);
}

.score-invite-form[hidden] {
  display: none;
}

.score-invite-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.score-invite-form input {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
}

.score-invite-form p {
  color: #fff1bc;
}

.scoreboard-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 0;
}

.scoreboard-mode-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scoreboard-tab {
  min-height: 36px;
  padding: 6px 4px;
  font-size: 0.72rem;
  font-weight: 900;
}

.scoreboard-tab.is-active {
  border-color: color-mix(in srgb, var(--game-text-warm) 72%, var(--game-primary));
  background:
    linear-gradient(135deg, var(--hot), var(--gold));
  color: var(--game-active-text);
}

.scoreboard-list {
  display: grid;
  gap: 5px;
  max-height: min(240px, 28svh);
  margin: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  list-style: none;
}

.scoreboard-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px minmax(104px, auto);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 20%, transparent);
  border-radius: 6px;
  background: rgba(8, 4, 0, 0.58);
  color: color-mix(in srgb, var(--game-text-warm) 84%, var(--game-primary));
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 900;
}

.scoreboard-rank {
  color: var(--game-primary);
}

.scoreboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard-level {
  color: #9de7d3;
}

.scoreboard-list strong {
  color: var(--game-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  text-shadow: 0 0 10px color-mix(in srgb, var(--game-primary) 68%, transparent);
}

.scoreboard-empty {
  grid-template-columns: 1fr !important;
  justify-items: center;
  color: var(--game-text-warm);
  text-align: center;
}

/* -------------------------------------------------------------------------- */
/* 5. Control Panel, Upgrades, Score Displays, And Perks                      */
/* -------------------------------------------------------------------------- */

#primary-action,
.primary {
  width: 100%;
  border: 0;
  background: linear-gradient(135deg, var(--hot), var(--gold));
  color: var(--game-active-text);
  font-weight: 900;
  box-shadow: 0 14px 40px color-mix(in srgb, var(--game-primary) 28%, transparent);
}

.game-over-high-scores {
  width: 100%;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 54%, var(--game-border));
  border-radius: 6px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 18%, transparent), rgba(0, 0, 0, 0.22)),
    color-mix(in srgb, var(--game-surface-dark) 88%, rgba(0, 0, 0, 0.92));
  color: var(--game-text-warm);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--game-primary) 18%, transparent);
}

.game-over-high-scores[hidden] {
  display: none;
}

.control-panel {
  display: contents;
}

.panel-section {
  padding: 16px;
}

.control-panel .panel-section,
.layout-upgrades,
.score-panel .stat-display {
  position: relative;
  overflow: hidden;
}

.control-panel .panel-section::before,
.layout-upgrades::before,
.score-panel .stat-display::before {
  content: "";
  position: absolute;
  inset: 6px;
  z-index: 0;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--game-text-warm) 18%, transparent);
  border-radius: 6px;
  box-shadow: 0 0 26px color-mix(in srgb, var(--game-primary) 16%, transparent) inset;
}

.control-panel .panel-section > *,
.layout-upgrades > *,
.score-panel .stat-display > * {
  position: relative;
  z-index: 1;
}

.panel-section.compact {
  min-height: 170px;
}

.angle-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  margin: 4px 0 16px;
}

.button-row,
.upgrade-grid {
  display: grid;
  gap: 8px;
}

.button-row {
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.rules-button {
  width: 100%;
  margin-top: 8px;
}

.arcade-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 52%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 22%, transparent), color-mix(in srgb, var(--game-surface-dark) 84%, transparent)),
    color-mix(in srgb, var(--game-surface-dark) 80%, transparent);
  color: var(--game-text-warm);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 14%, transparent) inset, 0 10px 24px rgba(0, 0, 0, 0.28);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.arcade-link:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--game-text-warm) 62%, var(--game-primary));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 34%, transparent), color-mix(in srgb, var(--game-surface-dark) 90%, transparent)),
    color-mix(in srgb, var(--game-primary) 22%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 20%, transparent) inset, 0 0 24px color-mix(in srgb, var(--game-primary) 24%, transparent), 0 12px 28px rgba(0, 0, 0, 0.34);
}

.arcade-link:focus-visible,
.inline-story-link:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--game-primary) 74%, transparent);
  outline-offset: 3px;
}

.launch-state {
  min-height: 22px;
  margin: 10px 0 0;
  color: #b8ffc6;
  font-size: 0.84rem;
  font-weight: 900;
  text-shadow: 0 0 12px rgba(116, 255, 141, 0.38);
}

.upgrade-grid {
  grid-template-columns: 1fr 1fr;
}

.upgrade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.upgrade-header .eyebrow {
  margin-bottom: 0;
}

.auto-upgrade-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 0;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--game-primary) 34%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--game-surface-low) 42%, transparent);
  color: var(--game-text-warm);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.95), 0 0 12px color-mix(in srgb, var(--game-primary) 38%, transparent);
  cursor: pointer;
  user-select: none;
}

.auto-upgrade-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--gold);
}

.upgrade-panel {
  border-color: color-mix(in srgb, var(--game-primary) 72%, var(--game-text-warm) 12%);
  background:
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--game-primary) 38%, transparent), transparent 11rem),
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 44%, transparent), color-mix(in srgb, var(--game-surface-dark) 72%, transparent) 38%, color-mix(in srgb, var(--game-surface-low) 84%, transparent)),
    var(--panel-strong);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 24%, transparent) inset,
    0 0 38px color-mix(in srgb, var(--game-primary) 26%, transparent),
    0 18px 60px rgba(0, 0, 0, 0.42);
}

.upgrade {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  min-height: 96px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 13px;
  border-color: color-mix(in srgb, var(--game-text-warm) 36%, var(--game-primary));
  background-blend-mode: normal;
  text-align: left;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--game-text-warm) 32%, transparent) inset,
    0 0 22px color-mix(in srgb, var(--game-primary) 24%, transparent),
    0 10px 26px rgba(0, 0, 0, 0.34);
}

.upgrade::before,
.upgrade::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.upgrade::before {
  opacity: 0.7;
  background:
    linear-gradient(108deg, transparent 0 28%, color-mix(in srgb, var(--game-text-warm) 42%, transparent) 39%, transparent 52%),
    linear-gradient(180deg, color-mix(in srgb, var(--game-text-warm) 22%, transparent), transparent 32%);
  transform: translateX(-55%);
  animation: upgrade-shimmer 5.8s ease-in-out infinite;
}

.upgrade::after {
  opacity: 0.9;
  mix-blend-mode: screen;
}

.upgrade[data-upgrade="balls"] {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-surface-low) 36%, transparent), color-mix(in srgb, var(--game-surface-dark) 28%, transparent)),
    radial-gradient(circle at 78% 22%, color-mix(in srgb, var(--game-primary) 55%, transparent), transparent 42px);
}

.upgrade[data-upgrade="balls"]::after {
  background:
    radial-gradient(circle at 72% 27%, #ffffff 0 2px, transparent 3px),
    radial-gradient(circle at 82% 62%, var(--game-primary) 0 2px, transparent 3px),
    radial-gradient(circle at 58% 48%, var(--game-primary) 0 1px, transparent 2px),
    linear-gradient(115deg, transparent 0 45%, color-mix(in srgb, var(--game-primary) 52%, transparent) 46% 48%, transparent 49%);
}

.upgrade[data-upgrade="impact"] {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-surface-dark) 32%, transparent), color-mix(in srgb, var(--game-danger) 12%, transparent)),
    radial-gradient(circle at 80% 26%, color-mix(in srgb, var(--game-primary) 58%, transparent), transparent 44px);
}

.upgrade[data-upgrade="impact"]::after {
  background:
    radial-gradient(circle at 78% 28%, color-mix(in srgb, var(--game-primary) 92%, transparent) 0 8px, transparent 9px),
    radial-gradient(circle at 68% 48%, color-mix(in srgb, var(--game-primary) 80%, transparent) 0 6px, transparent 7px),
    radial-gradient(circle at 88% 52%, color-mix(in srgb, var(--game-primary) 80%, transparent) 0 5px, transparent 6px),
    repeating-linear-gradient(90deg, transparent 0 13px, color-mix(in srgb, var(--game-primary) 26%, transparent) 13px 15px);
}

.upgrade[data-upgrade="launchTime"] {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-danger) 18%, transparent), color-mix(in srgb, var(--hot) 16%, transparent)),
    radial-gradient(circle at 78% 26%, color-mix(in srgb, var(--hot) 66%, transparent), transparent 46px);
}

.upgrade[data-upgrade="launchTime"]::after {
  background:
    radial-gradient(circle at 78% 38%, color-mix(in srgb, var(--game-primary) 78%, transparent) 0 15px, transparent 16px),
    radial-gradient(circle at 78% 38%, transparent 0 22px, color-mix(in srgb, var(--game-primary) 48%, transparent) 23px 25px, transparent 26px),
    linear-gradient(90deg, transparent 0 76%, color-mix(in srgb, var(--game-text-warm) 62%, transparent) 77% 79%, transparent 80%),
    linear-gradient(0deg, transparent 0 36%, color-mix(in srgb, var(--game-text-warm) 52%, transparent) 37% 39%, transparent 40%);
}

.upgrade[data-upgrade="powerupChance"] {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--game-surface-dark) 28%, transparent), color-mix(in srgb, var(--aqua) 12%, transparent)),
    radial-gradient(circle at 78% 25%, color-mix(in srgb, var(--aqua) 46%, transparent), transparent 46px);
}

.upgrade[data-upgrade="powerupChance"]::after {
  background:
    radial-gradient(circle at 72% 28%, rgba(157, 231, 211, 0.92) 0 5px, transparent 6px),
    radial-gradient(circle at 84% 42%, color-mix(in srgb, var(--game-primary) 86%, transparent) 0 5px, transparent 6px),
    radial-gradient(circle at 66% 56%, color-mix(in srgb, var(--hot) 82%, transparent) 0 5px, transparent 6px),
    radial-gradient(circle at 88% 64%, color-mix(in srgb, var(--game-text-warm) 80%, transparent) 0 4px, transparent 5px);
}

.upgrade span {
  color: var(--game-text-warm);
  font-size: 0.82rem;
  font-weight: 900;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.95), 0 0 12px color-mix(in srgb, var(--game-primary) 38%, transparent);
}

.upgrade strong {
  color: var(--game-text-warm);
  font-size: 1.32rem;
  text-shadow: 0 0 10px color-mix(in srgb, var(--game-primary) 82%, transparent), 0 0 22px color-mix(in srgb, var(--hot) 55%, transparent);
}

.upgrade strong::before {
  content: "$";
}

@keyframes upgrade-shimmer {
  0%,
  54% {
    transform: translateX(-62%);
    opacity: 0.2;
  }

  68% {
    opacity: 0.72;
  }

  82%,
  100% {
    transform: translateX(62%);
    opacity: 0.2;
  }
}

.mod-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mod-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--game-primary) 18%, transparent);
  background: color-mix(in srgb, var(--game-primary) 10%, transparent);
  color: color-mix(in srgb, var(--game-text-warm) 84%, var(--game-primary));
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------- */
/* 6. Rules Modal                                                             */
/* -------------------------------------------------------------------------- */

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 5, 14, 0.78);
}

.rules-modal.is-visible {
  display: flex;
}

.rules-panel {
  width: min(980px, 100%);
  max-height: min(86svh, 820px);
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--game-primary) 58%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 22%, transparent), color-mix(in srgb, var(--game-surface-low) 90%, transparent)),
    var(--panel-strong);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 20%, transparent) inset, 0 28px 90px rgba(0, 0, 0, 0.58);
}

.rules-art {
  display: grid;
  grid-template-columns: minmax(160px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin: 16px;
  padding: 12px;
}

.rules-art img {
  aspect-ratio: 16 / 9;
  border-radius: 6px;
}

.rules-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 24%, transparent), color-mix(in srgb, var(--game-surface-dark) 96%, transparent)),
    var(--panel-strong);
}

.rules-header h2 {
  font-size: clamp(1.55rem, 3vw, 2.4rem);
}

.rules-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rules-link-button {
  min-height: 40px;
  padding: 0 13px;
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 1.75rem;
  line-height: 1;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.rules-grid article {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(34, 14, 3, 0.68);
}

.rules-grid h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.rules-grid p,
.rules-grid li {
  color: #ffe7b5;
  font-size: 0.92rem;
  line-height: 1.5;
}

.rules-grid p,
.rules-grid ul {
  margin: 0;
}

.rules-grid ul {
  padding-left: 18px;
}

/* -------------------------------------------------------------------------- */
/* 7. Crew Story Page                                                         */
/* -------------------------------------------------------------------------- */

.story-page {
  overflow-y: auto;
}

.story-shell {
  width: min(1180px, 100%);
  max-width: 100vw;
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(42px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.story-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 16px;
}

.story-nav .arcade-link {
  min-width: 92px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.8rem;
}

.story-hero {
  min-height: calc(100vh - 76px);
  min-height: calc(100svh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
  align-items: center;
  gap: 36px;
  padding-bottom: 24px;
}

.story-hero-copy {
  min-width: 0;
  max-width: 100%;
}

.story-hero h1 {
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--game-text-warm);
  font-size: clamp(3rem, 6.2vw, 5.55rem);
  line-height: 0.92;
  max-width: 100%;
  text-align: left;
  text-shadow: 0 0 18px color-mix(in srgb, var(--hot) 42%, transparent), 0 9px 0 rgba(0, 0, 0, 0.62);
  overflow-wrap: anywhere;
  white-space: normal;
}

.story-title-line {
  display: block;
  width: 100%;
  white-space: nowrap;
}

.story-lead {
  max-width: 620px;
  margin: 22px 0;
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-size: clamp(1.02rem, 2vw, 1.34rem);
  font-weight: 700;
  line-height: 1.55;
}

.primary-story-link {
  min-width: 210px;
  padding: 0 18px;
}

.story-hero-art {
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

.story-hero-art img,
.crew-card img,
.comic-panel img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid color-mix(in srgb, var(--game-primary) 56%, transparent);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), 0 0 0 1px color-mix(in srgb, var(--game-text-warm) 18%, transparent) inset;
}

.story-hero-art img {
  aspect-ratio: 1200 / 640;
  object-fit: cover;
}

.story-band,
.section-heading {
  max-width: 920px;
  margin: 0 auto;
  text-align: center;
}

.story-band {
  padding: 54px 0;
}

.story-band h2,
.section-heading h2 {
  margin: 0;
  color: var(--game-text-warm);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  text-shadow: 0 0 18px color-mix(in srgb, var(--hot) 32%, transparent), 0 6px 0 rgba(0, 0, 0, 0.54);
}

.story-band p {
  margin: 18px auto 0;
  color: color-mix(in srgb, var(--game-text-warm) 82%, var(--game-primary));
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.6;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 54px 0;
}

.crew-grid .section-heading,
.comic-section .section-heading {
  grid-column: 1 / -1;
  margin-bottom: 10px;
}

.crew-card,
.comic-panel {
  border: 1px solid color-mix(in srgb, var(--game-primary) 48%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 18%, transparent), color-mix(in srgb, var(--game-surface-low) 82%, transparent)),
    color-mix(in srgb, var(--game-surface-dark) 68%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
}

.crew-card {
  padding: 12px;
}

.crew-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  object-fit: cover;
}

.crew-card h3,
.comic-panel h3 {
  margin: 14px 0 8px;
  color: var(--game-text-warm);
  font-size: 1.15rem;
}

.crew-card p,
.comic-panel p {
  margin: 0;
  color: #ffe7b5;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.55;
}

.comic-section {
  display: grid;
  gap: 18px;
  padding: 54px 0;
}

.comic-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.64fr) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 14px;
}

.comic-panel img {
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
}

.inline-story-link {
  color: #fff8dd;
  font-weight: 900;
}

.final-call {
  padding-bottom: 18px;
}

.final-call .primary-story-link {
  margin-top: 20px;
}

/* -------------------------------------------------------------------------- */
/* 8. Responsive Adjustments                                                  */
/* -------------------------------------------------------------------------- */

@media (max-width: 940px) {
  body {
    background-attachment: scroll;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "stats"
      "canvas"
      "score"
      "upgrades"
      "command"
      "perks";
    gap: 14px;
    width: min(720px, 100%);
  }

  .topbar {
    width: 100%;
  }

  h1 {
    min-height: 62px;
    font-size: 2.55rem;
  }

  .stat-grid {
    width: 100%;
  }

  canvas {
    width: min(100%, 620px);
    height: auto;
    min-height: 0;
  }

  .score-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .story-hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .story-hero h1,
  .story-hero-copy {
    text-align: center;
  }

  .story-title-line {
    display: block !important;
    width: 100%;
    white-space: nowrap;
  }

  .story-lead {
    margin-right: auto;
    margin-left: auto;
  }

  .crew-grid {
    grid-template-columns: 1fr;
  }

  .comic-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .story-shell {
    padding:
      max(16px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(34px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .story-nav {
    justify-content: center;
    gap: 8px;
    margin-bottom: 18px;
  }

  .story-nav .arcade-link {
    flex: 1 1 94px;
    min-width: 0;
    padding: 0 8px;
  }

  .story-hero {
    gap: 22px;
    padding-bottom: 8px;
  }

  .story-hero h1 {
    font-size: clamp(2.7rem, 12.5vw, 3.55rem);
    line-height: 0.94;
    text-shadow: 0 0 14px rgba(255, 138, 61, 0.38), 0 5px 0 rgba(30, 10, 2, 0.58);
  }

  .story-lead {
    margin: 18px auto;
    font-size: 1rem;
    line-height: 1.48;
  }

  .story-band,
  .crew-grid,
  .comic-section {
    padding: 42px 0;
  }

  .story-band h2,
  .section-heading h2 {
    font-size: clamp(1.75rem, 10vw, 2.8rem);
    line-height: 1.02;
  }

  .story-band p {
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .crew-grid,
  .comic-section {
    gap: 14px;
  }

  .crew-card,
  .comic-panel {
    padding: 10px;
  }

  .comic-panel {
    gap: 12px;
  }

  .comic-panel img {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .theme-steampunk:not(.story-page):not(.product-directory-page),
  .theme-neon-apocalypse:not(.story-page):not(.product-directory-page),
  .theme-ai-drone-wars:not(.story-page):not(.product-directory-page),
  .theme-olympus:not(.story-page):not(.product-directory-page),
  .theme-usa-2026-football-fest:not(.story-page):not(.product-directory-page) {
    height: var(--arcade-viewport-height, 100svh);
    min-height: var(--arcade-viewport-height, 100svh);
    overflow: hidden;
  }

  .product-directory-page {
    height: auto;
    min-height: 100svh;
    overflow-y: auto;
  }

  .product-directory-shell {
    width: min(100% - 20px, 1160px);
    padding:
      max(16px, env(safe-area-inset-top))
      0
      max(26px, env(safe-area-inset-bottom));
  }

  .product-directory-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: auto;
    padding: 18px 0 18px;
  }

  .product-directory-hero h1 {
    font-size: clamp(2rem, 9vw, 2.75rem);
  }

  .product-directory-hero p {
    margin-top: 12px;
    font-size: 0.98rem;
    line-height: 1.45;
  }

  .product-directory-actions .arcade-link {
    flex: 1 1 140px;
  }

  .product-directory-feature {
    min-height: 280px;
  }

  .product-directory-feature-art {
    min-height: 280px;
    aspect-ratio: 4 / 5;
  }

  .product-directory-feature-copy {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .product-directory-showcase {
    gap: 8px;
  }

  .product-directory-preview,
  .product-directory-preview img {
    min-height: 92px;
  }

  .product-directory-preview:nth-child(2),
  .product-directory-preview:nth-child(3) {
    transform: none;
  }

  .product-directory-preview span {
    left: 7px;
    right: 7px;
    bottom: 7px;
    padding: 6px 7px;
    font-size: 0.66rem;
  }

  .product-directory-highlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .product-directory-grid.product-promo {
    padding: 12px;
  }

  .product-directory-grid .product-card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .product-directory-grid .product-card-media-poster,
  .product-directory-grid .product-card-poster {
    min-height: 260px;
  }

  .product-card-media-poster .product-card-screenshot {
    width: min(46%, 150px);
  }

  body::before {
    inset: 4px;
    border-radius: 7px;
  }

  .game-shell {
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title stats"
      "canvas canvas"
      "score score"
      "upgrades upgrades"
      "command command"
      "perks perks";
    width: 100%;
    height: var(--arcade-viewport-height, 100svh);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  body.arcade-game-active .game-shell {
    overflow: hidden;
    touch-action: none;
  }

  .arcade-account-chip {
    display: none;
  }

  .topbar {
    margin-bottom: 0;
  }

  h1 {
    min-height: 46px;
    padding: 7px 9px 8px;
    font-size: clamp(0.94rem, 3.85vw, 1.13rem);
    text-align: center;
  }

  .title-full {
    display: inline;
  }

  .title-compact {
    display: none;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 66px);
    grid-template-areas: "level balls";
    gap: 6px;
    justify-self: end;
    width: max-content;
    margin-bottom: 0;
  }

  .stat-small {
    width: 66px;
    min-height: 46px;
    padding: 6px 5px;
  }

  .stat span,
  .angle-readout span {
    font-size: 0.68rem;
  }

  .stat strong,
  .angle-readout strong {
    font-size: 1.22rem;
  }

  .canvas-card {
    border-width: 2px;
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--game-surface-low) 90%, transparent),
      0 0 0 6px color-mix(in srgb, var(--game-secondary) 64%, transparent),
      0 16px 50px rgba(0, 0, 0, 0.5),
      0 0 0 1px color-mix(in srgb, var(--game-primary) 34%, transparent) inset;
  }

  canvas {
    height: auto;
    width: 100%;
    min-height: 0;
    margin-inline: auto;
  }

  .control-panel {
    gap: 10px;
  }

  .command-panel {
    display: none;
  }

  body:not([data-game-mode="classic"]) .layout-upgrades {
    min-height: 46px;
    padding: 10px 12px;
  }

  body:not([data-game-mode="classic"]) .layout-upgrades .upgrade-header {
    margin: 0;
  }

  body:not([data-game-mode="classic"]) .layout-upgrades .upgrade-grid {
    display: none;
  }

  .perks-panel {
    display: none;
  }

  .mobile-action-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
  }

  .button-row,
  .upgrade-grid,
  .score-panel {
    gap: 7px;
  }

  .panel-section {
    padding: 10px;
  }

  .panel-section.compact {
    min-height: 128px;
  }

  .mobile-action-button {
    min-height: 66px;
  }

  .upgrade {
    min-height: 58px;
    padding: 7px;
  }

  .stat-display {
    min-height: 60px;
  }

  .score-panel .stat-display {
    min-height: 60px;
  }

  .score-panel .stat-display strong {
    min-height: 34px;
    padding: 5px 6px 4px;
    font-size: clamp(1.05rem, 3.6vw, 1.24rem);
    letter-spacing: 0.025em;
  }

  .score-panel .stat-coins strong,
  .score-panel .stat-score strong {
    font-size: clamp(1.05rem, 3.6vw, 1.24rem);
  }

  .upgrade span,
  .mod-list li {
    font-size: 0.68rem;
  }

  .upgrade strong {
    font-size: 0.98rem;
  }

  .upgrade-panel .eyebrow {
    margin-bottom: 4px;
  }

  .upgrade-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .button-row {
    grid-template-columns: 1fr 1fr;
  }

  .overlay {
    padding: 8px;
  }

  .overlay-panel {
    max-height: min(calc(100svh - 16px), calc(100% - 16px));
    padding: 14px;
  }

  .arcade-chain-coach {
    display: none;
  }

  .overlay-panel p:not(.eyebrow) {
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .mode-select {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .mode-card {
    min-height: 62px;
    padding: 8px 5px;
    text-align: center;
  }

  .mode-card span {
    font-size: 0.82rem;
  }

  .mode-card strong {
    font-size: 0.54rem;
    line-height: 1.15;
  }

  .scoreboard {
    margin: 12px 0;
    padding: 10px;
    gap: 7px;
  }

  .scoreboard[data-scoreboard-mode="gameover"] {
    border-color: color-mix(in srgb, var(--game-text-warm) 58%, var(--game-primary));
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--game-primary) 20%, transparent), rgba(0, 0, 0, 0.54)),
      color-mix(in srgb, var(--game-surface-dark) 92%, rgba(0, 0, 0, 0.9));
  }

  .scoreboard-entry-row {
    grid-template-columns: 1fr;
  }

  .score-invite-row {
    grid-template-columns: 1fr;
  }

  .arcade-auth-actions {
    grid-template-columns: 1fr;
  }

  .overlay-art {
    display: none;
  }

  .overlay-art p,
  .scoreboard-art p,
  .rules-art p {
    font-size: 0.68rem;
    line-height: 1.28;
  }

  .scoreboard-art {
    display: none;
  }

  .scoreboard-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .scoreboard-tab {
    min-height: 34px;
    font-size: 0.66rem;
  }

  .scoreboard-list {
    max-height: min(176px, 23svh);
  }

  .scoreboard[data-scoreboard-mode="gameover"] .scoreboard-tabs,
  .scoreboard[data-scoreboard-mode="gameover"] .scoreboard-list {
    display: none;
  }

  .scoreboard[data-scoreboard-mode="gameover"] .scoreboard-entry {
    gap: 9px;
  }

  .scoreboard[data-scoreboard-mode="gameover"] .scoreboard-entry p {
    min-height: 0;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .scoreboard .product-promo {
    display: none;
  }

  .scoreboard-list li {
    grid-template-columns: 28px minmax(0, 1fr) 34px minmax(82px, auto);
    gap: 5px;
    padding: 6px;
    font-size: 0.72rem;
  }

  .rules-modal {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .rules-header,
  .rules-grid article {
    padding: 14px;
  }

  .rules-art {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 12px;
    padding: 10px;
  }

  .rules-actions {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .rules-link-button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.68rem;
  }
}

@media (max-width: 380px) {
  .game-shell {
    gap: 8px;
  }

  h1 {
    min-height: 44px;
    padding: 7px 6px;
    font-size: 0.86rem;
  }

  .stat-grid,
  .score-panel,
  .upgrade-grid {
    gap: 6px;
  }

  .stat-small {
    width: 60px;
    min-height: 44px;
    padding: 6px 4px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 60px);
  }

  .stat span,
  .angle-readout span,
  .eyebrow {
    font-size: 0.68rem;
  }

  canvas {
    height: auto;
    width: 100%;
    min-height: 0;
    margin-inline: auto;
  }

  .panel-section {
    padding: 10px;
  }

  .upgrade {
    min-height: 54px;
    padding: 6px;
  }

  .mobile-action-panel {
    gap: 6px;
  }

  .mobile-action-button {
    min-height: 64px;
    padding-inline: 4px;
  }

  .mobile-action-button span {
    font-size: 0.64rem;
  }

  .mobile-action-button small {
    font-size: 0.54rem;
  }

  .score-panel .stat-display strong,
  .score-panel .stat-coins strong,
  .score-panel .stat-score strong {
    font-size: 1rem;
  }

  .upgrade strong {
    font-size: 0.9rem;
  }

  .scoreboard-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scoreboard-list li {
    grid-template-columns: 24px minmax(0, 1fr) 30px minmax(70px, auto);
    font-size: 0.66rem;
  }
}

@media (max-width: 940px) and (orientation: landscape) {
  .game-shell {
    grid-template-columns: minmax(420px, 1fr) minmax(260px, 330px);
    grid-template-areas:
      "title stats"
      "canvas score"
      "canvas upgrades"
      "canvas command"
      "canvas perks";
    width: min(1120px, 100%);
    min-height: 100vh;
    min-height: 100svh;
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  h1 {
    min-height: 54px;
    font-size: 2rem;
  }

  canvas {
    width: min(100%, 520px);
    height: auto;
    min-height: 0;
  }

  .score-panel {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 760px) and (max-height: 520px) and (orientation: landscape) {
  .game-shell {
    grid-template-columns: minmax(360px, 1fr) minmax(232px, 280px);
    grid-template-areas:
      "title stats"
      "canvas score"
      "canvas upgrades"
      "canvas command"
      "canvas perks";
    gap: 6px;
  }

  .topbar {
    margin-bottom: 8px;
  }

  h1 {
    min-height: 38px;
    padding: 5px 9px 6px;
    font-size: 1.55rem;
  }

  canvas {
    width: min(100%, 420px);
    height: auto;
    min-height: 0;
  }

  .stat-grid {
    gap: 6px;
    margin-bottom: 0;
  }

  .stat {
    min-height: 42px;
    padding: 6px;
  }

  .stat-display,
  .score-panel .stat-display {
    min-height: 54px;
  }

  .stat strong,
  .angle-readout strong {
    font-size: 1.12rem;
  }

  .score-panel .stat-display strong {
    min-height: 32px;
  }

  .panel-section {
    padding: 7px;
  }

  .panel-section.compact {
    min-height: 0;
  }

  .upgrade {
    min-height: 52px;
    padding: 6px;
  }

  button {
    min-height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .overlay,
  .rules-modal,
  .scoreboard-gear,
  .scoreboard-orbit {
    animation: none !important;
  }
}
