/* Aincrad City: all styles. Mobile first; desktop tweaks at the bottom. */
:root {
  --ink: #17202b;
  --ink2: #3c4855;
  --mute: #6b7784;
  --paper: rgba(255, 255, 255, 0.88);
  --paper2: rgba(255, 255, 255, 0.62);
  --gold: #e2b23a;
  --gold2: #c9971f;
  --green: #2f6b4f;
  --red: #c8323a;
  --bg: #cfe3ee;
  --line: rgba(23, 32, 43, 0.12);
  --shadow: 0 6px 24px rgba(23, 32, 43, 0.16);
  --r: 16px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --topH: 56px;
  --navH: 64px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Malayalam', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font: inherit; color: var(--ink); user-select: text; -webkit-user-select: text; }
a { color: var(--green); }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.2; }
p { margin: 0 0 10px; }
kbd {
  font: 600 11px/1 var(--font);
  padding: 3px 5px;
  border-radius: 5px;
  background: rgba(23, 32, 43, 0.14);
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hide { display: none !important; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; outline: none; touch-action: none; }

/* ---------- building blocks ---------- */
.glass {
  background: var(--paper);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: var(--r);
}
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  background: var(--paper); color: var(--ink); font-weight: 600; white-space: nowrap;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.pill:active { transform: scale(0.96); }
.pill.gold { background: var(--gold); color: var(--ink); box-shadow: 0 3px 0 var(--gold2); }
.pill.dark { background: rgba(23, 32, 43, 0.86); color: #fff; }
.pill.line { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.pill.green { background: var(--green); color: #fff; }
.pill.sm { min-height: 30px; padding: 0 11px; font-size: 13px; }
.pill:disabled, .round:disabled { opacity: 0.45; pointer-events: none; }
.round {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 3px 12px rgba(23, 32, 43, 0.18);
  transition: transform 0.12s, background 0.15s;
}
.round:active { transform: scale(0.92); }
.round.on { background: var(--gold); }
.round.sm { width: 30px; height: 30px; box-shadow: none; background: rgba(23, 32, 43, 0.07); }
.round.sm svg { width: 16px; height: 16px; }
.round.big { width: 60px; height: 60px; }
.round.big svg { width: 24px; height: 24px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(47, 107, 79, 0.12); color: var(--green);
}
.badge.gold { background: rgba(226, 178, 58, 0.22); color: #8a6510; }
.badge.ink { background: var(--ink); color: #fff; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.col { flex-direction: column; align-items: stretch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 12px;
  border-radius: 14px; background: rgba(255, 255, 255, 0.75); box-shadow: inset 0 0 0 1px var(--line);
  text-align: left;
}
.tile.on { box-shadow: inset 0 0 0 2px var(--gold); }
.fine { font-size: 12px; color: var(--mute); }
.acInput {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; outline: none;
}
.acInput:focus { border-color: var(--gold); }
.acErr { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0; }
.payBtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.payBtns button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; border-radius: 14px; text-align: left;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--line);
}
.payBtns button b { font-size: 17px; }
.payBtns button:active { transform: scale(0.98); }
.xBtn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1;
  display: grid; place-items: center; background: rgba(23, 32, 43, 0.07);
}
.xBtn:active { transform: scale(0.92); }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(120% 90% at 50% 10%, #eef6fa 0%, var(--bg) 55%, #a9cbdb 100%);
  transition: opacity 0.5s;
}
#loader.out { opacity: 0; pointer-events: none; }
#loader .logo { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
#loader .logo svg { width: 72px; height: 72px; stroke: var(--green); stroke-width: 3; }
#loader .logo b { font-size: 28px; letter-spacing: -0.02em; }
#loader .logo span { color: var(--ink2); }
#loader .bar { width: min(280px, 70vw); height: 8px; border-radius: 99px; background: rgba(23, 32, 43, 0.1); overflow: hidden; }
#loader .bar i {
  display: block; height: 100%; width: 4%; border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #f3d27a, var(--gold));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  transition: width 0.35s ease;
}
#loader .msg { color: var(--ink2); font-weight: 600; min-height: 20px; }
#loader .msg::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

#bootErr {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: var(--bg); text-align: center;
}
#bootErr .be { max-width: 420px; }
#bootErr svg { width: 64px; height: 64px; stroke: var(--green); stroke-width: 3; }
#bootErr h1 { font-size: 24px; margin: 12px 0; }
#bootErr .d { font-size: 12px; color: var(--mute); word-break: break-word; }
#bootErr button {
  margin-top: 8px; min-height: 44px; padding: 0 22px; border-radius: 999px;
  background: var(--gold); font-weight: 700; box-shadow: 0 3px 0 var(--gold2);
}
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }

