:root {
  --bg: #06080c;
  --bezel: #1a1f2a;
  --panel: #12161f;
  --border: #2a3548;
  --mint: #7edfc0;
  --mint-dim: #4a9d7a;
  --phosphor: #5dffb0;
  --phosphor-dim: #2a9d6a;
  --accent: #6eb5ff;
  --text: #d8e2f0;
  --muted: #7a8799;
  --danger: #ff6b6b;
  --glow-rgb: 126, 236, 192;
  --accent-glow-rgb: 93, 255, 176;
  --hero-spot: #1a2438;
  --crt-glow: 0 0 12px rgba(var(--glow-rgb), 0.25);
  --dock-h: 4.5rem;
  --status-h: 2.25rem;
  --hall-h: 3.25rem;
  --touch-min: 3rem;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body.kiosk {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.kiosk-root {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--hero-spot) 0%, transparent 55%),
    var(--bg);
}

/* 4:3 device frame — Retro Pocket kiosk */
.device-frame {
  width: min(100vw - 1rem, calc((100vh - 1rem) * 4 / 3));
  max-height: calc(100vh - 1rem);
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
}

.device-bezel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 3px solid #2e3848;
  border-radius: 12px;
  background: linear-gradient(180deg, #161b24 0%, var(--panel) 8%, var(--panel) 100%);
  box-shadow:
    0 0 0 1px #0a0c10 inset,
    0 12px 40px rgba(0, 0, 0, 0.55),
    var(--crt-glow);
  overflow: hidden;
  position: relative;
}

.device-bezel::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  z-index: 20;
  border-radius: 9px;
}

