:root {
  --navy: #14213d; --navy-2: #1d2f57; --maroon: #7a1f24; --gold: #ffd43b; --gold-2: #f2b705; --cream: #fff6e5;
  --sky: #7cc8ff; --ink: #14213d; --muted: #5d6b85; --white: #fff;
  --glass: rgba(255, 255, 255, .78); --glass-dark: rgba(20, 33, 61, .82);
  --shadow: 0 10px 30px rgba(20, 33, 61, .18), 0 2px 6px rgba(20, 33, 61, .12);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: #bfe6ff; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; background: none; }
input, select { font: inherit; color: var(--ink); }
h1, h2, h3, .brand span, .btn, .chip, .tab, .nc-name, .loader-title { font-family: Fredoka, Inter, sans-serif; }
.hidden { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(10, 20, 45, .28) 100%); }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(circle at 50% 35%, #2a4a7a, var(--navy) 70%); color: var(--cream); transition: opacity .6s, visibility .6s; }
#loader.done { opacity: 0; visibility: hidden; }
.loader-logo { width: 112px; height: 112px; border-radius: 50%; box-shadow: 0 0 0 6px var(--gold), 0 18px 40px rgba(0,0,0,.4); animation: bob 1.6s ease-in-out infinite; }
.loader-title { font-size: 30px; font-weight: 700; letter-spacing: .02em; }
.loader-bar { width: 220px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
#loaderFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ffe58a); border-radius: 99px; transition: width .3s; }
.loader-msg { font-size: 14px; opacity: .8; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- top bar ---------- */
.topbar { position: fixed; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; z-index: 10; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 6px 14px 6px 6px; border-radius: 99px; box-shadow: var(--shadow); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand img { width: 32px; height: 32px; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold); }
.search { flex: 1; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 99px; padding: 0 16px;
  height: 46px; box-shadow: var(--shadow); border: 2px solid transparent; transition: border-color .2s; }
.search:focus-within { border-color: var(--gold-2); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--maroon); stroke-width: 2.4; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; font-size: 15px; background: transparent; }
.stats { display: flex; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border-radius: 99px; font-weight: 600; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow); }
.chip.day { background: var(--gold); color: var(--navy); font-weight: 700; }
.chip.dark { background: var(--glass-dark); color: #fff; backdrop-filter: blur(12px); }
.chip b { font-weight: 700; }
.demo-flag { position: fixed; top: calc(66px + var(--safe-t)); left: 14px; z-index: 9; background: var(--maroon); color: var(--cream); font: 700 11px Inter; letter-spacing: .12em;
  padding: 4px 9px; border-radius: 99px; opacity: .85; }

/* ---------- next stop card ---------- */
.nextcard { position: fixed; right: 14px; top: calc(74px + var(--safe-t)); z-index: 8; width: 250px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.nc-top { display: flex; justify-content: space-between; align-items: center; }
.nc-label { font: 700 11px Inter; letter-spacing: .14em; color: var(--maroon); }
.nc-eta { font: 600 12px Inter; color: var(--muted); }
.nc-name { font-size: 22px; font-weight: 700; margin: 4px 0 10px; cursor: pointer; }
.nc-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.nc-row b { color: var(--navy); }
.bar { height: 10px; border-radius: 99px; background: rgba(20,33,61,.1); overflow: hidden; margin-bottom: 10px; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 16px; padding: 12px 18px; font-weight: 600; font-size: 16px;
  transition: transform .12s, box-shadow .2s, background .2s; white-space: nowrap; }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(180deg, #ff8a3d, #f26b1d); color: #fff; box-shadow: 0 6px 0 #b8480b, var(--shadow); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.gold { background: linear-gradient(180deg, #ffe066, var(--gold)); color: var(--navy); box-shadow: 0 5px 0 #c99a00, var(--shadow); }
.btn.glass { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow); flex-direction: column; gap: 0; padding: 8px 14px; font-size: 20px; }
.btn.glass span { font-size: 12px; font-weight: 600; }
.btn.big { font-size: 19px; padding: 16px 22px; flex: 1; }
.btn.small { font-size: 14px; padding: 9px 12px; width: 100%; }
.btn.block { display: flex; flex-direction: column; width: 100%; margin-top: 10px; padding: 14px; }
.btn.block small { font: 500 13px Inter; opacity: .85; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link { display: block; margin: 14px auto 0; font-weight: 600; color: var(--muted); text-decoration: underline; }
.pill { background: #fff; padding: 8px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.pill.exit { background: var(--navy); color: #fff; }

/* ---------- dock ---------- */
.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); z-index: 10; width: min(560px, calc(100% - 20px));
  background: rgba(255,255,255,.55); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-radius: 24px; padding: 10px; box-shadow: var(--shadow); }
.dock-main { display: flex; gap: 8px; }
.dock-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.tab { background: rgba(255,255,255,.85); border-radius: 12px; padding: 9px 4px; font-weight: 600; font-size: 14px; transition: background .2s; }
.tab.active, .tab:hover { background: var(--navy); color: #fff; }

/* ---------- panels ---------- */
.panel { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); width: min(560px, calc(100% - 20px)); max-height: 72vh; overflow: auto;
  background: #fffdf8; border-radius: 24px; box-shadow: 0 -10px 40px rgba(20,33,61,.25); padding: 18px 18px 22px; animation: up .28s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } }
.panel header { display: flex; justify-content: space-between; align-items: center; }
.panel h2 { margin: 0; font-size: 24px; }
.panel h3 { margin: 18px 0 8px; font-size: 17px; }
.x { width: 36px; height: 36px; border-radius: 50%; background: rgba(20,33,61,.07); font-size: 22px; line-height: 1; }
.x.light { position: absolute; top: -14px; right: -6px; background: #fff; box-shadow: var(--shadow); z-index: 2; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.45; }
.tiny { font-size: 12px; color: var(--muted); margin-top: 14px; }
.cbar { margin: 10px 0; }
.cbar-top { display: flex; justify-content: space-between; font-weight: 600; font-size: 15px; margin-bottom: 5px; }
.cbar .bar { height: 14px; margin: 0; }
.cities { margin: 0; padding: 0; list-style: none; counter-reset: c; }
.cities li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(20,33,61,.07); counter-increment: c; font-weight: 600; }
.cities li::before { content: counter(c); width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 13px; flex: none; }
.cities li:nth-child(1)::before { background: var(--gold); color: var(--navy); }
.cities li span.n { margin-left: auto; color: var(--muted); font-weight: 500; }
.stops { list-style: none; margin: 10px 0 0; padding: 0; }
.stops li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; margin-bottom: 8px; background: rgba(20,33,61,.04); cursor: pointer; transition: background .2s; }
.stops li:hover { background: rgba(255,212,59,.3); }
.stops .ic { font-size: 26px; width: 40px; text-align: center; }
.stops b { display: block; font-family: Fredoka; font-size: 17px; }
.stops small { color: var(--muted); }
.stops .km { margin-left: auto; font-weight: 700; color: var(--maroon); white-space: nowrap; }
.today-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--navy); color: #fff; border-radius: 16px; padding: 12px; }
.stat b { display: block; font: 700 22px Fredoka; color: var(--gold); }
.stat small { font-size: 12px; opacity: .85; }
.poll { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.poll button { position: relative; overflow: hidden; text-align: left; background: #fff; border: 2px solid rgba(20,33,61,.1); border-radius: 14px; padding: 12px; font-weight: 600; }
.poll button .fill { position: absolute; inset: 0 auto 0 0; background: rgba(255,212,59,.35); z-index: 0; transition: width .5s; }
.poll button span { position: relative; z-index: 1; }
.poll button.voted { border-color: var(--gold-2); }
.row-btn { display: block; width: 100%; text-align: left; padding: 14px; border-radius: 14px; background: rgba(20,33,61,.04); margin-top: 8px; font-weight: 600; font-size: 15px; }
.row-btn:hover { background: rgba(255,212,59,.3); }
.how { padding-left: 20px; line-height: 1.55; }
.how li { margin: 8px 0; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(20,33,61,.45); backdrop-filter: blur(4px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card { position: relative; width: min(440px, 100%); max-height: 92vh; overflow: auto; background: #fffdf8; border-radius: 26px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: pop .25s cubic-bezier(.2,.8,.2,1.2); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.card > .x { position: absolute; top: 14px; right: 14px; }
.card h2 { margin: 0 0 4px; font-size: 26px; }
.card label { display: block; margin-top: 14px; font-weight: 600; font-size: 14px; }
.card input, .card select { width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(20,33,61,.12); background: #fff; outline: 0; font-size: 16px; }
.card input:focus, .card select:focus { border-color: var(--gold-2); }
.input-at { display: flex; align-items: center; margin-top: 6px; border-radius: 12px; border: 2px solid rgba(20,33,61,.12); background: #fff; }
.input-at:focus-within { border-color: var(--gold-2); }
.input-at span { padding-left: 14px; font-weight: 700; color: var(--maroon); }
.input-at input { border: 0; margin: 0; padding-left: 4px; }
.two { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.check { display: flex !important; align-items: center; gap: 10px; font-weight: 500 !important; }
.check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--maroon); }
.err { color: #c92a2a; font-weight: 600; font-size: 14px; min-height: 20px; margin-top: 10px; }
.welcome { text-align: center; }
.welcome-logo { width: 84px; height: 84px; border-radius: 50%; box-shadow: 0 0 0 4px var(--gold), var(--shadow); margin-top: -4px; }
.welcome h1 { font-size: 26px; margin: 12px 0 6px; line-height: 1.15; }
.welcome h1 span { color: var(--maroon); }

/* ---------- ticket ---------- */
.ticket-wrap { position: relative; width: min(460px, 100%); animation: pop .3s cubic-bezier(.2,.8,.2,1.2); }
.ticket { display: flex; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 70px rgba(0,0,0,.4); }
.t-left { flex: 1; background: var(--cream); padding: 20px 22px 26px; position: relative; }
.t-left::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: linear-gradient(var(--gold) 0 65%, var(--maroon) 65%); }
.t-brand { font: 700 11px Inter; letter-spacing: .14em; color: var(--maroon); }
.t-user { font: 700 32px Fredoka; margin: 6px 0 10px; word-break: break-all; }
.t-grid { display: grid; grid-template-columns: repeat(3, auto); gap: 14px; }
.t-grid small { display: block; font: 700 10px Inter; letter-spacing: .1em; color: var(--muted); }
.t-grid b { font: 700 17px Fredoka; }
.t-link, .t-extra { font-size: 13px; margin-top: 10px; }
.t-right { width: 104px; background: var(--navy); color: var(--gold); border-left: 4px dashed var(--cream); display: flex; flex-direction: column; align-items: center; justify-content: space-around; padding: 14px 8px; }
.t-stub { font: 700 18px Fredoka; text-align: center; line-height: 1.1; }
.t-swatch { width: 64px; height: 44px; border-radius: 8px; box-shadow: 0 0 0 3px var(--cream); }
.ticket-actions { display: flex; gap: 8px; margin-top: 14px; }
.ticket-actions .btn { flex: 1; font-size: 15px; padding: 12px 8px; flex-direction: row; }

/* ---------- 3D labels ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); background: rgba(255,255,255,.94); padding: 3px 9px; border-radius: 99px; font: 600 12px Inter;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.15); will-change: transform; }
.lbl img, .flag { width: 1.25em; height: auto; vertical-align: -0.15em; border-radius: 2px; }
.lbl.me { background: var(--gold); font-size: 14px; padding: 5px 12px; border: 2px solid var(--navy); z-index: 2; }
.lbl.sel { background: var(--navy); color: #fff; font-size: 13px; z-index: 2; }
.lbl.stn { background: var(--navy); color: #fff; font: 700 15px Fredoka; padding: 6px 14px; border: 2px solid var(--gold); pointer-events: auto; cursor: pointer; }
.lbl.stn .nx { margin-left: 6px; background: var(--gold); color: var(--navy); font-size: 10px; padding: 2px 7px; border-radius: 99px; letter-spacing: .06em; }
.lbl.avatar { background: var(--maroon); color: #fff; font-size: 13px; }

/* ---------- mode bar & joystick ---------- */
.modebar { position: fixed; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 12; display: flex; align-items: center; gap: 8px;
  background: var(--glass-dark); color: #fff; padding: 6px 6px 6px 16px; border-radius: 99px; box-shadow: var(--shadow); font: 600 14px Fredoka; white-space: nowrap; }
.modebar .pill { color: var(--navy); }
.modebar .pill.exit { color: #fff; background: var(--maroon); }
.joy { position: fixed; left: 26px; bottom: calc(30px + var(--safe-b)); width: 130px; height: 130px; border-radius: 50%; z-index: 12; background: rgba(255,255,255,.28);
  border: 3px solid rgba(255,255,255,.7); backdrop-filter: blur(6px); touch-action: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: var(--gold); box-shadow: 0 4px 0 #c99a00; }

.toast { position: fixed; left: 50%; top: calc(80px + var(--safe-t)); transform: translateX(-50%); z-index: 50; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px;
  font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 30px); text-align: center; animation: pop .25s; }
.rec { position: fixed; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 60; background: #e03131; color: #fff; font: 700 14px Inter; padding: 8px 14px; border-radius: 99px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .brand span, .hide-sm { display: none; }
  .brand { padding: 5px; }
  .search { height: 42px; }
  .search input { font-size: 14px; }
  .stats .chip.dark { padding: 7px 9px; font-size: 12px; }
  .chip.day { padding: 7px 9px; font-size: 12px; }
  .topbar { flex-wrap: wrap; }
  .stats { order: 3; width: 100%; justify-content: flex-end; }
  .nextcard { top: auto; bottom: calc(150px + var(--safe-b)); right: 10px; width: 200px; padding: 10px 12px; }
  .nc-name { font-size: 18px; margin-bottom: 6px; }
  .demo-flag { top: calc(108px + var(--safe-t)); }
  .modebar { top: calc(108px + var(--safe-t)); font-size: 13px; }
  .modebar #modeTitle { display: none; }
  .btn.big { font-size: 17px; }
}
