/* Edge Rush - played up close on the cabinet from the arcade hall (lime machine). */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --room: #120a24;
  --plastic: #0b0716;
  --glow: #b6ff3b;           /* this machine's colour on the front page */
  --glow-rgb: 182, 255, 59;
  --cyan: #36e4ff;
  --pink: #ff4fa3;
  --sun: #ffd23f;
  --ink: #f4efff;
  --muted: #8f84b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(var(--glow-rgb), 0.10), transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(120, 60, 220, 0.35), transparent 70%),
    var(--room);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cabinet {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 10px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Top strip: back, score, lives, sound */
.cab-top {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  height: 52px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #3a2a66;
  background: #1a1030;
  color: var(--ink);
  font: 700 1.2rem/1 'Space Grotesk', sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--glow); }
.icon-btn:focus-visible, .start-btn:focus-visible { outline: 2px solid var(--sun); outline-offset: 3px; }

.scoreline {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 18px;
  font-family: 'Press Start 2P', monospace;
  font-variant-numeric: tabular-nums;
}

.score {
  font-size: clamp(0.95rem, 3.4vw, 1.3rem);
  font-weight: 400;
  color: #fff;
  text-shadow: 0 0 10px rgba(var(--glow-rgb), 0.8);
}

.best {
  font-size: clamp(0.55rem, 2vw, 0.72rem);
  color: var(--sun);
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.6);
}

.lives { display: flex; gap: 7px; }

.life {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 8px rgba(var(--glow-rgb), 0.8);
  transition: background .2s, box-shadow .2s;
}

.life.lost {
  background: transparent;
  border: 2px solid var(--pink);
  box-shadow: 0 0 6px rgba(255, 79, 163, 0.6);
}

/* Cabinet bezel around the CRT */
.bezel {
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1a1230, var(--plastic));
  box-shadow:
    inset 3px 0 0 var(--glow),
    inset -3px 0 0 var(--glow),
    0 0 40px rgba(var(--glow-rgb), 0.18);
}

.screen {
  position: relative;
  width: min(100%, calc(100dvh - 120px));
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 18px / 22px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #0d1b33 0%, #04060f 85%);
  box-shadow: 0 0 0 4px #000, 0 0 26px rgba(var(--glow-rgb), 0.35), inset 0 0 40px rgba(0, 0, 0, 0.9);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

/* Scanlines and glass highlight */
.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 40% at 30% 10%, rgba(255, 255, 255, 0.07), transparent 70%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 2px, transparent 2px 4px);
  z-index: 3;
}

#arena { display: block; width: 100%; height: 100%; }

.screen.shake { animation: shake .28s; }

@keyframes shake {
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
}

/* Attract / game-over cards drawn on the screen */
.attract {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 4vw, 26px);
  padding: 20px;
  text-align: center;
  background: rgba(6, 4, 16, 0.78);
}

.attract.hidden { display: none; }

.attract__title {
  margin: 0;
  font: 400 clamp(1.3rem, 6vw, 2.4rem)/1.2 'Press Start 2P', monospace;
  color: #fff;
  text-shadow: 0 0 12px var(--glow), 3px 3px 0 #3d1a6e;
}

.attract__title--over { color: var(--pink); text-shadow: 0 0 12px var(--pink), 3px 3px 0 #3d1a6e; }

.attract__how {
  display: grid;
  gap: 10px;
  font: 400 clamp(0.5rem, 1.9vw, 0.68rem)/1.6 'Press Start 2P', monospace;
  color: #d9d0f5;
}

.attract__how p { margin: 0; }

.key {
  display: inline-block;
  min-width: 1.9em;
  padding: 0.25em 0.45em;
  margin-right: 0.35em;
  border: 1px solid rgba(var(--glow-rgb), 0.7);
  border-radius: 4px;
  color: var(--glow);
}

/* Touch screens don't need the keyboard lines */
@media (hover: none) { .attract__how .desk { display: none; } }

.final {
  margin: 0;
  font: 400 clamp(1.6rem, 7vw, 2.8rem) 'Press Start 2P', monospace;
  color: #fff;
  text-shadow: 0 0 14px rgba(var(--glow-rgb), 0.9);
}

.start-btn {
  font: 400 clamp(0.7rem, 2.6vw, 0.9rem) 'Press Start 2P', monospace;
  color: #160b2b;
  background: var(--glow);
  border: 0;
  border-radius: 6px;
  padding: 14px 20px;
  cursor: pointer;
  box-shadow: 0 5px 0 #4f7a0c, 0 0 22px rgba(var(--glow-rgb), 0.6);
  animation: blink 1.2s steps(1, end) infinite;
}

#again { font-size: 1.6rem; padding: 10px 22px; animation: none; }

.start-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #4f7a0c; }

@keyframes blink { 50% { filter: brightness(0.75); } }

@media (max-width: 480px) {
  .cabinet { padding: 6px 8px 12px; gap: 8px; }
  .cab-top { gap: 8px; height: 46px; }
  .icon-btn { width: 34px; height: 34px; }
  .bezel { padding: 8px; }
  .life { width: 10px; height: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .start-btn { animation: none; }
  .screen.shake { animation: none; }
}

/* The screen takes keyboard focus so arrow keys work; the cabinet glow already shows it */
.screen:focus { outline: none; }

/* Coin gate (v4) */
.cab-top { grid-template-columns: auto 1fr auto auto auto; }

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #160b2b;
  background: var(--sun);
  box-shadow: 0 5px 0 #8a6200, 0 0 22px rgba(255, 210, 63, 0.6);
}

.start-btn:active { box-shadow: 0 1px 0 #8a6200; }
#again { font-size: clamp(0.7rem, 2.6vw, 0.9rem); padding: 14px 20px; }
.start-btn[hidden], .get-coins[hidden] { display: none; }

.get-coins {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 6px;
  border: 2px solid var(--sun);
  background: rgba(40, 24, 6, 0.7);
  color: #ffe58a;
  font: 400 clamp(0.7rem, 2.6vw, 0.9rem) 'Press Start 2P', monospace;
  text-decoration: none;
}

.get-coins:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.start-btn .coin-icon, .get-coins .coin-icon { width: 22px; height: 22px; }
.start-btn .coin-icon::after, .get-coins .coin-icon::after { inset: 6px; }

@media (max-width: 480px) {
  .cab-top .coin-chip { height: 30px; padding: 0 9px 0 6px; font-size: 0.6rem; gap: 6px; }
  .cab-top .coin-chip .coin-icon { width: 14px; height: 14px; }
  .cab-top .coin-chip .coin-icon::after { inset: 3.5px; }
  .scoreline .best { display: none; }
}
