/* ============================================================================
   CRIT HIT — UI KIT
   ----------------------------------------------------------------------------
   Components built on tokens.css. Every interactive component defines
   default / hover / active / focus-visible / disabled, and a loading state
   where it can be pending.

   Naming: .ch-<block>__<element> --<modifier>
   Living reference: /Crit-Hit/ui/index.html
   ========================================================================= */

/* ==========================================================================
   1. LAYOUT PRIMITIVES
   ========================================================================== */

.ch-wide  { width: 100%; max-width: var(--w-wide); margin-inline: auto; padding-inline: var(--gutter); }
.ch-wide--cabinet { max-width: var(--w-cabinet); }
.ch-text  { width: 100%; max-width: var(--w-text); }
.ch-bleed { width: 100%; }

.ch-section       { padding-block: var(--section-y); }
.ch-section--tight{ padding-block: var(--section-y-tight); }
.ch-section--alt  { background: var(--bg-alt); }

/* 12-column grid. Cards span 4 / 6 / 12 across the three breakpoints. */
.ch-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--grid-gap); }

.ch-stack   { display: flex; flex-direction: column; }
.ch-stack > * + * { margin-top: var(--gap, var(--s-4)); }
.ch-row     { display: flex; align-items: center; gap: var(--gap, var(--s-3)); }
.ch-row--wrap { flex-wrap: wrap; }
.ch-spacer  { flex: 1 1 auto; }

.ch-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* ==========================================================================
   2. TYPOGRAPHY
   --------------------------------------------------------------------------
   The identity is: tiny pixel eyebrow + large tight sans headline.
   .ch-eyebrow is the ONLY place Press Start 2P appears in running layout,
   alongside .ch-readout for numerics and .ch-marquee for the cabinet.
   ========================================================================== */

.ch-eyebrow {
  font-family: var(--font-pixel);
  font-size: var(--fs-pixel-sm);
  line-height: var(--lh-pixel);
  letter-spacing: var(--tr-eyebrow);
  text-transform: uppercase;
  color: var(--meta);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}
/* The rule bar that makes an eyebrow read as a section marker, not a label. */
.ch-eyebrow::before {
  content: "";
  width: 22px; height: 2px;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  flex: none;
}
.ch-eyebrow--amber   { color: var(--amber); }
.ch-eyebrow--cobalt  { color: var(--cobalt-core); }
.ch-eyebrow--magenta { color: var(--magenta); }
.ch-eyebrow--bare::before { display: none; }

.ch-display {
  font-size: var(--fs-display); font-weight: 700;
  line-height: var(--lh-display); letter-spacing: var(--tr-display);
  color: var(--fg);
}
.ch-h1 { font-size: var(--fs-h1); font-weight: 700; line-height: var(--lh-head); letter-spacing: var(--tr-head); color: var(--fg); }
.ch-h2 { font-size: var(--fs-h2); font-weight: 700; line-height: var(--lh-head); letter-spacing: var(--tr-head); color: var(--fg); }
.ch-h3 { font-size: var(--fs-h3); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; color: var(--fg); }

.ch-lead  { font-size: var(--fs-lg); color: var(--fg-muted); max-width: var(--measure); }
.ch-body  { color: var(--fg-body); max-width: var(--measure); }
.ch-small { font-size: var(--fs-sm); color: var(--fg-muted); }
.ch-dim   { color: var(--fg-dim); }

/* Numeric readout — score, coins, timer. Uppercase pixel, tabular feel. */
.ch-readout {
  font-family: var(--font-pixel);
  font-size: var(--fs-pixel-md);
  letter-spacing: var(--tr-pixel);
  line-height: 1;
  color: var(--amber-core);
  text-shadow: 0 0 12px var(--amber-bloom);
}

/* Section header block: eyebrow + heading + optional lead, consistently spaced. */
.ch-sectionhead { display: flex; flex-direction: column; gap: var(--s-3); margin-bottom: var(--s-7); }
.ch-sectionhead .ch-lead { margin-top: var(--s-1); }

