:root {
  --ink: #f5f3ee;
  --muted: #b9c0c8;
  --panel: rgba(16, 20, 26, 0.78);
  --accent: #f2b544;
  --danger: #e8412c;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1116; color: var(--ink); font-family: var(--font); }
#app canvas { display: block; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

#loading, #start {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #233042, #0d1116 70%); z-index: 20; text-align: center; padding: 16px;
}
#loading .brand { font-size: clamp(26px, 5vw, 46px); font-weight: 800; letter-spacing: 0.02em; }
#loading .sub { color: var(--muted); margin: 6px 0 28px; }
#loading-text { color: var(--muted); max-width: 640px; }
#loading.error #loading-text { color: #ffb4a8; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #2c3a4d; border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin-bottom: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

#start { background: rgba(8, 11, 15, 0.6); cursor: pointer; }
#start .panel { background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px; padding: 26px 30px; max-width: 760px; width: 100%; backdrop-filter: blur(8px); }
#start h1 { margin: 0 0 8px; font-size: clamp(24px, 4vw, 36px); }
#start .lead { color: var(--muted); line-height: 1.45; margin: 0 0 18px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; text-align: left; font-size: 14px; color: #dfe3e8; margin-bottom: 20px; }
.controls b { color: var(--accent); }
#play { background: var(--accent); color: #1a1407; border: 0; border-radius: 10px; padding: 12px 26px; font-size: 16px; font-weight: 700; cursor: pointer; }
@media (max-width: 600px) { .controls { grid-template-columns: 1fr; } }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }
#topleft { position: absolute; top: 14px; left: 16px; display: flex; flex-direction: column; gap: 2px; }
#topleft .title { font-weight: 800; font-size: 18px; letter-spacing: 0.02em; }
#mode { color: var(--muted); font-size: 13px; }
#topright { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; color: var(--muted); }
#clock { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

#minimap { position: absolute; left: 16px; bottom: 34px; width: 210px; height: 210px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.55), 0 4px 18px rgba(0, 0, 0, 0.5); }
#street { position: absolute; right: 22px; bottom: 74px; text-align: right; }
#street-name { font-size: 24px; font-weight: 800; }
#street-old { font-size: 14px; color: var(--accent); }
#street.flash { animation: flash 0.6s ease-out; }
@keyframes flash { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#speed { position: absolute; right: 24px; bottom: 132px; font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; }
#speed small { font-size: 15px; margin-left: 6px; color: var(--muted); }
#prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--panel); padding: 8px 16px; border-radius: 8px; font-size: 15px; }
#info { position: absolute; top: 80px; right: 16px; width: min(380px, calc(100vw - 32px)); background: var(--panel); border-radius: 12px; padding: 14px 18px; text-shadow: none; }
#info-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
#info-body { margin: 0; padding-left: 18px; color: #dfe3e8; font-size: 14px; line-height: 1.5; }
#toast { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); background: var(--panel); padding: 10px 18px; border-radius: 10px; font-size: 15px; }
#help { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); width: min(820px, calc(100vw - 32px)); background: var(--panel); padding: 12px 16px; border-radius: 10px; font-size: 14px; line-height: 1.5; text-align: center; }
#stats { position: absolute; top: 64px; left: 16px; font: 12px ui-monospace, monospace; background: rgba(0, 0, 0, 0.55); padding: 4px 8px; border-radius: 6px; }
#attribution { position: absolute; bottom: 6px; right: 10px; font-size: 11px; color: rgba(255, 255, 255, 0.75); }
#fullmap { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 10; cursor: crosshair; }
