﻿/* Real Road Trip — planner page + full-screen WebGL driving view with DOM overlays */
:root { --text: #f3f5fb; --muted: #b3bfd6; --panel: rgba(14, 22, 38, .9); --line: rgba(220, 230, 255, .16);
  --accent: #5cc8ff; --accent-2: #2f7cf6; --good: #57d68d; --bad: #ff7a64; font-family: Inter, system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #14223a; color: var(--text); overscroll-behavior: none; }
h1, h2 { font-family: 'Space Grotesk', Inter, sans-serif; margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button, select { cursor: pointer; touch-action: manipulation; }

.game { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- planner ---------- */
.planner { position: absolute; inset: 0; z-index: 20; overflow: auto; padding: 18px 14px 30px; user-select: text; -webkit-user-select: text;
  background: radial-gradient(120% 70% at 20% 0%, #24406a 0%, transparent 60%), radial-gradient(90% 60% at 100% 100%, #1d3b4a 0%, transparent 70%), #101b2e; }
.pcard { width: min(640px, 100%); margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px 22px 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, .4); }
.kicker { margin: 0; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); text-align: center; }
.pcard h1 { font-size: clamp(36px, 8vw, 54px); text-align: center; line-height: 1.05; margin: 4px 0 2px;
  background: linear-gradient(180deg, #bfeaff, #4fa8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { text-align: center; margin: 0 0 16px; font: 600 17px 'Space Grotesk', sans-serif; color: var(--accent); }
.challenge { background: rgba(255, 196, 80, .15); border: 1px solid rgba(255, 196, 80, .45); color: #ffd98a; border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: 14px; }
.field { position: relative; margin-bottom: 4px; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 4px 2px; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; min-width: 0; background: #0c1526; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; }
.row input:focus { border-color: var(--accent); }
.icon { width: 48px; border-radius: 12px; border: 1px solid var(--line); background: #1d2a44; font-size: 18px; }
.ac { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: #0f1a2e; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 30px rgba(0, 0, 0, .5); }
.ac li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.ac li b { display: block; font-size: 15px; } .ac li small { color: var(--muted); font-size: 12px; }
.ac li:hover, .ac li.act { background: #1f3354; }
.swap { display: block; margin: 2px auto -2px; background: none; border: 0; color: var(--muted); font-size: 20px; padding: 0 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip { border: 1px solid var(--line); background: #1a2740; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip:hover { border-color: var(--accent); }
.modes { border: 0; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modes legend { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; padding: 0; }
.modes label { display: flex; cursor: pointer; }
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes span { flex: 1; border: 1px solid var(--line); background: #13203a; border-radius: 12px; padding: 9px 11px; }
.modes b { display: block; font-size: 15px; } .modes small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; margin-top: 2px; }
.modes input:checked + span { border-color: var(--accent); background: #183257; box-shadow: 0 0 0 2px rgba(92, 200, 255, .25); }
.modes input:focus-visible + span { outline: 2px solid var(--accent); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.opts label { display: flex; flex-direction: column; gap: 4px; }
.opts select { background: #0c1526; border: 1px solid var(--line); border-radius: 10px; padding: 8px; color: var(--text); }
.opts .chk { flex-direction: row; align-items: center; gap: 8px; }
.pick { display: flex; align-items: center; gap: 10px; }
.swatches { display: flex; gap: 6px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); padding: 0; }
.sw.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.btn { border: 1px solid var(--line); background: #22314f; border-radius: 12px; padding: 11px 18px; font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06172e; border: 0; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-size: 19px; padding: 14px 24px; }
.btn.wide { width: 100%; }
.status { min-height: 1.2em; color: #ffd98a; font-size: 14px; margin: 8px 0 0; }
.route-box { margin-top: 6px; }
#pmap { height: 280px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #0c1526; }
.alts { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.alts li { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; background: #13203a; }
.alts li.sel { border-color: var(--accent); background: #183257; }
.alts b { display: block; } .alts small { color: var(--muted); }
.seg-info { color: var(--muted); font-size: 13px; margin: 10px 0; }
.help { margin-top: 16px; font-size: 13px; color: var(--muted); }
.help summary { cursor: pointer; font-weight: 700; color: var(--text); }
.help ul { padding-left: 18px; line-height: 1.55; }
.attrib { font-size: 12px; color: var(--muted); margin: 14px 0 0; text-align: center; }
.links { font-size: 13px; color: var(--muted); margin: 10px 0 0; text-align: center; }
kbd { display: inline-block; min-width: 22px; padding: 0 5px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 3px; background: #22314f; font: 600 12px Inter, sans-serif; text-align: center; color: var(--text); }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.hud b { font-family: 'Space Grotesk', sans-serif; }
.nav { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; gap: 12px; align-items: center;
  background: rgba(16, 70, 52, .9); border-radius: 16px; padding: 10px 16px 10px 12px; max-width: min(520px, calc(100vw - 24px)); box-shadow: 0 8px 22px rgba(0, 0, 0, .35); text-shadow: none; }
.nav-arrow { width: 52px; height: 52px; flex: none; display: grid; place-items: center; color: #fff; font-size: 36px; }
.nav-arrow svg { width: 50px; height: 50px; transition: transform .3s; }
.nav-main b { display: block; font-size: 26px; line-height: 1.05; }
.nav-main span { display: block; font-size: 15px; font-weight: 600; line-height: 1.3; }
.nav-main small { display: block; font-size: 12px; color: #bfe8d4; margin-top: 2px; }
.nav-main small:empty { display: none; }
.hud-r { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 14px; background: rgba(10, 16, 30, .62); border-radius: 14px; padding: 8px 12px; backdrop-filter: blur(3px); text-align: right; }
.stats span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stats b { font-size: 18px; }
.stats small { display: block; font-size: 11px; color: var(--muted); }
.stats small:empty { display: none; }
.btns { display: flex; gap: 6px; pointer-events: auto; }
.hb { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(12, 18, 32, .55); font-size: 15px; font-weight: 700; display: grid; place-items: center; padding: 0; backdrop-filter: blur(3px); }
.hb.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06172e; border-color: transparent; }
.speedo { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 12px; }
.spd { text-align: right; }
.spd b { font-size: 54px; line-height: .9; display: block; }
.spd span { font-size: 13px; color: var(--muted); }
.spd em { display: block; font-style: normal; font-size: 12px; color: var(--accent); margin-top: 3px; }
.limit { text-shadow: none; color: #111; background: #fff; display: grid; place-items: center; text-align: center; box-shadow: 0 4px 12px rgba(0, 0, 0, .4); transition: transform .2s; }
.limit.us { width: 58px; height: 72px; border: 3px solid #111; border-radius: 6px; outline: 2px solid #fff; }
.limit.us small { font: 800 9px/1.05 Inter, sans-serif; }
.limit.us b { font-size: 28px; line-height: 1; }
.limit.eu { width: 64px; height: 64px; border-radius: 50%; border: 7px solid #d0191e; }
.limit.eu small { display: none; }
.limit.eu b { font-size: 24px; }
.limit.over { animation: limflash .5s ease-in-out infinite alternate; }
#h-unit::before { content: ''; }
.minimap-wrap { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: 210px; height: 210px; border-radius: 50%;
  overflow: hidden; border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 8px 22px rgba(0, 0, 0, .45); z-index: 5; transition: all .25s; }
#minimap { position: absolute; inset: 0; }
.minimap-wrap .leaflet-control-attribution { font-size: 8px; padding: 0 4px; max-width: 100%; }
.minimap-wrap:not(.big) .leaflet-control-attribution { position: fixed; display: none; }
.minimap-wrap.big { left: 50%; bottom: 50%; transform: translate(-50%, 50%); width: min(92vw, 900px); height: min(78vh, 680px); border-radius: 18px; z-index: 15; }
.mapsize { position: absolute; z-index: 800; right: 50%; transform: translateX(50%); bottom: 6px; border: 0; border-radius: 999px; background: rgba(12, 18, 32, .75); color: #fff; width: 30px; height: 26px; padding: 0; }
.minimap-wrap.big .mapsize { right: 10px; transform: none; top: 10px; bottom: auto; width: 36px; height: 36px; font-size: 18px; }
.car-ico { display: grid; place-items: center; }
#car-arrow { color: #e2483d; font-size: 22px; line-height: 1; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }

.advise { position: absolute; left: 50%; top: max(18px, calc(env(safe-area-inset-top) + 8px)); transform: translateX(-50%); pointer-events: none; }
.advise span { width: 60px; height: 60px; display: grid; place-content: center; text-align: center; background: #f6c431; color: #1b1b1b; border: 3px solid #1b1b1b;
  border-radius: 8px; transform: rotate(45deg); box-shadow: 0 0 0 2px #f6c431, 0 4px 14px rgba(0, 0, 0, .4); }
.advise b, .advise small { display: block; transform: rotate(-45deg); line-height: 1; }
.advise b { font: 700 20px 'Space Grotesk', sans-serif; } .advise small { font-size: 7px; font-weight: 800; }
.advise.over span { background: #ff5a3c; box-shadow: 0 0 0 2px #ff5a3c, 0 0 22px rgba(255, 90, 60, .8); animation: pulse .5s ease-in-out infinite alternate; }
.offroad { position: absolute; left: 50%; bottom: max(120px, calc(env(safe-area-inset-bottom) + 120px)); transform: translateX(-50%); background: rgba(12, 18, 32, .78);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 14px; white-space: nowrap; z-index: 4; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 700; }
.toast { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); background: rgba(12, 18, 32, .82); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; z-index: 6; }
.toast.show { opacity: 1; }
.touch { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; z-index: 6;
  padding: 0 max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.tgroup { display: flex; gap: 10px; pointer-events: auto; }
.tb { width: 66px; height: 66px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(12, 18, 32, .4); font-size: 24px; color: rgba(255, 255, 255, .85); display: grid; place-items: center; padding: 0; }
.tb.down { background: rgba(92, 200, 255, .55); color: #06172e; }
@media (pointer: coarse) {
  .minimap-wrap:not(.big) { width: 130px; height: 130px; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); }
  .speedo { bottom: max(96px, calc(env(safe-area-inset-bottom) + 96px)); }
}

/* ---------- panels ---------- */
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; z-index: 30; overflow: auto; background: rgba(8, 12, 22, .5); }
.card { width: min(520px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 22px 16px; box-shadow: 0 30px 70px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); text-align: center; animation: rise .3s ease-out; user-select: text; }
.card.small { width: min(320px, 100%); }
.card h2 { font-size: 30px; }
.sub { color: var(--muted); margin: 6px 0 14px; }
.spinner { width: 40px; height: 40px; margin: 6px auto 12px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.settings { display: grid; gap: 8px; margin: 14px 0; text-align: left; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.settings select { background: #0c1526; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 160px; }
.row2 { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.o-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.o-stats div { background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 4px; }
.o-stats span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.o-stats b { font: 700 20px 'Space Grotesk', sans-serif; }
.good { color: var(--good); } .bad { color: var(--bad); }
.r-score { font-size: 15px; color: var(--muted); margin: 10px 0 4px; } .r-score b { font: 700 36px 'Space Grotesk', sans-serif; color: var(--text); margin-left: 6px; }
.r-lines { list-style: none; padding: 8px 12px; margin: 0; text-align: left; font-size: 13px; background: rgba(0, 0, 0, .22); border-radius: 12px; }
.r-lines li { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); } .r-lines b { color: var(--text); }
.r-best { color: #ffd98a; font-weight: 600; min-height: 1em; margin: 10px 0 0; }
.r-challenge { background: rgba(255, 196, 80, .15); border-radius: 10px; padding: 8px; color: #ffd98a; font-weight: 600; }
.share { display: flex; gap: 8px; margin-top: 12px; }
.share input { flex: 1; min-width: 0; background: #0c1526; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.share-msg { color: var(--good); font-size: 13px; min-height: 1em; margin: 6px 0 0; }
.ad-wrap { width: 100%; text-align: center; margin-top: 12px; }
.ad-wrap.ad-on { min-height: 100px; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; }

/* small screens */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, auto); }
  .nav { max-width: calc(100vw - 24px); padding: 8px 12px 8px 8px; }
  .nav-main b { font-size: 21px; } .nav-main span { font-size: 13px; }
  .hud-r { top: auto; bottom: max(200px, calc(env(safe-area-inset-bottom) + 200px)); }
  .modes, .opts { grid-template-columns: 1fr; }
  .spd b { font-size: 42px; }
}
@media (max-height: 520px) {
  .hud-r { top: max(12px, env(safe-area-inset-top)); bottom: auto; }
  .nav { max-width: 46vw; }
  .minimap-wrap:not(.big) { width: 120px; height: 120px; }
  .speedo { bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px)); }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { to { transform: rotate(45deg) scale(1.1); } }
@keyframes limflash { to { transform: scale(1.12); box-shadow: 0 0 0 4px #ff5a3c, 0 0 22px rgba(255, 90, 60, .9); } }
