/* =====================================================================
   Limestone Arcade — Game Chrome (Cabinet Hall)
   Drop-in CSS for any game page in /arcade/<game>/
   Wraps the canvas in a CRT bezel inside a wood-paneled hall, with a
   shared top bar (back · title · score · hi-score · pause/restart/mute)
   and an INSERT COIN status strip at the bottom.

   Markup contract (HTML):
   <div class="ch-stage">
     <header class="ch-topbar">
       <a class="ch-back" href="..">← Arcade</a>
       <div class="ch-title">
         <div class="ch-eyebrow"><span class="ch-dot"></span>Cabinet · Pong</div>
         <h1>Pong</h1>
       </div>
       <div class="ch-scores">
         <div class="ch-score"><span class="ch-l">Score</span><b id="ch-score">0</b></div>
         <div class="ch-score"><span class="ch-l">Hi</span><b id="ch-hi">21</b></div>
       </div>
       <div class="ch-controls">
         <button class="ch-btn" data-act="pause">Pause</button>
         <button class="ch-btn" data-act="restart">Restart</button>
         <button class="ch-btn ch-btn-icon" data-act="mute" aria-label="Mute">♪</button>
       </div>
     </header>

     <div class="ch-bezel">
       <span class="ch-coin">INSERT COIN</span>
       <canvas id="game" width="800" height="600"></canvas>
     </div>

     <footer class="ch-hint">
       <span><kbd>↑</kbd><kbd>↓</kbd> move paddle</span>
       <span><kbd>Space</kbd> pause</span>
       <span><kbd>R</kbd> restart</span>
     </footer>
   </div>
   ===================================================================== */

:root {
  --ch-bg:        #120A05;
  --ch-panel:     #1B0F07;
  --ch-panel2:    #241509;
  --ch-bezel:     #08040A;
  --ch-brass:     #D89C56;
  --ch-brass-dim: #8E6534;
  --ch-ember:     #FF5A2C;
  --ch-amber:     #FFC34D;
  --ch-ink:       #F4E6D2;
  --ch-ink2:      #C7B196;
  --ch-ink3:      #8E7A60;
  --ch-line:      rgba(216, 156, 86, 0.18);
  --ch-line-soft: rgba(216, 156, 86, 0.08);
  --ch-display:   'Bricolage Grotesque', system-ui, sans-serif;
  --ch-mono:      'JetBrains Mono', ui-monospace, monospace;
  --ch-font:      'Inter', system-ui, -apple-system, sans-serif;
}

body.ch-game {
  margin: 0; min-height: 100vh;
  font-family: var(--ch-font); color: var(--ch-ink);
  background:
    radial-gradient(900px 600px at 50% -20%, rgba(255,90,44,0.18), transparent 70%),
    linear-gradient(180deg, var(--ch-panel) 0%, var(--ch-bg) 100%);
}
body.ch-game::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(0deg,  rgba(255,217,61,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,217,61,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse at 50% 30%, #000 30%, transparent 80%);
}

/* Hide each game's pre-existing in-page chrome — chrome JS owns these now.
   The original markup stays in the DOM as the source of truth that the
   chrome's MutationObserver mirrors into the topbar. */
body.ch-game .container > h1,
body.ch-game .container > h2,
body.ch-game .container > .game-info,
body.ch-game .container > .controls,
body.ch-game .container > p { display: none; }
body.ch-game .container { background: transparent !important; box-shadow: none !important; padding: 0 !important; max-width: none !important; }

.ch-stage {
  max-width: 1180px; margin: 24px auto; padding: 0 24px;
  display: flex; flex-direction: column; gap: 14px;
}

/* ---------- Top bar ---------- */
.ch-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 24px; align-items: center;
  padding: 14px 18px;
  background: rgba(8,4,2,0.55);
  backdrop-filter: blur(6px);
  border: 1px solid var(--ch-line);
  border-radius: 18px;
}

.ch-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 999px;
  background: transparent; border: 1px solid var(--ch-line);
  color: var(--ch-ink2); text-decoration: none;
  font-size: 12.5px; font-weight: 500;
  font-family: var(--ch-font);
  transition: color .15s, border-color .15s, background .15s;
}
.ch-back:hover { color: var(--ch-amber); border-color: var(--ch-amber); }

.ch-title h1 {
  font-family: var(--ch-display); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; margin: 2px 0 0;
}
.ch-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--ch-mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ch-amber);
}
.ch-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ch-ember); box-shadow: 0 0 8px var(--ch-ember);
  animation: ch-pulse 1.6s ease-in-out infinite;
}
@keyframes ch-pulse {
  50% { opacity: 0.4; box-shadow: 0 0 4px var(--ch-ember); }
}