/* Status bar */
.status-bar {
  flex: 0 0 var(--status-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.65rem;
  background: #0d1118;
  border-bottom: 1px solid var(--border);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 5;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-right { justify-content: flex-end; }

.status-logo {
  height: 1.1rem;
  width: auto;
  opacity: 0.95;
}

.status-hall { color: var(--mint); font-weight: 700; }

.status-center {
  color: var(--muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.status-gear {
  border: 1px solid var(--border);
  background: #141a24;
  color: var(--muted);
  border-radius: 4px;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

.status-gear:hover {
  border-color: var(--mint-dim);
  color: var(--text);
}

.status-track { color: var(--accent); }

.status-pill {
  border: 1px solid var(--mint-dim);
  color: var(--mint);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.58rem;
}

/* Hall launcher tiles */
.hall-launcher {
  flex: 0 0 var(--hall-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 0.35rem 0.5rem;
  background: #0a0e14;
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.hall-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: var(--touch-min);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #141a24;
  color: var(--muted);
  font: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.hall-tile:not(:disabled):not(.hall-locked):hover {
  border-color: var(--mint-dim);
  color: var(--text);
}

.hall-tile.active {
  border-color: var(--mint);
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--mint);
  box-shadow: inset 0 0 12px rgba(var(--accent-glow-rgb), 0.08);
}

.hall-tile.hall-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.hall-icon { font-size: 1rem; line-height: 1; }

.hall-name { font-weight: 600; }

.hall-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.45rem;
  color: var(--accent);
}

.hall-badge.hall-beta {
  color: var(--phosphor);
  border: 1px solid var(--phosphor-dim);
  border-radius: 3px;
  padding: 0 0.2rem;
}

.hall-exit { color: var(--muted); }

/* Views */
.view {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 3;
}

.view.active { display: flex; }

/* Browse — jukebox grid */
.view-browse {
  padding: 0.5rem 0.65rem;
  overflow-y: auto;
}

.browse-header { margin-bottom: 0.5rem; }

.browse-title {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.browse-sub {
  margin: 0.15rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
}

/* Homebrew — platform shelves */
.platform-shelf {
  flex: 0 0 auto;
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  padding: 0.35rem 0 0.45rem;
  margin-bottom: 0.15rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.platform-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.85rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #141a24;
  color: var(--muted);
  font: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}

.platform-chip:hover {
  border-color: var(--mint-dim);
  color: var(--text);
}

.platform-chip.active {
  border-color: var(--mint);
  background: rgba(var(--glow-rgb), 0.12);
  color: var(--mint);
}

.platform-chip-count {
  font-size: 0.5rem;
  color: var(--accent);
  opacity: 0.9;
}

.platform-chip.active .platform-chip-count {
  color: var(--mint);
}

.track-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.4rem;
  flex: 1;
}

.track-grid li { margin: 0; perspective: 900px; }

.track-grid.launch-active {
  position: relative;
  z-index: 2;
}

.track-grid.launch-active .track-card:not(.launch-spinflip) {
  opacity: 0.28;
  transition: opacity 0.14s ease;
}

.track-card.launch-spinflip {
  animation: card-spinflip 0.52s cubic-bezier(0.33, 1.05, 0.42, 1) forwards;
  pointer-events: none;
  z-index: 30;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  border-color: var(--mint);
  box-shadow: 0 0 28px rgba(var(--glow-rgb), 0.55);
}

@keyframes card-spinflip {
  0% {
    transform: rotateY(0deg) rotateX(0deg) scale(1);
    opacity: 1;
  }
  40% {
    transform: rotateY(94deg) rotateX(10deg) scale(1.08);
    opacity: 1;
  }
  72% {
    transform: rotateY(158deg) rotateX(14deg) scale(0.88);
    opacity: 0.75;
  }
  100% {
    transform: rotateY(180deg) rotateX(22deg) scale(0.12);
    opacity: 0;
  }
}

.view-play.play-launch-in .viz-stage,
.view-emu.play-launch-in .emu-stage {
  animation: stage-flip-in 0.42s cubic-bezier(0.22, 1, 0.32, 1) backwards;
}

@keyframes stage-flip-in {
  from {
    opacity: 0;
    transform: rotateY(-16deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .track-card.launch-spinflip {
    animation: none;
  }
  .view-play.play-launch-in .viz-stage,
  .view-emu.play-launch-in .emu-stage {
    animation: none;
  }
}

.track-card {
  width: 100%;
  min-height: 4.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.15rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(145deg, #1a2230 0%, #121820 100%);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}

.track-card:hover {
  border-color: var(--mint-dim);
  transform: translateY(-1px);
}

.track-card.active {
  border-color: var(--mint);
  background: linear-gradient(145deg, #1e2e28 0%, #141f1a 100%);
  box-shadow: 0 0 16px rgba(var(--accent-glow-rgb), 0.15);
}

.track-card .format-badge {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor);
}

.track-card .track-title {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.track-card .track-artist {
  font-size: 0.58rem;
  color: var(--muted);
}

.track-card .license-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.4rem;
  font-size: 0.42rem;
  letter-spacing: 0.06em;
  padding: 0.08rem 0.25rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--accent);
  max-width: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hb-now {
  flex: 0 0 auto;
  margin-top: 0.4rem;
  padding: 0.4rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(var(--accent-glow-rgb), 0.06) 0%, rgba(12, 16, 22, 0.9) 55%);
}

.hb-now-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.hb-now-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hb-now-meta {
  font-size: 0.58rem;
  color: var(--muted);
}

.hb-now-status {
  flex: 0 0 auto;
  font-size: 0.52rem;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: rgba(110, 181, 255, 0.08);
}

.hb-now-status.is-ready {
  border-color: var(--mint);
  color: var(--mint);
  background: rgba(var(--glow-rgb), 0.12);
  box-shadow: 0 0 10px rgba(var(--accent-glow-rgb), 0.2);
}

.grid-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 1rem;
}

.track-card .format-badge.badge-ready {
  border-color: var(--mint);
  color: var(--mint);
  box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.25);
}

.track-card .format-badge.badge-core {
  border-color: var(--accent);
  color: var(--accent);
}

.pd-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.25rem;
}

.pd-source-btn {
  background: #141a24;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--accent);
  font: inherit;
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.45rem;
  cursor: pointer;
}

.pd-source-btn:hover {
  border-color: var(--mint-dim);
  color: var(--mint);
}

/* Play view — homebrew EmulatorJS */
.view-emu {
  padding: 0.35rem 0.5rem 0;
  position: relative;
  flex-direction: column;
}

.emu-stage {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.emu-frame {
  width: 100%;
  height: 100%;
  min-height: 12rem;
  border: 0;
  display: block;
  background: #000;
}

.browse-footer {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.62rem;
}

.claim-hint { margin: 0; color: var(--muted); }

.link-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.62rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
}

/* Play view — music viz */
.view-play {
  padding: 0.35rem 0.5rem 0;
  position: relative;
}

.viz-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

#viz {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.title-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  z-index: 4;
  animation: fade-overlay 3s ease forwards;
}

@keyframes fade-overlay {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

.overlay-title {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--phosphor);
  text-shadow: var(--crt-glow);
  text-align: center;
  padding: 0 1rem;
}

.overlay-meta {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.credits-roll {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  text-align: center;
  font-size: 0.65rem;
  color: var(--phosphor);
  text-shadow: var(--crt-glow);
  pointer-events: none;
  z-index: 3;
}

.now-playing-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.15rem;
  min-height: 2.25rem;
}

.np-title {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
}

.np-meta {
  font-size: 0.6rem;
  color: var(--muted);
}

.viz-chip {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mint);
  border: 1px solid var(--mint-dim);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

/* Control dock — kiosk buttons */
.control-dock {
  flex: 0 0 var(--dock-h);
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 0.35rem 0.5rem 0.45rem;
  background: #0a0e14;
  border-top: 1px solid var(--border);
  z-index: 5;
}

.dock-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-width: 0;
  min-height: var(--touch-min);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #1a2230;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: filter 0.12s, border-color 0.12s;
}

.dock-btn:hover { filter: brightness(1.12); border-color: var(--mint-dim); }

.dock-btn:active { transform: scale(0.97); }

.dock-btn.dock-primary {
  flex: 1.4;
  background: linear-gradient(180deg, var(--mint-dim) 0%, #3a8a62 100%);
  border-color: var(--mint);
  color: #041008;
}

.dock-primary .dock-glyph { font-size: 1.35rem; }

.dock-glyph { font-size: 1rem; line-height: 1; }

.dock-label {
  font-size: 0.48rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.dock-btn[hidden] { display: none; }

/* Attract mode */
.attract {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.94);
  cursor: pointer;
}

.attract[hidden] { display: none; }

.attract-inner {
  text-align: center;
  padding: 2rem;
  animation: attract-pulse 3s ease-in-out infinite;
}

@keyframes attract-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.attract-logo {
  max-width: 12rem;
  height: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 20px rgba(var(--accent-glow-rgb), 0.35));
}

.attract-line {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  color: var(--phosphor);
  text-shadow: var(--crt-glow);
}

.attract-sub {
  margin: 0.75rem auto 0;
  max-width: 22rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.attract-cta {
  margin: 1.25rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--mint);
  animation: blink-cta 1.5s step-end infinite;
}

@keyframes blink-cta {
  50% { opacity: 0.4; }
}

.attract-est {
  margin: 2rem 0 0;
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* Game fullscreen — expand playfield inside device bezel (not browser chrome) */
body.kiosk.game-fullscreen .status-bar,
body.kiosk.game-fullscreen .hall-launcher {
  display: none;
}

body.kiosk.game-fullscreen .view-emu,
body.kiosk.game-fullscreen .view-play {
  flex: 1;
  padding: 0;
  min-height: 0;
}

body.kiosk.game-fullscreen .emu-stage,
body.kiosk.game-fullscreen .viz-stage {
  flex: 1;
  border: none;
  border-radius: 0;
  min-height: 0;
}

body.kiosk.game-fullscreen .emu-frame {
  min-height: 0;
}

body.kiosk.game-fullscreen .view-emu .now-playing-bar,
body.kiosk.game-fullscreen .view-play .now-playing-bar {
  display: none;
}

body.kiosk.game-fullscreen .control-dock .dock-btn {
  display: none;
}

body.kiosk.game-fullscreen .control-dock #btn-back,
body.kiosk.game-fullscreen .control-dock #btn-fullscreen,
body.kiosk.game-fullscreen .control-dock #btn-play {
  display: flex;
}

/* Homebrew — true 4:3 CRT: game owns the whole bezel, dock peeks on tap */
body.kiosk.game-fullscreen.hall-homebrew .view-emu {
  position: absolute;
  inset: 0;
  z-index: 4;
}

body.kiosk.game-fullscreen.hall-homebrew .emu-stage {
  width: 100%;
  height: 100%;
}

body.kiosk.game-fullscreen.hall-homebrew .control-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
  transition: opacity 0.22s ease, transform 0.22s ease;
  background: linear-gradient(transparent, rgba(10, 14, 20, 0.94) 35%);
  border-top: none;
}

body.kiosk.game-fullscreen.hall-homebrew.game-hud-visible .control-dock {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

body.kiosk.game-fullscreen.hall-homebrew .control-dock .dock-btn {
  display: none;
}

body.kiosk.game-fullscreen.hall-homebrew.game-hud-visible .control-dock #btn-back,
body.kiosk.game-fullscreen.hall-homebrew.game-hud-visible .control-dock #btn-fullscreen,
body.kiosk.game-fullscreen.hall-homebrew.game-hud-visible .control-dock #btn-play {
  display: flex;
}

body.kiosk.game-fullscreen .control-dock #btn-fullscreen.active {
  color: var(--mint);
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
}

/* Fullscreen kiosk — legacy browser fullscreen (unused on device) */
body.kiosk:fullscreen .kiosk-root,
body.kiosk:-webkit-full-screen .kiosk-root {
  padding: 0;
}

body.kiosk:fullscreen .device-frame,
body.kiosk:-webkit-full-screen .device-frame {
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: unset;
}

body.kiosk:fullscreen .device-bezel,
body.kiosk:-webkit-full-screen .device-bezel {
  border-radius: 0;
  border-width: 0;
}

/* Homebrew hall — sexay launcher (no browser chrome) */
.hall-homebrew .browse-header {
  margin-bottom: 0.25rem;
}

.hall-music .platform-shelf {
  gap: 0.2rem;
  padding: 0.2rem 0 0.3rem;
  border-bottom: 1px solid rgba(var(--glow-rgb), 0.15);
  flex-wrap: wrap;
  overflow-x: visible;
}

.hall-music .platform-chip {
  min-height: 1.65rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.52rem;
}

.hall-music .platform-chip-count {
  font-size: 0.46rem;
}

.hall-music .platform-chip.active {
  box-shadow: 0 0 10px rgba(var(--glow-rgb), 0.2);
}

.hall-homebrew .browse-title {
  color: var(--phosphor);
  text-shadow: 0 0 14px rgba(var(--accent-glow-rgb), 0.35);
}

.hall-homebrew .platform-shelf {
  gap: 0.25rem;
  padding: 0.25rem 0 0.35rem;
  border-bottom: 1px solid rgba(42, 53, 72, 0.8);
}

.hall-homebrew .platform-chip {
  min-height: 2rem;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  background: linear-gradient(180deg, #1a2230 0%, #121820 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hall-homebrew .platform-chip.active {
  background: linear-gradient(180deg, #1e3a32 0%, #142820 100%);
  box-shadow:
    inset 0 0 14px rgba(var(--accent-glow-rgb), 0.12),
    0 0 10px rgba(var(--accent-glow-rgb), 0.15);
}

.hall-homebrew .track-grid {
  grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.35rem;
  align-content: start;
}

.hall-homebrew .track-card.game-card {
  min-height: 0;
  padding: 0;
  overflow: hidden;
  align-items: stretch;
  justify-content: flex-start;
  border-radius: 8px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.hall-homebrew .track-card.game-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--glow-rgb), 0.35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.hall-homebrew .track-card.game-card.active {
  transform: translateY(-4px) scale(1.03);
  box-shadow:
    0 0 0 1px rgba(var(--glow-rgb), 0.45),
    0 0 24px rgba(var(--accent-glow-rgb), 0.28),
    0 8px 20px rgba(0, 0, 0, 0.4);
}

.box-cover.has-art {
  background: #0a0c10;
}

.box-cover-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  z-index: 1;
}

.box-cover.has-art .box-cover-initials {
  display: none;
}

.box-cover.has-art .box-cover-glyph {
  z-index: 2;
  color: rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

/* Generated box art */
.box-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background:
    linear-gradient(
      hue-rotate(var(--cover-shift, 0deg)) 145deg,
      var(--cover-a, #2a3548) 0%,
      var(--cover-b, #121820) 55%,
      #080c12 100%
    );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.box-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 38%,
    rgba(255, 255, 255, 0.07) 48%,
    transparent 58%
  );
  transform: translateX(-120%);
  animation: cover-shimmer 4.5s ease-in-out infinite;
  pointer-events: none;
}

.hall-homebrew .track-card.game-card:hover .box-cover::after,
.hall-homebrew .track-card.game-card.active .box-cover::after {
  animation-duration: 2.2s;
}

.box-cover-glyph {
  position: absolute;
  top: 0.28rem;
  right: 0.32rem;
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.22);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.box-cover-glyph::before {
  content: var(--cover-glyph, "???");
}

.box-cover-initials {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.88);
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.55),
    0 0 18px rgba(255, 255, 255, 0.12);
  z-index: 1;
}

.game-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.32rem 0.38rem 0.38rem;
  background: linear-gradient(180deg, #141a24 0%, #101620 100%);
}

.hall-homebrew .game-card-body .format-badge {
  align-self: flex-start;
  font-size: 0.44rem;
  padding: 0.1rem 0.28rem;
}

.hall-homebrew .game-card-body .format-badge.badge-ready {
  background: rgba(var(--accent-glow-rgb), 0.18);
  color: var(--mint);
  border-color: rgba(var(--accent-glow-rgb), 0.35);
}

.hall-homebrew .game-card-body .format-badge.badge-core {
  background: rgba(126, 180, 255, 0.12);
  color: #9ec8ff;
  border-color: rgba(126, 180, 255, 0.28);
}

.hall-homebrew .track-card.game-card .track-title {
  font-size: 0.62rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hall-homebrew .track-card.game-card .track-artist {
  font-size: 0.5rem;
  opacity: 0.75;
}

/* Shelf swap animations */
@keyframes shelf-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(6px); }
}

