/* ==========================================================================
   TramTracker 2088 — Melbourne Yarra Trams 3D Simulator
   UI design system: Yarra Trams green & gold + cyberpunk neon glass HUD
   ========================================================================== */

:root {
  --green: #00853e;
  --green-bright: #00b85c;
  --green-deep: #004a25;
  --gold: #f6c800;
  --gold-hot: #ffdf5c;
  --neon: #46ffd3;
  --neon-soft: rgba(70, 255, 211, 0.22);
  --ice: #d8fff4;
  --ink: #03100c;
  --ink-2: #071a14;
  --panel: rgba(5, 24, 18, 0.74);
  --panel-strong: rgba(4, 18, 14, 0.92);
  --line: rgba(78, 255, 210, 0.22);
  --line-strong: rgba(78, 255, 210, 0.42);
  --text: #e8fff8;
  --muted: #8fb7a9;
  --danger: #ff5577;
  --amber: #ffb340;

  --font-display: "Orbitron", "Arial Black", system-ui, sans-serif;
  --font-body: "Rajdhani", "Trebuchet MS", system-ui, sans-serif;

  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  --glass-blur: blur(18px) saturate(140%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #020806;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button, input { font-family: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

h1, h2, h3, h4, p { margin: 0; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ice);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  vertical-align: middle;
}

#app {
  position: fixed;
  inset: 0;
  isolation: isolate;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(0, 133, 62, 0.28), transparent 65%),
    radial-gradient(900px 500px at 5% 100%, rgba(246, 200, 0, 0.08), transparent 60%),
    #020806;
}

#viewport {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 45%, transparent 45%, rgba(0, 8, 5, 0.44) 100%),
    linear-gradient(180deg, rgba(0, 10, 6, 0.42) 0%, transparent 18%, transparent 74%, rgba(0, 8, 5, 0.6) 100%);
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}

/* --------------------------------------------------------------------------
   Glass primitives
   -------------------------------------------------------------------------- */

.glass {
  background:
    linear-gradient(155deg, rgba(18, 56, 44, 0.78), rgba(4, 20, 15, 0.68) 55%, rgba(3, 16, 12, 0.8));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: relative;
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(70, 255, 211, 0.05), transparent) top / 100% 1px no-repeat,
    radial-gradient(120% 80% at 100% 0%, rgba(246, 200, 0, 0.08), transparent 55%);
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--gold);
  text-transform: uppercase;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 0 0 rgba(70, 255, 211, 0.6);
  animation: livePulse 2.2s ease-out infinite;
  flex: none;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(70, 255, 211, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(70, 255, 211, 0); }
  100% { box-shadow: 0 0 0 0 rgba(70, 255, 211, 0); }
}

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  z-index: 30;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 18px 11px 12px;
  min-width: 290px;
}

.brand-mark {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(150deg, var(--green) 0%, var(--green-deep) 100%);
  border: 1px solid rgba(246, 200, 0, 0.55);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.4), 0 0 18px rgba(0, 133, 62, 0.5);
  overflow: hidden;
  flex: none;
}

.brand-mark span {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.06em;
  z-index: 1;
}

.brand-mark i {
  position: absolute;
  left: -12px;
  right: -12px;
  top: 50%;
  height: 1px;
  background: var(--gold);
  opacity: 0.55;
  transform: rotate(-28deg);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.brand-text h1 em {
  font-style: normal;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(246, 200, 0, 0.45);
}

.brand-text p {
  margin-top: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.weather-switch {
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
}

.weather-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}

.weather-btn span { font-size: 15px; filter: grayscale(0.35); transition: filter 0.2s; }
.weather-btn b {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.14em;
  font-weight: 700;
  text-transform: uppercase;
}

.weather-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.weather-btn.is-active {
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold), #ffb300);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 4px 18px rgba(246, 200, 0, 0.32);
}
.weather-btn.is-active span { filter: none; }

.top-actions {
  display: flex;
  gap: 5px;
  padding: 6px;
  border-radius: 14px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ice);
  font-size: 16px;
  font-family: var(--font-display);
  font-weight: 700;
  transition: 0.2s;
}
.icon-btn:hover { background: rgba(70, 255, 211, 0.12); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn.is-off { color: #6f8a7f; background: rgba(255, 255, 255, 0.02); }

/* --------------------------------------------------------------------------
   Telemetry
   -------------------------------------------------------------------------- */

.telemetry {
  position: fixed;
  top: 108px;
  right: 18px;
  width: 306px;
  z-index: 25;
  padding: 15px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.tel-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.route-chip {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 8px;
  letter-spacing: 0.12em;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.speed-block {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 2px;
}

.speed-ring {
  --pct: 0;
  position: relative;
  width: 102px;
  height: 102px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--panel-strong) 58%, transparent 59%),
    conic-gradient(from 220deg, var(--neon) calc(var(--pct) * 72%), rgba(70, 255, 211, 0.09) 0 72%, transparent 72%);
  filter: drop-shadow(0 0 14px rgba(70, 255, 211, 0.18));
  display: grid;
  place-items: center;
}

.speed-ring::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1px dashed rgba(70, 255, 211, 0.16);
}

.speed-inner { display: grid; place-items: center; gap: 1px; }
.speed-inner strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: var(--ice);
  text-shadow: 0 0 16px rgba(70, 255, 211, 0.4);
  font-variant-numeric: tabular-nums;
}
.speed-inner span {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--muted);
  font-weight: 700;
}

