/* ════════════════════════════════════════════════════
   EAST COAST RACER — style.css
   ════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:  #f5c518;
  --dark:  #1a0a00;
  --white: #ffffff;
  --font:  'Press Start 2P', monospace;
}

html, body {
  width: 100%; height: 100%;
  background: #0a0a0a;
  display: flex; justify-content: center; align-items: center;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#wrapper {
  position: relative;
  width: 420px; height: 780px;
  overflow: hidden;
  background: #000;
}

/* ── Screens ───────────────────────────────────────── */
.screen { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 10; }
.screen.hidden { display: none !important; }
#screen-game { display: flex; flex-direction: column; z-index: 1; }
#screen-game.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   MENU
   ════════════════════════════════════════════════════ */
#screen-menu { cursor: pointer; z-index: 20; }

#menu-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  image-rendering: pixelated;
}

#menu-logo {
  position: absolute;
  bottom: 490px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%; max-width: 390px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.55));
  z-index: 2;
}

#menu-car {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  image-rendering: pixelated;
  z-index: 4;
}

#menu-btn {
  position: absolute; bottom: 120px; left: 50%;
  transform: translateX(-50%);
  width: 70%; max-width: 300px;
  image-rendering: pixelated;
  z-index: 4; cursor: pointer;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 99% { opacity: 0; }
}
.blink { animation: blink 1s step-start infinite; }

/* ════════════════════════════════════════════════════
   GAME SCREEN
   ════════════════════════════════════════════════════ */
#game-canvas {
  display: block;
  width: 420px;
  flex: 1 1 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud-divider {
  display: block;
  width: 100%;
  height: 18px;
  object-fit: fill;
  flex-shrink: 0;
  image-rendering: pixelated;
}

#hud {
  width: 100%;
  height: 110px;
  flex-shrink: 0;
  background: url('assets/image/sunset_background.png') center top / 100% auto no-repeat;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
}

#hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#hud-driver {
  font-family: var(--font);
  font-size: 10px;
  color: var(--dark);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#btn-restart {
  background: none;
  border: none;
  box-shadow: none;
  font-size: 38px;
  color: var(--dark);
  cursor: pointer;
  padding: 0; margin: 0;
  line-height: 1;
  flex-shrink: 0;
  align-self: center;
  transition: transform 0.15s;
}
#btn-restart:hover  { transform: rotate(-30deg); background: none; }
#btn-restart:active { transform: rotate(-180deg); }

#hud-dist {
  font-family: var(--font);
  font-size: 20px;
  color: var(--dark);
  letter-spacing: 1px;
  align-self: center;
}

/* ════════════════════════════════════════════════════
   GAME OVER
   ════════════════════════════════════════════════════ */
#screen-gameover { z-index: 15; background: var(--gold); }
#go-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
#go-content {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px; padding: 40px;
  text-align: center;
  background: rgba(0,0,0,0.62);
}
#go-title {
  font-family: var(--font);
  font-size: 40px; color: var(--gold);
  text-shadow: 4px 4px 0 #7a5500, -2px -2px 0 #000;
  margin-bottom: 20px;
}
.go-row { display: flex; gap: 20px; align-items: center; }
.go-label { font-family: var(--font); font-size: 11px; color: #aaa; letter-spacing: 2px; }
.go-val   { font-family: var(--font); font-size: 20px; color: var(--white); letter-spacing: 2px; }

/* ── Buttons ───────────────────────────────────────── */
button {
  font-family: var(--font);
  font-size: 13px; padding: 14px 32px;
  background: var(--gold); color: var(--dark);
  border: 4px solid var(--dark);
  cursor: pointer; letter-spacing: 2px;
  box-shadow: 4px 4px 0 #7a5500;
  transition: transform 0.07s, box-shadow 0.07s;
  margin-top: 8px;
}
button:hover  { background: #ffd93d; }
button:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 #7a5500; }
button.btn-sec {
  background: transparent; color: var(--white);
  border-color: var(--white); box-shadow: 4px 4px 0 #555;
  font-size: 11px; padding: 10px 24px;
  width: 100%; box-sizing: border-box;
}
button.btn-sec:hover { background: rgba(255,255,255,0.1); }

/* ════════════════════════════════════════════════════
   NAME ENTRY
   ════════════════════════════════════════════════════ */
#name-bg, #lb-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
}
#name-content, #lb-content {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 30px 20px;
}
#name-logo {
  width: 85%; max-width: 360px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  margin-bottom: 8px;
}
#name-prompt {
  font-family: var(--font);
  font-size: 11px; color: var(--dark);
  letter-spacing: 2px;
}
#name-display {
  font-family: var(--font);
  font-size: 28px; color: var(--dark);
  letter-spacing: 10px;
  background: rgba(0,0,0,0.15);
  padding: 12px 20px;
  border: 3px solid var(--dark);
  min-width: 240px; text-align: center;
}
#name-keyboard { width: 100%; }
.kb-row {
  display: flex; justify-content: center;
  gap: 5px; margin-bottom: 5px;
}
.kb-key {
  font-family: var(--font);
  font-size: 10px;
  width: 40px; height: 36px;
  padding: 0; margin: 0;
  background: var(--dark); color: var(--gold);
  border: 2px solid var(--gold);
  box-shadow: 2px 2px 0 #7a5500;
  cursor: pointer; letter-spacing: 0;
}
.kb-key:hover  { background: #2a1a00; }
.kb-key:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 #7a5500; }
.kb-del {
  width: 52px;
  background: #5a0000; color: #ffaaaa;
  border-color: #ffaaaa;
}
.kb-go {
  width: 120px; height: 40px;
  background: var(--gold); color: var(--dark);
  font-size: 13px;
  box-shadow: 3px 3px 0 #7a5500;
}

#btn-name-back {
  font-family: var(--font);
  font-size: 8px;
  background: transparent;
  border: 2px solid var(--dark);
  color: var(--dark);
  padding: 6px 18px;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: 1px;
}
#btn-name-back:hover { background: rgba(0,0,0,0.1); }

