:root {
  --bg: #07090d;
  --panel: rgba(12, 16, 24, 0.82);
  --panel-solid: #0e131c;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eaf2ff;
  --muted: #8a96aa;
  --accent: #3fb6ff;
  --accent2: #7cf7d4;
  --warn: #ffb547;
  --danger: #ff5a6a;
  --gold: #ffd66b;
  --c-history: #ffb547;
  --c-nature: #5de38b;
  --c-town: #3fb6ff;
  --c-culture: #c38bff;
  --c-structure: #ff7ab8;
  --c-oddity: #7cf7d4;
  --radius: 18px;
  --dock-h: 96px;
  --top-h: 84px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 18px/1.35 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; user-select: none; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 15px; }

#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 11px; opacity: .6; }
.maplibregl-ctrl-bottom-right { bottom: calc(var(--dock-h) + 4px); }

/* Car */
#car { position: fixed; z-index: 5; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none;
  left: 50%; top: 68%; transition: opacity .3s; filter: drop-shadow(0 0 14px rgba(63,182,255,.7)); }
#car svg { position: relative; transition: transform .4s ease-out; }
.car-pulse { position: absolute; inset: -18px; border-radius: 50%; border: 2px solid rgba(63,182,255,.5);
  animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
#car.stale svg path { fill: #56607a; }
#car.stale .car-pulse { display: none; }

/* Top bar */
#topbar { position: fixed; z-index: 10; top: 0; left: 0; right: 0; height: var(--top-h); display: flex;
  align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px;
  background: linear-gradient(180deg, rgba(7,9,13,.95) 0%, rgba(7,9,13,.6) 70%, transparent 100%); }
.tb-left, .tb-mid, .tb-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
#speed { font-size: 50px; font-weight: 700; letter-spacing: -2px; min-width: 110px; font-variant-numeric: tabular-nums; }
#speed small { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.place { min-width: 0; }
#placeName { font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
#placeSub { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 16px; white-space: nowrap; }
#explored b { color: var(--accent2); font-variant-numeric: tabular-nums; }
#newRoad { color: var(--accent2); border-color: rgba(124,247,212,.5); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(124,247,212,.5); } }
#clock { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #555; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.dot.ok { background: #36e27b; box-shadow: 0 0 10px #36e27b; }
.dot.weak { background: var(--warn); }
.dot.bad { background: var(--danger); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 50px rgba(0,0,0,.45); }

/* Story card */
#story { position: fixed; z-index: 12; top: calc(var(--top-h) + 8px); left: 22px; width: min(560px, 42vw);
  display: flex; overflow: hidden; animation: slideIn .55s cubic-bezier(.2,.9,.2,1); }
#story.out { animation: slideOut .45s ease-in forwards; }
@keyframes slideIn { from { transform: translateX(-110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(-110%); opacity: 0; } }
.story-img { width: 160px; flex: 0 0 160px; background: #1a2130 center/cover no-repeat; }
.story-img.empty { display: none; }
.story-body { padding: 16px 44px 18px 18px; min-width: 0; }
.story-kicker { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); font-weight: 700; }
#story h2 { margin: 4px 0 6px; font-size: 24px; line-height: 1.15; }
#story p { margin: 0; color: #c3cddd; font-size: 17px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.story-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); cursor: pointer; }

/* Alert banner */
#alert { position: fixed; z-index: 14; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%);
  padding: 14px 26px; border-radius: 999px; font-size: 22px; font-weight: 700; display: flex; gap: 12px; align-items: center;
  background: rgba(255, 90, 106, .92); box-shadow: 0 0 40px rgba(255,90,106,.5); animation: pop .35s ease-out; }
#alert.police { background: rgba(40, 110, 255, .94); box-shadow: 0 0 40px rgba(40,110,255,.6); }
#alert.hazard { background: rgba(255, 170, 40, .94); color: #1a1000; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } }

/* Glass */
#glassBox { position: fixed; z-index: 11; left: 22px; bottom: calc(var(--dock-h) + 16px); padding: 10px 14px 12px; display: flex; flex-direction: column; align-items: center; }
#glass { width: 150px; height: 177px; }
.glass-stats { display: flex; gap: 22px; margin-top: 4px; }
.glass-stats div { text-align: center; }
.glass-stats b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.glass-stats small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
#glassBox.spill { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* Waze panel */
#wazePanel { position: fixed; z-index: 13; right: 22px; top: calc(var(--top-h) + 8px); bottom: calc(var(--dock-h) + 16px);
  width: min(620px, 44vw); display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-head .muted { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#wazeFrame { flex: 1; width: 100%; border: 0; background: #111; }

/* Buttons */
.btn { border: 0; border-radius: 14px; padding: 14px 24px; background: var(--accent); color: #001627; font-weight: 700; cursor: pointer; font-size: 18px; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--text); }
.btn.sm { padding: 8px 14px; font-size: 15px; border-radius: 10px; }
.btn.big { font-size: 24px; padding: 20px 48px; border-radius: 18px; }
.btn.danger { background: var(--danger); color: #fff; }

/* Dock */
#dock { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: var(--dock-h); display: flex; align-items: stretch; justify-content: center;
  gap: 6px; padding: 8px 16px 10px; background: linear-gradient(0deg, rgba(7,9,13,.97) 55%, rgba(7,9,13,0)); }
#dock button { flex: 0 1 118px; border: 0; background: transparent; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; color: var(--muted); }
#dock button i { font-style: normal; font-size: 30px; line-height: 1; filter: grayscale(.6); }
#dock button span { font-size: 14px; font-weight: 600; }
#dock button.active { background: rgba(63,182,255,.14); color: var(--text); }
#dock button.active i, #dock .toggle.on i { filter: none; }
#dock .toggle.on { color: var(--text); }
#dock .toggle:not(.on) i { opacity: .4; }
.dock-sep { width: 1px; background: var(--line); margin: 10px 8px; }

/* Sheet */
#sheet { position: fixed; z-index: 18; inset: 0 0 var(--dock-h) 0; background: rgba(7,9,13,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  overflow-y: auto; animation: fadeUp .3s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } }
.sheet-inner { max-width: 1500px; margin: 0 auto; padding: 26px 32px 40px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-head h1 { margin: 0; font-size: 36px; letter-spacing: -.5px; }
.lock { text-align: center; padding: 80px 20px; }
.lock-icon { font-size: 64px; }
.lock h2 { font-size: 32px; margin: 10px 0; }
.lock p { color: var(--muted); font-size: 20px; margin-bottom: 26px; }

/* Grids & cards inside sheets */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.stat b { display: block; font-size: 34px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters button { border: 1px solid var(--line); background: var(--panel-solid); padding: 10px 16px; border-radius: 999px; cursor: pointer; font-size: 16px; }
.filters button.on { background: var(--accent); color: #001627; border-color: transparent; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.item { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.item .img { height: 130px; background: #151c28 center/cover no-repeat; position: relative; }
.item .img .badge { position: absolute; left: 10px; top: 10px; }
.item .body { padding: 12px 14px 14px; }
.item h3 { margin: 0 0 4px; font-size: 18px; }
.item p { margin: 0; color: var(--muted); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #0a0d12; }
.rar-rare { box-shadow: inset 0 0 0 2px var(--c-culture); }
.rar-legendary { box-shadow: inset 0 0 0 2px var(--gold), 0 0 24px rgba(255,214,107,.25); }
.empty-note { color: var(--muted); padding: 40px; text-align: center; font-size: 20px; }

.quest { display: flex; gap: 18px; align-items: center; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px; margin-bottom: 12px; }
.quest .qi { font-size: 36px; }
.quest .qb { flex: 1; }
.quest h3 { margin: 0 0 2px; font-size: 20px; }
.quest p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width .6s; }
.quest.done { border-color: rgba(124,247,212,.5); }
.quest .qp { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 90px; text-align: right; }
.xp { font-size: 20px; margin-bottom: 18px; }
.xp b { color: var(--gold); }

.trip { display: flex; gap: 16px; align-items: center; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; margin-bottom: 10px; }
.trip .tb { flex: 1; }
.trip h3 { margin: 0; font-size: 19px; }
.trip p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.score { font-size: 28px; font-weight: 800; min-width: 70px; text-align: center; }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
.recap-map { height: 60vh; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.recap-side { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.recap-pop { animation: pop2 .5s ease-out; }
@keyframes pop2 { from { opacity: 0; transform: translateY(10px) scale(.96); } }

.wrapped { background: radial-gradient(1200px 400px at 10% 0%, rgba(63,182,255,.25), transparent), radial-gradient(900px 400px at 100% 100%, rgba(124,247,212,.18), transparent), var(--panel-solid);
  border: 1px solid var(--line); border-radius: 22px; padding: 28px 30px; margin-bottom: 22px; }
.wrapped h2 { margin: 0 0 16px; font-size: 26px; }

/* Quiz */
.quiz { max-width: 900px; margin: 0 auto; text-align: center; }
.quiz .q { font-size: 30px; font-weight: 700; margin: 20px 0 26px; line-height: 1.25; }
.quiz .qimg { height: 220px; border-radius: 18px; background: #151c28 center/cover no-repeat; margin: 0 auto 10px; max-width: 520px; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.answers button { padding: 22px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel-solid); font-size: 20px; cursor: pointer; min-height: 88px; }
.answers button.right { background: #1f7a4a; border-color: #36e27b; }
.answers button.wrong { background: #7a1f2b; border-color: var(--danger); }
.quiz .meta { color: var(--muted); font-size: 18px; }

/* Settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; margin-bottom: 10px; }
.set-row .sl b { display: block; font-size: 19px; }
.set-row .sl span { color: var(--muted); font-size: 15px; }
.seg { display: flex; background: rgba(255,255,255,.06); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 10px 16px; border-radius: 9px; cursor: pointer; font-size: 16px; color: var(--muted); }
.seg button.on { background: var(--accent); color: #001627; font-weight: 700; }
.set-row input[type=text] { background: #070a10; border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 12px; font-size: 16px; width: min(520px, 50vw); user-select: text; }
.diag { font-family: ui-monospace, Consolas, monospace; font-size: 15px; background: #05070a; border-radius: 12px; padding: 14px 16px; white-space: pre-wrap; color: #9fd8ff; border: 1px solid var(--line); }
h2.sec { font-size: 22px; margin: 26px 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-size: 15px; }

/* Toasts */
#toasts { position: fixed; z-index: 30; right: 22px; bottom: calc(var(--dock-h) + 16px); display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); border-radius: 14px; padding: 12px 18px; font-size: 18px; animation: toastIn .4s cubic-bezier(.2,.9,.2,1); display: flex; gap: 10px; align-items: center; max-width: 480px; }
.toast.gold { border-color: rgba(255,214,107,.6); box-shadow: 0 0 30px rgba(255,214,107,.25); }
.toast.out { opacity: 0; transform: translateX(40px); transition: .4s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(60px); } }

/* Start overlay */
#start { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(900px 600px at 50% 40%, rgba(63,182,255,.18), transparent), rgba(5,7,10,.94); }
.start-inner { text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.logo { font-size: 84px; font-weight: 900; letter-spacing: 18px; background: linear-gradient(90deg, #9fe8ff, #3fb6ff 40%, #7cf7d4); -webkit-background-clip: text; background-clip: text; color: transparent; margin-right: -18px; }
.tag { font-size: 24px; color: #b9c6da; margin: 0 0 18px; }
#start.gone { opacity: 0; pointer-events: none; transition: opacity .6s; }

/* POI markers */
.poi { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 12px currentColor; background: currentColor; cursor: pointer; }
.poi.got { width: 12px; height: 12px; opacity: .55; box-shadow: none; }
.poi.hot { animation: hot 1.2s ease-in-out infinite; }
@keyframes hot { 50% { transform: scale(1.5); } }
.alert-mk { font-size: 28px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.8)); }

@media (max-width: 900px) {
  :root { --dock-h: 78px; --top-h: 70px; }
  #speed { font-size: 36px; min-width: 80px; }
  .tb-mid, #sun { display: none; }
  #dock button span { display: none; }
  #story { width: calc(100vw - 44px); }
  .story-img { display: none; }
  #wazePanel { left: 22px; width: auto; }
  #glassBox { transform: scale(.75); transform-origin: bottom left; }
  .answers { grid-template-columns: 1fr; }
}