.speed-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.gear {
  align-self: flex-start;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: linear-gradient(145deg, rgba(246, 200, 0, 0.2), rgba(246, 200, 0, 0.04));
  border: 1px solid rgba(246, 200, 0, 0.42);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 14px;
}
.speed-label { font-size: 8px; letter-spacing: 0.2em; color: var(--muted); font-weight: 700; }

.traction-bars { display: flex; gap: 3px; }
.traction-bars i {
  width: 10px;
  height: 4px;
  border-radius: 2px;
  background: rgba(70, 255, 211, 0.13);
  transition: background 0.15s, box-shadow 0.15s;
}
.traction-bars i.on { background: var(--neon); box-shadow: 0 0 7px rgba(70, 255, 211, 0.6); }
.traction-bars i.brake { background: var(--amber); box-shadow: 0 0 7px rgba(255, 179, 64, 0.55); }

.door-state {
  margin-top: 2px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.door-state.open { color: var(--gold); }

.tel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(70, 255, 211, 0.1);
  border: 1px solid rgba(70, 255, 211, 0.12);
  border-radius: 10px;
  overflow: hidden;
}

.tel-cell {
  padding: 8px 10px 9px;
  background: rgba(3, 18, 13, 0.8);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tel-cell span { font-size: 8px; letter-spacing: 0.16em; color: var(--muted); font-weight: 700; }
.tel-cell strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ice);
  font-variant-numeric: tabular-nums;
}
.tel-cell:nth-child(1) strong { color: var(--gold); }

.next-stop {
  border-top: 1px solid rgba(70, 255, 211, 0.14);
  padding-top: 10px;
}

.next-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 700;
}
.next-head b { color: var(--neon); font-size: 10px; letter-spacing: 0.06em; }

.next-name {
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ice);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-track {
  height: 3px;
  margin: 8px 0 6px;
  border-radius: 2px;
  background: rgba(70, 255, 211, 0.12);
  overflow: hidden;
}
.stop-track i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-bright), var(--neon), var(--gold));
  box-shadow: 0 0 8px rgba(70, 255, 211, 0.5);
  transition: width 0.25s linear;
}

.next-hint { font-size: 10px; color: var(--muted); letter-spacing: 0.03em; }

/* --------------------------------------------------------------------------
   Minimap
   -------------------------------------------------------------------------- */

.minimap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 25;
  width: 246px;
  padding: 10px 10px 8px;
  border-radius: 15px;
}

.minimap-head {
  display: flex;
  justify-content: space-between;
  padding: 0 3px 6px;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.minimap-head b { color: var(--gold); letter-spacing: 0.1em; }

#minimap { display: block; width: 100%; height: auto; border-radius: 9px; background: rgba(1, 10, 7, 0.6); }

.minimap-legend {
  display: flex;
  gap: 12px;
  padding: 7px 3px 0;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.minimap-legend span { display: flex; align-items: center; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-tram { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.dot-stop { background: var(--neon); }
.dot-hook { background: #ff5577; }

/* --------------------------------------------------------------------------
   Stop prompt
   -------------------------------------------------------------------------- */

.stop-prompt {
  position: fixed;
  left: 50%;
  bottom: 112px;
  transform: translate(-50%, 18px);
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 380px;
  padding: 10px 15px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  border-color: rgba(246, 200, 0, 0.35);
}
.stop-prompt.show { opacity: 1; transform: translate(-50%, 0); }
.stop-prompt.ready { border-color: var(--neon); box-shadow: 0 0 38px rgba(70, 255, 211, 0.18), var(--shadow); }

.prompt-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(246, 200, 0, 0.12);
  border: 1px solid rgba(246, 200, 0, 0.35);
  font-size: 18px;
}
.prompt-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prompt-copy strong {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--gold);
  white-space: nowrap;
}
.prompt-copy span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.prompt-dist {
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--ice);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Toolbar
   -------------------------------------------------------------------------- */

.toolbar {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 27;
  display: flex;
  gap: 3px;
  padding: 6px;
  border-radius: 15px;
}

.tool-btn {
  min-width: 68px;
  padding: 7px 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: 0.18s;
}
.tool-btn:hover {
  color: var(--ice);
  background: rgba(70, 255, 211, 0.08);
  border-color: rgba(70, 255, 211, 0.2);
  transform: translateY(-2px);
}
.tool-btn:active { transform: translateY(0); }
.tool-icon { font-size: 17px; line-height: 1; filter: saturate(1.2); }
.tool-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tool-label kbd { min-width: 14px; padding: 0 3px; font-size: 8px; border-radius: 3px; }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 560px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px 9px 11px;
  border-radius: 11px;
  background: linear-gradient(140deg, rgba(9, 43, 31, 0.96), rgba(3, 17, 12, 0.94));
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ice);
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.2, 1);
  max-width: 100%;
}
.toast.out { animation: toastOut 0.3s ease forwards; }
.toast b { color: var(--gold); }
.toast .toast-badge {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(246, 200, 0, 0.14);
  border: 1px solid rgba(246, 200, 0, 0.4);
  font-size: 15px;
  flex: none;
}
.toast.danger { border-color: rgba(255, 85, 119, 0.5); }
.toast.danger .toast-badge { background: rgba(255, 85, 119, 0.15); border-color: rgba(255, 85, 119, 0.45); }

