/* The hidden attribute's default `display: none` is a browser-stylesheet
   rule, which any of this file's own `display` declarations below silently
   overrides (author styles beat the browser default regardless of selector
   specificity) — so every element toggled via `.hidden = true/false` in JS
   needs this guard, or it stays visible/laid-out even while "hidden". */
[hidden] {
  display: none !important;
}

.games-intro {
  padding: 64px 0 32px;
  background: radial-gradient(circle at 50% 0%, var(--lighter-background), var(--background) 70%);
}

.games-intro h1 {
  font-size: 2.5rem;
  color: var(--foreground);
}

.games-intro .tagline {
  margin-top: 8px;
  color: var(--cyan);
  font-size: 1.1rem;
}

.game-room {
  padding: 16px 0 80px;
}

.game-room-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

/* --- Console (old-school top-loader look) --- */

.console {
  --shell-light: #e4dfd0;
  --shell: #cdc7b6;
  --shell-dark: #a19b8a;
  --shell-deck: #4a473e;
  --shell-ink: #2c2a24;
  --accent-maroon: #7c1f2b;

  width: 100%;
  max-width: 760px;
  background: linear-gradient(180deg, var(--shell-light) 0%, var(--shell) 55%, var(--shell-dark) 100%);
  border: 1px solid #8a8474;
  border-radius: 16px 16px 30px 30px;
  padding: 18px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
}

.console::before {
  /* maroon accent band, classic top-loader trim */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 54px;
  height: 8px;
  background: linear-gradient(180deg, var(--accent-maroon), #591620);
}

.console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.console-brand {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--shell-ink);
}

.console-brand em {
  font-style: normal;
  font-weight: 400;
  font-size: 0.6rem;
  color: #5b5646;
  letter-spacing: 0.12em;
  margin-left: 6px;
}

.console-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5c1219;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.6);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.console.powered-on .console-led {
  background: #ff4136;
  box-shadow: 0 0 8px 2px rgba(255, 65, 54, 0.7), inset 0 0 2px rgba(0, 0, 0, 0.3);
}

.console-vents {
  position: absolute;
  top: 24px;
  right: 45px; /* clears the "Power" LED to its right — was overlapping it by ~5px at 28px */
  width: 60px;
  height: 10px;
  background: repeating-linear-gradient(
    90deg,
    var(--shell-dark) 0,
    var(--shell-dark) 3px,
    transparent 3px,
    transparent 8px
  );
  opacity: 0.7;
}

.console-slot {
  height: 30px;
  margin: 22px auto 18px;
  max-width: 440px;
  background: linear-gradient(180deg, #3a382f, #1c1a16);
  border-radius: 4px;
  border: 1px solid #171510;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: box-shadow 0.15s ease, background 0.15s ease;
  color: #cfc9b8;
  font-family: monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.console-slot .slot-opening {
  width: 46px;
  height: 4px;
  background: #030302;
  border-radius: 2px;
}

.console-slot.slot-hover {
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6), 0 0 0 2px var(--accent), 0 1px 0 rgba(255, 255, 255, 0.3);
  color: var(--accent, #faa968);
}

.console-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--background);
  border-radius: 6px;
  border: 10px solid var(--shell-ink);
  box-shadow: inset 0 0 0 2px #000, inset 0 2px 12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* Fullscreen swaps the fixed 3:2 box for the full viewport. The canvas
   itself (not just its painted content) needs to stay 3:2 and fit within
   whichever dimension is tighter — object-fit only scales what's *drawn*
   inside the box, not the box itself, so getBoundingClientRect() would
   still report the full unshaped viewport and throw off click-position
   mapping in the picker screens. This is the standard max-width/max-height
   cross-cap trick: each dimension is capped by a calc() derived from the
   *other* live viewport dimension, so whichever one is actually the
   constraint wins and the box resolves to a real 3:2 rectangle. */
.console-screen:fullscreen,
.console-screen:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.console-screen:fullscreen #game-canvas,
.console-screen:-webkit-full-screen #game-canvas {
  width: 100vw;
  height: 100vh;
  max-width: calc(100vh * 3 / 2);
  max-height: calc(100vw * 2 / 3);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#game-canvas:focus {
  outline: none;
}

/* Shown briefly while a cartridge is "being read," between the click sound
   and the game actually starting — solid gray so it's clearly a in-progress
   blank, not mistaken for the console being off (NO SIGNAL static/black). */