/* ==========================================================================
   3. NEON UTILITIES
   --------------------------------------------------------------------------
   Composed from the three-value channels. --neon defaults to amber; set it
   on a parent (or per-game) to retint the whole treatment.
   ========================================================================== */

.ch-neon-text {
  color: var(--neon-core, var(--amber-core));
  text-shadow:
    0 0 6px  var(--neon-bloom, var(--amber-bloom)),
    0 0 22px var(--neon-bloom, var(--amber-bloom));
}
.ch-neon-rule {
  height: 1px; border: 0;
  background: linear-gradient(90deg, transparent, var(--neon, var(--amber)), transparent);
  box-shadow: 0 0 12px var(--neon-bloom, var(--amber-bloom));
  opacity: .7;
}
/* A soft light pool. Use behind a lockup so the sign appears to light the
   surface it sits on, rather than being pasted onto it. */
.ch-glow {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 55% at 50% 42%, var(--amber-veil), transparent 70%),
    radial-gradient(75% 65% at 50% 58%, var(--cobalt-veil), transparent 72%);
  filter: blur(2px);
}

/* The one-shot neon strike-on. Used exactly once per page load, on the hero
   wordmark. Repeated flicker is what makes neon sites look cheap. */
@keyframes ch-strike {
  0%   { opacity: 0;   filter: brightness(.35) saturate(.5); }
  18%  { opacity: 1;   filter: brightness(1.6) saturate(1.2); }
  24%  { opacity: .25; filter: brightness(.4)  saturate(.6); }
  36%  { opacity: 1;   filter: brightness(1.35); }
  44%  { opacity: .55; filter: brightness(.7); }
  100% { opacity: 1;   filter: brightness(1); }
}
.ch-strike { animation: ch-strike 700ms var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .ch-strike { animation: none; } }

/* ==========================================================================
   4. BUTTON
   ========================================================================== */

.ch-btn {
  --btn-h: 42px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--btn-h);
  padding: 0 var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-md); font-weight: 700; letter-spacing: -0.01em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  background: transparent; color: var(--fg);
  transition:
    background var(--t-instant) var(--ease),
    border-color var(--t-instant) var(--ease),
    box-shadow var(--t-instant) var(--ease),
    transform var(--t-instant) var(--ease),
    color var(--t-instant) var(--ease);
}
.ch-btn:active { transform: translateY(1px); }

.ch-btn--sm { --btn-h: 34px; padding: 0 var(--s-4); font-size: var(--fs-sm); }
.ch-btn--lg { --btn-h: 52px; padding: 0 var(--s-6); font-size: var(--fs-lg); }
.ch-btn--block { display: flex; width: 100%; }

/* Primary is amber and amber only: if it is amber, it is the action. */
.ch-btn--primary {
  background: linear-gradient(180deg, var(--amber-core), var(--amber));
  color: var(--action-ink);
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 0 var(--amber-bloom), var(--shadow-1);
}
.ch-btn--primary:hover {
  background: linear-gradient(180deg, #fff0cf, var(--amber-core));
  box-shadow: 0 0 24px var(--amber-bloom), var(--shadow-1);
}

/* Secondary is cobalt-outlined: structure, never the primary action. */
.ch-btn--secondary {
  border-color: var(--cobalt-deep);
  color: var(--cobalt-core);
  background: var(--cobalt-veil);
}
.ch-btn--secondary:hover {
  border-color: var(--cobalt);
  background: rgba(67, 97, 255, 0.2);
  box-shadow: 0 0 20px var(--cobalt-bloom);
}

.ch-btn--ghost { border-color: var(--line); color: var(--fg-muted); }
.ch-btn--ghost:hover { border-color: var(--line-strong); color: var(--fg); background: var(--surface-hover); }

.ch-btn--danger { border-color: var(--danger); color: var(--danger); background: var(--danger-veil); }
.ch-btn--danger:hover { background: rgba(244, 63, 94, 0.22); color: #ffe3e8; }

.ch-btn--icon { padding: 0; width: var(--btn-h); }

.ch-btn:disabled,
.ch-btn[aria-disabled="true"] {
  cursor: not-allowed; opacity: 1;
  background: var(--surface-sunk); color: var(--fg-disabled);
  border-color: var(--line); box-shadow: none; transform: none;
}

/* Loading: the label stays in flow so the button does not resize, and the
   spinner replaces it visually. aria-busy carries the meaning. */
.ch-btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.ch-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: ch-spin 700ms linear infinite;
  color: var(--action-ink);
}
.ch-btn--secondary[aria-busy="true"]::after,
.ch-btn--ghost[aria-busy="true"]::after { color: var(--fg-muted); }
@keyframes ch-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   5. CHIP / BADGE
   ========================================================================== */

.ch-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
  color: var(--fg-muted);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.ch-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex: none; }

