/* Game pages (bigboxchaser.com/games/...), generated by seed/build_game_pages.py.
   The app's look: PC-case colours, debossed Saira title, LCD panel, landing-page keys.
   Light/dark follow the device unless the visitor flips the sun/moon switch (data-theme). */
:root {
  --case: #E1DAC7;          /* PCCaseBeige */
  --case-edge: #C9C1AC;
  --recess: #CEA67D;        /* the app's Game Detail content area (contentBackgroundColor): case + 50% amber, Oklab */
  --groove: #75634C;
  --fg: #1A0800;            /* DarkBark */
  --fg-muted: rgba(26, 8, 0, 0.66);
  --accent: #D80082;        /* LightPrimary */
  --lcd-glass: #241408;
  --lcd-on: #FFA518;
  --lcd-off: rgba(106, 86, 71, 0.55);
  --deboss-hi: rgba(255, 255, 255, 0.7);
  --deboss-lo: rgba(60, 45, 25, 0.45);
  /* The app's debossed toolbar title (DebossedText.kt debossColors, Oklab): lettering, dark upper
     wall, lit lower wall. */
  --title-fill: #7D796E; --title-shadow: #272521; --title-highlight: #FCFBF9;
  --card: #F3EEE2;
  --cardboard: #B49A72;
  --font-display: "Saira", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Exo 2", "Segoe UI", system-ui, sans-serif;
  --font-lcd: "VT323", "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --case: #2F3234; --case-edge: #3B3F41; --recess: #323D37; --groove: #232628;
    --fg: #EFE0D0; --fg-muted: rgba(239, 224, 208, 0.7);
    --accent: #FF0099;
    --lcd-glass: #0E241C; --lcd-on: #3DFF6E; --lcd-off: rgba(91, 106, 98, 0.5);
    --deboss-hi: rgba(255, 255, 255, 0.12); --deboss-lo: rgba(0, 0, 0, 0.6);
    --title-fill: #717375; --title-shadow: #010101; --title-highlight: #9A9C9D;
    --card: #36393B; --cardboard: #8E7854;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --case: #2F3234; --case-edge: #3B3F41; --recess: #323D37; --groove: #232628;
  --fg: #EFE0D0; --fg-muted: rgba(239, 224, 208, 0.7);
  --accent: #FF0099;
  --lcd-glass: #0E241C; --lcd-on: #3DFF6E; --lcd-off: rgba(91, 106, 98, 0.5);
  --deboss-hi: rgba(255, 255, 255, 0.12); --deboss-lo: rgba(0, 0, 0, 0.6);
    --title-fill: #717375; --title-shadow: #010101; --title-highlight: #9A9C9D;
  --card: #36393B; --cardboard: #8E7854;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--case);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap { max-width: 1080px; margin-inline: auto; padding-inline: 16px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 14px; padding-block: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.app-icon {
  width: 40px; height: 40px; border-radius: 50%; display: block; flex: none;
  box-shadow: 0 1px 0 var(--deboss-hi), 0 -1px 0 var(--deboss-lo), 0 2px 6px rgba(0, 0, 0, 0.25);
}
.deboss {
  font-family: var(--font-display); font-weight: 700; font-stretch: 112.5%;
  font-size: 20px; letter-spacing: 0.03em; color: var(--title-fill);
  /* Light from the top-left, like the app: dark wall above-left, lit wall below-right. */
  text-shadow: -0.5px -1px 0 var(--title-shadow), 0.5px 1px 0 var(--title-highlight);
}
.toolbar nav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; flex-wrap: wrap; }
.toolbar nav a { color: var(--fg); text-decoration: none; opacity: 0.8; }
.toolbar nav a:hover { opacity: 1; text-decoration: underline; }
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 1px solid var(--case-edge); background: var(--case); color: var(--fg); cursor: pointer;
  box-shadow: inset 0 1px 0 var(--deboss-hi), 0 2px 0 var(--groove), 0 3px 6px rgba(0, 0, 0, 0.2);
}
.theme-btn:active { box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.35); }
.theme-btn svg { width: 20px; height: 20px; fill: currentColor; }
.theme-btn .sun { display: none; }
/* Phones: the full toolbar (brand name + link + switch) doesn't fit, so the brand shows only its
   icon, "Catalogue Preview" sits next to it on the left, and the theme switch stays on the right. */
