:root {
  color-scheme: dark;
  --bg: #0a0613;
  --ink: #f4f0ff;
  --pink: #ff3ca6;
  --cyan: #3cf0ff;
  --violet: #9b6bff;
  --lime: #5dff9e;
  --gold: #ffd23c;
  --font-logo: "Bungee", system-ui, sans-serif;
  --font-pixel: "Press Start 2P", monospace;
  --font-ui: "Chakra Petch", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 80% at 50% 8%, #1a0f3d 0%, #0a0613 55%, #05030c 100%);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow-x: hidden;
  /* Vertically (and horizontally) center the console in the viewport. The
     atmosphere layers, chrome, game iframe and ticker are all fixed, so the
     cabinet is the only flow child — it lands dead center. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* A game console, not a document */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   Atmosphere: synthwave grid floor, horizon sun, particles,
   CRT scanlines + vignette
   ============================================================ */
.fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.floor {
  position: fixed;
  left: -25%;
  right: -25%;
  bottom: 0;
  height: 62vh;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 60, 166, 0.75) 2px, transparent 2px),
    linear-gradient(90deg, rgba(60, 240, 255, 0.6) 2px, transparent 2px);
  background-size: 100% 46px, 46px 100%;
  transform: perspective(58vh) rotateX(74deg);
  transform-origin: bottom center;
  mask-image: linear-gradient(transparent, #000 52%);
  -webkit-mask-image: linear-gradient(transparent, #000 52%);
  opacity: 0.9;
}

.sun {
  position: fixed;
  bottom: 31vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 74vw);
  height: min(440px, 74vw);
  border-radius: 50%;
  z-index: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 7px, #0a0613 7px 10px) bottom / 100% 52% no-repeat,
    linear-gradient(180deg, #ffe58a 0%, #ff9f40 44%, #ff3ca6 100%);
  box-shadow: 0 0 100px 26px rgba(255, 120, 90, 0.4), 0 0 40px 6px rgba(255, 60, 166, 0.35);
  opacity: 0.9;
  pointer-events: none;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0.16) 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 59;
  pointer-events: none;
  box-shadow: inset 0 0 200px 40px rgba(4, 2, 12, 0.9);
}

/* ============================================================
   Global console chrome — one control cluster (home · volume ·
   fullscreen) that floats above everything and never tears down,
   so it governs the hub and every game the same way.
   ============================================================ */
.chrome {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  background: rgba(10, 6, 19, 0.72);
  border: 2px solid rgba(155, 107, 255, 0.6);
  border-radius: 12px;
  color: var(--cyan);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, opacity 0.2s ease;
}

.chip svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 5px currentColor);
}

.chip:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(60, 240, 255, 0.5);
}

.chip:active {
  transform: scale(0.92);
}

/* Home chip — only meaningful inside a game; hidden on the hub. */
.chip-home {
  font-family: var(--font-logo);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--lime);
  border-color: rgba(93, 255, 158, 0.55);
  display: none;
}
.chip-home:hover {
  border-color: var(--lime);
  box-shadow: 0 0 18px rgba(93, 255, 158, 0.5);
}
body.in-game .chip-home {
  display: flex;
}

.chip-fs {
  color: var(--gold);
  border-color: rgba(255, 210, 60, 0.55);
}
.chip-fs:hover {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 210, 60, 0.5);
}

.chip-mute.muted {
  color: var(--pink);
  border-color: rgba(255, 60, 166, 0.6);
}

/* Volume: a mute chip + an inline neon slider, joined as one control. */
.vol {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-slider {
  --fill: 85%;
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--cyan), var(--pink)) 0 / var(--fill) 100% no-repeat,
    rgba(120, 90, 200, 0.28);
  outline: none;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(124, 92, 255, 0.35), inset 0 0 0 1px rgba(155, 107, 255, 0.4);
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--violet);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 0 14px rgba(155, 107, 255, 0.7);
  cursor: pointer;
}