.ch-chip--accent  { color: var(--accent, var(--amber)); border-color: color-mix(in srgb, var(--accent, var(--amber)) 45%, transparent); background: color-mix(in srgb, var(--accent, var(--amber)) 12%, transparent); }
.ch-chip--live    { color: var(--magenta); border-color: var(--magenta-deep); background: var(--magenta-veil); }
.ch-chip--meta    { color: var(--cyan); border-color: var(--cyan-deep); background: var(--cyan-veil); }
.ch-chip--ok      { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-veil); }
.ch-chip--archived{ color: var(--fg-dim); }

/* Live pulse — the one continuously animating element allowed on the page,
   and only while something genuinely is live. */
@keyframes ch-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.ch-chip--live .ch-chip__dot { animation: ch-pulse 1.6s ease-in-out infinite; }

.ch-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--amber); color: var(--action-ink);
  font-size: 11px; font-weight: 700;
}

/* ==========================================================================
   6. PANEL / CARD
   ========================================================================== */

.ch-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1), var(--rim);
}
.ch-panel__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.ch-panel__body { padding: var(--s-5); }
.ch-panel--sunk { background: var(--surface-sunk); box-shadow: none; }

.ch-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--t-quick) var(--ease),
              box-shadow var(--t-quick) var(--ease),
              transform var(--t-quick) var(--ease);
}

/* ---- game card: the shelf's whole job is to show the actual games ------- */

.ch-gamecard { --accent: var(--amber); }
.ch-gamecard__link { position: absolute; inset: 0; z-index: 3; border-radius: inherit; }
.ch-gamecard__link:focus-visible { box-shadow: var(--focus-ring); }

.ch-gamecard__cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-sunk);
  overflow: hidden;
}
/* Two stacked layers: illustrated key art at rest, the real captured frame on
   hover. The art sells the game, the capture keeps the claim honest. */
.ch-gamecard__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.001);           /* avoid subpixel edge seams */
  transition: transform 6s linear, opacity var(--t-slow) var(--ease);
}
.ch-gamecard__img.is-shot { opacity: 0; }
.ch-gamecard:hover .ch-gamecard__img.is-art,
.ch-gamecard:focus-within .ch-gamecard__img.is-art { opacity: 0; }
.ch-gamecard:hover .ch-gamecard__img.is-shot,
.ch-gamecard:focus-within .ch-gamecard__img.is-shot { opacity: 1; }
/* A quiet marker so the swap reads as intentional rather than a loading glitch.
   Only on cards that actually have a capture to reveal. */