@media (max-width: 520px) {
  .toolbar { flex-wrap: nowrap; }
  .brand .deboss { display: none; }
  .toolbar nav { margin-left: 0; }
  .theme-btn { margin-left: auto; }
}
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: none; }
}

/* Content area cut into the case, in the app's Game Detail content colour (--recess) */
.recess {
  background: var(--recess);
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 8px 14px -6px rgba(0, 0, 0, 0.35), inset 6px 0 10px -8px rgba(0, 0, 0, 0.3);
  padding-block: 20px 40px;
}
.crumbs { font-size: 13px; color: var(--fg-muted); margin: 0 0 18px; overflow-wrap: anywhere; }
.crumbs a { color: inherit; }

/* Hero: box on the left, title and facts on the right */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; }
@media (max-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr); gap: 20px; } }

.box-stage {
  perspective: 1400px; height: 460px; display: grid; place-items: center;
  position: relative; user-select: none;
}
.box-stage.is-3d { cursor: grab; touch-action: pan-y; }
.box-stage.is-3d:active { cursor: grabbing; }
@media (max-width: 760px) { .box-stage { height: 400px; } }
/* A fixed height, not max-height: 100%: the stage is a grid whose row sizes to its content, so a
   percentage didn't stop a tall front scan from spilling over the scans below. */
.hero-cover {
  display: block; width: auto; height: auto;
  max-width: 100%; max-height: 420px; object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}
@media (max-width: 760px) { .hero-cover { max-height: 360px; } }
.box-stage .hint { position: absolute; bottom: 0; left: 0; right: 0; margin: 0; text-align: center; font-size: 12px; color: var(--fg-muted); }

/* The 3D box: size set by game.js from the front and spine scans (--w, --h, --d) */
.box {
  --w: 252px; --h: 380px; --d: 58px;
  width: var(--w); height: var(--h); position: relative;
  transform-style: preserve-3d; transform: rotateX(-8deg) rotateY(-28deg);
}
.face { position: absolute; backface-visibility: hidden; background-size: 100% 100%; background-color: var(--cardboard); }
.face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.f-front  { width: var(--w); height: var(--h); transform: translateZ(calc(var(--d) / 2)); }
.f-front::after { background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.12)); }
.f-back   { width: var(--w); height: var(--h); transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); }
.f-back::after { background: rgba(0, 0, 0, 0.12); }
.f-right  { width: var(--d); height: var(--h); left: calc((var(--w) - var(--d)) / 2); transform: rotateY(90deg) translateZ(calc(var(--w) / 2)); }
.f-right::after { background: rgba(0, 0, 0, 0.32); }
.f-left   { width: var(--d); height: var(--h); left: calc((var(--w) - var(--d)) / 2); transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); }
.f-left::after { background: rgba(255, 255, 255, 0.05); }
.f-top    { width: var(--w); height: var(--d); top: calc((var(--h) - var(--d)) / 2); transform: rotateX(90deg) translateZ(calc(var(--h) / 2)); }
.f-top::after { background: linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.05)); }
.f-bottom { width: var(--w); height: var(--d); top: calc((var(--h) - var(--d)) / 2); transform: rotateX(-90deg) translateZ(calc(var(--h) / 2)); }
.f-bottom::after { background: rgba(0, 0, 0, 0.35); }