/* ---------- ui root ---------- */
#ui { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#ui > *, #ui button, #ui input, #ui a, #ui .chip, #ui .glass { pointer-events: auto; }
#ui > #walkHud { pointer-events: none; }

/* ---------- top bar ---------- */
#top {
  position: absolute; top: calc(var(--sat) + 8px); left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px);
  display: flex; align-items: center; gap: 8px; pointer-events: none;
}
#top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; border-radius: 999px; min-width: 0;
}
.brand svg { stroke: var(--green); stroke-width: 2.2; }
.brand b { font-size: 15px; white-space: nowrap; letter-spacing: -0.01em; }
#resCount { font-size: 12px; color: var(--mute); white-space: nowrap; display: none; }
#gameHud { display: flex; align-items: center; gap: 5px; min-width: 0; }
#gameHud .pill { min-height: 34px; padding: 0 10px; font-size: 13px; }
#gameHud .pill.badge { border-radius: 999px; }
@media (max-width: 420px) { #gameHud .pill.line { display: none; } .brand b { display: none; } }
#gameHud:empty { display: none; }
#gameHud svg { width: 16px; height: 16px; }
.topBtns { margin-left: auto; display: flex; gap: 6px; align-items: center; }
#findBtn { height: 42px; padding: 0 12px; border-radius: 999px; }
#findBtn span { display: none; }
#findN { font-size: 12px; color: var(--mute); font-weight: 600; }
#supportBtn { height: 42px; padding: 0 12px; }
#supportBtn span { display: none; }
#menuBtn { width: 42px; height: 42px; }

/* ---------- search ---------- */
#searchWrap {
  position: absolute; top: calc(var(--sat) + 58px); left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100vw - 16px - var(--sal) - var(--sar)));
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 999px;
}
#searchWrap svg { color: var(--mute); }
#q { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16px; }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
#searchWrap.spot, #searchWrap:focus-within { box-shadow: 0 0 0 3px rgba(226, 178, 58, 0.55), var(--shadow); }
#results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 50vh; overflow: auto;
  padding: 6px; border-radius: 16px; background: rgba(255, 255, 255, 0.96); box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
#results button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 10px; text-align: left;
}
#results button:hover, #results button.sel { background: rgba(226, 178, 58, 0.18); }
#results .no { font-weight: 700; min-width: 48px; color: var(--green); font-variant-numeric: tabular-nums; }
#results .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results .empty { padding: 10px; color: var(--mute); }

/* ---------- chips under the brand ---------- */
.chip {
  position: absolute; left: calc(var(--sal) + 8px);
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 999px;
  max-width: calc(100vw - 16px); font-size: 13px;
}
#markChip { top: calc(var(--sat) + 110px); }
#radioChip { top: calc(var(--sat) + 158px); }
#markChip.solo, #radioChip.first { top: calc(var(--sat) + 110px); }
.chip .arrow { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--gold); transition: transform 0.15s linear; }
.chip .arrow svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.mtxt, .rtxt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.mtxt b, .rtxt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.mtxt small, .rtxt small { color: var(--mute); font-size: 11px; }
#radioPower.on { background: var(--gold); }
body:not([data-mode='walk']):not([data-mode='drive']) #markArrow { display: none; }

/* ---------- house card ---------- */
#card {
  position: absolute; left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px);
  bottom: calc(var(--sab) + var(--navH) + 16px);
  padding: 16px; max-height: 58vh; overflow: auto; border-radius: 20px;
  animation: rise 0.25s ease;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