@keyframes card-pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cover-shimmer {
  0%, 72%, 100% { transform: translateX(-120%); }
  88% { transform: translateX(120%); }
}

.hall-homebrew .track-grid.shelf-swap-out {
  animation: shelf-fade-out 0.18s ease forwards;
  pointer-events: none;
}

.hall-homebrew .track-grid.shelf-swap-in > li {
  animation: card-pop-in 0.32s ease backwards;
}

.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(1) { animation-delay: 0.02s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(2) { animation-delay: 0.04s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(3) { animation-delay: 0.06s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(4) { animation-delay: 0.08s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(5) { animation-delay: 0.1s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(6) { animation-delay: 0.12s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(7) { animation-delay: 0.14s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(8) { animation-delay: 0.16s; }
.hall-homebrew .track-grid.shelf-swap-in > li:nth-child(n + 9) { animation-delay: 0.18s; }

.hall-homebrew .track-card {
  min-height: 5.25rem;
  border-radius: 10px;
  background:
    linear-gradient(160deg, rgba(var(--accent-glow-rgb), 0.05) 0%, transparent 42%),
    linear-gradient(145deg, #1a2230 0%, #101620 100%);
}

.hall-homebrew .track-card.active {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(var(--glow-rgb), 0.35),
    0 0 22px rgba(var(--accent-glow-rgb), 0.22);
}

.hall-homebrew .track-card .track-title {
  font-size: 0.76rem;
}

.dock-btn.dock-wait.dock-primary {
  background: linear-gradient(180deg, #3a5a48 0%, #2a4034 100%);
  opacity: 0.85;
}

/* Narrow / portrait — stack halls 2x2 already, smaller grid */
@media (max-width: 520px) {
  .track-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .hall-launcher {
    grid-template-columns: repeat(2, 1fr);
    height: auto;
    min-height: var(--hall-h);
  }
}

/* ── Theme variants ── */
[data-theme="phosphor"] {
  /* :root defaults — Cursy CRT green */
}

[data-theme="mint"] {
  --mint: #8ee8cc;
  --mint-dim: #5aab8a;
  --phosphor: #7edfc0;
  --phosphor-dim: #4a9d7a;
  --accent: #7ec8ff;
  --glow-rgb: 142, 232, 204;
  --accent-glow-rgb: 126, 223, 192;
  --hero-spot: #152a28;
}

[data-theme="amber"] {
  --mint: #e8c07a;
  --mint-dim: #9a7340;
  --phosphor: #ffb84d;
  --phosphor-dim: #b87820;
  --accent: #ffcc66;
  --glow-rgb: 255, 184, 77;
  --accent-glow-rgb: 232, 168, 58;
  --hero-spot: #2a2010;
}

[data-theme="compos"] {
  --mint: #6eb5ff;
  --mint-dim: #3a78b8;
  --phosphor: #8fd4ff;
  --phosphor-dim: #4a8cc4;
  --accent: #b8e0ff;
  --glow-rgb: 110, 181, 255;
  --accent-glow-rgb: 143, 212, 255;
  --hero-spot: #142030;
}

[data-theme="slate"] {
  --mint: #a8b4c4;
  --mint-dim: #6a7588;
  --phosphor: #c8d2e0;
  --phosphor-dim: #7a8494;
  --accent: #9eb0c8;
  --glow-rgb: 168, 180, 196;
  --accent-glow-rgb: 158, 176, 200;
  --hero-spot: #181c24;
  --crt-glow: 0 0 8px rgba(var(--glow-rgb), 0.12);
}

[data-theme="ruby"] {
  --mint: #ff8ab0;
  --mint-dim: #b84a6a;
  --phosphor: #ff6b9d;
  --phosphor-dim: #c43868;
  --accent: #ffb3cc;
  --glow-rgb: 255, 107, 157;
  --accent-glow-rgb: 255, 138, 176;
  --hero-spot: #2a1018;
}

[data-theme="violet"] {
  --mint: #c49cff;
  --mint-dim: #7a4ab8;
  --phosphor: #b87aff;
  --phosphor-dim: #6a38a8;
  --accent: #d4b0ff;
  --glow-rgb: 184, 122, 255;
  --accent-glow-rgb: 196, 156, 255;
  --hero-spot: #1a1028;
}

[data-theme="ocean"] {
  --mint: #5ec4e8;
  --mint-dim: #2a7898;
  --phosphor: #4ab8e0;
  --phosphor-dim: #206880;
  --accent: #88d4f8;
  --glow-rgb: 74, 184, 224;
  --accent-glow-rgb: 94, 196, 232;
  --hero-spot: #081820;
}

[data-theme="sunset"] {
  --mint: #ffb0a0;
  --mint-dim: #c87060;
  --phosphor: #ff9078;
  --phosphor-dim: #c05848;
  --accent: #ffc8b8;
  --glow-rgb: 255, 144, 120;
  --accent-glow-rgb: 255, 176, 160;
  --hero-spot: #281418;
}

[data-theme="c64"] {
  --mint: #7aa8ff;
  --mint-dim: #4a68b8;
  --phosphor: #6890ff;
  --phosphor-dim: #3848a0;
  --accent: #a0c0ff;
  --glow-rgb: 104, 144, 255;
  --accent-glow-rgb: 122, 168, 255;
  --hero-spot: #181040;
  --bg: #40318d;
  --panel: #2a2070;
  --border: #5040a0;
}

[data-theme="gbc"] {
  --mint: #9bcc60;
  --mint-dim: #5a8038;
  --phosphor: #8bac0f;
  --phosphor-dim: #4a6808;
  --accent: #c4e878;
  --glow-rgb: 139, 172, 15;
  --accent-glow-rgb: 155, 204, 96;
  --hero-spot: #1a2810;
  --bg: #0f1808;
}

[data-theme="gothic"] {
  --mint: #c87898;
  --mint-dim: #784058;
  --phosphor: #e06088;
  --phosphor-dim: #883050;
  --accent: #a888c0;
  --glow-rgb: 224, 96, 136;
  --accent-glow-rgb: 168, 136, 192;
  --hero-spot: #180818;
  --bg: #0c060c;
}

/* ── Settings sheet (inside 4:3 bezel) ── */
.settings-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 40;
  border-radius: 9px;
}

.settings-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(11.5rem, 72%);
  z-index: 41;
  background: linear-gradient(180deg, #161b24 0%, var(--panel) 100%);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  padding: 0.55rem;
  overflow-y: auto;
  border-radius: 0 9px 9px 0;
  animation: settings-slide-in 0.22s ease-out;
}

.settings-sheet[hidden],
.settings-scrim[hidden] {
  display: none;
}

@keyframes settings-slide-in {
  from { transform: translateX(100%); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.settings-title {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.settings-close {
  border: 1px solid var(--border);
  background: #141a24;
  color: var(--muted);
  border-radius: 4px;
  width: 1.75rem;
  height: 1.75rem;
  cursor: pointer;
}

.settings-label {
  margin: 0 0 0.25rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mint);
}

.settings-hint {
  margin: 0 0 0.6rem;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.35;
}

.theme-grid {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.theme-chip {
  display: grid;
  grid-template-columns: 1.35rem 1fr;
  grid-template-rows: auto auto;
  gap: 0 0.4rem;
  align-items: center;
  text-align: left;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #141a24;
  color: var(--text);
  cursor: pointer;
  min-height: 2.4rem;
}

.theme-chip:hover {
  border-color: var(--mint-dim);
}

.theme-chip.active {
  border-color: var(--phosphor);
  box-shadow: inset 0 0 10px rgba(var(--accent-glow-rgb), 0.12);
}

.theme-chip-swatch {
  grid-row: 1 / span 2;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.theme-swatch-phosphor { background: linear-gradient(135deg, #5dffb0, #2a9d6a); }
.theme-swatch-mint { background: linear-gradient(135deg, #8ee8cc, #4a9d7a); }
.theme-swatch-amber { background: linear-gradient(135deg, #ffb84d, #b87820); }
.theme-swatch-compos { background: linear-gradient(135deg, #8fd4ff, #3a78b8); }
.theme-swatch-slate { background: linear-gradient(135deg, #c8d2e0, #6a7588); }
.theme-swatch-ruby { background: linear-gradient(135deg, #ff6b9d, #8a2048); }
.theme-swatch-violet { background: linear-gradient(135deg, #b87aff, #502888); }
.theme-swatch-ocean { background: linear-gradient(135deg, #4ab8e0, #104868); }
.theme-swatch-sunset { background: linear-gradient(135deg, #ff9078, #c04868); }
.theme-swatch-c64 { background: linear-gradient(135deg, #6890ff, #40318d); }
.theme-swatch-gbc { background: linear-gradient(135deg, #9bcc60, #306850); }
.theme-swatch-gothic { background: linear-gradient(135deg, #e06088, #401030); }

.theme-chip-label {
  font-size: 0.66rem;
  font-weight: 600;
}

.theme-chip-sub {
  grid-column: 2;
  font-size: 0.52rem;
  color: var(--muted);
  line-height: 1.25;
}

.settings-section {
  margin-bottom: 0.85rem;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.62rem;
  color: var(--text);
}

.settings-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-toggle-ui {
  flex: 0 0 1.65rem;
  height: 0.9rem;
  border-radius: 999px;
  background: #2a3240;
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.settings-toggle-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

.settings-toggle input:checked + .settings-toggle-ui {
  background: rgba(var(--glow-rgb), 0.25);
  border-color: var(--mint-dim);
}

.settings-toggle input:checked + .settings-toggle-ui::after {
  transform: translateX(0.72rem);
  background: var(--mint);
}

.settings-toggle-text {
  line-height: 1.3;
}

.np-actions {
  display: flex;
  gap: 0.25rem;
  flex: 0 0 auto;
}

.np-actions[hidden] {
  display: none;
}

.np-action-btn {
  width: 1.65rem;
  height: 1.65rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #141a24;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.np-action-btn:hover {
  border-color: var(--mint-dim);
  color: var(--text);
}

.np-action-btn.is-on {
  color: #ff7aa8;
  border-color: #b84a6a;
}

.dock-btn.is-on {
  border-color: #b84a6a;
  color: #ff9ab8;
}

.track-fav-mark {
  position: absolute;
  top: 0.28rem;
  left: 0.32rem;
  font-size: 0.55rem;
  color: #ff7aa8;
  text-shadow: 0 0 6px rgba(255, 100, 140, 0.45);
}

.platform-chip-library .platform-chip-label {
  color: var(--accent);
}

.picker-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 42;
  border-radius: 9px;
}

.picker-sheet {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(13rem, 84%);
  max-height: 70%;
  z-index: 43;
  background: linear-gradient(180deg, #161b24 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  overflow: hidden;
}

.picker-sheet[hidden],
.picker-scrim[hidden] {
  display: none;
}

.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.picker-title {
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.picker-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #141a24;
  color: var(--text);
  padding: 0.38rem 0.45rem;
  cursor: pointer;
}

.picker-item:hover {
  border-color: var(--mint-dim);
}

.picker-item-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
}

.picker-item-meta {
  display: block;
  font-size: 0.52rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.picker-new-btn {
  margin-top: 0.45rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--mint);
  font: inherit;
  font-size: 0.62rem;
  padding: 0.4rem;
  cursor: pointer;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + 0.35rem);
  transform: translateX(-50%);
  z-index: 44;
  background: rgba(10, 14, 20, 0.92);
  border: 1px solid var(--mint-dim);
  color: var(--phosphor);
  font-size: 0.62rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  animation: toast-in 0.18s ease-out;
}

.toast[hidden] {
  display: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