.ch-scores { display: flex; gap: 28px; align-items: center; padding-right: 6px; }
.ch-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.ch-score .ch-l {
  font-family: var(--ch-mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--ch-ink3); text-transform: uppercase; margin-bottom: 6px;
}
.ch-score b {
  font-family: var(--ch-mono); font-size: 22px; font-weight: 600;
  color: var(--ch-amber); font-variant-numeric: tabular-nums;
}
.ch-score:first-child b { color: var(--ch-ink); }

.ch-controls { display: flex; gap: 6px; }
.ch-btn {
  appearance: none; -webkit-appearance: none;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--ch-line);
  background: rgba(0,0,0,0.25); color: var(--ch-ink2);
  font-family: var(--ch-font); font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
}
.ch-btn:hover { color: var(--ch-ink); border-color: var(--ch-amber); }
.ch-btn:active { transform: translateY(1px); }
.ch-btn-icon { width: 34px; padding: 8px 0; text-align: center; }
.ch-btn[data-active="true"] {
  background: var(--ch-amber); color: var(--ch-bg); border-color: var(--ch-amber);
}

/* ---------- Bezel + canvas ---------- */
.ch-bezel {
  position: relative;
  background:
    linear-gradient(135deg, #2A1A0E 0%, #1A0E08 100%);
  padding: 28px;
  border-radius: 20px;
  box-shadow:
    0 0 0 1px var(--ch-brass-dim),
    inset 0 0 0 6px var(--ch-bezel),
    inset 0 0 60px rgba(0,0,0,0.6),
    0 30px 60px -30px rgba(0,0,0,0.7);
  overflow: hidden;
}
.ch-bezel::after {
  /* glass highlight */
  content: ''; position: absolute; inset: 6px; border-radius: 14px;
  pointer-events: none; z-index: 4;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 30%);
}
.ch-bezel canvas, .ch-bezel > .ch-screen {
  display: block; width: 100%; height: auto;
  max-height: 70vh;
  background: #050304;
  border-radius: 8px;
  position: relative; z-index: 1;
  image-rendering: pixelated;
}

/* Phaser containers must fill the bezel cleanly. Phaser injects its
   canvas into one of these wrappers asynchronously; we hand the wrapper
   to the bezel so Phaser.Scale.FIT computes against a sized parent. */
.ch-bezel #phaser-container,
.ch-bezel #game-container {
  width: 100%;
  max-height: 70vh;
  aspect-ratio: 4 / 3;
  position: relative; z-index: 1;
}
.ch-bezel #phaser-container canvas,
.ch-bezel #game-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  image-rendering: pixelated;
}

.ch-coin {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 5;
  font-family: var(--ch-mono); font-size: 11px; letter-spacing: 0.32em;
  color: var(--ch-amber); font-weight: 600;
  text-shadow: 0 0 10px var(--ch-amber), 0 0 2px #fff;
  animation: ch-blink 1.4s steps(2, end) infinite;
}
.ch-bezel.ch-started .ch-coin { display: none; }
@keyframes ch-blink { 50% { opacity: 0.35; } }

/* ---------- Hint footer ---------- */
.ch-hint {
  display: flex; gap: 22px; flex-wrap: wrap; justify-content: center;
  padding: 10px 18px;
  font-family: var(--ch-mono); font-size: 11px;
  color: var(--ch-ink3); letter-spacing: 0.06em;
}
.ch-hint kbd {
  display: inline-block;
  padding: 2px 7px;
  margin-right: 6px;
  font-family: var(--ch-mono); font-size: 10.5px;
  background: rgba(216,156,86,0.08);
  border: 1px solid var(--ch-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ch-ink2);
}

/* ---------- Pause overlay (use .ch-paused on .ch-bezel) ---------- */
.ch-paused canvas { filter: brightness(0.4) saturate(0.6); }
.ch-paused::after {
  content: 'PAUSED';
  position: absolute; inset: 6px; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ch-display); font-size: 64px; font-weight: 700;
  letter-spacing: 0.2em; color: var(--ch-amber);
  text-shadow: 0 0 24px var(--ch-amber), 0 0 4px #fff;
  background: rgba(8,4,2,0.5);
  border-radius: 14px;
  pointer-events: none;
}