/* ════════════════════════════════════════════════════
   LEADERBOARD
   ════════════════════════════════════════════════════ */
#lb-title {
  font-family: var(--font);
  font-size: 22px; color: var(--dark);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.2);
  margin-bottom: 8px;
}
#lb-list {
  width: 100%;
  display: flex; flex-direction: column; gap: 6px;
}
.lb-row {
  display: flex; align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.15);
  padding: 8px 14px;
  border-left: 4px solid var(--dark);
}
.lb-rank { font-family: var(--font); font-size: 9px; color: var(--dark); width: 24px; }
.lb-name { font-family: var(--font); font-size: 12px; color: var(--dark); flex: 1; margin-left: 10px; }
.lb-score { font-family: var(--font); font-size: 12px; color: var(--dark); }
.lb-row.lb-gold   { border-color: #b8860b; background: rgba(255,215,0,0.25); }
.lb-row.lb-silver { border-color: #888; background: rgba(192,192,192,0.2); }
.lb-row.lb-bronze { border-color: #cd7f32; background: rgba(205,127,50,0.2); }

/* ════════════════════════════════════════════════════
   PIN SCREEN
   ════════════════════════════════════════════════════ */
#pin-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
#pin-content {
  position: relative; z-index: 2;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 30px 20px;
}
#pin-logo { width: 75%; max-width: 320px; image-rendering: pixelated; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5)); }
#pin-prompt { font-family: var(--font); font-size: 11px; color: var(--dark); letter-spacing: 2px; }
#pin-sub { font-family: var(--font); font-size: 7px; color: var(--dark); opacity: 0.7; text-align: center; line-height: 1.6; }
#pin-display {
  font-family: var(--font); font-size: 32px; color: var(--dark);
  letter-spacing: 14px; background: rgba(0,0,0,0.15);
  padding: 12px 24px; border: 3px solid var(--dark);
  min-width: 180px; text-align: center;
}
#pin-error { font-family: var(--font); font-size: 8px; color: #cc0000; min-height: 16px; text-align: center; }
#pin-keyboard { width: 70%; max-width: 240px; }
.pin-key {
  font-family: var(--font); font-size: 13px;
  width: 60px; height: 48px; padding: 0; margin: 3px;
  background: var(--dark); color: var(--gold);
  border: 2px solid var(--gold); box-shadow: 2px 2px 0 #7a5500;
  cursor: pointer;
}
.pin-key:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 #7a5500; }
.pin-key.kb-del { background: #5a0000; color: #ffaaaa; border-color: #ffaaaa; font-size: 9px; }
.pin-key.kb-go  { background: var(--gold); color: var(--dark); font-size: 9px; }
#btn-pin-back {
  font-family: var(--font); font-size: 8px;
  background: transparent; border: 2px solid var(--dark);
  color: var(--dark); padding: 6px 18px; cursor: pointer; margin-top: 4px;
}

#btn-menu-leaderboard {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: var(--gold);
  border: 3px solid var(--dark);
  color: var(--dark);
  font-size: 10px;
  padding: 8px 24px;
  box-shadow: 3px 3px 0 #7a5500;
  letter-spacing: 2px;
  white-space: nowrap;
}
#btn-menu-leaderboard:hover { background: #ffd93d; }

#btn-lb-retry {
  font-family: var(--font);
  font-size: 10px;
  background: var(--gold);
  border: 3px solid var(--dark);
  color: var(--dark);
  padding: 10px 28px;
  box-shadow: 3px 3px 0 #7a5500;
  cursor: pointer;
  margin-top: 8px;
}
#btn-lb-retry.hidden { display: none; }

#btn-name-back {
  font-family: var(--font);
  font-size: 8px;
  background: transparent;
  border: 2px solid var(--dark);
  color: var(--dark);
  padding: 6px 18px;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: 1px;
}
#btn-name-back:hover { background: rgba(0,0,0,0.1); }