.ch-gamecard__cover.has-shot::before {
  content: "ACTUAL GAMEPLAY";
  position: absolute; top: var(--s-3); right: var(--s-3); z-index: 3;
  padding: 3px 7px; border-radius: var(--r-xs);
  background: rgba(6,5,12,.72); border: 1px solid var(--void-600);
  font-family: var(--font-pixel); font-size: 8px; letter-spacing: .08em;
  color: var(--cyan); opacity: 0; transition: opacity var(--t-quick) var(--ease);
  pointer-events: none;
}
.ch-gamecard:hover .ch-gamecard__cover.has-shot::before,
.ch-gamecard:focus-within .ch-gamecard__cover.has-shot::before { opacity: 1; }
/* Scrim so the overlaid chips stay legible over any frame. */
.ch-gamecard__cover::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 45%, rgba(16,12,28,.92) 100%);
}
.ch-gamecard__overlay {
  position: absolute; left: var(--s-4); right: var(--s-4); bottom: var(--s-3);
  z-index: 2; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
}
/* The pixel icon, demoted from hero to garnish. */
.ch-gamecard__icon {
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-xs);
  background: var(--void-1000);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  image-rendering: pixelated;
}
.ch-gamecard__body { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4) var(--s-5) var(--s-5); flex: 1; }
.ch-gamecard__title { font-size: var(--fs-h3); font-weight: 700; letter-spacing: -0.01em; color: var(--fg); }
.ch-gamecard__hook {
  font-size: var(--fs-sm); color: var(--fg-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ch-gamecard__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--fg-dim);
}
.ch-gamecard__play { color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }

.ch-gamecard:hover,
.ch-gamecard:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
              0 18px 44px rgba(0,0,0,.55),
              0 0 40px color-mix(in srgb, var(--accent) 18%, transparent);
  transform: translateY(-2px);
}
.ch-gamecard:hover .ch-gamecard__img,
.ch-gamecard:focus-within .ch-gamecard__img { transform: scale(1.04); }

/* Selected = the cartridge currently in the slot. Amber corner brackets. */
.ch-gamecard[aria-current="true"] { border-color: var(--amber); }
.ch-gamecard[aria-current="true"]::before,
.ch-gamecard[aria-current="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; z-index: 4;
  border: 2px solid var(--amber); pointer-events: none;
}
.ch-gamecard[aria-current="true"]::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.ch-gamecard[aria-current="true"]::after  { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .ch-gamecard:hover, .ch-gamecard:focus-within { transform: none; }
  .ch-gamecard__img { transition: none; }
  .ch-gamecard:hover .ch-gamecard__img { transform: scale(1.001); }
}

/* ==========================================================================
   7. SEGMENTED CONTROL  (roving tabindex — see ui.js)
   ========================================================================== */

.ch-segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
.ch-segmented__item {
  appearance: none; border: 0; cursor: pointer;
  padding: 7px var(--s-4);
  border-radius: var(--r-pill);
  background: transparent; color: var(--fg-muted);
  font-size: var(--fs-sm); font-weight: 700; white-space: nowrap;
  transition: background var(--t-instant) var(--ease), color var(--t-instant) var(--ease);
}
.ch-segmented__item:hover { color: var(--fg); background: var(--surface-hover); }
.ch-segmented__item[aria-selected="true"] {
  background: var(--cobalt-veil);
  color: var(--cobalt-core);
  box-shadow: inset 0 0 0 1px var(--cobalt-deep);
}

/* ==========================================================================
   8. KEYCAP
   ========================================================================== */

.ch-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--s-2); list-style: none; padding: 0; }

.ch-keycap {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 38px; padding: var(--s-2) var(--s-3);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--fg-muted); font-size: var(--fs-xs); text-align: left;
  cursor: default;
  transition: border-color var(--t-instant) var(--ease), background var(--t-instant) var(--ease);
}
.ch-keycap kbd {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; padding: 4px 7px;
  font-family: var(--font-pixel); font-size: 10px; letter-spacing: .04em;
  color: var(--fg); background: var(--void-700);
  border: 1px solid var(--line-strong);
  border-bottom-width: 3px;             /* the physical key face */
  border-radius: var(--r-xs);
}
/* Pressable only while a game is running. */
.ch-keycap:not(:disabled) { cursor: pointer; }
.ch-keycap:not(:disabled):hover { border-color: var(--cobalt-deep); background: var(--surface-hover); }
.ch-keycap:not(:disabled):active kbd { border-bottom-width: 1px; transform: translateY(2px); }
.ch-keycap:disabled { opacity: .55; }