@keyframes toastIn { from { opacity: 0; transform: translateY(-12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(0.97); } }

/* --------------------------------------------------------------------------
   Touch controls
   -------------------------------------------------------------------------- */

.touch-controls {
  position: fixed;
  inset: auto 16px 92px 16px;
  z-index: 28;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.touch-controls > * { pointer-events: auto; }
.touch-pad { display: flex; gap: 10px; align-items: flex-end; }
.touch-side { display: flex; gap: 10px; align-items: flex-end; }

.touch-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(4, 25, 18, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ice);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.touch-btn small { font-size: 7px; letter-spacing: 0.14em; color: var(--muted); }
.touch-btn:active, .touch-btn.is-pressed {
  background: rgba(246, 200, 0, 0.22);
  border-color: var(--gold);
  transform: scale(0.95);
}
.touch-throttle { border-color: rgba(70, 255, 211, 0.4); }
.touch-brake { border-color: rgba(255, 179, 64, 0.45); }
.touch-reverse { border-color: rgba(157, 123, 255, 0.55); color: #d9c8ff; }
.touch-bell, .touch-hook { width: 54px; height: 54px; font-size: 18px; }

/* --------------------------------------------------------------------------
   Start screen
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% 40%, rgba(0, 133, 62, 0.22), transparent 65%),
    linear-gradient(180deg, rgba(1, 10, 7, 0.66), rgba(1, 8, 6, 0.9));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  overflow: auto;
}
.overlay.show { display: grid; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.start-card {
  width: min(760px, 100%);
  padding: clamp(24px, 4vw, 46px) clamp(22px, 4vw, 52px);
  border-radius: 26px;
  text-align: center;
  overflow: hidden;
  animation: cardRise 0.6s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes cardRise { from { opacity: 0; transform: translateY(26px) scale(0.98); } to { opacity: 1; transform: none; } }

.start-card::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto;
  height: 230px;
  background: radial-gradient(closest-side, rgba(246, 200, 0, 0.18), transparent 70%);
  pointer-events: none;
}

.start-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(70, 255, 211, 0.05);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.start-title {
  margin: 18px 0 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 6.6vw, 64px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 0.98;
  color: var(--ice);
  text-shadow: 0 0 42px rgba(70, 255, 211, 0.22);
}
.start-title span {
  color: var(--gold);
  text-shadow: 0 0 34px rgba(246, 200, 0, 0.45);
}

.start-sub {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: clamp(9px, 1.4vw, 12px);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--green-bright);
}

.start-lead {
  max-width: 560px;
  margin: 18px auto 0;
  font-size: 14px;
  line-height: 1.55;
  color: #b9d6cb;
}

.start-features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 22px 0;
}
.start-features div {
  padding: 12px 6px 10px;
  border: 1px solid rgba(70, 255, 211, 0.13);
  border-radius: 11px;
  background: rgba(2, 15, 11, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.start-features b { font-size: 19px; }
.start-features span {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.start-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 16px;
  margin: 0 0 24px;
  font-size: 11px;
  color: var(--muted);
}
.start-controls div { display: flex; align-items: center; gap: 4px; }

.primary-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 44px 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold) 0%, #ffb300 100%);
  color: #1b1400;
  box-shadow: 0 12px 34px rgba(246, 200, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.18s, box-shadow 0.18s, filter 0.18s;
  overflow: hidden;
}
.primary-btn::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: btnSheen 4.5s ease-in-out infinite;
}
@keyframes btnSheen { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.primary-btn span { font-family: var(--font-display); font-size: 15px; font-weight: 900; letter-spacing: 0.14em; }
.primary-btn small { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.68; font-weight: 700; }
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(246, 200, 0, 0.35); filter: brightness(1.04); }
.primary-btn:active { transform: translateY(0) scale(0.99); }

.start-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 22px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(70, 255, 211, 0.12);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.start-foot b { color: var(--ice); font-weight: 700; }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(1, 8, 5, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  overflow: auto;
}
.modal.show { display: grid; animation: fadeIn 0.25s ease; }

.modal-card {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 30px 32px 25px;
  border-radius: 22px;
  animation: cardRise 0.34s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.modal-card.wide { width: min(900px, 100%); }

.modal-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: 0.18s;
  z-index: 2;
}
.modal-close:hover { color: var(--ice); background: rgba(255, 85, 119, 0.14); border-color: rgba(255, 85, 119, 0.4); }
.modal-close.inline { position: static; width: 30px; height: 30px; flex: none; }

.modal-card h2 {
  margin: 5px 0 16px;
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 900;
  letter-spacing: 0.02em;
}
.modal-card h3 {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 17px 0 6px;
}
.modal-card h3:first-child { margin-top: 0; }
.modal-card p { font-size: 13.5px; line-height: 1.6; color: #b6d3c7; }
.modal-card code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(70, 255, 211, 0.1);
  color: var(--neon);
  font-size: 12px;
}

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 17px;
  border-top: 1px solid rgba(70, 255, 211, 0.14);
  font-size: 11px;
  color: var(--muted);
}

.ghost-btn {
  padding: 9px 17px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(70, 255, 211, 0.05);
  color: var(--ice);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: 0.18s;
  white-space: nowrap;
}
.ghost-btn:hover { background: rgba(70, 255, 211, 0.13); border-color: var(--neon); }

.career-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.career-stats div {
  padding: 10px 12px;
  border: 1px solid rgba(70, 255, 211, 0.14);
  border-radius: 10px;
  background: rgba(2, 15, 11, 0.55);
}
.career-stats span { display: block; font-size: 8px; letter-spacing: 0.14em; color: var(--muted); font-weight: 700; }
.career-stats b { font-family: var(--font-display); font-size: 17px; color: var(--gold); font-variant-numeric: tabular-nums; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.badge-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(70, 255, 211, 0.12);
  border-radius: 11px;
  background: rgba(2, 15, 11, 0.5);
  opacity: 0.55;
  filter: grayscale(0.8);
  transition: 0.2s;
}
.badge-card.earned {
  opacity: 1;
  filter: none;
  border-color: rgba(246, 200, 0, 0.34);
  background: linear-gradient(140deg, rgba(246, 200, 0, 0.1), rgba(2, 15, 11, 0.5));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.badge-icon {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  font-size: 17px;
}
.badge-card.earned .badge-icon { background: rgba(246, 200, 0, 0.14); box-shadow: 0 0 14px rgba(246, 200, 0, 0.12); }
.badge-copy strong { display: block; font-size: 11.5px; color: var(--ice); letter-spacing: 0.02em; }
.badge-copy span { display: block; margin-top: 2px; font-size: 10px; line-height: 1.3; color: var(--muted); }

/* --------------------------------------------------------------------------
   Hook turn mini-game
   -------------------------------------------------------------------------- */

.hook-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: none;
  background: #04100c;
}
.hook-overlay.show { display: block; animation: fadeIn 0.3s ease; }
#hookCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hook-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 18px max(16px, env(safe-area-inset-bottom));
}
.hook-hud > * { pointer-events: auto; }

.hook-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 13px 16px;
  border-radius: 14px;
  margin: 0 auto;
  width: min(880px, 100%);
}
.hook-top h2 {
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: clamp(15px, 2.2vw, 21px);
  font-weight: 900;
  letter-spacing: 0.04em;
}
.hook-stats { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.hook-stats div { text-align: right; }
.hook-stats span { display: block; font-size: 8px; letter-spacing: 0.16em; color: var(--muted); font-weight: 700; }
.hook-stats b { font-family: var(--font-display); font-size: 18px; color: var(--gold); font-variant-numeric: tabular-nums; }

.hook-phase {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 13px;
  width: min(560px, calc(100% - 36px));
  padding: 12px 16px;
  border-radius: 13px;
  border-color: rgba(246, 200, 0, 0.32);
}
.phase-step {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(246, 200, 0, 0.5);
  background: rgba(246, 200, 0, 0.12);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
}
.hook-phase strong { display: block; font-family: var(--font-display); font-size: 11px; letter-spacing: 0.06em; color: var(--gold); }
.hook-phase p { margin-top: 2px; font-size: 11.5px; color: #b6d3c7; line-height: 1.35; }
.hook-phase.success { border-color: rgba(70, 255, 211, 0.45); }
.hook-phase.success strong { color: var(--neon); }

.hook-signal {
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  min-width: 230px;
}
.signal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
  flex: none;
}
.signal-dot.go { background: var(--neon); box-shadow: 0 0 14px var(--neon); }
.hook-signal span { font-size: 8px; letter-spacing: 0.16em; color: var(--muted); font-weight: 700; display: block; }
.hook-signal b { font-family: var(--font-display); font-size: 12px; color: var(--ice); letter-spacing: 0.06em; }
.signal-timer { width: 56px; height: 4px; border-radius: 2px; background: rgba(70, 255, 211, 0.13); overflow: hidden; margin-left: auto; }
.signal-timer i { display: block; height: 100%; width: 0%; background: var(--neon); transition: width 0.2s linear; }

.hook-tip {
  position: absolute;
  right: 20px;
  bottom: 32px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 4px;
  align-items: center;
}

.hook-touch {
  display: none;
  position: absolute;
  inset: auto 16px 110px;
  justify-content: space-between;
  gap: 10px;
}
.hook-touch .touch-btn { pointer-events: auto; width: 58px; height: 58px; font-size: 18px; }

.hook-result {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(430px, calc(100% - 36px));
  padding: 26px;
  text-align: center;
  z-index: 3;
}
.hook-result h2 { margin: 6px 0 7px; font-family: var(--font-display); font-size: 23px; font-weight: 900; }
.hook-result p { font-size: 13px; color: #b6d3c7; line-height: 1.5; }
.hook-score {
  margin: 16px 0;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(246, 200, 0, 0.35);
}
.hook-actions { display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
.hook-actions .primary-btn { padding: 11px 24px 9px; }
.hook-actions .primary-btn span { font-size: 12px; }

/* --------------------------------------------------------------------------
   Loading
   -------------------------------------------------------------------------- */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background:
    radial-gradient(700px 500px at 50% 50%, rgba(0, 133, 62, 0.2), transparent 70%),
    #020806;
  transition: opacity 0.5s, visibility 0.5s;
}
.loading-screen.hide { opacity: 0; visibility: hidden; }
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading-tram { font-size: 42px; animation: tramBob 1.6s ease-in-out infinite; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5)); }
@keyframes tramBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.loading-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.loading-title span { color: var(--gold); }
.loading-bar { width: 220px; height: 3px; border-radius: 2px; background: rgba(70, 255, 211, 0.12); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 8%; background: linear-gradient(90deg, var(--green-bright), var(--gold)); transition: width 0.4s; }
.loading-copy { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

/* --------------------------------------------------------------------------
   Screen flash & assorted
   -------------------------------------------------------------------------- */

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: #eaffff;
  opacity: 0;
  mix-blend-mode: screen;
}

