/* ============================================================
   VECTARCADE /play/ — full-viewport arcade console.
   Locked to the viewport. No page scroll on desktop.
   Layout grid:
     [ top bar              ]
     [ rail | preview | det ]
     [ tile carousel        ]
     [ status / kbd hints   ]
   ============================================================ */

html, body { height: 100%; }
body.play-mode {
  overflow: hidden;
  margin: 0;
}

.play-app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 60px auto 1fr 124px 44px;
  grid-template-areas:
    "top"
    "marquee"
    "main"
    "carousel"
    "status";
  z-index: 5;
  background:
    radial-gradient(900px 380px at 50% 0%, rgba(0,255,238,0.06), transparent 60%),
    radial-gradient(700px 400px at 100% 100%, rgba(255,0,170,0.05), transparent 60%);
  font-family: var(--f-body);
  color: var(--text);
}

/* ---------------- Top bar ---------------- */
.app-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(5,0,16,0.92), rgba(5,0,16,0.66));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: relative;
  z-index: 8;
}
.app-top .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.app-top .wordmark { font-size: 20px; }
.app-top .right-tools {
  display: flex; align-items: center; gap: 18px;
  font-family: var(--f-pixel);
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.app-top .ready {
  color: var(--green);
  text-shadow: 0 0 8px rgba(0,255,102,0.55);
}
.app-top .ready::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  margin-right: 8px;
  vertical-align: 1px;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink {
  0%, 60%, 100% { opacity: 1; }
  70%, 85% { opacity: 0.35; }
}
.app-top .back-btn {
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
  text-decoration: none;
  padding: 7px 14px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  transition: color .12s, border-color .12s;
}
.app-top .back-btn:hover { color: var(--text); border-color: var(--cyan); }

/* ---------------- Main area ---------------- */
.app-main {
  grid-area: main;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 280px;
  grid-template-areas: "rail preview details";
  overflow: hidden;
  position: relative;
  z-index: 6;
}

/* Rail (left) */
.app-rail {
  grid-area: rail;
  border-right: 1px solid var(--line);
  background: rgba(10,5,24,0.45);
  padding: 22px 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.app-rail .rail-label {
  font-family: var(--f-pixel);
  font-size: 13px;
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 0 22px;
  margin-bottom: 14px;
}
.buckets { display: flex; flex-direction: column; }
.bucket {
  display: flex; align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 14px 22px;
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  transition: color .12s, background .12s;
}
.bucket .icon {
  display: inline-block; width: 18px; margin-right: 12px;
  text-align: center; font-size: 14px;
  color: var(--text-mute);
}
.bucket:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.bucket:hover .icon { color: var(--text-2); }
.bucket.active { color: var(--cyan); background: rgba(0,255,238,0.06); }
.bucket.active .icon { color: var(--cyan); }
.bucket.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(0,255,238,0.6);
}

/* Preview (centre) */
.app-preview {
  grid-area: preview;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.preview-frame {
  position: relative;
  width: 100%;
  max-width: 880px;
  aspect-ratio: 3 / 2;
  border: 1px solid rgba(0,255,238,0.28);
  background:
    radial-gradient(700px 240px at 50% 50%, rgba(0,255,238,0.10), transparent 60%),
    linear-gradient(160deg, var(--bg-2), var(--bg-1));
  overflow: hidden;
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.55),
    0 0 0 1px rgba(0,255,238,0.08),
    0 20px 60px rgba(0,0,0,0.5);
}
.preview-stage,
.preview-stage svg {
  width: 100%; height: 100%; display: block;
}

/* HUD corner brackets */
.hud-corner {
  position: absolute;
  width: 18px; height: 18px;
  pointer-events: none;
}
.hud-corner.tl { top: -1px;    left: -1px;  border-top: 2px solid var(--cyan); border-left:  2px solid var(--cyan); }
.hud-corner.tr { top: -1px;    right: -1px; border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.hud-corner.bl { bottom: -1px; left: -1px;  border-bottom: 2px solid var(--cyan); border-left:  2px solid var(--cyan); }
.hud-corner.br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }

/* CRT scanlines layered over the preview */
.scanlines {
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(0,0,0,0.16) 2px,
    rgba(0,0,0,0.16) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.7;
}

/* Top marquee bar — like a real arcade cabinet's lit overhead sign.
   Shows the currently selected game's name in HUGE Anton display, with a
   pixel-font tag (FLAGSHIP / VECTOR / etc.) as the eyebrow. */
.play-marquee {
  grid-area: marquee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 22px 18px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(900px 120px at 50% 50%, rgba(0,255,238,0.10), transparent 70%),
    linear-gradient(180deg, rgba(10,5,24,0.45) 0%, rgba(10,5,24,0.25) 100%);
  isolation: isolate;
}
/* Glowing rails top and bottom — like a lit marquee panel */
.play-marquee::before,
.play-marquee::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--cyan) 50%, transparent 100%);
  opacity: 0.55;
  filter: blur(0.5px);
  pointer-events: none;
}
.play-marquee::before { top: 0; }
.play-marquee::after  { bottom: 0; }
.play-marquee .marquee-tag {
  display: inline-block;
  font-family: var(--f-pixel);
  font-size: 14px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,212,0,0.5);
  margin-bottom: 8px;
}
.play-marquee .marquee-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(44px, 6.4vw, 88px);
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text);
  text-shadow:
    0 0 14px rgba(0,255,238,0.55),
    0 0 38px rgba(255,0,170,0.30);
}
/* Cursor "blips" framing the title — cabinet selection indicators */
.play-marquee .marquee-title::before,
.play-marquee .marquee-title::after {
  display: inline-block;
  color: var(--cyan);
  margin: 0 0.4em;
  text-shadow: 0 0 8px var(--cyan);
  font-size: 0.5em;
  vertical-align: 0.45em;
  animation: marquee-blip 1.4s ease-in-out infinite;
}
.play-marquee .marquee-title::before { content: "◆"; }
.play-marquee .marquee-title::after  { content: "◆"; animation-delay: 0.7s; }
@keyframes marquee-blip {
  0%, 100% { opacity: 1; }
  55%      { opacity: 0.25; }
}

