/* ==========================================================================
   Midnight Taxi — stylesheet
   Palette: near-black navy base, taxi-yellow accent, pink/cyan neon trim.
   Type: Oxanium (display / titles) + Rajdhani (HUD numerals & labels).
   ========================================================================== */

:root {
  --bg-deep: #05060c;
  --bg-panel: rgba(9, 12, 22, 0.68);
  --bg-panel-strong: rgba(8, 10, 18, 0.88);
  --line: rgba(255, 255, 255, 0.09);
  --neon-pink: #ff2e88;
  --neon-cyan: #22e5ff;
  --taxi-yellow: #ffd23f;
  --warm-amber: #ffb347;
  --text-primary: #eef1ff;
  --text-dim: #93a0c2;
  --danger: #ff4d4d;
  --success: #5cffa8;
  --font-display: 'Oxanium', 'Rajdhani', sans-serif;
  --font-hud: 'Rajdhani', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg-deep);
  overflow: hidden;
  font-family: var(--font-hud);
  color: var(--text-primary);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#app {
  position: fixed; inset: 0; width: 100%; height: 100%;
  overflow: hidden;
}

#gameCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  background: #05060c;
}

.hidden { display: none !important; }

/* --------------------------------------------------------------------- */
/* Diagnostic watchdog banner (shown only if the game fails to boot)     */
/* --------------------------------------------------------------------- */
.diag-banner {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 4, 8, 0.92);
  padding: 24px;
}
.diag-inner {
  max-width: 640px; width: 100%;
  background: #12141f;
  border: 1px solid rgba(255, 77, 77, 0.4);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 0 40px rgba(255, 46, 136, 0.15);
}
.diag-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  color: var(--danger);
  margin-bottom: 12px;
}
.diag-message {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Courier New', monospace;
  font-size: 12.5px; line-height: 1.6;
  color: var(--text-dim);
  max-height: 50vh; overflow-y: auto;
  margin: 0 0 16px 0;
}
.diag-close {
  appearance: none; border: none; cursor: pointer;
  padding: 8px 16px; border-radius: 8px;
  background: rgba(255,255,255,0.08); color: var(--text-primary);
  font-family: var(--font-hud); font-size: 13px;
}

/* --------------------------------------------------------------------- */
/* Shared overlay-screen scaffolding (start / loading / pause)            */
/* --------------------------------------------------------------------- */
.overlay-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  padding: 32px 20px;
  text-align: center;
  z-index: 50;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 46, 136, 0.12), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(34, 229, 255, 0.10), transparent 55%),
    linear-gradient(180deg, #060810 0%, #0a0c18 60%, #0d0a16 100%);
}

/* ---------------------------------- start screen ---------------------- */
.title-wrap { max-width: 560px; }
.eyebrow {
  font-family: var(--font-hud);
  letter-spacing: 0.35em;
  font-size: 11px;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(34, 229, 255, 0.6);
  margin-bottom: 10px;
}
.game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 11vw, 86px);
  line-height: 0.95;
  margin: 0;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  text-shadow: 0 0 24px rgba(255, 210, 63, 0.25);
}
.game-title span {
  display: block;
  color: var(--taxi-yellow);
  text-shadow: 0 0 18px rgba(255, 210, 63, 0.75), 0 0 46px rgba(255, 46, 136, 0.35);
}
.tagline {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
}

.start-panel {
  width: min(360px, 90vw);
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 10px;
}
.seed-label { font-size: 12px; color: var(--text-dim); text-align: left; }
.seed-label .hint { opacity: 0.7; }
#seedInput {
  width: 100%; padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-hud);
  font-size: 14px;
  outline: none;
}
#seedInput:focus { border-color: var(--neon-cyan); }

.cta-btn {
  appearance: none; border: none; cursor: pointer;
  padding: 13px 20px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: #10121c;
  background: linear-gradient(135deg, var(--taxi-yellow), var(--warm-amber));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 6px 24px rgba(255, 179, 71, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta-btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255,255,255,0.12) inset, 0 10px 28px rgba(255, 179, 71, 0.35); }
.cta-btn:active { transform: translateY(0); }
.cta-btn.ghost-btn {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 1px var(--line) inset;
}

.controls-legend {
  display: flex; gap: 40px; flex-wrap: wrap; justify-content: center;
  font-size: 13px; color: var(--text-dim);
  max-width: 560px;
}
.legend-title { color: var(--neon-cyan); font-weight: 600; margin-bottom: 6px; letter-spacing: 0.06em; text-transform: uppercase; font-size: 11px; }
.legend-row { margin: 3px 0; display: flex; align-items: center; gap: 6px; }
kbd {
  display: inline-block; min-width: 18px; text-align: center;
  padding: 2px 6px; border-radius: 5px;
  background: rgba(255,255,255,0.08); border: 1px solid var(--line);
  font-family: var(--font-hud); font-size: 11px; color: var(--text-primary);
}

/* ---------------------------------- loading screen --------------------- */
.loader-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--taxi-yellow);
  border-right-color: var(--neon-pink);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--font-display); font-size: 18px; letter-spacing: 0.04em; }