#selftestOut {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 200;
  max-width: 420px;
  max-height: 40vh;
  overflow: auto;
  font: 10px/1.4 ui-monospace, monospace;
  color: #afffd9;
  background: rgba(0, 0, 0, 0.85);
  padding: 8px;
  border-radius: 6px;
  white-space: pre-wrap;
}

body.selftest #startScreen { display: none; }
body.shot .topbar,
body.shot .telemetry,
body.shot .toolbar,
body.shot .minimap,
body.shot .touch-controls { opacity: 1; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .brand { min-width: 0; }
  .brand-text p { display: none; }
  .telemetry { width: 280px; }
  .minimap { width: 220px; }
  .stop-prompt { min-width: 320px; bottom: 104px; }
}

@media (max-width: 900px) {
  .topbar { left: 12px; right: 12px; gap: 8px; }
  .brand { padding: 8px 12px 8px 9px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 10px; }
  .brand-mark span { font-size: 11px; }
  .brand-text h1 { font-size: 14px; }
  .weather-btn { padding: 6px 9px; }
  .weather-btn b { display: none; }
  .weather-btn span { font-size: 16px; }
  .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .telemetry { top: 78px; right: 12px; width: 230px; padding: 11px 12px; gap: 9px; }
  .speed-ring { width: 78px; height: 78px; }
  .speed-inner strong { font-size: 21px; }
  .tel-cell strong { font-size: 14px; }
  .tel-cell { padding: 6px 8px; }
  .minimap { width: 190px; right: 12px; bottom: 84px; }
  .toolbar { left: 12px; bottom: 12px; }
  .tool-btn { min-width: 54px; }
  .tool-label { font-size: 7px; }
  .stop-prompt { bottom: 88px; }
  .touch-controls { display: flex; }
  .toasts { top: 190px; }
  .badge-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .topbar { align-items: stretch; }
  .brand-text { display: none; }
  .brand { padding: 6px; }
  .weather-switch { margin-left: auto; }
  .top-actions { padding: 4px; }
  .telemetry {
    top: 68px;
    left: 12px;
    right: 12px;
    width: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    padding: 9px 11px;
  }
  .tel-head { grid-column: 1 / -1; }
  .speed-block { gap: 9px; }
  .speed-ring { width: 64px; height: 64px; }
  .speed-inner strong { font-size: 17px; }
  .speed-inner span { font-size: 6px; }
  .gear { width: 22px; height: 22px; font-size: 11px; }
  .speed-label, .traction-bars, .door-state { display: none; }
  .tel-grid { grid-template-columns: 1fr 1fr; gap: 1px; align-self: center; }
  .tel-cell { padding: 4px 7px; }
  .tel-cell span { font-size: 7px; }
  .tel-cell strong { font-size: 12px; }
  .next-stop { grid-column: 1 / -1; border-top: none; padding-top: 2px; }
  .next-head { display: none; }
  .next-name { font-size: 11px; }
  .stop-track { margin: 5px 0 3px; }
  .next-hint { display: none; }
  .minimap { display: none; }
  .toolbar {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: space-around;
  }
  .tool-btn { min-width: 0; flex: 1; }
  .tool-label { display: none; }
  .stop-prompt { bottom: 150px; min-width: 0; width: calc(100% - 24px); }
  .prompt-copy span { white-space: normal; }
  .touch-controls { bottom: 74px; }
  .touch-btn { width: 58px; height: 58px; font-size: 17px; }
  .touch-bell, .touch-hook { width: 48px; height: 48px; }
  .toasts { top: 232px; }
  .start-card { padding: 22px 18px 18px; }
  .start-features { grid-template-columns: repeat(2, 1fr); }
  .start-controls { display: none; }
  .start-lead { font-size: 12.5px; }
  .help-grid { grid-template-columns: 1fr; gap: 10px; }
  .career-stats { grid-template-columns: 1fr 1fr; }
  .badge-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 24px 18px 18px; }
  .modal-foot { flex-direction: column; align-items: stretch; text-align: center; }
  .hook-top { padding: 10px 12px; }
  .hook-stats { gap: 11px; }
  .hook-stats div:nth-child(3) { display: none; }
  .hook-signal { top: 84px; }
  .hook-tip { display: none; }
  .hook-touch { display: flex; }
  .hook-phase { bottom: 18px; }
  .hook-phase p { font-size: 10.5px; }
}