/* Details (right) */
.app-details {
  grid-area: details;
  border-left: 1px solid var(--line);
  background: rgba(10,5,24,0.4);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.detail-label {
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 8px;
}
.detail-hook {
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0;
  max-width: 32ch;
}
.tag-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag-row .tag {
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 2px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.detail-actions {
  margin-top: auto;
  display: flex; gap: 10px; align-items: center;
}
.detail-actions .btn-play {
  flex: 1;
  padding: 26px 22px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.32em;
  border-width: 2px;
}
.fav-toggle {
  flex: 0 0 auto;
  width: 64px; height: 64px;
  background: transparent;
  border: 1.5px solid var(--line-3);
  border-radius: 3px;
  color: var(--text-mute);
  font-size: 20px;
  cursor: pointer;
  transition: color .12s, border-color .12s, transform .12s;
}
.fav-toggle:hover { transform: translateY(-1px); color: var(--text); }
.fav-toggle.on {
  color: var(--amber);
  border-color: var(--amber);
  text-shadow: 0 0 10px rgba(255,212,0,0.65);
}

/* ---------------- Tile carousel (bottom) ---------------- */
.app-carousel {
  grid-area: carousel;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px 8px;
  border-top: 1px solid var(--line);
  background: rgba(10,5,24,0.55);
  position: relative;
  z-index: 6;
  overflow: visible;
}
.app-carousel .carousel-label {
  font-family: var(--f-pixel);
  font-size: 15px;
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--text-mute);
  flex: 0 0 auto;
  padding-right: 16px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

#game-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding: 8px 0;
  /* hide x-scrollbar visually but keep functional */
}
#game-list::-webkit-scrollbar { height: 6px; }
#game-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

#game-list .game-card {
  flex: 0 0 150px;
  height: 92px;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .12s, box-shadow .15s, transform .12s;
  outline: none;
}
#game-list .game-card:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
}
#game-list .game-card.active,
#game-list .game-card:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan), 0 0 22px rgba(0,255,238,0.6);
  transform: translateY(-4px) scale(1.06);
  z-index: 3;
}
#game-list .game-card.active::after {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid var(--cyan);
  filter: drop-shadow(0 0 4px var(--cyan));
}
#game-list .game-card .thumb {
  flex: 1; overflow: hidden; position: relative;
  background: rgba(0,0,0,0.4);
}
#game-list .game-card .thumb svg { width: 100%; height: 100%; display: block; }
#game-list .game-card .meta {
  padding: 3px 6px 4px;
  background: rgba(0,0,0,0.55);
  border-top: 1px solid var(--line);
  text-align: center;
}
#game-list .game-card .title {
  font-family: var(--f-pixel);
  font-size: 13px;
  font-weight: normal;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#game-list .game-card .sub { display: none; }