.dots span { animation: blink 1.2s infinite; opacity: 0; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 20% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
.loading-sub { color: var(--text-dim); font-size: 12px; }

/* ---------------------------------- pause screen ------------------------ */
.pause-screen { z-index: 60; background: rgba(3, 4, 8, 0.82); backdrop-filter: blur(6px); }
.pause-title { font-family: var(--font-display); font-size: 34px; margin: 0; color: var(--text-primary); }
.music-toggle { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.pause-hint { font-size: 12px; color: var(--text-dim); }

/* --------------------------------------------------------------------- */
/* HUD                                                                    */
/* --------------------------------------------------------------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.panel {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

/* top-left: money / level / district */
.top-left { top: 14px; left: 14px; min-width: 180px; }
.money-row {
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  color: var(--taxi-yellow); text-shadow: 0 0 14px rgba(255,210,63,0.35);
  display: flex; align-items: baseline; gap: 2px;
}
.dollar { font-size: 16px; opacity: 0.75; }
.level-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.level-tag { font-size: 11px; color: var(--text-dim); letter-spacing: 0.04em; white-space: nowrap; }
.level-tag b { color: var(--neon-cyan); }
.xp-track { flex: 1; height: 5px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.xp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink)); transition: width 0.25s ease; }
.location-row { margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.dot-sep { margin: 0 5px; opacity: 0.5; }

/* mission panel top-center */
.mission-panel {
  top: 14px; left: 50%; transform: translateX(-50%);
  min-width: 220px; text-align: center;
}
.fare-state { font-family: var(--font-display); font-size: 14px; letter-spacing: 0.02em; color: var(--text-primary); }
.timer-wrap { margin-top: 8px; }
.timer-track { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--neon-cyan); transition: width 0.2s linear, background 0.3s ease; }
.combo-wrap { margin-top: 8px; font-size: 12px; color: var(--warm-amber); letter-spacing: 0.06em; }
.combo-label { color: var(--text-dim); margin-right: 6px; }
#comboVal { font-family: var(--font-display); font-weight: 700; }

/* toasts */
.toasts {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 7px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--bg-panel-strong);
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: opacity 0.3s ease;
}
.toast-success { color: var(--success); border-color: rgba(92,255,168,0.3); }
.toast-bonus { color: var(--neon-cyan); border-color: rgba(34,229,255,0.3); }
.toast-warn { color: var(--danger); border-color: rgba(255,77,77,0.3); }
.toast-level { color: var(--taxi-yellow); border-color: rgba(255,210,63,0.3); }
.toast-pickup { color: var(--text-primary); }
.toast-info { color: var(--text-dim); }

/* minimap */
.minimap {
  position: absolute; top: 14px; right: 14px;
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}

/* health / boost gauges, above speedo */
.bottom-right-gauges {
  right: 14px; bottom: 148px; left: auto; top: auto;
  width: 168px; display: flex; flex-direction: column; gap: 7px;
}
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.06em; width: 42px; }
.mini-track { flex: 1; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.mini-fill { height: 100%; width: 100%; transition: width 0.2s ease; }
.health-fill { background: linear-gradient(90deg, var(--danger), var(--taxi-yellow)); }
.boost-fill { background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan)); }

/* speedometer */
.speedo {
  position: absolute; right: 10px; bottom: 8px;
  width: 190px; height: 118px;
  pointer-events: none;
}
.speedo-arc { position: absolute; inset: 0; width: 100%; height: 100%; }
.speed-needle {
  position: absolute; left: 100px; top: 108px; width: 3px; height: 66px;
  background: linear-gradient(180deg, var(--text-primary), transparent);
  transform-origin: top center; transform: rotate(-110deg);
  border-radius: 2px;
  transition: transform 0.08s linear;
}
.speed-readout {
  position: absolute; left: 0; right: 0; bottom: 6px; text-align: center;
  font-family: var(--font-display); color: var(--text-primary);
}
.speed-readout span { font-size: 32px; font-weight: 700; }
.speed-readout small { font-size: 11px; color: var(--text-dim); margin-left: 3px; }

/* --------------------------------------------------------------------- */
/* Touch controls                                                        */
/* --------------------------------------------------------------------- */
.joystick {
  position: absolute; left: 22px; bottom: 26px;
  width: 108px; height: 108px;
  pointer-events: auto;
  touch-action: none;
}
.joy-base {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--bg-panel);
  border: 1px solid var(--line);
}
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--taxi-yellow), var(--warm-amber));
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  transition: transform 0.05s linear;
}

.pedal-buttons {
  position: absolute; right: 20px; bottom: 26px;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: auto;
}
.pedal {
  width: 66px; height: 66px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 20px;
  pointer-events: auto;
}
.pedal-gas { color: var(--success); border-color: rgba(92,255,168,0.3); }
.pedal-brake { color: var(--danger); border-color: rgba(255,77,77,0.3); }
.pedal:active { transform: scale(0.94); }

.touch-buttons {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; gap: 10px;
  pointer-events: auto;
}
.tbtn {
  padding: 10px 16px; border-radius: 20px;
  background: var(--bg-panel); border: 1px solid var(--line);
  color: var(--text-primary); font-family: var(--font-hud); font-weight: 600;
  font-size: 12px; letter-spacing: 0.05em;
  pointer-events: auto;
}
.tbtn-hb { color: var(--neon-pink); border-color: rgba(255,46,136,0.35); }
.tbtn-boost { color: var(--neon-cyan); border-color: rgba(34,229,255,0.35); }
.tbtn:active { transform: scale(0.95); }

/* Hide touch controls on mouse-driven desktops; show on coarse pointers */
@media (hover: hover) and (pointer: fine) {
  .joystick, .pedal-buttons, .touch-buttons { display: none; }
}

/* Small phones: shrink panels a touch */
@media (max-width: 420px) {
  .game-title { font-size: clamp(34px, 13vw, 60px); }
  .minimap { width: 84px; height: 84px; }
  .speedo { width: 160px; height: 100px; }
  .speed-readout span { font-size: 26px; }
  .top-left { min-width: 150px; padding: 8px 10px; }
  .bottom-right-gauges { width: 140px; bottom: 128px; }
}