.vol-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--violet);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 0 14px rgba(155, 107, 255, 0.7);
  cursor: pointer;
}

/* The volume slider collapses on narrow screens; the mute chip stays. */
@media (max-width: 560px) {
  .vol-slider {
    width: 64px;
  }
}

/* ============================================================
   The game screen — a game boots INTO this iframe, so the shell
   (chrome, atmosphere, fullscreen state) is never torn down.
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 80;
  background: #05030c;
  opacity: 0;
  visibility: hidden; /* resting state is definitively gone — no stray click target */
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

body.in-game .screen {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.35s ease, visibility 0s;
}

/* While a game is playing, tuck the hub UI away (it stays mounted,
   just hidden behind the game screen) and hush the loud atmosphere. */
body.in-game .cabinet,
body.in-game .ticker {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   Cabinet shell + marquee
   ============================================================ */
.cabinet {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 960px;
  /* Centered by the body flex; keep a little breathing room top/bottom so tall
     layouts never tuck under the ticker. */
  padding: clamp(1rem, 3vw, 2rem) 1.1rem clamp(3rem, 7vh, 5rem);
}

.marquee {
  position: relative;
  text-align: center;
  padding: 1.4rem 1.4rem 1.6rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 16, 60, 0.72), rgba(12, 7, 26, 0.55));
  border: 2px solid rgba(155, 107, 255, 0.35);
  box-shadow:
    0 0 0 4px rgba(10, 6, 19, 0.6),
    0 0 60px rgba(155, 107, 255, 0.28),
    inset 0 0 40px rgba(155, 107, 255, 0.08);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-14px);
  animation: pop-in 0.6s cubic-bezier(0.2, 1.2, 0.3, 1) 0.1s forwards;
}

/* chase-light bulbs around the marquee */
.bulbs {
  position: absolute;
  inset: 9px;
  border-radius: 14px;
  pointer-events: none;
}

.bulb {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px 2px rgba(255, 210, 60, 0.9);
  animation: bulb-blink 1.1s steps(1) infinite;
}

@keyframes bulb-blink {
  0%, 49% {
    opacity: 1;
    background: var(--gold);
    box-shadow: 0 0 9px 2px rgba(255, 210, 60, 0.95);
  }
  50%, 100% {
    opacity: 0.35;
    background: var(--pink);
    box-shadow: 0 0 5px 1px rgba(255, 60, 166, 0.5);
  }
}

.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-pixel);
  font-size: clamp(0.42rem, 1.6vw, 0.56rem);
  letter-spacing: 0.02em;
  color: #b7a6e6;
  margin: 0 0.6rem 0.9rem;
}

.p1 {
  color: var(--cyan);
}
.credits {
  display: inline-flex;
  align-items: center;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 210, 60, 0.75);
  animation: freeplay-pulse 1.1s ease-in-out infinite;
}

