/* Palette: Zimbabwe gold + green on dark glass (no ride-hailing lime/white) */
:root {
  --accent: #FFB81C;        /* Zim flag gold */
  --accent-dark: #E59F00;
  --accent-glow: rgba(255, 184, 28, .35);
  --green: #1E9E4A;         /* Zim flag green */
  --red: #D7263D;
  --ink: #F4F1EA;           /* text on dark panels */
  --ink-2: #A9AFB6;
  --card: rgba(16, 18, 21, .88);
  --card-solid: #15181C;
  --line: rgba(255, 255, 255, .1);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; font-family: var(--font); color: var(--ink); }
button { font-family: inherit; color: inherit; cursor: pointer; }
#game { position: fixed; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity .25s; }
#hud > * { pointer-events: auto; }
#hud.dim #keys-hint, #hud.dim #speedo, #hud.dim #carChip, #hud.dim #radarWrap { opacity: 0; pointer-events: none; }
#hud.paused > * { opacity: 0; pointer-events: none; }
#keys-hint.hidden { display: none; }

.fab {
  width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow); display: grid; place-items: center; color: var(--ink);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .12s, background .12s, color .12s;
}
.fab:hover { transform: scale(1.05); background: #23272C; }
.fab:active { transform: scale(.96); }
.fab.active { background: var(--accent); color: #111; }

#btnMenu { position: absolute; top: 16px; left: 16px; }

.pill {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
  padding: 8px 20px 8px 14px; border-radius: 12px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  max-width: calc(100vw - 420px); white-space: nowrap;
}
.pin-dot { width: 4px; height: 30px; border-radius: 2px; background: var(--accent); flex: none; }
.pill-sub { font-size: 11px; color: var(--accent); font-weight: 700; line-height: 1.2; text-transform: uppercase; letter-spacing: .06em; }
.pill-main { font-size: 15px; font-weight: 700; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }

/* ---------- round GTA-style radar (top-right) ---------- */
#radarWrap { position: absolute; top: 14px; right: 14px; width: 176px; height: 176px; transition: opacity .2s; }
#radar { display: block; width: 176px; height: 176px; border-radius: 50%; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }

.fabs-right { position: absolute; right: 22px; top: 204px; display: flex; flex-direction: column; gap: 8px; }

#carChip {
  position: absolute; left: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px 6px 6px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-align: left; transition: opacity .2s, transform .12s; height: 64px;
}
#carChip:hover { transform: translateY(-2px); }
#chipThumb { width: 52px; height: 52px; border-radius: 10px; background: #2A2E33; }
.chip-name { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.chip-sub { font-size: 11px; color: var(--ink-2); font-weight: 500; }
.chip-sub kbd { margin: 0 3px 0 0; }

#speedo {
  position: absolute; right: 16px; bottom: 16px; width: 112px; height: 112px; border-radius: 50%;
  background: var(--card-solid); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, .06); border: 4px solid var(--accent); transition: opacity .2s;
}
#speedVal { font-size: 36px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.unit { font-size: 11px; color: #BDBDBD; margin-top: 2px; }
#gear { position: absolute; bottom: 10px; font-size: 11px; font-weight: 800; color: var(--accent); }

#keys-hint {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap;
  justify-content: center; max-width: calc(100vw - 480px); transition: opacity .2s;
}
#keys-hint span { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; font-size: 12px; color: var(--ink-2); }
#keys-hint b { color: var(--accent); font-weight: 700; }

#toast {
  position: absolute; top: 84px; left: 50%; transform: translate(-50%, -8px); background: var(--accent); color: #111;
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- garage bottom sheet ---------- */
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(760px, 100vw); transform: translate(-50%, 105%);
  background: var(--card-solid); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .45); border-top: 4px solid var(--accent);
  padding: 10px 20px 20px; transition: transform .35s cubic-bezier(.2, .9, .3, 1);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #3A3F45; margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head h1 { font-family: Anton, Impact, sans-serif; font-weight: 400; font-size: 26px; margin: 0 0 2px; letter-spacing: .02em; text-transform: uppercase; }