#game-list .game-card.active .title { color: var(--cyan); }
#game-list .game-card .star {
  position: absolute;
  top: 3px; right: 5px;
  font-size: 11px;
  color: var(--amber);
  text-shadow: 0 0 5px rgba(255,212,0,0.7);
  opacity: 0;
}
#game-list .game-card.fav .star { opacity: 1; }

/* Empty / coming variants — compact horizontal inside the carousel strip */
#game-list .empty-state,
#game-list .coming-card {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 76px;
  padding: 8px 22px;
  border: 1px dashed var(--line-2);
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
  margin: 8px 0;
  text-align: center;
}
#game-list .coming-card {
  border-color: rgba(255,0,170,0.32);
  background: rgba(255,0,170,0.04);
}
#game-list .coming-card .label,
#game-list .coming-card h4,
#game-list .coming-card p,
#game-list .empty-state .label,
#game-list .empty-state p {
  margin: 0;
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--text-mute);
  display: inline;
}
#game-list .coming-card .label { color: var(--magenta); margin-right: 10px; }
#game-list .coming-card h4 { color: var(--text); font-size: 14px; margin-right: 10px; }

/* ---------------- Status bar (very bottom) ---------------- */
.app-status {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 24px;
  background: rgba(5,0,16,0.78);
  border-top: 1px solid var(--line);
  font-family: var(--f-pixel);
  font-size: 14px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
  position: relative;
  z-index: 7;
}
.app-status .kbd-grp {
  display: inline-flex;
  align-items: center;
}
.app-status .kbd {
  display: inline-block;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 2px 8px;
  margin-right: 7px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  font-weight: 600;
}
.app-status .selected {
  margin-left: auto;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(0,255,238,0.45);
}