/* LCD title */
.lcd {
  background: var(--lcd-glass); border-radius: 10px; padding: 14px 18px 10px;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.55), 0 1px 0 var(--deboss-hi), 0 -1px 0 var(--deboss-lo);
  position: relative; overflow: hidden;
}
.lcd::before {
  content: ""; position: absolute; inset: 0; opacity: 0.35;
  background-image: radial-gradient(circle, var(--lcd-off) 0.9px, transparent 1.3px); background-size: 5px 5px;
}
.lcd h1 {
  margin: 0; position: relative;
  font-family: var(--font-lcd); font-weight: 400; font-size: clamp(36px, 7vw, 64px);
  line-height: 0.95; letter-spacing: 0.06em; color: var(--lcd-on); overflow-wrap: anywhere;
  text-shadow: 0 0 12px color-mix(in srgb, var(--lcd-on) 55%, transparent);
  -webkit-mask-image: radial-gradient(circle, #000 58%, transparent 62%); -webkit-mask-size: 5px 5px;
  mask-image: radial-gradient(circle, #000 58%, transparent 62%); mask-size: 5px 5px;
  text-wrap: balance;
}
.lcd .sub { position: relative; margin: 6px 0 0; font-family: var(--font-lcd); font-size: 22px; letter-spacing: 0.06em; color: var(--lcd-on); opacity: 0.8; }

.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; margin: 20px 0 0; font-size: 14.5px; }
.facts dt { color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11.5px; padding-top: 3px; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Keys: the landing page's own .key / .key-primary */
.actions-heading { margin: 28px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  text-align: center; text-decoration: none; font-family: var(--font-body); font-weight: 600; font-size: 15px;
  border-radius: 0.5rem; padding: 0.85rem 1.25rem; color: #1A0800; background-color: #ECE6D8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.05s ease;
}
.key:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 3px 6px rgba(0, 0, 0, 0.3); }
.key:active { box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5); }
.key-primary {
  color: #FFFFFF; background-color: #D80082;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.key-icon { width: 22px; height: 22px; flex: none; fill: currentColor; }
img.key-icon { border-radius: 50%; }
.note { font-size: 13px; color: var(--fg-muted); margin: 12px 0 0; max-width: 52ch; }

/* Sections */
section { margin-top: 48px; }
h2 {
  font-family: var(--font-display); font-weight: 700; font-stretch: 112.5%;
  font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; margin: 0 0 16px;
}
.scans { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.scan { margin: 0; }
.scan button { display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 4px; }
.scan img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)); }
.scan figcaption { font-size: 13px; margin-top: 8px; line-height: 1.35; }
.scan figcaption span { display: block; color: var(--fg-muted); font-size: 12px; }

.releases { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 0; list-style: none; }
.releases a {
  display: block; padding: 8px 14px; border-radius: 8px; background: var(--card); color: var(--fg);
  text-decoration: none; font-size: 14px; border: 1px solid var(--case-edge);
}
.releases a:hover { border-color: var(--accent); }
.releases span { color: var(--fg-muted); }

footer { padding-block: 24px 40px; font-size: 13px; color: var(--fg-muted); }
footer p { margin: 0 0 6px; max-width: 70ch; }

dialog { border: 0; padding: 0; background: transparent; max-width: 92vw; max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, 0.8); }
.viewer-close { all: unset; cursor: zoom-out; display: block; }
dialog img { max-width: 92vw; max-height: 86vh; display: block; }
dialog span { display: block; color: #fff; text-align: center; margin-top: 8px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { .key { transition: none; } }

/* Listing pages: /games/, /games/<platform>/, /games/<platform>/<letter>/ */
.listing-lcd { max-width: 640px; }
.intro { max-width: 62ch; margin: 18px 0 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding: 0; margin: 0; list-style: none; }
.cards a {
  display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border-radius: 10px;
  background: var(--card); color: var(--fg); text-decoration: none; border: 1px solid var(--case-edge);
}
.cards a:hover { border-color: var(--accent); }
.cards a.card-more { background: transparent; border-style: dashed; border-color: var(--groove); }
.cards a.card-more:hover { border-color: var(--accent); }
.card-title { font-family: var(--font-display); font-weight: 700; font-stretch: 112.5%; font-size: 18px; }
.cards span:not(.card-title) { color: var(--fg-muted); font-size: 14px; }
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; padding: 0; margin: 0; list-style: none; }
.letters a, .letters .empty {
  display: flex; flex-direction: column; align-items: center; padding: 10px 6px; border-radius: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 20px; text-decoration: none;
}
.letters a { background: var(--card); color: var(--fg); border: 1px solid var(--case-edge); }
.letters a:hover { border-color: var(--accent); }
.letters a span { font-family: var(--font-body); font-weight: 400; font-size: 12px; color: var(--fg-muted); }
.letters .empty { color: var(--fg-muted); opacity: 0.45; }
.letter-nav { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 18px 0 20px; font-family: var(--font-display); font-weight: 700; }
.letter-nav a { color: var(--fg); }
.letter-nav strong { color: var(--accent); }
.game-list { columns: 2 320px; column-gap: 32px; padding: 0; margin: 0; list-style: none; }
.game-list li { break-inside: avoid; padding: 5px 0; border-bottom: 1px solid var(--case-edge); }
.game-list a { color: var(--fg); font-weight: 600; text-decoration: none; }
.game-list a:hover { color: var(--accent); text-decoration: underline; }
.game-list span { color: var(--fg-muted); font-size: 13px; }