@media (max-width: 380px) {
  .brand-mark { width: 36px; height: 36px; }
  .weather-btn { padding: 5px 7px; }
  .icon-btn { width: 29px; height: 29px; }
  .telemetry { top: 62px; }
  .toolbar { gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Screenshot / automated capture mode */
body.shot .loading-screen { display: none !important; }
body.shot .overlay.start-screen { display: none !important; }

/* --------------------------------------------------------------------------
   Driver's cab view
   -------------------------------------------------------------------------- */

.tool-btn.is-active {
  color: var(--gold);
  background: rgba(246, 200, 0, 0.1);
  border-color: rgba(246, 200, 0, 0.42);
  box-shadow: inset 0 0 18px rgba(246, 200, 0, 0.08);
}

.cab-overlay {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: none;
  pointer-events: none;
  overflow: hidden;
}

body.view-driver .cab-overlay { display: block; }

body.view-driver #scene { cursor: grab; }
body.view-driver.is-looking #scene { cursor: grabbing; }

.cab-glass {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(115deg, rgba(255, 255, 255, 0.055) 0 18%, transparent 18.5% 62%, rgba(255, 255, 255, 0.035) 62.5% 72%, transparent 72.5%),
    radial-gradient(60% 50% at 80% 80%, rgba(70, 255, 211, 0.05), transparent 70%);
  mix-blend-mode: screen;
}

.cab-rain {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  opacity: 0.52;
  background-image:
    radial-gradient(ellipse 5px 8px at 22% 28%, rgba(200, 240, 255, 0.5), transparent 62%),
    radial-gradient(ellipse 4px 7px at 68% 18%, rgba(200, 240, 255, 0.42), transparent 62%),
    radial-gradient(ellipse 6px 10px at 84% 48%, rgba(200, 240, 255, 0.36), transparent 64%),
    radial-gradient(ellipse 4px 6px at 38% 62%, rgba(200, 240, 255, 0.34), transparent 64%),
    radial-gradient(ellipse 3px 5px at 52% 34%, rgba(200, 240, 255, 0.4), transparent 66%);
  background-size: 170px 220px, 230px 290px, 190px 240px, 260px 330px, 150px 190px;
  animation: cabRainDrift 9s linear infinite;
}

body[data-weather="rain"] .cab-rain { display: block; }

@keyframes cabRainDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  to { background-position: -34px 220px, 22px 290px, -18px 240px, 16px 330px, -10px 190px; }
}

.cab-wipers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 19vh;
  height: 42vh;
  z-index: 3;
}