.screen-blank {
  position: absolute;
  inset: 0;
  background: #4d4d4d;
}

.screen-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-family: monospace;
  letter-spacing: 0.1em;
}

.screen-placeholder p {
  margin: 0;
}

.placeholder-off {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.placeholder-off canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.static-scanlines {
  /* Oversized and translated on a diagonal so the sweep never reveals an
     edge, like interference bars drifting across old TV static. */
  position: absolute;
  inset: -20%;
  background: repeating-linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.14) 0px,
    rgba(255, 255, 255, 0.14) 2px,
    transparent 2px,
    transparent 14px
  );
  animation: static-scroll 1.4s linear infinite;
  mix-blend-mode: overlay;
  pointer-events: none;
}

@keyframes static-scroll {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(40px, 40px);
  }
}

.placeholder-off-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(2, 12, 23, 0.8);
  padding: 10px 18px;
  border-radius: 4px;
}

.placeholder-off-text p:first-child {
  color: var(--foreground);
  font-weight: 700;
}

.placeholder-boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.placeholder-boot #boot-logo-canvas {
  width: 120px;
  height: 120px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.placeholder-boot p {
  color: var(--light-foreground);
  font-size: 0.85rem;
  animation: boot-blink 1.1s steps(1) infinite;
}

@keyframes boot-blink {
  50% {
    opacity: 0.35;
  }
}

.hud {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud #hud-title {
  color: var(--light-foreground);
  font-size: 0.7rem;
  font-family: monospace;
  letter-spacing: 0.08em;
  background: rgba(2, 12, 23, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
}

.console-controls {
  margin-top: 16px;
  text-align: center;
}

.console-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}

.console-btn {
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f0ece0;
  background: linear-gradient(180deg, #6b6a63, #38372f);
  border: 1px solid #24231d;
  border-radius: 999px;
  padding: 7px 18px;
  box-shadow: 0 2px 0 #1a1913, inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

button.console-btn {
  cursor: pointer;
}

button.console-btn:hover {
  filter: brightness(1.15);
}

button.console-btn:active {
  box-shadow: 0 0 0 #1a1913, inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translateY(2px);
}

.console-btn-power {
  /* Same maroon as the accent band across the top of the console. */
  background: linear-gradient(180deg, var(--accent-maroon), #591620);
}

.console-controls p {
  color: var(--shell-ink, #2c2a24);
  font-size: 0.8rem;
  opacity: 0.85;
}

/* --- Cartridge shelf --- */

.cartridge-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
}

.cartridge {
  --cart-shell: #d6d1c2;
  --cart-shell-dark: #a6a190;

  width: 116px;
  height: 148px;
  cursor: grab;
  position: relative;
  margin-top: 10px;
  background: linear-gradient(180deg, var(--cart-shell), var(--cart-shell-dark));
  border: 1px solid #78735f;
  border-radius: 5px 5px 9px 9px;
  padding: 10px 9px 16px;
  display: flex;
  align-items: stretch;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 6px 14px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cartridge::before {
  /* thumb notch */
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 10px;
  background: var(--cart-shell-dark);
  border-radius: 4px 4px 0 0;
  border: 1px solid #78735f;
  border-bottom: none;
}

.cartridge::after {
  /* connector ridges */
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 6px;
  height: 10px;
  border-radius: 0 0 3px 3px;
  background: repeating-linear-gradient(90deg, #45423a 0 3px, #58544a 3px 6px);
}

.cartridge:hover {
  transform: translateY(-4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 12px 22px rgba(0, 0, 0, 0.4);
}

.cartridge:active,
.cartridge.dragging {
  cursor: grabbing;
  opacity: 0.7;
}

.cartridge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cartridge-label {
  width: 100%;
  border-radius: 3px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  border: 3px solid var(--label-border, var(--teal));
  background: #f4efe0;
}

.cartridge-title {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: #211f1a;
  line-height: 1.15;
}

.cartridge-sub {
  font-size: 0.55rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6b6656;
}

.cartridge-asteroids {
  --label-border: var(--green);
}

.cartridge-coolcars {
  --label-border: var(--red);
}

.cartridge-lavalamp {
  --label-border: var(--cyan);
}

/* --- Cool Cars Konami-code cheat-unlock toast --- */

.cheat-unlock-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 1000;
  padding: 14px 22px;
  background: var(--lighter-background);
  color: var(--foreground);
  border: 2px solid var(--accent);
  border-radius: 10px;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cheat-unlock-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