/* ==========================================================================
   9. PROGRESS
   ========================================================================== */

.ch-progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-sunk); overflow: hidden; }
.ch-progress__bar {
  height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber-core));
  box-shadow: 0 0 12px var(--amber-bloom);
  transition: width var(--t-slow) var(--ease);
}
.ch-progress--indeterminate .ch-progress__bar { width: 35%; animation: ch-indet 1.3s var(--ease) infinite; }
@keyframes ch-indet { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

/* ==========================================================================
   10. SKELETON
   ========================================================================== */

.ch-skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-sunk); border-radius: var(--r-sm);
}
.ch-skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(199,208,255,.07), transparent);
  animation: ch-shimmer 1.4s linear infinite;
}
@keyframes ch-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.ch-skeleton--text { height: 12px; }
.ch-skeleton--cover { aspect-ratio: 16 / 10; border-radius: 0; }

/* ==========================================================================
   11. MODAL
   ========================================================================== */

.ch-modal { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: var(--gutter); }
.ch-modal__backdrop { position: absolute; inset: 0; background: rgba(6,5,12,.78); backdrop-filter: blur(8px); }
.ch-modal__panel {
  position: relative; z-index: 1;
  width: min(640px, 100%); max-height: min(80vh, 720px); overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--amber);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  animation: ch-modal-in var(--t-slow) var(--ease-out) both;
}
@keyframes ch-modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.ch-modal__head { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); }
.ch-modal__body { padding: var(--s-6); }
.ch-modal__foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); }

/* ==========================================================================
   12. TOAST
   ========================================================================== */

.ch-toasts { position: fixed; z-index: var(--z-toast); right: var(--gutter); bottom: var(--gutter); display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.ch-toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 260px; max-width: 380px;
  padding: var(--s-3) var(--s-4);
  background: var(--void-850);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--cobalt);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); color: var(--fg-body);
  animation: ch-toast-in var(--t-quick) var(--ease-out) both;
}
.ch-toast--error { border-left-color: var(--danger); }
.ch-toast--ok    { border-left-color: var(--ok); }
@keyframes ch-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   13. TOPBAR
   ========================================================================== */

.ch-topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--topbar-h);
  background: rgba(6,5,12,.72);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.ch-topbar__inner { display: flex; align-items: center; gap: var(--s-5); height: 100%; }
.ch-topbar__brand { display: inline-flex; align-items: center; gap: var(--s-3); text-decoration: none; }
.ch-topbar__mark { height: 30px; width: auto; }
.ch-topbar__word { font-family: var(--font-pixel); font-size: var(--fs-pixel-sm); letter-spacing: var(--tr-pixel); color: var(--fg); }
.ch-topbar__nav { display: flex; align-items: center; gap: var(--s-2); }
.ch-topbar__link {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  color: var(--fg-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 700;
  transition: color var(--t-instant) var(--ease), background var(--t-instant) var(--ease);
}
.ch-topbar__link:hover { color: var(--fg); background: var(--surface-hover); }
.ch-topbar__link[aria-current="page"] { color: var(--amber-core); }

/* ==========================================================================
   14. RAIL — horizontal scroller with snap and edge fades
   ========================================================================== */

.ch-rail { position: relative; }
.ch-rail__track {
  display: flex; gap: var(--s-4); overflow-x: auto; scroll-snap-type: x mandatory;
  padding-bottom: var(--s-2); scrollbar-width: thin;
}
.ch-rail__track > * { scroll-snap-align: start; flex: 0 0 clamp(240px, 30vw, 320px); }
.ch-rail::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 56px;
  background: linear-gradient(90deg, transparent, var(--bg)); pointer-events: none;
}

/* ==========================================================================
   15. TOOLTIP
   ========================================================================== */