.cab-wipers i {
  position: absolute;
  bottom: 0;
  left: 31%;
  width: 3px;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(210, 255, 245, 0.32), rgba(3, 12, 8, 0.96) 26%, rgba(3, 12, 8, 0.98));
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.65), 0 0 2px rgba(220, 255, 245, 0.25);
  transform-origin: 50% 100%;
  transform: rotate(-28deg);
  opacity: 0.16;
}

.cab-wipers i:nth-child(2) {
  left: 57%;
  height: 92%;
  opacity: 0.1;
}

body[data-weather="rain"] .cab-wipers i {
  opacity: 0.55;
  animation: cabWipe 3.8s ease-in-out infinite;
}

body[data-weather="rain"] .cab-wipers i:nth-child(2) {
  animation-delay: 0.35s;
  animation-duration: 4.1s;
}

@keyframes cabWipe {
  0%, 10% { transform: rotate(-30deg); }
  46%, 54% { transform: rotate(56deg); }
  90%, 100% { transform: rotate(-30deg); }
}

.cab-roof {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7vh;
  z-index: 4;
  background: linear-gradient(180deg, #020a07 0%, #051510 62%, rgba(3, 12, 8, 0.55) 100%);
  border-bottom: 1px solid rgba(246, 200, 0, 0.12);
}

.cab-pillar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(26px, 7vw, 110px);
  z-index: 4;
  background: linear-gradient(180deg, #061912 0%, #03100b 60%, #020a07 100%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.cab-left {
  left: 0;
  clip-path: polygon(0 0, 100% 0, 62% 100%, 0 100%);
  border-right: 1px solid rgba(70, 255, 211, 0.12);
}

.cab-right {
  right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 38% 100%);
  border-left: 1px solid rgba(70, 255, 211, 0.12);
}

.cab-dash {
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: -2vh;
  height: 23vh;
  z-index: 5;
  background:
    radial-gradient(80% 120% at 50% 0%, rgba(0, 133, 62, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(3, 14, 10, 0.5) 0%, #061a13 26%, #03100b 70%, #020a07 100%);
  border-top: 1px solid rgba(246, 200, 0, 0.36);
  border-radius: 48% 48% 0 0 / 16% 16% 0 0;
  box-shadow:
    inset 0 3px 0 rgba(246, 200, 0, 0.18),
    inset 0 40px 90px rgba(0, 0, 0, 0.65),
    0 -18px 50px rgba(0, 0, 0, 0.35);
}

.cab-dash::before {
  content: "";
  position: absolute;
  top: 3.4vh;
  left: 13%;
  right: 13%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 200, 0, 0.5), transparent);
}

.cab-dash-inner {
  position: absolute;
  inset: 4.8vh 8% auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cab-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--gold);
  font-family: var(--font-display);
  text-transform: uppercase;
}

.cab-brand span { font-size: 9px; letter-spacing: 0.2em; color: var(--muted); }
.cab-brand b { font-size: 20px; font-weight: 900; letter-spacing: 0.06em; text-shadow: 0 0 18px rgba(246, 200, 0, 0.3); }
.cab-brand em {
  font-style: normal;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--neon);
  opacity: 0.75;
}

.cab-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.cab-gauge i {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #03100b 58%, transparent 59%),
    conic-gradient(from 210deg, var(--neon) 0 55%, rgba(70, 255, 211, 0.09) 55% 75%, transparent 75%);
  border: 1px solid rgba(70, 255, 211, 0.18);
  box-shadow: 0 0 14px rgba(70, 255, 211, 0.12);
}

.cab-gauge span {
  font-size: 6.5px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 700;
}