#card .cNo { font-size: 12px; font-weight: 700; color: var(--green); letter-spacing: 0.06em; text-transform: uppercase; }
#card h2 { font-size: 22px; margin: 2px 0 6px; word-break: break-word; padding-right: 36px; }
#card .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
#card .style { color: var(--ink2); font-size: 14px; margin-bottom: 12px; }
#card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
#card .acts .pill { flex: 1 1 auto; }
#card .empty p { color: var(--ink2); }

/* ---------- milestone strip ---------- */
#mile {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--sat) + 108px);
  width: min(360px, calc(100vw - 16px)); padding: 7px 12px 6px; border-radius: 14px;
}
#mile .track { position: relative; height: 5px; border-radius: 99px; background: rgba(23, 32, 43, 0.1); }
#mile .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--green), #4f9a72); transition: width 0.6s; }
#mile .ticks { position: absolute; inset: 0; }
#mile .ticks i { position: absolute; top: -2px; width: 2px; height: 9px; margin-left: -1px; background: rgba(23, 32, 43, 0.28); border-radius: 1px; }
#mile .ticks i.done { background: var(--gold); }
#mile .lbl { margin-top: 5px; font-size: 11.5px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mile .lbl b { color: var(--ink); }
#mile { display: flex; align-items: center; gap: 8px; padding-left: 6px; cursor: pointer; }
#mile .mbody { flex: 1; min-width: 0; }
#mile .mfig { flex: none; width: 48px; height: 36px; margin: -4px 0; }
#mile .mfig svg { width: 48px; height: 36px; display: block; }

/* ---------- crafted isometric art (art.js) ---------- */
svg.aa { stroke: none; fill: none; }
svg.aa-shop, svg.aa-mile { overflow: visible; }
.tile svg.aa-shop { width: 64px; height: 64px; align-self: center; }
.sheet.miles .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.sheet.miles .tile svg.aa-mile { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.sheet.miles .tile.on { box-shadow: inset 0 0 0 2px var(--green); }
.sheet.miles .tile.locked b { color: var(--mute); }
.aa .aa-flk { transform-box: fill-box; transform-origin: 50% 100%; animation: aaFlk 1.6s ease-in-out infinite alternate; }
.aa .aa-wave { animation: aaWave 5s ease-in-out infinite alternate; }
.aa .aa-drift { animation: aaDrift 14s ease-in-out infinite alternate; }
.aa .aa-drift.slow { animation-duration: 22s; }
.aa .aa-steam { animation: aaSteam 3s ease-in-out infinite alternate; }
#mile .aa *, .tile .aa * { animation: none !important; }
@keyframes aaFlk { from { transform: scale(0.94, 0.9); } to { transform: scale(1.04, 1.06); } }
@keyframes aaWave { from { transform: translate(-1.5px, -0.8px); opacity: 0.75; } to { transform: translate(1.5px, 0.8px); opacity: 1; } }
@keyframes aaDrift { from { transform: translateX(-6px); } to { transform: translateX(10px); } }
@keyframes aaSteam { from { opacity: 0.35; transform: translateY(0.5px); } to { opacity: 0.9; transform: translateY(-0.6px); } }
@media (prefers-reduced-motion: reduce) { .aa * { animation: none !important; } }

/* ---------- bottom nav ---------- */
#bottom {
  position: absolute; left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px); bottom: calc(var(--sab) + 8px);
  display: flex; align-items: stretch; justify-content: space-around; gap: 2px;
  height: var(--navH); padding: 6px; border-radius: 22px;
}
#bottom button {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 16px; font-size: 11px; font-weight: 600; color: var(--ink2);
  transition: background 0.15s, transform 0.12s;
}
#bottom button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#bottom button:active { transform: scale(0.95); }
#bottom button:hover { background: rgba(23, 32, 43, 0.05); }
#bottom button.main { background: var(--gold); color: var(--ink); flex-grow: 1.4; box-shadow: 0 3px 0 var(--gold2); }
#bottom button.main span { white-space: normal; text-align: center; line-height: 1.1; }
#bottom svg { width: 22px; height: 22px; }