.ch-tip { position: relative; }
.ch-tip__bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 0;
  padding: 6px var(--s-3); border-radius: var(--r-xs);
  background: var(--void-800); border: 1px solid var(--line-strong);
  color: var(--fg-body); font-size: var(--fs-xs); white-space: nowrap;
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-instant) var(--ease) 300ms, visibility 0s linear 300ms;
  box-shadow: var(--shadow-2); z-index: var(--z-overlay);
}
.ch-tip:hover .ch-tip__bubble,
.ch-tip:focus-within .ch-tip__bubble { opacity: 1; visibility: visible; transition-delay: 300ms, 0s; }

/* ==========================================================================
   16. CABINET — the arcade chrome
   ========================================================================== */

.ch-cabinet {
  background: linear-gradient(180deg, var(--cab-edge), var(--cab-body));
  border: 1px solid var(--void-700);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3), var(--rim);
  padding: var(--s-4);
}
.ch-marquee {
  display: flex; align-items: stretch; justify-content: center; gap: 0;
  padding: 0;
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, rgba(255,200,120,.10), transparent);
  border: 1px solid var(--void-700);
  box-shadow: inset 0 -14px 26px -18px var(--marquee-light);
  font-family: var(--font-pixel); font-size: var(--fs-pixel-lg);
  letter-spacing: var(--tr-pixel); color: var(--amber-core);
  text-shadow: 0 0 14px var(--amber-bloom);
  overflow: hidden;
}
/* Photographed end brackets clamping the lit header panel. They carry their own
   warm spill, so the panel's glow is tuned to meet it rather than fight it. */
.ch-marquee__cap {
  height: 54px; width: auto; flex: none;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6));
}
.ch-marquee__word {
  display: flex; align-items: center; justify-content: center;
  flex: 1; min-width: 0; padding: var(--s-3) var(--s-4);
  text-align: center;
}
@media (max-width: 700px) {
  .ch-marquee__cap { height: 40px; }
  .ch-marquee { font-size: var(--fs-pixel-sm); }
}

.ch-crt {
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 9;
  /* Width is capped by the height actually available, so the screen grows as
     large as it can without ever pushing the eject/fullscreen controls below
     the fold. svh keeps mobile browser chrome out of the sum. */
  width: min(100%, calc((100svh - var(--crt-chrome)) * 16 / 9));
  margin-inline: auto;
  background: radial-gradient(120% 100% at 50% 0%, var(--crt-bg-2), var(--crt-bg));
  border-radius: var(--r-sm);
  /* the 1px lit glass edge — this is what makes it read as a screen */
  box-shadow: inset 0 0 0 1px var(--crt-rim),
              inset 0 0 60px rgba(0,0,0,.9),
              0 0 40px rgba(67,97,255,.10);
}
.ch-crt__scan {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(180deg, var(--crt-scanline) 0 1px, transparent 1px 3px);
}
.ch-crt__glass {
  position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(120% 90% at 50% 0%, var(--crt-glass), transparent 60%),
              radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%);
}
.ch-crt__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 2; background: var(--crt-bg); }
.ch-crt__layer { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; }

.ch-bios {
  font-family: var(--font-pixel); font-size: var(--fs-pixel-sm); line-height: 2;
  letter-spacing: var(--tr-pixel); color: var(--amber); text-shadow: 0 0 10px var(--amber-bloom);
}

/* ==========================================================================
   17. GRID SPANS
   ========================================================================== */

.ch-col-3  { grid-column: span 3; }
.ch-col-4  { grid-column: span 4; }
.ch-col-6  { grid-column: span 6; }
.ch-col-8  { grid-column: span 8; }
.ch-col-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .ch-col-3, .ch-col-4 { grid-column: span 6; }
  .ch-col-8 { grid-column: span 12; }
}
@media (max-width: 700px) {
  .ch-col-3, .ch-col-4, .ch-col-6 { grid-column: span 12; }
  .ch-keys { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}