/* a little spinning gold coin so "free play" reads as endless coins */
.coin {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  margin-right: 6px;
  background: radial-gradient(circle at 35% 30%, #fff6c0, #ffd23c 48%, #d98a12 100%);
  box-shadow: 0 0 9px rgba(255, 210, 60, 0.9), inset -1px -1px 2px rgba(120, 70, 0, 0.5);
  animation: coin-flip 1.6s linear infinite;
}

@keyframes coin-flip {
  to {
    transform: rotateY(360deg);
  }
}

@keyframes freeplay-pulse {
  50% {
    transform: scale(1.06);
    text-shadow: 0 0 14px rgba(255, 210, 60, 1);
  }
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  vertical-align: middle;
  margin-right: 4px;
  animation: ready-blink 1s steps(1) infinite;
}

@keyframes ready-blink {
  50% {
    opacity: 0.2;
  }
}

.logo {
  margin: 0.1rem 0 0.05rem;
  font-family: var(--font-logo);
  font-size: clamp(1.7rem, 9.2vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: 0.02em;
  /* Glossy 80s chrome: white highlight -> sunset -> violet, hard bevel + glow */
  background: linear-gradient(180deg, #ffffff 0%, #ffe58a 20%, #ff9f40 44%, #ff3ca6 66%, #9b6bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter:
    drop-shadow(0 3px 0 #2a1030)
    drop-shadow(0 5px 2px rgba(0, 0, 0, 0.55))
    drop-shadow(0 0 22px rgba(255, 120, 180, 0.5))
    drop-shadow(0 0 44px rgba(120, 80, 255, 0.32));
  animation: neon-flicker 4.5s infinite;
}

@keyframes neon-flicker {
  0%, 100%, 42%, 46% {
    opacity: 1;
  }
  43%, 45% {
    opacity: 0.55;
  }
  44% {
    opacity: 0.85;
  }
}

/* "Special Max Edition" — a glowing neon-script signature under the logo */
.edition {
  margin: -0.1rem 0 0.5rem;
  font-family: "Kaushan Script", cursive;
  font-size: clamp(1.3rem, 4.6vw, 2.2rem);
  font-weight: 400;
  line-height: 1;
  transform: rotate(-2.5deg);
  background: linear-gradient(90deg, #3cf0ff, #ff3ca6 55%, #ffd23c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 60, 166, 0.65)) drop-shadow(0 0 26px rgba(60, 240, 255, 0.4));
}

.tagline {
  margin: 0;
  font-size: clamp(0.72rem, 2.4vw, 0.95rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #c8b8f0;
  font-weight: 500;
}

/* ============================================================
   Game rack of cabinets
   ============================================================ */
.rack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: clamp(1rem, 2.6vw, 1.6rem);
  margin-top: clamp(1.6rem, 5vw, 2.8rem);
}

.cab {
  --glow: hsl(var(--hue), 100%, 62%);
  --glow-soft: hsla(var(--hue), 100%, 62%, 0.35);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.9rem 0.9rem 1rem;
  border-radius: 18px;
  text-decoration: none;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(26, 16, 48, 0.85), rgba(12, 7, 24, 0.9));
  border: 2px solid hsla(var(--hue), 90%, 62%, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 22px hsla(var(--hue), 90%, 60%, 0.06);
  opacity: 0;
  animation: fade-in 0.5s ease forwards;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

/* Attract mode — the selected cabinet's screen plays itself */
.cab.selected .cab-screen {
  animation: crt-on 0.5s ease;
}

@keyframes crt-on {
  0% {
    filter: brightness(3) saturate(0.2);
    opacity: 0.25;
  }
  28% {
    filter: brightness(0.5);
    opacity: 1;
  }
  45% {
    filter: brightness(1.7);
  }
  60% {
    filter: brightness(0.85);
  }
  100% {
    filter: brightness(1);
  }
}

.cab.selected .bo-ball {
  animation: bo-ball 2.6s ease-in-out infinite;
}
.cab.selected .bo-paddle {
  animation: bo-paddle 2.6s ease-in-out infinite;
}

@keyframes bo-ball {
  0% { transform: translate(0, 0); }
  22% { transform: translate(-32px, -30px); }
  44% { transform: translate(24px, -16px); }
  62% { transform: translate(-14px, -34px); }
  80% { transform: translate(18px, 4px); }
  100% { transform: translate(0, 0); }
}

@keyframes bo-paddle {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-16px); }
  44% { transform: translateX(14px); }
  80% { transform: translateX(10px); }
}

.cab.selected .ttt-mark {
  animation: ttt-pop 3s ease-in-out infinite;
}

@keyframes ttt-pop {
  0%, 8% { opacity: 0.15; }
  20%, 72% { opacity: 1; }
  92%, 100% { opacity: 0.15; }
}

.rack .cab:nth-child(1) { animation-delay: 0.28s; }
.rack .cab:nth-child(2) { animation-delay: 0.4s; }
.rack .cab:nth-child(3) { animation-delay: 0.52s; }

.cab-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, hsla(var(--hue), 80%, 22%, 0.7), #060310 80%);
  border: 1.5px solid hsla(var(--hue), 90%, 60%, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* scanline sheen inside each little screen */
.cab-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.22) 3px 3px);
  opacity: 0.4;
  pointer-events: none;
}

.cab-art {
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cab-art svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cab-art--soon {
  font-family: var(--font-logo);
  font-size: 3rem;
  color: hsla(var(--hue), 90%, 70%, 0.5);
  filter: drop-shadow(0 0 12px hsla(var(--hue), 90%, 60%, 0.4));
}

.cab-plate {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 0.2rem;
}

.cab-name {
  font-family: var(--font-logo);
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 0 12px var(--glow-soft);
}

.cab-tag {
  font-family: var(--font-pixel);
  font-size: 0.46rem;
  letter-spacing: 0.06em;
  color: hsl(var(--hue), 90%, 72%);
}

.cab-badge {
  position: absolute;
  top: -9px;
  right: 12px;
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  padding: 5px 8px;
  border-radius: 7px;
  color: #1a0616;
  background: var(--gold);
  box-shadow: 0 0 14px rgba(255, 210, 60, 0.7);
  transform: rotate(6deg);
  animation: badge-bob 1.4s ease-in-out infinite;
}

@keyframes badge-bob {
  50% {
    transform: rotate(6deg) translateY(-3px);
  }
}

/* hover / keyboard-selected state */
.cab:hover,
.cab.selected {
  transform: translateY(-8px) scale(1.03);
  border-color: var(--glow);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55), 0 0 34px var(--glow-soft),
    inset 0 0 26px hsla(var(--hue), 90%, 60%, 0.12);
}

.cab--soon {
  cursor: default;
  filter: saturate(0.6);
  opacity: 0.7;
}

.cab--soon:hover {
  transform: none;
  border-color: hsla(var(--hue), 90%, 62%, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Launch: dive into the game */
.cab.launching {
  transform: translateY(-6px) scale(1.34);
  z-index: 40;
  filter: brightness(1.7) saturate(1.2);
  transition: transform 0.4s cubic-bezier(0.5, 0, 0.9, 0.4), filter 0.4s ease;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 200;
  /* Dive to dark (not white) so the transition stays on-theme */
  background: radial-gradient(circle at 50% 45%, #241155 0%, #05030c 68%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.34s ease;
}
.flash.on {
  opacity: 1;
}

/* Konami rainbow party */
body.rainbow {
  animation: rainbow 1.1s linear infinite;
}
@keyframes rainbow {
  to {
    filter: hue-rotate(360deg);
  }
}

/* ============================================================
   Control hint
   ============================================================ */
.hint {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  margin: 2rem auto 0;
  padding: 9px 20px;
  border-radius: 999px;
  background: rgba(10, 6, 22, 0.72);
  border: 1px solid rgba(155, 107, 255, 0.35);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  color: #a99bd6;
  opacity: 0;
  animation: pop-in 0.6s ease 0.7s forwards;
}

.hint .keys b {
  display: inline-block;
  padding: 4px 6px;
  margin: 0 1px;
  border-radius: 5px;
  background: rgba(155, 107, 255, 0.16);
  border: 1px solid rgba(155, 107, 255, 0.4);
  color: #cbb8ff;
}

/* ============================================================
   Bottom marquee ticker
   ============================================================ */
.ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  height: 34px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 10, 40, 0.95), rgba(8, 4, 18, 0.98));
  border-top: 2px solid rgba(255, 60, 166, 0.5);
  box-shadow: 0 -6px 24px rgba(255, 60, 166, 0.18);
}

.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  will-change: transform;
  animation: ticker-scroll 26s linear infinite;
}

.ticker-track span {
  padding: 0 1.4rem;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

@keyframes pop-in {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .floor,
  .logo,
  .bulb,
  .dot,
  .badge,
  .cab-badge,
  .ticker-track,
  .marquee,
  .cab,
  .hint {
    animation: none !important;
  }
  .marquee,
  .cab,
  .hint {
    opacity: 1;
    transform: none;
  }
}