#policyLink {
  position: absolute; right: calc(var(--sar) + 12px); bottom: calc(var(--sab) + var(--navH) + 14px);
  font-size: 11px; color: var(--ink2); text-decoration: none; opacity: 0.75;
  background: rgba(255, 255, 255, 0.55); padding: 2px 8px; border-radius: 99px;
}

/* the guide spotlight on a real button */
#ui .spot { z-index: 3; box-shadow: 0 0 0 3px var(--gold), 0 0 0 9px rgba(226, 178, 58, 0.3) !important; animation: spotPulse 1.4s ease-in-out infinite; }
@keyframes spotPulse { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 0 14px rgba(226, 178, 58, 0.12); } }

/* ---------- mode switching ---------- */
#walkHud { display: none; }
body[data-mode='walk'] #walkHud, body[data-mode='drive'] #walkHud { display: block; }
body:not([data-mode='map']) #searchWrap,
body:not([data-mode='map']) #bottom,
body:not([data-mode='map']) #card,
body:not([data-mode='map']) #mile,
body:not([data-mode='map']) #policyLink { display: none !important; }
body[data-mode='trip'] #top, body[data-mode='trip'] .chip, body[data-mode='trip'] #guide { display: none !important; }
body:not([data-mode='bus']) #busChip { display: none !important; }

/* ---------- walk HUD ---------- */
#walkHud { position: absolute; inset: 0; pointer-events: none; }
#walkHud button, #walkHud #stick { pointer-events: auto; }
#stick {
  position: absolute; left: calc(var(--sal) + 22px); bottom: calc(var(--sab) + 22px);
  width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28) 0 55%, rgba(255, 255, 255, 0.4) 56% 100%);
  border: 2px solid rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  touch-action: none;
}
#stick i {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 4px 14px rgba(23, 32, 43, 0.28);
  transition: transform 0.06s;
}
#walkHud .acts {
  position: absolute; right: calc(var(--sar) + 18px); bottom: calc(var(--sab) + 22px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
#walkHud .actRow { display: flex; gap: 12px; }
#runBtn, #jumpBtn { flex-direction: column; gap: 0; }
#runBtn span, #jumpBtn span { font-size: 10px; font-weight: 700; line-height: 1; margin-top: -2px; }
#runBtn.on { background: var(--gold); }
#actBtn { min-height: 52px; padding: 0 20px; font-size: 16px; box-shadow: 0 4px 0 var(--gold2), var(--shadow); animation: pop 0.2s ease; }
#actBtn kbd { display: none; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

#steer, #pedals, #speedo { display: none; }
body[data-mode='drive'] #steer, body[data-mode='drive'] #pedals { display: flex; }
body[data-mode='drive'] #speedo { display: flex; }
body[data-mode='drive'] #stick, body[data-mode='drive'] #runBtn { display: none; }
#steer { position: absolute; left: calc(var(--sal) + 18px); bottom: calc(var(--sab) + 22px); gap: 14px; }
#pedals { gap: 12px; align-items: flex-end; }
#pedals button {
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px;
  width: 64px; border-radius: 14px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
  background: linear-gradient(#3a4552, #1e2630); color: #fff; box-shadow: 0 4px 0 #0c1117;
  background-image: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255, 255, 255, 0.08) 7px 9px), linear-gradient(#3a4552, #1e2630);
}
#brakePedal { height: 70px; }
#gasPedal { height: 96px; background-image: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255, 255, 255, 0.1) 7px 9px), linear-gradient(#2f6b4f, #1d4a35); }
#pedals button:active, #pedals button.on, #steer button.on { transform: translateY(3px); box-shadow: 0 1px 0 #0c1117; }
#speedo {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 26px); transform: translateX(-50%);
  flex-direction: column; align-items: center; justify-content: center;
  width: 86px; height: 86px; border-radius: 50%;
  background: rgba(23, 32, 43, 0.82); color: #fff; box-shadow: inset 0 0 0 3px var(--gold), var(--shadow);
}
#speedo b { font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
#speedo small { font-size: 10px; opacity: 0.75; }