/* ---------- Real Start overlay (gameAPI.start games) ---------- */
.ch-start {
  position: absolute; inset: 6px; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; border: none; border-radius: 14px; cursor: pointer;
  background: radial-gradient(ellipse at 50% 38%, rgba(8,4,2,0.5), rgba(8,4,2,0.84));
  -webkit-tap-highlight-color: transparent;
}
.ch-start .ch-start-btn {
  font-family: var(--ch-display); font-size: 30px; font-weight: 700; letter-spacing: 0.03em;
  padding: 14px 32px; border-radius: 999px;
  background: var(--ch-ember); color: #fff;
  box-shadow: 0 12px 30px -8px rgba(255,90,44,0.7), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform .12s;
}
.ch-start .ch-start-sub {
  font-family: var(--ch-mono); font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ch-ink2);
}
.ch-start:hover .ch-start-btn { transform: translateY(-2px); }

/* ---------- On-screen touch controls ---------- */
.ch-touch { display: none; }
.ch-touch-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.ch-touch-btn {
  -webkit-appearance: none; appearance: none;
  min-width: 62px; height: 62px; padding: 0 16px;
  border-radius: 16px; border: 1px solid var(--ch-line);
  background: rgba(36,21,9,0.94); color: var(--ch-ink);
  font-family: var(--ch-display); font-size: 22px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.06), 0 6px 14px -6px rgba(0,0,0,0.6);
}
.ch-touch-btn.ch-touch-active { background: var(--ch-ember); color: #fff; border-color: var(--ch-ember); }
/* Show the pad on touch devices and narrow screens. */
@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .ch-touch { display: flex; justify-content: space-between; gap: 14px; padding: 2px 2px 4px; }
}

/* ---------- SEO content panel (below the cabinet) ----------
   For arcade games that ship a How-to-play / Tips / FAQ block. The
   .ch-stage CSS hides .container > h1, .game-info etc., but a
   <section class="game-overview"> stays visible and uses these rules. */
body.ch-game .game-overview {
  width: 100%; max-width: 760px;
  margin: 32px auto 16px; padding: 28px 32px;
  background: rgba(8,4,2,0.55);
  border: 1px solid var(--ch-line);
  border-radius: 18px;
  color: var(--ch-ink2); line-height: 1.65;
  text-align: left;
}
body.ch-game .game-overview h2 {
  font-family: var(--ch-display); font-size: 22px; font-weight: 700;
  color: var(--ch-ink); margin: 0 0 12px; letter-spacing: -0.01em;
}
body.ch-game .game-overview h3 {
  font-family: var(--ch-display); font-size: 15px; font-weight: 700;
  color: var(--ch-amber); margin: 20px 0 8px; letter-spacing: 0.02em;
}
body.ch-game .game-overview p { margin: 0 0 12px; font-size: 14.5px; }
body.ch-game .game-overview ul { margin: 0 0 12px; padding-left: 22px; }
body.ch-game .game-overview ul li { margin-bottom: 6px; font-size: 14.5px; }
body.ch-game .game-overview b, body.ch-game .game-overview strong { color: var(--ch-ink); }
body.ch-game .game-overview i { color: var(--ch-ink); }
body.ch-game .game-overview kbd {
  display: inline-block; padding: 1px 7px;
  background: rgba(216,156,86,0.08);
  border: 1px solid var(--ch-line); border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--ch-mono); font-size: 12px;
  color: var(--ch-ink2); margin: 0 1px;
}
body.ch-game .game-overview .related-games-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  list-style: none; padding-left: 0; margin-top: 0;
}
body.ch-game .game-overview .related-games-list li { margin-bottom: 0; }
body.ch-game .game-overview .related-games-list a {
  display: inline-block;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(216,156,86,0.08);
  color: var(--ch-amber);
  text-decoration: none; font-weight: 600; font-size: 13px;
  border: 1px solid var(--ch-line);
  transition: background .15s, color .15s, border-color .15s;
}
body.ch-game .game-overview .related-games-list a:hover {
  background: var(--ch-amber); color: var(--ch-bg); border-color: var(--ch-amber);
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .ch-topbar {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "back  title"
      "scores controls";
    gap: 12px 16px;
  }
  .ch-back     { grid-area: back; }
  .ch-title    { grid-area: title; }
  .ch-scores   { grid-area: scores; gap: 18px; }
  .ch-controls { grid-area: controls; justify-self: end; }
  .ch-title h1 { font-size: 18px; }
  .ch-bezel { padding: 16px; }
  .ch-coin { top: 6px; font-size: 9.5px; letter-spacing: 0.28em; }
}