/* ---------------- Mobile ---------------- */
@media (max-width: 760px) {
  body.play-mode { overflow: auto; }
  .play-app {
    position: relative;
    inset: auto;
    min-height: 100vh;
    grid-template-rows: 52px auto auto auto auto auto;
    grid-template-areas:
      "top"
      "marquee"
      "rail"
      "main"
      "carousel"
      "status";
  }
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "preview"
      "details";
  }
  .app-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .app-rail .rail-label { display: none; }
  .buckets {
    flex-direction: row;
    gap: 8px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bucket {
    padding: 8px 14px;
    border: 1px solid var(--line-2);
    border-radius: 3px;
    flex-shrink: 0;
  }
  .bucket.active::before { display: none; }
  .bucket.active {
    border-color: var(--cyan);
    background: rgba(0,255,238,0.10);
  }
  .app-preview { padding: 12px; }
  /* Mobile carousel: shorter row, smaller tiles, single line scrollable */
  .app-carousel { padding: 8px 12px 6px; gap: 8px; }
  .app-carousel .carousel-label { font-size: 11px; padding-right: 10px; }
  #game-list .game-card { flex: 0 0 116px; height: 70px; }
  #game-list .game-card .title { font-size: 10px; letter-spacing: 0.14em; }
  #game-list .game-card.active { transform: translateY(-2px) scale(1.04); }
  #game-list .game-card.active::after { top: -8px; border-top-width: 6px; }
  /* Carousel row constrained on mobile */
  .play-app { grid-template-rows: 52px auto auto auto 88px auto; }
  .preview-frame { max-width: none; }
  /* Mobile: shrink the top marquee so it doesn't dominate the screen */
  .play-marquee { padding: 10px 14px 12px; }
  .play-marquee .marquee-tag { font-size: 11px; letter-spacing: 0.28em; margin-bottom: 4px; }
  .play-marquee .marquee-title { font-size: clamp(26px, 9vw, 44px); letter-spacing: 0.04em; }
  .play-marquee .marquee-title::before,
  .play-marquee .marquee-title::after { display: none; }
  .play-marquee::before, .play-marquee::after { left: 12%; right: 12%; }
  .app-details {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 16px 22px;
    gap: 14px;
  }
  .detail-hook { max-width: none; }
  .detail-actions { margin-top: 6px; }
  .app-status {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 8px 12px 10px;
    height: auto;
    font-size: 10px;
    letter-spacing: 0.16em;
  }
  .app-status .kbd { font-size: 9px; padding: 1px 5px; margin-right: 4px; }
  .app-status .selected { font-size: 10px; }
  .app-status .selected { margin-left: 0; width: 100%; }
}

/* ============================================================
   Selection transition — quick cyan scan-band sweeps the preview
   frame when the selected game changes. Feels like the cart is
   being loaded into the cabinet.
   ============================================================ */
.preview-frame::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: -28%;
  height: 28%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0,255,238,0.55) 50%,
    transparent 100%
  );
  filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.preview-frame.loading::after {
  animation: load-sweep 220ms ease-out forwards;
}
@keyframes load-sweep {
  0%   { opacity: 0; transform: translateY(0); }
  18%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(560%); }
}
.preview-stage,
.preview-marquee {
  transition: opacity 180ms ease;
}
.preview-frame.loading .preview-stage,
.preview-frame.loading .preview-marquee {
  opacity: 0.68;
}

/* ============================================================
   Attract mode — subtle indicator in the status bar.
   ============================================================ */
.app-status .attract-indicator {
  display: none;
  margin-left: auto;
  margin-right: 16px;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,212,0,0.55);
}
.app-status.attract .attract-indicator {
  display: inline;
  animation: attract-blink 1.6s ease-in-out infinite;
}
.app-status.attract .selected { opacity: 0.3; }
@keyframes attract-blink {
  0%, 100% { opacity: 1; }
  55%      { opacity: 0.35; }
}

/* Reduced motion: kill the cabinet animations. The global reduced-motion
   rule in vectarcade.css covers most of this, but explicit safety here. */
@media (prefers-reduced-motion: reduce) {
  .preview-frame.loading::after { animation: none !important; opacity: 0 !important; }
  .preview-stage, .preview-marquee { transition: none !important; }
  .preview-frame.loading .preview-stage,
  .preview-frame.loading .preview-marquee { opacity: 1 !important; }
  .app-status.attract .attract-indicator { animation: none !important; }
}

/* Live preview canvas — layered on top of the static SVG stage so when
   JS runs the canvas animates the game's actual rendering style. */
.preview-frame #preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 2;          /* above stage SVG (z auto), below scanlines (z auto inline-order) */
  pointer-events: none;
}
.preview-frame .preview-stage {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 1;          /* fallback under the canvas */
}


/* Tiny phones (≤ 380px): make the play action row hold together */
@media (max-width: 380px) {
  .app-details { padding: 14px 12px 18px; gap: 10px; }
  .detail-actions .btn-play { padding: 18px 12px; font-size: 13px; letter-spacing: 0.22em; }
  .fav-toggle { width: 52px; height: 52px; font-size: 18px; }
  .play-marquee .marquee-title { font-size: clamp(22px, 9vw, 36px); }
  #game-list .game-card { flex: 0 0 100px; height: 64px; }
}