#walkHint {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 170px); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 8px 14px; border-radius: 999px; text-align: center;
  background: rgba(23, 32, 43, 0.72); color: #fff; font-size: 13px; animation: rise 0.3s ease;
}
#walkHint .t { display: none; }
body.touch #walkHint .k { display: none; }
body.touch #walkHint .t { display: inline; }

body:not(.touch) #stick, body:not(.touch) #walkHud .actRow, body:not(.touch) #steer, body:not(.touch) #pedals { display: none !important; }
body:not(.touch) #actBtn kbd { display: inline-block; }
body:not(.touch) #walkHint { bottom: calc(var(--sab) + 100px); }

.wbtns {
  position: absolute; right: calc(var(--sar) + 10px); top: calc(var(--sat) + 60px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.wbtns .round { pointer-events: auto; }
.wbtns .x { display: none; }
.wbtns.more .x { display: inline-grid; animation: pop 0.18s ease; }
.wbtns.more #moreBtn { background: var(--ink); color: #fff; }
#exitWalk { background: var(--ink); color: #fff; }
#chatDot { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
body[data-mode='drive'] #waveBtn, body[data-mode='drive'] #danceBtn, body[data-mode='drive'] #lookBtn { display: none !important; }

/* ---------- bus chip ---------- */
#busChip {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 18px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 999px;
  width: max-content; max-width: calc(100vw - 16px);
}
#busChip > svg { color: var(--green); width: 26px; height: 26px; }
#busChip .bc { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
#busChip small { color: var(--mute); font-size: 11.5px; }
#busChip b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- heritage trip ---------- */
#tripHud {
  position: absolute; left: 50%; top: calc(var(--sat) + 14px); transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px)); padding: 12px 16px; border-radius: 18px;
  background: rgba(23, 32, 43, 0.72); color: #fff;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 8px;
}
#tripHud .thTop { display: flex; align-items: center; gap: 10px; }
#tripHud .thTop span { flex: 1; min-width: 0; }
#tripHud small { opacity: 0.7; font-size: 11.5px; display: block; }
#tripHud b { font-size: 16px; }
#tripHud .thBar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
#tripHud .thBar i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: inherit; }
#tripHud .pill { background: rgba(255, 255, 255, 0.16); color: #fff; }
#tripHud::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.35);
}
#tripCard {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(23, 32, 43, 0.35); animation: fadeIn 0.6s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
#tripCard .tc { width: min(440px, 100%); max-height: calc(100% - 20px); overflow: auto; padding: 0 0 18px; border-radius: 22px; background: #fffaf0; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); animation: rise 0.5s ease; }
#tripCard .art svg { display: block; width: 100%; height: auto; stroke: none; border-radius: 22px 22px 0 0; }
#tripCard .tcIn { padding: 16px 20px 0; }
#tripCard h2 { font-size: 24px; }
#tripCard .stamp { display: inline-flex; gap: 6px; align-items: center; margin: 4px 0 12px; }
#tripCard .pill { width: 100%; min-height: 48px; font-size: 16px; }

/* ---------- studio / settings panels ---------- */
#studio, #settings {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: 0;
  max-height: 82vh; overflow: auto; padding: 16px 16px calc(var(--sab) + 18px);
  border-radius: 22px 22px 0 0; animation: rise 0.25s ease;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
}
#studio .stHead, #settings .stHead { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding-right: 40px; min-height: 34px; }
#studio .stHead b, #settings .stHead b { font-size: 18px; }
#settings .sRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
#settings .sRow.col { flex-direction: column; align-items: stretch; }
#settings .sRow span small { display: block; color: var(--mute); font-size: 12px; }
#settings input[type='range'] { width: 100%; accent-color: var(--green); }
#settings .seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(23, 32, 43, 0.07); }
#settings .seg button { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink2); }
#settings .seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(23, 32, 43, 0.18); transition: background 0.15s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- modal ---------- */
#modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(23, 32, 43, 0); transition: background 0.22s;
}
#modal.on { background: rgba(23, 32, 43, 0.38); }
.sheet {
  position: relative; width: 100%; max-height: 88vh; overflow: auto;
  padding: 22px 18px calc(var(--sab) + 20px); border-radius: 24px 24px 0 0;
  background: #fff; box-shadow: 0 -10px 40px rgba(23, 32, 43, 0.2);
  transform: translateY(100%); transition: transform 0.22s ease;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
  user-select: text; -webkit-user-select: text;
}
#modal.on .sheet { transform: none; }
.sheet h2, .sheet h3 { padding-right: 40px; }
.sheet .lead { color: var(--ink2); }
.sheet img.selfie { display: block; width: 100%; border-radius: 14px; margin: 6px 0 12px; box-shadow: var(--shadow); }
.sheet .place { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); margin-bottom: 10px; }
.sheet .place svg { width: 96px; height: 64px; border-radius: 10px; stroke: none; }
.sheet .place h4 { margin: 0 0 2px; }
.sheet .place p { margin: 0 0 6px; font-size: 13px; color: var(--ink2); }
.sheet .place s { color: var(--mute); margin-right: 4px; }
.sheet .place .visited { font-size: 11px; }