.cab-hint {
  position: absolute;
  left: 50%;
  bottom: calc(23vh + 14px);
  transform: translateX(-50%);
  z-index: 6;
  padding: 5px 11px;
  border: 1px solid rgba(70, 255, 211, 0.18);
  border-radius: 999px;
  background: rgba(2, 12, 8, 0.45);
  color: rgba(220, 255, 246, 0.55);
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.16em;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@media (max-width: 900px) {
  .cab-dash { height: 25vh; }
  .cab-hint { bottom: calc(25vh + 10px); font-size: 6.5px; }
  .cab-dash-inner { inset: 5vh 7% auto; }
  .cab-brand b { font-size: 16px; }
  .cab-brand span, .cab-brand em { font-size: 7px; }
  .cab-gauge i { width: 30px; height: 30px; }
}

@media (max-width: 640px) {
  .cab-pillar { width: 10vw; }
  .cab-roof { height: 6vh; }
  .cab-dash { height: 20vh; }
  .cab-hint { display: none; }
  .cab-dash-inner { display: none; }
  .cab-wipers { bottom: 18vh; height: 40vh; }
}

/* --------------------------------------------------------------------------
   Doors and tram announcements
   -------------------------------------------------------------------------- */

.tool-btn.is-ready {
  color: var(--gold);
  background: rgba(246, 200, 0, 0.12);
  border-color: rgba(246, 200, 0, 0.52);
  animation: doorReady 1.8s ease-out infinite;
}

.tool-btn.is-ready .tool-icon { animation: doorNudge 1.8s ease-in-out infinite; }

.tool-btn.is-open {
  color: var(--neon);
  background: rgba(70, 255, 211, 0.1);
  border-color: rgba(70, 255, 211, 0.52);
  box-shadow: inset 0 0 18px rgba(70, 255, 211, 0.08);
}

.tool-btn.is-busy {
  color: var(--amber);
  border-color: rgba(255, 179, 64, 0.4);
  background: rgba(255, 179, 64, 0.08);
}

@keyframes doorReady {
  0% { box-shadow: 0 0 0 0 rgba(246, 200, 0, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(246, 200, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(246, 200, 0, 0); }
}

@keyframes doorNudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
}

.announcement {
  position: fixed;
  left: 50%;
  bottom: 188px;
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 15px 9px 11px;
  border-radius: 13px;
  border-color: rgba(70, 255, 211, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.24s, transform 0.24s;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.announcement.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.announcement-icon {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid rgba(70, 255, 211, 0.28);
  background: rgba(70, 255, 211, 0.08);
  font-size: 16px;
}

.announcement.show .announcement-icon { animation: announcePulse 1.3s ease-in-out infinite; }

@keyframes announcePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(70, 255, 211, 0.25); }
  50% { box-shadow: 0 0 0 7px rgba(70, 255, 211, 0); }
}

.announcement-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.announcement-copy span {
  font-family: var(--font-display);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--neon);
}

.announcement-copy strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
  color: var(--ice);
}

@media (max-width: 900px) {
  .announcement { bottom: 176px; }
  .announcement-copy strong { font-size: 12px; }
}

@media (max-width: 640px) {
  .announcement {
    bottom: 204px;
    width: calc(100% - 24px);
    padding: 8px 11px 8px 9px;
  }
  .announcement-icon { width: 30px; height: 30px; font-size: 14px; }
  .announcement-copy strong { font-size: 11.5px; }
}

/* --------------------------------------------------------------------------
   Stop guide and live stop information
   -------------------------------------------------------------------------- */

.next-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.next-name-row .next-name {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.stop-info-btn {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(246, 200, 0, 0.35);
  background: rgba(246, 200, 0, 0.08);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  transition: 0.18s;
}

.stop-info-btn:hover {
  background: rgba(246, 200, 0, 0.2);
  border-color: var(--gold);
  transform: scale(1.07);
}

.stop-info {
  position: fixed;
  left: 18px;
  top: 108px;
  z-index: 29;
  width: 336px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 20px 20px 17px;
  border-radius: 16px;
  border-color: rgba(246, 200, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-18px);
  transition: opacity 0.25s, transform 0.25s;
}

.stop-info.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.stop-info::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 16px 0 0 16px;
  background: linear-gradient(180deg, var(--gold), var(--neon));
  opacity: 0.75;
}

.stop-info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.stop-info-close:hover {
  color: var(--ice);
  background: rgba(255, 85, 119, 0.14);
  border-color: rgba(255, 85, 119, 0.4);
}

.stop-info h2 {
  margin: 5px 0 7px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--ice);
  padding-right: 20px;
}

.stop-info p {
  font-size: 12.5px;
  line-height: 1.55;
  color: #b9d6cb;
}

.stop-info-nearby {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid rgba(70, 255, 211, 0.13);
}

.stop-info-nearby > span {
  display: block;
  font-family: var(--font-display);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--neon);
  margin-bottom: 6px;
}

.stop-info-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stop-info-chips span {
  padding: 3px 8px;
  border: 1px solid rgba(70, 255, 211, 0.18);
  border-radius: 999px;
  background: rgba(70, 255, 211, 0.05);
  color: #cdece1;
  font-size: 10px;
  line-height: 1.35;
}

.stop-info-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding: 6px 10px;
  border: 1px solid rgba(246, 200, 0, 0.3);
  border-radius: 7px;
  background: rgba(246, 200, 0, 0.07);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: 0.18s;
}

.stop-info-link:hover {
  background: rgba(246, 200, 0, 0.16);
  border-color: var(--gold);
}

.stop-info-link span { font-size: 12px; }

@media (max-width: 900px) {
  .stop-info {
    left: 12px;
    top: 86px;
    width: 300px;
  }
}

@media (max-width: 640px) {
  .stop-info {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 238px;
    width: auto;
    max-height: 42vh;
    padding: 17px 16px 14px;
    transform: translateY(12px);
  }
  .stop-info.show { transform: translateY(0); }
  .stop-info h2 { font-size: 16px; }
  .stop-info p { font-size: 11.5px; }
}

/* --------------------------------------------------------------------------
   Onboard manifest and passenger stop requests
   -------------------------------------------------------------------------- */

.load-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 1px;
  border-top: 1px solid rgba(70, 255, 211, 0.12);
  padding-top: 8px;
}

.onboard-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  white-space: nowrap;
}

.onboard-chip b {
  color: var(--ice);
  font-size: 11px;
  letter-spacing: 0;
}

.request-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border: 1px solid rgba(246, 200, 0, 0.42);
  border-radius: 999px;
  background: rgba(246, 200, 0, 0.1);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.2s, transform 0.2s;
}

.request-chip.show {
  opacity: 1;
  transform: translateY(0);
  animation: requestPulse 1.5s ease-in-out infinite;
}