.sheet-head p { margin: 0; color: var(--ink-2); font-size: 13px; }
.brand { font-family: Anton, Impact, sans-serif; font-size: 17px; background: #000; color: #fff; padding: 5px 12px; border-radius: 6px; letter-spacing: .03em; text-transform: uppercase; }
.brand span { color: var(--accent); margin-left: 4px; }

#carList { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; }
#carList::-webkit-scrollbar { height: 6px; }
#carList::-webkit-scrollbar-thumb { background: #3A3F45; border-radius: 3px; }
.car-card {
  flex: none; width: 132px; border: 2px solid var(--line); background: #1D2125; border-radius: 14px; padding: 8px 10px 10px;
  text-align: left; scroll-snap-align: start; transition: border-color .12s, transform .12s, background .12s;
}
.car-card:hover { transform: translateY(-2px); background: #252A2F; }
.car-card.selected { border-color: var(--accent); background: #2A2620; box-shadow: 0 0 0 3px var(--accent-glow); }
.car-card canvas { width: 100%; height: 96px; display: block; }
.cc-name { font-weight: 700; font-size: 13px; margin-top: 2px; }
.cc-nick { font-size: 11px; color: var(--ink-2); min-height: 28px; line-height: 1.25; margin-top: 2px; }
.cc-meta { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; margin-top: 6px; color: var(--ink-2); }
.cc-meta span:last-child { background: var(--green); color: #fff; padding: 1px 6px; border-radius: 5px; }

.sheet-row { display: flex; gap: 20px; align-items: center; justify-content: space-between; margin: 8px 0 16px; flex-wrap: wrap; }
.label { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 6px; }
#swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2); padding: 0; transition: transform .12s; }
.swatch.selected { box-shadow: 0 0 0 2px var(--card-solid), 0 0 0 4px var(--accent); transform: scale(1.06); }
.stats { flex: 1; min-width: 220px; max-width: 340px; display: grid; gap: 6px; }
.stat { display: grid; grid-template-columns: 96px 1fr; align-items: center; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.stat i { height: 7px; background: #2A2E33; border-radius: 4px; overflow: hidden; }
.stat b { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }

#startBtn {
  width: 100%; border: 0; background: var(--accent); color: #111; font-family: Anton, Impact, sans-serif; font-size: 20px;
  letter-spacing: .04em; text-transform: uppercase; height: 56px; border-radius: 12px; transition: background .12s, transform .1s;
}
#startBtn:hover { background: var(--accent-dark); }
#startBtn:active { transform: scale(.99); }
#startBtn kbd { font-family: var(--font); background: rgba(0, 0, 0, .15); vertical-align: 3px; }
kbd {
  font-family: inherit; font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .12); border-radius: 5px; padding: 2px 6px; margin-left: 6px;
}

/* ---------- pause menu (GTA style) ---------- */
#menu {
  position: fixed; inset: 0; z-index: 20; color: #fff;
  background: linear-gradient(180deg, rgba(8, 10, 14, .82), rgba(8, 10, 14, .9));
  backdrop-filter: blur(6px) saturate(.7); -webkit-backdrop-filter: blur(6px) saturate(.7);
  display: flex; justify-content: center; align-items: flex-start; overflow: auto;
}
#menu.hidden { display: none; }
.menu-inner { width: min(1100px, calc(100vw - 48px)); padding: 36px 0 24px; display: flex; flex-direction: column; min-height: 100%; }
.menu-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 16px; }
.menu-title { font-family: Anton, Impact, sans-serif; font-size: clamp(34px, 5vw, 56px); letter-spacing: .01em; line-height: 1; text-shadow: 0 3px 0 #000; }
.menu-title span { color: var(--accent); }
.menu-meta { text-align: right; font-size: 13px; color: #C9CCD1; line-height: 1.5; }
.menu-meta div:first-child { font-family: Anton, Impact, sans-serif; font-size: 20px; color: #fff; letter-spacing: .02em; }

.menu-tabs { display: flex; gap: 4px; border-top: 4px solid var(--accent); padding-top: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.menu-tabs button {
  border: 0; background: rgba(0, 0, 0, .55); color: #fff; height: 38px; padding: 0 26px; min-width: 150px;
  font-family: Anton, Impact, sans-serif; font-size: 18px; letter-spacing: .04em; text-transform: uppercase;
}
.menu-tabs button:hover { background: rgba(255, 255, 255, .15); }
.menu-tabs button.active { background: #fff; color: #000; }
.menu-tabs .spacer { flex: 1; }
.menu-tabs .act { min-width: 0; background: rgba(255, 255, 255, .08); }
.menu-tabs .resume { background: var(--accent); color: #000; }
.menu-tabs .resume:hover { background: var(--accent-dark); }

.tab { background: rgba(0, 0, 0, .55); padding: 18px; flex: 1; min-height: 420px; }
#menu .tab.hidden { display: none; }
#tab-map { padding: 0; display: flex; min-height: 0; flex: none; }
#bigmap { width: 100%; height: min(62vh, 620px); display: block; }

/* keyboard diagram */
#tab-controls { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
#kbd { display: flex; gap: 14px; align-items: flex-end; }
.kb-main { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.kb-row { display: flex; gap: 5px; }
.kb-arrows { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 150px; flex: none; }
.kb-arrows > .key { width: 46px; flex: none !important; }
.kb-arrows .kb-row .key { width: 46px; flex: none !important; }
.key {
  height: 52px; min-width: 0; border-radius: 7px; background: #2A2D33; border: 1px solid #3A3E45; box-shadow: 0 3px 0 #15171A;
  display: flex; flex-direction: column; justify-content: space-between; padding: 5px 6px; transition: transform .06s, box-shadow .06s;
  overflow: hidden;
}
.key .k { font-size: 13px; font-weight: 700; color: #8C9199; white-space: nowrap; }
.key .a { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.key.bound .k { color: #111; }
.key.bound.lime { background: var(--accent); border-color: #FFD36B; box-shadow: 0 3px 0 #9A6A00; }
.key.bound.sky { background: #7CC4F5; border-color: #A7DAFB; box-shadow: 0 3px 0 #2F6F9C; }
.key.bound.white { background: #F2F2F0; border-color: #fff; box-shadow: 0 3px 0 #8A8A86; }
.key.bound .a { color: rgba(0, 0, 0, .7); }
.key.down { transform: translateY(3px); box-shadow: 0 0 0 #000 !important; filter: brightness(1.15); outline: 2px solid #fff; }
#kbdLegend { display: grid; gap: 16px; }
.lg-title { font-family: Anton, Impact, sans-serif; font-size: 16px; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.lg-title i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg-title i.lime { background: var(--accent); } .lg-title i.sky { background: #7CC4F5; } .lg-title i.white { background: #F2F2F0; }
.lg-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: #D4D6DA; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.lg-row kbd, .menu-foot kbd { background: rgba(255, 255, 255, .14); color: #fff; margin: 0 4px 0 0; }

/* settings list */
#tab-settings { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
#settingsList { display: flex; flex-direction: column; gap: 2px; }
.set-row {
  display: flex; justify-content: space-between; align-items: center; height: 42px; padding: 0 14px;
  background: rgba(0, 0, 0, .45); cursor: pointer; font-size: 15px; font-weight: 600;
}
.set-row.sel { background: #fff; color: #000; }
.set-value { display: flex; align-items: center; gap: 8px; }
.set-value .val { min-width: 120px; text-align: center; }
.arr { border: 0; background: none; font-size: 22px; line-height: 1; padding: 0 4px; color: inherit; opacity: .55; }
.set-row.sel .arr { opacity: 1; }
.bars { display: flex; gap: 3px; }
.bars i { width: 11px; height: 16px; background: rgba(255, 255, 255, .2); }
.bars i.on { background: var(--accent); }
.set-row.sel .bars i { background: rgba(0, 0, 0, .15); }
.set-row.sel .bars i.on { background: #000; }
.set-action { font-size: 12px; opacity: .6; }
#setHelp { background: rgba(0, 0, 0, .45); padding: 16px; font-size: 14px; line-height: 1.5; color: #D4D6DA; border-left: 4px solid var(--accent); }
.menu-foot { display: flex; gap: 22px; justify-content: flex-end; padding-top: 12px; font-size: 12px; color: #AEB2B8; flex-wrap: wrap; }

/* ---------- loading screen ---------- */
#loading { position: fixed; inset: 0; z-index: 30; background: #000; overflow: hidden; cursor: default; transition: opacity .6s; }
#loading.out { opacity: 0; pointer-events: none; }
#loading.hidden { display: none; }
#loadCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ld-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .65) 100%),
              linear-gradient(0deg, rgba(0, 0, 0, .75) 0%, rgba(0, 0, 0, 0) 32%);
}
.ld-caption {
  position: absolute; top: 28px; left: 36px; font-family: Anton, Impact, sans-serif; font-size: 22px; letter-spacing: .06em;
  text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 #000; padding-left: 12px; border-left: 4px solid var(--accent);
}
.ld-logo {
  position: absolute; left: 36px; bottom: 92px; font-family: Anton, Impact, sans-serif; color: #fff; line-height: .9;
  font-size: clamp(48px, 8vw, 110px); letter-spacing: .01em;
  text-shadow: 4px 4px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}
.ld-logo span { display: block; color: var(--accent); font-size: .62em; margin-top: 4px; }
.ld-tip {
  position: absolute; left: 36px; bottom: 30px; max-width: min(620px, 60vw); display: flex; gap: 12px; align-items: center;
  background: rgba(0, 0, 0, .7); padding: 10px 14px; font-size: 14px; color: #E6E7E9;
}
.ld-tip b { font-family: Anton, Impact, sans-serif; font-weight: 400; color: #000; background: var(--accent); padding: 1px 7px; letter-spacing: .05em; }
.ld-status { position: absolute; right: 36px; bottom: 30px; display: flex; align-items: center; gap: 12px; color: #fff; font-size: 14px; font-weight: 600; }
.ld-progress { width: 140px; height: 4px; background: rgba(255, 255, 255, .2); }
.ld-progress b { display: block; height: 100%; width: 0; background: var(--accent); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ld-press {
  position: absolute; right: 36px; bottom: 70px; font-family: Anton, Impact, sans-serif; font-size: 22px; letter-spacing: .05em;
  text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 #000; opacity: 0; transition: opacity .4s;
}
.ld-press kbd { font-family: Inter, sans-serif; background: #fff; color: #000; font-size: 14px; padding: 3px 8px; margin: 0 4px; vertical-align: 3px; }
#loading.ready .ld-press { opacity: 1; animation: pulse 1.2s ease-in-out infinite alternate; }
#loading.ready .spinner, #loading.ready .ld-progress { display: none; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

@media (max-width: 900px) {
  #tab-controls, #tab-settings { grid-template-columns: 1fr; }
  .key .a { display: none; }
}
@media (max-width: 720px) {
  .pill { max-width: calc(100vw - 150px); left: 76px; transform: none; }
  #carChip { display: none; }
  #radarWrap, #radar { width: 130px; height: 130px; }
  .fabs-right { top: 152px; }
  #keys-hint { display: none; }
  .ld-tip { max-width: calc(100vw - 72px); bottom: 74px; }
  .ld-logo { bottom: 140px; }
}