/* ---------- labels (name tags and speech bubbles) ---------- */
#labels { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
#labels.off { display: none; }
#labels > div { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; will-change: left, top; }
#labels .name {
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: rgba(23, 32, 43, 0.72); color: #fff;
}
#labels .name.me { background: var(--gold); color: var(--ink); }
#labels .local { padding: 1px 6px; border-radius: 6px; font-size: 10.5px; font-weight: 600; background: rgba(255, 255, 255, 0.85); color: var(--ink2); }
#labels .tag { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(23, 32, 43, 0.72); color: #fff; }
#labels .tag.npc { background: rgba(47, 107, 79, 0.88); }
#labels .tag.small { padding: 1px 6px; font-size: 10.5px; font-weight: 600; background: rgba(255, 255, 255, 0.85); color: var(--ink2); }
#labels .live { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(43, 95, 168, 0.85); color: #fff; }
#labels .cat { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 800; background: var(--gold); color: var(--ink); }
#labels .spot { padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, 0.92); color: var(--ink); box-shadow: 0 2px 8px rgba(23, 32, 43, 0.18); }
#labels .bubble {
  max-width: 240px; white-space: normal; padding: 8px 12px; margin-top: -14px;
  border-radius: 14px; background: #fff; color: var(--ink); font-size: 13.5px; line-height: 1.3;
  box-shadow: 0 4px 16px rgba(23, 32, 43, 0.22); animation: pop 0.2s ease;
}
#labels .bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px;
  border: 7px solid transparent; border-bottom: 0; border-top-color: #fff;
}
#labels .bubble b { color: var(--green); }

/* ---------- guide ---------- */
#guide {
  position: absolute; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + var(--navH) + 26px);
  width: min(380px, calc(100vw - 24px)); padding: 14px 16px 12px; border-radius: 18px;
  background: #fff; box-shadow: 0 10px 34px rgba(23, 32, 43, 0.28); animation: rise 0.25s ease;
}
#guide::after {
  content: ''; position: absolute; left: var(--ax, 50%); margin-left: -9px; border: 9px solid transparent;
}
#guide.down::after { bottom: -9px; border-bottom: 0; border-top-color: #fff; }
#guide.up::after { top: -9px; border-top: 0; border-bottom-color: #fff; }
#guide.flat::after { display: none; }
#guide.mid { bottom: auto; top: 42%; }
body:not([data-mode='map']) #guide { bottom: calc(var(--sab) + 180px); }
#guide .gWho { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#guide .gWho i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; font-style: normal; font-weight: 800; }
#guide .gWho small { color: var(--mute); }
#guide p { margin: 0 0 10px; }
#guide .gBtns { display: flex; align-items: center; gap: 8px; }
#guide .gBtns .dots { flex: 1; display: flex; gap: 4px; }
#guide .gBtns .dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(23, 32, 43, 0.18); }
#guide .gBtns .dots i.on { background: var(--gold); }

/* ---------- turn tip + toast ---------- */
#turnTip {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 18px; max-width: 300px;
  animation: pop 0.25s ease;
}
#turnTip svg { width: 34px; height: 34px; animation: tilt 1.6s ease-in-out infinite; }
@keyframes tilt { 50% { transform: rotate(-90deg); } }

#toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(var(--sab) + var(--navH) + 30px);
  transform: translate(-50%, 12px); opacity: 0;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px;
  background: rgba(23, 32, 43, 0.9); color: #fff; font-weight: 600; font-size: 14px; text-align: center;
  transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
body:not([data-mode='map']) #toast { bottom: auto; top: calc(var(--sat) + 64px); }

body.flash::after { content: ''; position: fixed; inset: 0; z-index: 45; background: #fff; animation: flash 0.4s ease forwards; pointer-events: none; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

/* ---------- wider phones / tablets / desktop ---------- */
@media (min-width: 560px) {
  #resCount { display: inline; }
  #findBtn span, #supportBtn span { display: inline; }
  #bottom { left: 50%; right: auto; transform: translateX(-50%); width: 560px; }
  #bottom button { font-size: 12px; }
  #bottom button.main span { white-space: nowrap; }
}
@media (min-width: 900px) {
  :root { --navH: 68px; }
  #searchWrap { top: calc(var(--sat) + 10px); width: 380px; }
  #mile { top: auto; bottom: calc(var(--sab) + var(--navH) + 20px); left: 16px; transform: none; width: 300px; }
  #markChip { top: calc(var(--sat) + 62px); }
  #radioChip { top: calc(var(--sat) + 110px); }
  #markChip.solo, #radioChip.first { top: calc(var(--sat) + 62px); }
  #card {
    left: auto; right: 16px; top: calc(var(--sat) + 66px); bottom: auto;
    width: 340px; max-height: calc(100vh - 180px);
    animation-name: slideIn;
  }
  @keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
  .sheet { width: 520px; margin-bottom: 4vh; border-radius: 24px; max-height: 84vh; padding-bottom: 22px; transform: translateY(30px); opacity: 0; transition: transform 0.22s, opacity 0.22s; }
  #modal { align-items: center; }
  #modal.on .sheet { opacity: 1; }
  #studio, #settings { left: auto; right: 16px; top: calc(var(--sat) + 62px); bottom: auto; width: 380px; max-height: calc(100vh - 90px); border-radius: 22px; }
  .wbtns { top: calc(var(--sat) + 62px); }
  #toast { bottom: calc(var(--sab) + var(--navH) + 34px); }
}

/* phones held sideways: short screens */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --navH: 52px; }
  #searchWrap { top: calc(var(--sat) + 8px); width: 300px; height: 40px; }
  #top .brand b { display: none; }
  #mile { display: none; }
  #bottom { width: min(520px, 70vw); left: 50%; right: auto; transform: translateX(-50%); }
  #bottom button { flex-direction: row; gap: 6px; }
  #bottom button span { font-size: 11px; }
  #card { left: auto; right: calc(var(--sar) + 8px); top: calc(var(--sat) + 56px); bottom: calc(var(--sab) + var(--navH) + 14px); width: 320px; max-height: none; }
  #stick { width: 112px; height: 112px; left: calc(var(--sal) + 28px); bottom: calc(var(--sab) + 16px); }
  #walkHud .acts { bottom: calc(var(--sab) + 14px); right: calc(var(--sar) + 24px); }
  .round.big { width: 54px; height: 54px; }
  .wbtns { top: calc(var(--sat) + 8px); right: calc(var(--sar) + 70px); flex-direction: row; }
  #markChip, #markChip.solo { top: calc(var(--sat) + 56px); }
  #radioChip { top: calc(var(--sat) + 100px); }
  #radioChip.first { top: calc(var(--sat) + 56px); }
  #walkHint { bottom: calc(var(--sab) + 12px); max-width: 40vw; border-radius: 14px; }
  #speedo { width: 70px; height: 70px; bottom: calc(var(--sab) + 12px); }
  #speedo b { font-size: 22px; }
  .sheet, #studio, #settings { max-height: 92vh; }
  #guide { bottom: calc(var(--sab) + var(--navH) + 18px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* modules wrap their content in .sheet inside #modalBody (itself a .sheet): flatten the inner one */
.sheet .sheet { position: static; max-height: none; overflow: visible; padding: 0; border-radius: 0; background: none; box-shadow: none; transform: none; }