.request-chip b {
  color: var(--ice);
  font-size: 10px;
}

.request-chip .cord {
  position: relative;
  width: 2px;
  height: 13px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold), rgba(246, 200, 0, 0.25));
  transform-origin: 50% 0;
}

.request-chip .cord::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 7px;
  height: 7px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: rgba(246, 200, 0, 0.22);
  transform: translateX(-50%);
}

.request-chip.is-pulling .cord {
  animation: pullCord 0.85s cubic-bezier(0.3, 0.9, 0.3, 1);
}

@keyframes pullCord {
  0% { transform: rotate(0) scaleY(1); }
  22% { transform: rotate(-24deg) scaleY(1.22); }
  50% { transform: rotate(19deg) scaleY(1.05); }
  75% { transform: rotate(-7deg) scaleY(1); }
  100% { transform: rotate(0) scaleY(1); }
}

@keyframes requestPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 200, 0, 0.3); }
  50% { box-shadow: 0 0 0 5px rgba(246, 200, 0, 0); }
}

body.stop-requested .cab-request {
  opacity: 1;
  transform: translate(-50%, 0);
}

.cab-request {
  position: absolute;
  left: 50%;
  bottom: calc(23vh + 22px);
  transform: translate(-50%, 8px);
  z-index: 7;
  padding: 6px 12px;
  border: 1px solid rgba(246, 200, 0, 0.55);
  border-radius: 999px;
  background: rgba(10, 8, 2, 0.6);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 0 24px rgba(246, 200, 0, 0.18);
  backdrop-filter: blur(7px);
}

@media (max-width: 640px) {
  .load-row { padding-top: 6px; }
  .onboard-chip { font-size: 6.5px; }
  .request-chip { font-size: 6px; padding: 2px 5px; }
  .cab-request { bottom: calc(20vh + 18px); }
}

/* --------------------------------------------------------------------------
   Mobile panel controls and door interlock
   -------------------------------------------------------------------------- */

.panel-toggle {
  position: absolute;
  right: 7px;
  top: 6px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(70, 255, 211, 0.22);
  border-radius: 5px;
  background: rgba(70, 255, 211, 0.06);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1;
  z-index: 2;
}

.panel-toggle:hover { color: var(--ice); border-color: var(--line-strong); }
.tel-head { position: relative; padding-right: 24px; }
.tel-head .route-chip { margin-right: 18px; }

body.telemetry-min .telemetry > *:not(.tel-head) { display: none; }
body.telemetry-min .telemetry { gap: 0; }
body.telemetry-min .telemetry .route-chip { margin-left: auto; }

.stop-info-toggle {
  position: absolute;
  top: 10px;
  right: 43px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(70, 255, 211, 0.25);
  border-radius: 7px;
  background: rgba(70, 255, 211, 0.05);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1;
  z-index: 2;
}

.stop-info-toggle:hover { color: var(--ice); border-color: var(--line-strong); }

.stop-info.minimized {
  width: min(270px, calc(100vw - 24px));
  max-height: none;
  padding: 12px 74px 12px 16px;
}

.stop-info.minimized h2 {
  margin: 2px 0 0;
  padding: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-info.minimized .eyebrow { font-size: 7px; }
.stop-info.minimized p,
.stop-info.minimized .stop-info-nearby,
.stop-info.minimized .stop-info-link { display: none; }

.door-warning {
  position: fixed;
  left: 50%;
  bottom: 174px;
  transform: translate(-50%, 8px);
  z-index: 30;
  padding: 8px 15px;
  border: 1px solid rgba(255, 179, 64, 0.6);
  border-radius: 999px;
  background: rgba(34, 17, 3, 0.9);
  color: var(--amber);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 0 28px rgba(255, 179, 64, 0.22);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.door-warning.show {
  opacity: 1;
  transform: translate(-50%, 0);
  animation: doorWarnPulse 1.2s ease-in-out infinite;
}

@keyframes doorWarnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 179, 64, 0.25); }
  50% { box-shadow: 0 0 0 7px rgba(255, 179, 64, 0); }
}

.cab-door-warning {
  position: absolute;
  left: 50%;
  bottom: calc(23vh + 58px);
  transform: translate(-50%, 6px);
  z-index: 7;
  padding: 7px 14px;
  border: 1px solid rgba(255, 179, 64, 0.7);
  border-radius: 999px;
  background: rgba(36, 17, 2, 0.82);
  color: var(--amber);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(6px);
}

body.door-blocked .cab-door-warning {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  .stop-info.minimized {
    left: 12px;
    right: auto;
    width: min(270px, calc(100vw - 24px));
    bottom: 238px;
  }
  .door-warning { bottom: 224px; font-size: 7.5px; max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
  .panel-toggle { right: 6px; top: 5px; }
  .tel-head { padding-right: 22px; }
}

/* In the cab the dedicated cab warning is enough; avoid a duplicate bar. */
body.view-driver .door-warning { display: none; }

/* Auto-driver indicator in the cab. */
.cab-auto {
  position: absolute;
  left: 50%;
  bottom: calc(23vh + 58px);
  transform: translate(-50%, 8px);
  z-index: 7;
  padding: 6px 12px;
  border: 1px solid rgba(70, 255, 211, 0.55);
  border-radius: 999px;
  background: rgba(2, 20, 16, 0.7);
  color: var(--neon);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  backdrop-filter: blur(7px);
}

body.auto-drive .cab-auto { opacity: 1; transform: translate(-50%, 0); }
body.view-driver .cab-door-warning { bottom: calc(23vh + 92px); }
