/* ============ TRACE — design system ============ */

@font-face {
  font-family: "Grotesk";
  src: url("fonts/EuropaGroteskSH-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Grotesk";
  src: url("fonts/Grotesk-Medium.ttf") format("truetype");
  font-weight: 500 900; /* covers 500 through 800/900 — every bold spot (b, strong, h1/h2, .btn, etc.) resolves to this face */
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-top: #e4e5e9;
  --bg-mid: #dcdde2;
  --bg-bot: #d4d6dc;
  --ink: #2b3240;
  --ink-soft: #7d8798;
  --blue: #4a90e2;
  --blue-deep: #2f6fd0;
  --sage: #a7b8a0;
  --sage-deep: #8ba283;
  --lavender: #b9aede;
  --sky: #aecbe8;
  --card: rgba(255,255,255,.72);
  --glass-border: rgba(255,255,255,.85);
  --shadow: 0 12px 40px rgba(90,110,150,.14);
  --radius: 24px;

  --surface-soft: rgba(255,255,255,.9);
  --surface-soft-border: rgba(90,110,150,.08);
  --surface-strong: rgba(255,255,255,.95);
  --chip-gray-bg: #b9c0cc;
  --chip-gray-ink: #2b3240;
  --avatar-border: #fff;
  --hex-locked-a: #eceef2;
  --hex-locked-b: #d3d8df;
  --sheet-bg: rgba(252,253,255,.96);
  --sheet-handle: #d5dae2;
  --sheet-border: rgba(90,110,150,.1);
  --overlay: rgba(43,50,64,.28);
  --scout-photo-a: #d7e8f6;
  --scout-photo-b: #cdd8e8;
  --shimmer-a: #dfe7f0;
  --shimmer-b: #eef3f8;
  --map-tiles: light_all;
  --map-bg: #dfe7f0;
  --outer-shadow: 0 30px 90px rgba(60,80,120,.25);
  --body-bg: #d4d6dc;
  --app-h: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --edge-x: max(16px, var(--safe-left), var(--safe-right));
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
html {
  min-height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  font-family: "Grotesk", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bot) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  min-height: var(--app-h);
  min-height: 100svh;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: var(--app-h);
  min-height: 100svh;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

button, input, textarea, select {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
button { touch-action: manipulation; }
img, video, canvas, svg { max-width: 100%; }

.hidden { display: none !important; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* ---- glass ---- */
.glass {
  background: var(--card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ---- screens ---- */
.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: calc(18px + var(--safe-top)) max(18px, var(--safe-right)) calc(110px + var(--safe-bottom)) max(18px, var(--safe-left));
  scrollbar-width: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.screen::-webkit-scrollbar { display: none; }
.screen.active { display: block; }
#screen-ride { padding: 0; overflow: hidden; }

.screen-header { padding: 26px 6px 18px; }
.screen-header h1 { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.subtitle { color: var(--ink-soft); margin-top: 4px; font-size: 15px; }
.section-title { font-size: 17px; font-weight: 700; margin: 26px 6px 12px; }

/* ---- topbar: a row of soft rounded-square buttons (no enclosing pill) ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0; background: none; box-shadow: none; border: none;
}
.module-pill {
  border: none; font: inherit; font-weight: 800; font-size: 15px; color: var(--ink);
  cursor: pointer; height: 56px; padding: 0 22px; border-radius: 22px;
  background: #fff; display: inline-flex; align-items: center; gap: 6px;
}
.chev { color: var(--ink-soft); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 5px; }
.chip {
  display: inline-flex; flex-direction: row; align-items: center; justify-content: center;
  height: 56px; border-radius: 22px; gap: 5px;
  font-size: 14px; font-weight: 800; line-height: 1;
}
.chip b { font-size: 14px; }
.chip-purple { background: #b1e6e8; color: #235d60; width: 72px; }
.chip-gray { background: #2c2c3b; color: #e9eaef; width: 66px; }
/* mask icons inside chips — colour follows chip text colour */
.chip-ic {
  width: 19px; height: 19px; flex-shrink: 0; display: inline-block; background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
}
.ic-xp    { -webkit-mask-image: url(assets/xp.png);    mask-image: url(assets/xp.png); }
.ic-medal { -webkit-mask-image: url(assets/medal.png); mask-image: url(assets/medal.png); }
.avatar {
  width: 56px; height: 56px; border-radius: 22px;
  background: #ff0303;
  display: flex; align-items: center; justify-content: center;
  border: none; color: #fff;
}
.avatar-ic {
  width: 28px; height: 28px; display: inline-block; background: currentColor;
  -webkit-mask: url(assets/profile.png) center / contain no-repeat;
  mask: url(assets/profile.png) center / contain no-repeat;
}
.avatar-big { width: 72px; height: 72px; font-size: 36px; border-radius: 20px; }

/* ---- chapter pills ---- */
.chapter-row { display: flex; justify-content: space-between; margin: 18px 4px 6px; }
.pill {
  background: var(--surface-soft); padding: 10px 18px; border-radius: 20px;
  font-weight: 700; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.12);
  border: 1px solid var(--surface-soft-border);
}
.pill-soft { color: var(--ink-soft); font-weight: 600; }
.pill-tag { font-size: 12px; padding: 6px 12px; color: var(--sage-deep); background: rgba(159,212,168,.14); border-color: transparent; }

/* ---- mission map: big pannable canvas dragged with a finger ---- */
#screen-journey { padding: 0; overflow: hidden; position: relative; }
.map-viewport {
  position: absolute; inset: 0; overflow: hidden;
  cursor: grab; touch-action: none; z-index: 0;
}
.map-viewport.dragging { cursor: grabbing; }
.map-canvas {
  position: absolute; top: 0; left: 0;
  will-change: transform; /* size set from JS to match CANVAS_W/H */
  background-image: radial-gradient(circle, rgba(120,130,150,.14) 1.5px, transparent 1.5px);
  background-size: 40px 40px;
  user-select: none; -webkit-user-select: none;
}
/* kill native image/text drag so swiping doesn't spawn a ghost drag preview */
.map-canvas, .level, .sticker, .sticker-img, .sticker-caption {
  -webkit-user-drag: none; user-select: none; -webkit-user-select: none;
}
.sticker-img { pointer-events: none; }
.floating { position: absolute; z-index: 20; }
.topbar.floating {
  top: calc(14px + var(--safe-top));
  left: max(14px, var(--safe-left));
  right: max(14px, var(--safe-right));
}
.chapter-row.floating { top: 78px; left: 14px; right: 14px; margin: 0; }

/* connector lines between stickers, drawn on the canvas by JS */
.map-connectors { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.map-connector-line { stroke: rgba(120,135,160,.35); stroke-width: 3; stroke-dasharray: 2 9; stroke-linecap: round; fill: none; }
.map-connector-line.done { stroke: var(--blue); stroke-dasharray: none; }

/* level = die-cut sticker centered on the trail point; caption floats beside it. */
.level {
  position: absolute; width: 160px; height: 160px;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(calc(var(--tilt, 0deg) + var(--sway, 0deg)));
  transition: transform .5s cubic-bezier(.2, 1.5, .4, 1);
  animation: fav-float 6s ease-in-out infinite;
}
.level:nth-child(even) { animation-delay: -3s; }
@keyframes fav-float {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -8px; }
}
.level:hover { z-index: 5; }

.sticker { position: relative; width: 160px; height: 160px; }
/* caption sits to the right of the sticker without shifting its centre */
.sticker-caption {
  position: absolute; left: calc(100% + 12px); top: 50%;
  transform: translateY(-50%); width: 150px;
}
.sticker-placeholder {
  width: 100%; height: 100%; border-radius: 30px;
  display: flex; align-items: center; justify-content: center; font-size: 56px;
  background: #eceef2; border: 4px solid #fff;
  box-shadow: 0 7px 8px rgba(60,70,110,.2);
  filter: none;
}
.sticker-img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  user-select: none; -webkit-user-drag: none;
  /* die-cut white border: stacked white outlines + a soft drop shadow */
  filter:
    drop-shadow(2.5px 0 0 #fff) drop-shadow(-2.5px 0 0 #fff)
    drop-shadow(0 2.5px 0 #fff) drop-shadow(0 -2.5px 0 #fff)
    drop-shadow(1.8px 1.8px 0 #fff) drop-shadow(-1.8px 1.8px 0 #fff)
    drop-shadow(1.8px -1.8px 0 #fff) drop-shadow(-1.8px -1.8px 0 #fff)
    drop-shadow(0 7px 8px rgba(60,70,110,.35));
  transition: transform .2s ease;
}
.level:hover .sticker-img { transform: scale(1.06) rotate(-2deg); }
.level:active .sticker-img { transform: scale(.94); }

/* glossy light glare that sweeps across the sticker (masked to its shape) */
.sticker-holo {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  background: linear-gradient(112deg,
    transparent 38%,
    rgba(255,255,255,.35) 46%,
    rgba(255,255,255,.9)  50%,
    rgba(255,255,255,.35) 54%,
    transparent 62%);
  background-size: 260% 100%;
  mix-blend-mode: screen;
  animation: glare-sweep 4.5s ease-in-out infinite;
}
@keyframes glare-sweep {
  0%   { background-position: 150% 0; }
  22%  { background-position: -60% 0; }
  100% { background-position: -60% 0; }
}

.sticker-mark {
  position: absolute; top: -4px; right: -2px; font-size: 20px; z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.25));
}
.level.done .sticker-mark { animation: fav-pop .4s ease; }
@keyframes fav-pop { 0% { transform: scale(0); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }

.level-num {
  display: block; font-size: 10px; color: var(--ink-soft);
  font-weight: 700; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 3px;
}
.level-name { font-size: 17px; font-weight: 800; color: var(--ink); line-height: 1.15; }

/* states */
.level.locked { animation: none; }
.level.locked .sticker-img { filter: grayscale(1) drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff) drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff) drop-shadow(0 6px 7px rgba(60,70,110,.2)); opacity: .6; }
.level.locked .sticker-placeholder { filter: grayscale(1); opacity: .55; }
.level.locked .level-name { color: var(--ink-soft); }

/* on launch: each sticker gets "slapped" onto the page */
.level.drop { animation: none; }
.level.drop .sticker { animation: sticker-apply .55s cubic-bezier(.3,1.4,.4,1) backwards; animation-delay: calc(var(--i) * .12s); }
@keyframes sticker-apply {
  0%   { transform: translateY(-40px) scale(1.55) rotate(-7deg); opacity: 0; filter: blur(3px); }
  55%  { opacity: 1; filter: blur(0); }
  72%  { transform: translateY(0) scale(.9) rotate(2deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}

.start-tag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--blue); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 3px 12px; border-radius: 10px; z-index: 3; white-space: nowrap;
  box-shadow: 0 6px 14px rgba(74,144,226,.5);
}

/* big square preview used in the mission sheet + complete modal */
.preview-box {
  width: 116px; height: 116px; border-radius: 30px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 50px;
  background: linear-gradient(160deg, #dce9f8, #c6dbf2);
  box-shadow: 0 14px 30px rgba(90,110,150,.2);
}

/* ---- ride ---- */
#map { position: absolute; inset: 0; z-index: 0; background: var(--map-bg); }
.ride-top {
  position: absolute; top: calc(14px + var(--safe-top)); left: max(14px, var(--safe-left)); right: max(14px, var(--safe-right)); z-index: 500;
  border-radius: 22px; padding: 14px 18px;
}
.ride-mission-name { font-weight: 700; font-size: 15px; }
.ride-progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ride-progress-bar {
  flex: 1; height: 8px; border-radius: 6px; background: rgba(125,135,152,.18); overflow: hidden;
}
.ride-progress-bar > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--blue));
  border-radius: 6px; transition: width .4s ease;
}
#ride-progress-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); min-width: 34px; text-align: right; }

/* compact ORB-flavoured ride panel — small, so the map stays visible */
.ride-panel {
  position: absolute; left: max(14px, var(--safe-left)); right: max(14px, var(--safe-right)); bottom: calc(90px + var(--safe-bottom)); z-index: 500;
  border-radius: 24px; padding: 14px 18px 10px;
  background: #fff; box-shadow: 0 14px 34px rgba(30,40,60,.2);
}
.rp-stats { display: flex; justify-content: space-around; align-items: baseline; }
.rp-stat { text-align: center; }
.rp-stat b { font-size: 23px; font-weight: 800; letter-spacing: -.6px; display: block; }
.rp-stat span { font-size: 11px; color: var(--ink-soft); }
.rp-legend {
  display: flex; gap: 14px; justify-content: center;
  font-size: 11px; color: var(--ink-soft); margin: 10px 0 2px;
}
.rp-legend span { display: inline-flex; align-items: center; gap: 5px; }

.rp-buttons { display: flex; gap: 9px; margin-top: 12px; }
.rp-btn {
  flex: 1; border: none; font: inherit; font-weight: 800; font-size: 15px;
  padding: 13px; border-radius: 999px; cursor: pointer; letter-spacing: -.3px;
  transition: transform .15s ease, opacity .2s;
}
.rp-btn:active { transform: scale(.96); }
.rp-btn-dark { background: var(--ink); color: #fff; }
.rp-btn-light { background: #fff; color: var(--ink); border: 1.5px solid rgba(40,50,70,.2); }
.rp-status {
  text-align: center; font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  color: var(--ink-soft); margin-top: 10px;
}
.btn {
  border: none; font: inherit; font-weight: 700; font-size: 15px;
  padding: 14px 20px; border-radius: 20px; cursor: pointer; flex: 1;
  transition: transform .15s ease, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-deep)); color: #fff;
  box-shadow: 0 10px 24px rgba(74,144,226,.35);
}
.btn-ghost { background: var(--surface-soft); color: var(--ink); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.btn-wide { width: 100%; margin-top: 18px; }
.danger { color: #c0574f; margin-top: 28px; width: 100%; }
/* speed legend dots (used by the ride panel legend) */
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-slow { background: #42afd6; box-shadow: 0 0 5px rgba(66,175,214,.7); }
.dot-normal { background: #9dcb40; box-shadow: 0 0 5px rgba(157,203,64,.7); }
.dot-fast { background: #ec5c70; box-shadow: 0 0 5px rgba(236,92,112,.7); }

/* track tube edge glow */
.trk-edge { filter: drop-shadow(0 0 3px rgba(255,255,255,.85)) drop-shadow(0 1px 1px rgba(0,0,0,.25)); }

/* ---- journal ---- */
.journal-list { display: flex; flex-direction: column; gap: 12px; }
.journal-item {
  border-radius: 20px; padding: 16px 18px; display: flex; align-items: center; gap: 14px;
}
.journal-item .j-ic { font-size: 28px; }
.j-sticker { width: 62px; height: 62px; flex-shrink: 0; }
.j-sticker img {
  width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;
  filter: drop-shadow(1.6px 0 0 #fff) drop-shadow(-1.6px 0 0 #fff) drop-shadow(0 1.6px 0 #fff) drop-shadow(0 -1.6px 0 #fff) drop-shadow(0 2px 2px rgba(60,70,110,.16));
}
.journal-item .j-body { flex: 1; }
.journal-item .j-title { font-weight: 700; font-size: 15px; }
.journal-item .j-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.j-done { color: var(--sage-deep); font-weight: 800; font-size: 13px; }
.empty-state { text-align: center; color: var(--ink-soft); padding: 60px 30px; font-size: 15px; line-height: 1.6; }

/* ---- profile: decoratable cover + editorial rows ---- */
.pf-cover {
  position: relative; height: 340px; border-radius: 28px; overflow: hidden;
  margin: 6px 0 4px; touch-action: none; user-select: none;
  background: #ffffff;
}
.pf-edit {
  position: absolute; top: 12px; right: 12px; z-index: 4;
  width: 38px; height: 38px; border-radius: 12px; border: none; cursor: pointer;
  background: rgba(255,255,255,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(60,70,110,.15); transition: transform .15s ease;
}
.pf-edit:active { transform: scale(.9); }
.pf-edit.on { background: var(--ink); }
.pf-edit-ic {
  width: 19px; height: 19px; display: inline-block; background: var(--ink);
  -webkit-mask: url(assets/palette.png) center / contain no-repeat;
  mask: url(assets/palette.png) center / contain no-repeat;
}
.pf-edit.on .pf-edit-ic { background: #fff; }
.pf-cover::before { /* subtle sticker-wall dot texture, tinted per cover */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, var(--cover-dot, rgba(90,100,130,.14)) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
}
.pf-cover-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--cover-ink, #1b2233); opacity: .5; font-size: 15px; font-weight: 700;
  line-height: 1.4; pointer-events: none;
}
.pf-cover-foot {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 16px;
  pointer-events: none;
}
.pf-avatar {
  width: 56px; height: 56px; border-radius: 18px; flex-shrink: 0;
  background: #1222b3; color: #e7cf6d;
  display: flex; align-items: center; justify-content: center;
}
.pf-avatar-ic {
  width: 30px; height: 30px; display: inline-block; background: currentColor;
  -webkit-mask: url(assets/profile.png) center / contain no-repeat;
  mask: url(assets/profile.png) center / contain no-repeat;
}
.pf-cover-id { min-width: 0; }
.pf-title { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; overflow-wrap: anywhere; color: var(--cover-ink, #1b2233); }
.pf-cover-sub { font-size: 13px; font-weight: 700; color: var(--cover-sub, var(--ink-soft)); }

/* cover background colour picker */
.pf-swatches { display: flex; gap: 10px; padding: 12px 2px 4px; overflow-x: auto; scrollbar-width: none; }
.pf-swatches::-webkit-scrollbar { display: none; }
.pf-swatch {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(60,70,110,.18);
  transition: transform .15s ease;
}
.pf-swatch:active { transform: scale(.88); }
.pf-swatch.selected { outline: 2.5px solid var(--ink); outline-offset: 1px; }

.pf-rows { margin: 14px 4px; display: flex; flex-direction: column; }
.pf-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 2px; border-bottom: 1px solid rgba(120,130,150,.16);
  font-size: 15px;
}
.pf-row:last-child { border-bottom: none; }
.pf-k { color: var(--ink-soft); font-weight: 600; }
.pf-v { font-weight: 800; }
.pf-v.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; letter-spacing: -.3px; }

.pf-collection { margin: 22px 4px 0; }
.pf-coll-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.pf-coll-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.5px; }
.pf-count { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.pf-soon { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: #fff; background: var(--blue); padding: 3px 9px; border-radius: 8px; }
.pf-hint { font-size: 11px; color: var(--ink-soft); margin-bottom: 8px; }

.pf-tray {
  display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px 10px;
  scrollbar-width: none;
}
.pf-tray::-webkit-scrollbar { display: none; }
.pf-sticker {
  position: relative; width: 84px; height: 84px; flex-shrink: 0; cursor: pointer;
  transition: transform .18s cubic-bezier(.3,1.4,.4,1), filter .18s ease;
}
.pf-sticker.pf-custom-photo {
  width: 68px;
  height: 48px;
}
.pf-sticker:active { transform: scale(.9); }
.pf-sticker.peeling { transform: scale(1.22) rotate(-7deg); filter: drop-shadow(0 12px 14px rgba(60,70,110,.4)); }
.pf-sticker.pf-custom-photo.peeling { filter: none; }
.pf-sticker img { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; user-select: none;
  filter: drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff) drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff) drop-shadow(0 5px 6px rgba(60,70,110,.3)); }
.pf-custom-photo img {
  border-radius: 10px;
  object-fit: cover;
  filter:
    drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff)
    drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff)
    drop-shadow(1.2px 1.2px 0 #fff) drop-shadow(-1.2px 1.2px 0 #fff)
    drop-shadow(1.2px -1.2px 0 #fff) drop-shadow(-1.2px -1.2px 0 #fff);
}
.pf-sticker.locked img { filter: grayscale(1) opacity(.5) drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff) drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff); }
.pf-sticker.locked { cursor: default; pointer-events: none; }
/* already stuck on the cover → greyed out, can't place a duplicate */
.pf-sticker.used { filter: grayscale(1); opacity: .35; pointer-events: none; cursor: default; }
.pf-sticker-holo {
  position: absolute; inset: 0; pointer-events: none;
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
  background: linear-gradient(112deg, transparent 40%, rgba(255,255,255,.85) 50%, transparent 60%);
  background-size: 260% 100%; mix-blend-mode: screen;
  animation: glare-sweep 4.5s ease-in-out infinite;
}
.pf-tray-empty { padding: 0; }
.pf-empty {
  width: 100%; text-align: center; color: var(--ink-soft); font-size: 13.5px;
  padding: 22px; border: 1.5px dashed rgba(120,130,150,.3); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pf-empty-ic {
  width: 18px; height: 18px; flex-shrink: 0; display: inline-block; background: var(--ink-soft);
  -webkit-mask: url(assets/camera.png) center / contain no-repeat;
  mask: url(assets/camera.png) center / contain no-repeat;
}

/* ---- saved routes: full-width rectangular picture blocks, grouped by day ---- */
.pf-routes { display: flex; flex-direction: column; gap: 10px; }
.route-group-head {
  font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--ink-soft); margin: 10px 2px 0;
}
.route-group-head:first-child { margin-top: 0; }
.route-card {
  background: #fff; border-radius: 22px; overflow: hidden; cursor: pointer;
  transition: transform .15s ease;
}
.route-card:active { transform: scale(.98); }
.route-thumb { aspect-ratio: 16 / 5; background: #eef1f6; display: block; }
.route-thumb svg { width: 100%; height: 100%; display: block; }
.route-card-foot { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 16px 14px; }
.route-card-foot b { font-size: 17px; font-weight: 800; letter-spacing: -.3px; }
.route-card-foot span { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

/* ---- route detail: full page ---- */
#screen-route { padding: 18px 18px 40px; }
.route-back {
  border: none; background: #fff; cursor: pointer;
  width: 44px; height: 44px; border-radius: 14px; font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(70,90,130,.12); margin-bottom: 14px;
}
.route-back:active { transform: scale(.92); }
.route-canvas {
  background: #fff; border-radius: 26px; padding: 8px; margin-bottom: 18px;
}
.route-canvas svg { width: 100%; height: auto; display: block; }
.route-date { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.route-title { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; margin: 4px 0 6px; }
/* hide the tabbar on the full route page for a clean detail view */
body:has(#screen-route.active) .tabbar { display: none; }

.pf-placed {
  position: absolute; width: 84px; height: 84px; cursor: grab; z-index: 2;
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  touch-action: none; transition: filter .18s ease;
}
.pf-placed.pf-placed-custom {
  width: 76px;
  height: 52px;
}
/* only newly-added stickers pop in; keyframe keeps the centering so it never shifts */
.pf-placed.pop { animation: pf-apply .5s cubic-bezier(.3,1.4,.4,1); }
@keyframes pf-apply {
  0%   { transform: translate(-50%,-50%) rotate(var(--r,0deg)) scale(1.5); opacity: 0; }
  70%  { transform: translate(-50%,-50%) rotate(var(--r,0deg)) scale(.9); opacity: 1; }
  100% { transform: translate(-50%,-50%) rotate(var(--r,0deg)) scale(1); opacity: 1; }
}
.pf-placed:active { cursor: grabbing; }
.pf-placed.peeling { transform: translate(-50%, -50%) rotate(calc(var(--r, 0deg) - 6deg)) scale(1.22); filter: drop-shadow(0 12px 16px rgba(60,70,110,.45)); z-index: 6; }
.pf-placed img { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;
  filter: drop-shadow(1.6px 0 0 #fff) drop-shadow(-1.6px 0 0 #fff) drop-shadow(0 1.6px 0 #fff) drop-shadow(0 -1.6px 0 #fff) drop-shadow(0 2px 3px rgba(60,70,110,.22)); }
.pf-placed-custom img {
  border-radius: 10px;
  object-fit: cover;
  filter:
    drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff)
    drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff)
    drop-shadow(1.2px 1.2px 0 #fff) drop-shadow(-1.2px 1.2px 0 #fff)
    drop-shadow(1.2px -1.2px 0 #fff) drop-shadow(-1.2px -1.2px 0 #fff);
}
.pf-placed .pf-sticker-holo {
  -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center;
  background: linear-gradient(112deg, transparent 40%, rgba(255,255,255,.85) 50%, transparent 60%);
  background-size: 260% 100%; mix-blend-mode: screen; animation: glare-sweep 4.5s ease-in-out infinite;
}

.pf-sticker-tip {
  position: fixed; z-index: 800; pointer-events: none;
  background: #16181d; color: #fff; font-size: 12.5px; font-weight: 700;
  padding: 8px 13px; border-radius: 12px; white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
/* trash target that appears while dragging — lives in the bottom-right of the cover */
.pf-trash {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  width: 52px; height: 52px; border-radius: 16px;
  background: #16181d; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
  opacity: 0; transform: scale(.6) translateY(10px); pointer-events: none;
  transition: opacity .2s ease, transform .2s cubic-bezier(.3,1.4,.4,1), background .15s;
}
.pf-trash.show { opacity: 1; transform: scale(1) translateY(0); }
.pf-trash.hot { background: #e63946; transform: scale(1.18); }
.pf-trash-ic {
  width: 26px; height: 26px; display: inline-block; background: #fff;
  -webkit-mask: url(assets/trash.png) center / contain no-repeat;
  mask: url(assets/trash.png) center / contain no-repeat;
}
/* floating sticker while dragging from the tray onto the cover */
.pf-ghost {
  position: fixed; z-index: 900; width: 92px; height: 92px; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-6deg) scale(1.1);
  filter: drop-shadow(0 10px 14px rgba(60,70,110,.4));
}
.pf-ghost img { width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff) drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff); }
.pf-ghost.pf-ghost-custom {
  width: 76px;
  height: 52px;
  filter: none;
}
.pf-ghost.pf-ghost-custom img {
  border-radius: 10px;
  object-fit: cover;
  filter:
    drop-shadow(1.8px 0 0 #fff) drop-shadow(-1.8px 0 0 #fff)
    drop-shadow(0 1.8px 0 #fff) drop-shadow(0 -1.8px 0 #fff)
    drop-shadow(1.2px 1.2px 0 #fff) drop-shadow(-1.2px 1.2px 0 #fff)
    drop-shadow(1.2px -1.2px 0 #fff) drop-shadow(-1.2px -1.2px 0 #fff);
}
.pf-cover.drop-target { outline: 3px dashed rgba(74,144,226,.6); outline-offset: -6px; }

/* ---- tabbar: dark container, flat segmented pills, active expands ---- */
.tabbar {
  position: absolute; bottom: calc(16px + var(--safe-bottom)); left: max(16px, var(--safe-left)); right: max(16px, var(--safe-right)); z-index: 600;
  border-radius: 26px; padding: 5px;
  display: flex; gap: 3px;
  background: #16181d;
  transition: transform .34s cubic-bezier(.2,1,.3,1), opacity .24s ease;
}
.tab {
  border: none; font: inherit; cursor: pointer;
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 0;
  height: 52px; border-radius: 19px;
  font-size: 14px; font-weight: 700; color: #c3c8d2;
  background: rgba(255,255,255,.07);
  transition: flex-grow .32s cubic-bezier(.2,1,.3,1.2), background .25s ease, color .25s ease;
  overflow: hidden;
}
.tab:active { transform: scale(.97); }
.tab-ic { font-size: 21px; line-height: 1; flex-shrink: 0; }
.tab-ic-img {
  width: 23px; height: 23px; display: inline-block; flex-shrink: 0;
  background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
}
.ic-journey { -webkit-mask-image: url(assets/journey.png); mask-image: url(assets/journey.png); }
.ic-ride    { -webkit-mask-image: url(assets/ride.png);    mask-image: url(assets/ride.png); }
.ic-journal { -webkit-mask-image: url(assets/journal.png); mask-image: url(assets/journal.png); }
.ic-profile { -webkit-mask-image: url(assets/profile.png); mask-image: url(assets/profile.png); }
.tab-label {
  max-width: 0; opacity: 0; white-space: nowrap;
  transition: max-width .32s cubic-bezier(.2,1,.3,1.2), opacity .25s ease;
}
.tab.active {
  flex: 2.4;
  gap: 8px;
  background: #1222b3;
  color: #e7cf6d;
}
.tab.active .tab-label { max-width: 90px; opacity: 1; }

/* ---- sheet / modal ---- */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 700;
  background: var(--overlay); backdrop-filter: blur(3px);
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 710;
  background: #fff;
  border-radius: 32px 32px 0 0; padding: 14px max(26px, var(--safe-right)) calc(30px + var(--safe-bottom)) max(26px, var(--safe-left)); text-align: left;
  box-shadow: 0 -20px 60px rgba(0,0,0,.25);
  animation: slideUp .3s ease;
  max-height: calc(var(--app-h) - var(--safe-top) - 12px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--sheet-handle); margin: 0 auto 16px; }

/* ORB-style mission sheet: sticker icon + bold title + editorial rows */
.ms-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ms-sticker { width: 74px; height: 74px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.ms-sticker img {
  width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;
  filter:
    drop-shadow(2.8px 0 0 #fff) drop-shadow(-2.8px 0 0 #fff)
    drop-shadow(0 2.8px 0 #fff) drop-shadow(0 -2.8px 0 #fff)
    drop-shadow(2px 2px 0 #fff) drop-shadow(-2px 2px 0 #fff)
    drop-shadow(2px -2px 0 #fff) drop-shadow(-2px -2px 0 #fff);
}
.ms-sticker .icon { font-size: 52px; }
.ms-headtext { min-width: 0; }
.ms-num { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-soft); }
.ms-title { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.02; margin-top: 2px; }
.ms-desc { color: var(--ink-soft); font-size: 14px; line-height: 1.5; margin-bottom: 6px; white-space: pre-line; }
.ms-dice {
  width: 16px; height: 16px; display: inline-block; vertical-align: -3px;
  background: currentColor;
  -webkit-mask: url(assets/dice.png) center / contain no-repeat;
  mask: url(assets/dice.png) center / contain no-repeat;
}
.ms-rows { display: flex; flex-direction: column; margin: 6px 0 4px; }
.ms-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid rgba(120,130,150,.16); font-size: 15px;
}
.ms-row:last-child { border-bottom: none; }
.ms-k { color: var(--ink-soft); font-weight: 600; }
.ms-v { font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.ms-badge-ic {
  width: 24px; height: 24px; object-fit: contain; -webkit-user-drag: none;
  filter:
    drop-shadow(1.6px 0 0 #fff) drop-shadow(-1.6px 0 0 #fff)
    drop-shadow(0 1.6px 0 #fff) drop-shadow(0 -1.6px 0 #fff)
    drop-shadow(1.1px 1.1px 0 #fff) drop-shadow(-1.1px 1.1px 0 #fff)
    drop-shadow(1.1px -1.1px 0 #fff) drop-shadow(-1.1px -1.1px 0 #fff);
}
.ms-accept {
  width: 100%; margin-top: 16px; border: none; cursor: pointer;
  background: var(--ink); color: #fff; font: inherit; font-weight: 800; font-size: 16px;
  padding: 17px; border-radius: 999px; letter-spacing: -.3px;
  transition: transform .15s ease;
}
.ms-accept:active { transform: scale(.97); }
.sheet-variants { display: flex; gap: 10px; justify-content: flex-start; margin-top: 14px; flex-wrap: wrap; }
.variant-chip {
  border: 2px solid transparent; background: var(--surface-soft); color: var(--ink); font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 16px; cursor: pointer; transition: all .15s;
}
.variant-chip.selected { border-color: var(--blue); background: rgba(91,159,239,.16); color: var(--blue); }

.modal {
  position: absolute; top: 50%; left: max(26px, var(--safe-left)); right: max(26px, var(--safe-right)); z-index: 720;
  transform: translateY(-50%);
  border-radius: 32px; padding: 30px 24px 24px; text-align: center; overflow: hidden;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: none;
  animation: popIn .35s cubic-bezier(.2,1.4,.4,1);
  max-height: calc(var(--app-h) - var(--safe-top) - var(--safe-bottom) - 28px);
}
@keyframes popIn { from { transform: translateY(-50%) scale(.7); opacity: 0; } to { transform: translateY(-50%) scale(1); opacity: 1; } }
.modal h2 { font-size: 32px; line-height: .95; font-weight: 900; margin: 18px 0 8px; letter-spacing: -0.06em; }
.modal p { color: rgba(0,0,0,.54); font-size: 14px; font-weight: 700; line-height: 1.35; }
.complete-sticker {
  width: 106px;
  height: 106px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.complete-sticker.complete-sticker-custom {
  width: 118px;
  height: 82px;
}
.complete-sticker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  filter:
    drop-shadow(2.8px 0 0 #fff) drop-shadow(-2.8px 0 0 #fff)
    drop-shadow(0 2.8px 0 #fff) drop-shadow(0 -2.8px 0 #fff)
    drop-shadow(2px 2px 0 #fff) drop-shadow(-2px 2px 0 #fff)
    drop-shadow(2px -2px 0 #fff) drop-shadow(-2px -2px 0 #fff);
}
.complete-sticker .icon {
  font-size: 54px;
}
.complete-sticker.complete-sticker-custom img {
  border-radius: 12px;
  object-fit: cover;
  filter:
    drop-shadow(2.2px 0 0 #fff) drop-shadow(-2.2px 0 0 #fff)
    drop-shadow(0 2.2px 0 #fff) drop-shadow(0 -2.2px 0 #fff)
    drop-shadow(1.4px 1.4px 0 #fff) drop-shadow(-1.4px 1.4px 0 #fff)
    drop-shadow(1.4px -1.4px 0 #fff) drop-shadow(-1.4px -1.4px 0 #fff);
}
.reward-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.reward-btn {
  flex: 1;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  padding: 15px 12px;
  border-radius: 999px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform .15s ease;
}
.reward-btn:active { transform: scale(.97); }
.reward-btn-dark { background: #111; color: #fff; }
.reward-btn-light {
  background: #fff;
  color: #111;
  border: 1.5px solid rgba(0,0,0,.14);
}
.reward-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.reward-confetti i {
  position: absolute;
  top: -18px;
  left: 50%;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  background: #111;
  opacity: 0;
}
.reward-confetti i:nth-child(1) { left: 12%; background: #f5df4d; }
.reward-confetti i:nth-child(2) { left: 24%; background: #ff6f61; }
.reward-confetti i:nth-child(3) { left: 38%; background: #1222b3; }
.reward-confetti i:nth-child(4) { left: 52%; background: #88b04b; }
.reward-confetti i:nth-child(5) { left: 66%; background: #f5df4d; }
.reward-confetti i:nth-child(6) { left: 78%; background: #ff6f61; }
.reward-confetti i:nth-child(7) { left: 88%; background: #1222b3; }
.reward-confetti i:nth-child(8) { left: 46%; background: #88b04b; }
.reward-confetti.burst i { animation: reward-confetti-fall .9s ease-out forwards; }
.reward-confetti.burst i:nth-child(2n) { animation-delay: .04s; }
.reward-confetti.burst i:nth-child(3n) { animation-delay: .08s; }
.reward-confetti.burst i:nth-child(4n) { animation-delay: .12s; }
@keyframes reward-confetti-fall {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  100% { transform: translateY(190px) rotate(260deg); opacity: 0; }
}

/* ---- AI scout: ORB-style white card ---- */
.scout-card {
  position: absolute; top: 100px; left: 14px; right: 14px; z-index: 500;
  border-radius: 22px; padding: 12px 14px;
  display: flex; gap: 13px; align-items: center;
  background: #fff; box-shadow: 0 14px 34px rgba(30,40,60,.2);
  animation: slideUp .3s ease;
}
.scout-photo {
  width: 66px; height: 66px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--scout-photo-a), var(--scout-photo-b)) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.scout-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scout-body b { font-size: 17px; font-weight: 800; letter-spacing: -.4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scout-ai {
  font-size: 10px; font-weight: 800; color: var(--ink-soft);
  letter-spacing: .8px; text-transform: uppercase;
}
.scout-meta { font-size: 12px; color: var(--ink-soft); }
.scout-actions { display: flex; flex-direction: column; gap: 6px; }
.scout-actions button {
  border: none; background: var(--ink); color: #fff; cursor: pointer;
  width: 36px; height: 36px; border-radius: 12px; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
#btn-scout-close { background: rgba(40,50,70,.08); color: var(--ink); }
.scout-actions button:active { transform: scale(.9); }
.scout-dice-ic {
  width: 18px; height: 18px; display: inline-block; background: #fff;
  -webkit-mask: url(assets/dice.png) center / contain no-repeat;
  mask: url(assets/dice.png) center / contain no-repeat;
}

/* ---- result: dialog-bubble callout anchored to the map point ---- */
.scout-pop-wrap { overflow: visible; }
.scout-pop {
  position: relative; width: 150px; padding: 8px; box-sizing: border-box;
  background: #fff; border-radius: 18px;
  box-shadow: 0 12px 28px rgba(20,30,50,.28);
  animation: pop-in .28s cubic-bezier(.3,1.4,.4,1);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.85); } to { opacity: 1; transform: none; } }
.scout-pop-photo {
  width: 100%; height: 84px; border-radius: 12px;
  background: #e7eaef center/cover no-repeat;
}
.scout-pop-photo.loading {
  background: linear-gradient(100deg, var(--shimmer-a) 30%, var(--shimmer-b) 50%, var(--shimmer-a) 70%) 0/300% 100%;
  animation: scout-shimmer 1.2s ease infinite;
}
.scout-pop-photo.no-photo::after {
  content: "";
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: url("https://img.icons8.com/?size=100&id=VtJeIY6JnuIM&format=png&color=000000") center / 38px 38px no-repeat;
}
.scout-pop-name { font-size: 14px; font-weight: 800; letter-spacing: -.3px; margin: 7px 4px 0; line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scout-pop-meta { font-size: 11px; color: var(--ink-soft); margin: 2px 4px 4px; font-weight: 600; }
.scout-kind-ic {
  width: 13px;
  height: 13px;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 3px;
}
.scout-pop-tail {
  position: absolute; bottom: -6px; left: 50%; margin-left: -8px;
  width: 16px; height: 16px; background: #fff; border-radius: 3px;
  transform: rotate(45deg); box-shadow: 4px 4px 8px rgba(20,30,50,.16);
}
.scout-pop-actions { position: absolute; top: -10px; right: -6px; display: flex; gap: 5px; z-index: 2; }
.scout-pop-btn {
  width: 28px; height: 28px; border-radius: 9px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  background: var(--ink); color: #fff; box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.scout-pop-btn:active { transform: scale(.9); }
.scout-pop-btn[data-act="close"] { background: #fff; color: var(--ink); }
.scout-pop-btn .scout-dice-ic { width: 15px; height: 15px; }
.scout-pin { font-size: 28px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.25)); }

/* photo loading shimmer */
.scout-photo.loading {
  background: linear-gradient(100deg, var(--shimmer-a) 30%, var(--shimmer-b) 50%, var(--shimmer-a) 70%) 0/300% 100%;
  animation: scout-shimmer 1.2s ease infinite;
}
@keyframes scout-shimmer { to { background-position: -300% 0; } }

/* ---- searching state: circular dot loader + top label + blurred shimmer name ---- */
.scout-top { display: none; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.scout-card.searching .scout-top { display: block; }
.scout-card.searching .scout-meta { display: none; }
.scout-card.searching .scout-photo { display: none; }
.scout-card.searching .scout-actions { display: none; }

.scout-spinner { display: none; width: 40px; height: 40px; flex-shrink: 0; position: relative; }
.scout-card.searching .scout-spinner { display: block; }
.scout-spinner i {
  position: absolute; top: 50%; left: 50%; width: 5.5px; height: 5.5px; margin: -2.75px;
  border-radius: 50%; background: var(--ink);
  animation: dot-fade 1s linear infinite;
}
.scout-spinner i:nth-child(1) { transform: rotate(0deg)   translateY(-15px); animation-delay: 0s; }
.scout-spinner i:nth-child(2) { transform: rotate(45deg)  translateY(-15px); animation-delay: .125s; }
.scout-spinner i:nth-child(3) { transform: rotate(90deg)  translateY(-15px); animation-delay: .25s; }
.scout-spinner i:nth-child(4) { transform: rotate(135deg) translateY(-15px); animation-delay: .375s; }
.scout-spinner i:nth-child(5) { transform: rotate(180deg) translateY(-15px); animation-delay: .5s; }
.scout-spinner i:nth-child(6) { transform: rotate(225deg) translateY(-15px); animation-delay: .625s; }
.scout-spinner i:nth-child(7) { transform: rotate(270deg) translateY(-15px); animation-delay: .75s; }
.scout-spinner i:nth-child(8) { transform: rotate(315deg) translateY(-15px); animation-delay: .875s; }
@keyframes dot-fade { 0%, 100% { opacity: .18; } 30% { opacity: 1; } }

/* big name placeholder: blurred, colourful shimmer + glowing aura while searching */
.scout-card.searching .scout-name, #scout-name.shimmering {
  font-size: 24px; font-weight: 800; letter-spacing: -.6px;
  overflow: visible; padding: 6px 10px; margin: -6px -10px; /* room so blur/glow isn't clipped */
  filter: none;
  color: rgba(20,24,32,.42);
  background: none;
  animation: loading-breathe 1.35s ease-in-out infinite;
}
@keyframes name-shimmer { to { background-position: -320% 0; } }
@keyframes loading-breathe {
  0%, 100% { opacity: .48; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-1px); }
}

/* leaflet tweaks */
.leaflet-control-attribution { font-size: 9px !important; opacity: .6; }
.leaflet-control-zoom { display: none; }

/* ---- collectible XP orbs: glowing 3D fireflies ---- */
.orb-marker {
  background: transparent !important;
  border: 0 !important;
  overflow: visible !important;
}
.orb-marker .orb {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.orb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  animation: orb-hover 2.8s ease-in-out infinite, orb-pulse 1.9s ease-in-out infinite;
}
.orb::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,1) 0 15%, rgba(255,255,255,.72) 24%, rgba(255,241,166,.9) 42%, rgba(255,194,85,.58) 62%, rgba(255,194,85,0) 76%);
  box-shadow:
    0 0 8px rgba(255,244,172,.98),
    0 0 18px rgba(255,215,105,.82),
    0 0 22px rgba(255,184,67,.32),
    inset 0 -3px 7px rgba(118,71,16,.24);
}
.orb::after {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,232,137,.28), rgba(255,232,137,.08) 46%, transparent 68%);
  filter: blur(.5px);
  animation: orb-aura 2.2s ease-in-out infinite;
}
@keyframes orb-hover {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) scale(1); }
  50% { transform: translate(-50%, -50%) translateY(-5px) scale(1.04); }
}
@keyframes orb-pulse {
  0%, 100% { opacity: .78; }
  45% { opacity: 1; }
}
@keyframes orb-aura {
  0%, 100% { transform: scale(.82); opacity: .58; }
  50% { transform: scale(1.08); opacity: .92; }
}
.orb.orb-uncommon {
  width: 32px;
  height: 32px;
}
.orb.orb-uncommon::before {
  box-shadow:
    0 0 10px rgba(255,249,198,1),
    0 0 24px rgba(255,223,112,.9),
    0 0 30px rgba(255,184,67,.38),
    inset 0 -4px 8px rgba(118,71,16,.22);
}
.orb.orb-rare {
  width: 40px;
  height: 40px;
  animation-duration: 2.4s, 1.45s;
}
.orb.orb-rare::before {
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,1) 0 14%, rgba(255,255,255,.82) 24%, rgba(255,245,184,.96) 42%, rgba(255,205,83,.64) 62%, rgba(255,205,83,0) 78%);
  box-shadow:
    0 0 12px rgba(255,250,207,1),
    0 0 28px rgba(255,223,112,.92),
    0 0 42px rgba(255,184,67,.48),
    inset 0 -5px 10px rgba(118,71,16,.2);
}
.orb.orb-rare::after {
  background: radial-gradient(circle, rgba(255,242,166,.32), rgba(255,236,149,.12) 42%, transparent 68%);
}

/* collect burst + floating +XP */
.orb-burst {
  position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(255,241,166,.9); box-shadow: 0 0 18px rgba(255,218,101,.8);
  animation: orb-pop .55s ease-out forwards;
}
@keyframes orb-pop { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
.orb-gain {
  position: absolute; left: -30px; top: -34px; width: 60px; text-align: center;
  font-weight: 800; font-size: 14px; color: #fff2a6; letter-spacing: -.3px;
  text-shadow: 0 0 8px rgba(255,216,91,.95), 0 1px 2px rgba(20,20,20,.55);
  animation: orb-rise .9s ease-out forwards;
}
@keyframes orb-rise { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }

/* orb HUD pill */
.orb-hud {
  position: absolute; top: 112px; left: 50%; transform: translateX(-50%); z-index: 545;
  display: flex; align-items: center; gap: 7px;
  background: #16181d; color: #fff; padding: 8px 14px 8px 10px; border-radius: 999px;
  font-weight: 800; font-size: 15px; box-shadow: none;
}
.orb-hud.pop { animation: orb-hud-pop .28s ease; }
@keyframes orb-hud-pop { 0% { transform: translateX(-50%) scale(1); } 45% { transform: translateX(-50%) scale(1.14); } 100% { transform: translateX(-50%) scale(1); } }
.orb-hud-ball {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  background:
    radial-gradient(circle at 34% 28%, #fff 0 16%, rgba(255,255,255,.78) 28%, rgba(255,241,166,.95) 48%, rgba(255,194,85,.55) 68%, transparent 78%);
  box-shadow: 0 0 8px rgba(255,244,172,.9), 0 0 16px rgba(255,215,105,.68);
  animation: orb-pulse 1.9s ease-in-out infinite;
}
.orb-hud-xp { font-size: 11px; opacity: .7; font-weight: 700; }
.orb-hud-combo {
  background: rgba(255,242,166,.14);
  color: #fff2a6;
  border: 1px solid rgba(255,242,166,.28);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

/* leaflet-rotate compass — move it out from under the top panel into the
   visible map area (top-left corner is hidden behind ride-top) and style it */
.leaflet-control-rotate {
  transform: translate(4px, 200px); /* drop below the mission panel */
  border: none !important; border-radius: 50% !important;
  box-shadow: 0 8px 20px rgba(30,40,60,.18) !important;
  overflow: hidden;
}
.leaflet-control-rotate a, .leaflet-control-rotate .leaflet-control-rotate-toggle {
  width: 46px !important; height: 46px !important; border-radius: 50% !important;
  background-color: #fff !important; background-size: 60% !important;
}
.user-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--blue); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(74,144,226,.25), 0 4px 10px rgba(0,0,0,.2);
}

.nav-cursor-on .user-dot {
  position: relative;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 0;
  background: url("assets/chapter1/IMG_9798-Photoroom.png") center / contain no-repeat;
  box-shadow: none;
  filter:
    drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff)
    drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff)
    drop-shadow(1.4px 1.4px 0 #fff) drop-shadow(-1.4px 1.4px 0 #fff)
    drop-shadow(1.4px -1.4px 0 #fff) drop-shadow(-1.4px -1.4px 0 #fff);
  transform: rotate(var(--heading, 0deg));
  transition: transform .28s ease;
}

.nav-fixed-cursor {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 540;
  width: 58px;
  height: 58px;
  pointer-events: none;
  opacity: 0;
  background: url("assets/chapter1/IMG_9798-Photoroom.png") center / contain no-repeat;
  filter:
    drop-shadow(2.5px 0 0 #fff) drop-shadow(-2.5px 0 0 #fff)
    drop-shadow(0 2.5px 0 #fff) drop-shadow(0 -2.5px 0 #fff)
    drop-shadow(1.8px 1.8px 0 #fff) drop-shadow(-1.8px 1.8px 0 #fff)
    drop-shadow(1.8px -1.8px 0 #fff) drop-shadow(-1.8px -1.8px 0 #fff);
  transform: translate(-50%, -50%) translateY(10px) rotate(var(--heading, 0deg));
  transition: opacity .22s ease, transform .28s cubic-bezier(.2,1,.3,1);
}

#app.navigating .nav-fixed-cursor {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(var(--heading, 0deg));
}

#app.navigating .leaflet-marker-icon.nav-cursor-on {
  opacity: 0;
}

@media (min-width: 500px) {
  #app { border-radius: 36px; margin-top: 2vh; height: 96vh; box-shadow: var(--outer-shadow); }
}

html, body { background: var(--body-bg); transition: background .3s ease; }
#app, .glass, .hex, .btn, .pill, .chip, .tab { transition: background .3s ease, color .3s ease, box-shadow .3s ease; }

/* Illustrator tracking of -50 = -50/1000 em = -0.05em letter-spacing. */
b, strong, h1, h2,
.module-pill, .section-title, .pill, .chip, .btn,
.stat b, .mini-card b,
.journal-item .j-title, .j-done,
.mission-label small,
.sheet h2, .modal h2, .sheet-meta,
.ride-mission-name, #ride-progress-label, .scout-ai, .start-tag,
.pf-title, .pf-coll-head h2 {
  letter-spacing: -0.05em;
}

/* ============ ORB reference skin: Ride screen overlays only ============ */
#screen-ride {
  position: relative;
  color: #fff;
}

#screen-ride .ride-top {
  top: calc(18px + var(--safe-top));
  left: max(18px, var(--safe-left));
  right: max(18px, var(--safe-right));
  z-index: 520;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(0,0,0,.72);
  box-shadow: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#screen-ride .ride-mission-name {
  max-width: 100%;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#screen-ride .ride-progress-wrap {
  width: 100%;
  margin-top: 9px;
  gap: 12px;
}

#screen-ride .ride-progress-bar {
  height: 5px;
  border-radius: 0;
  background: rgba(255,255,255,.16);
}

#screen-ride .ride-progress-bar > div {
  border-radius: 0;
  background: #fff;
  box-shadow: 0 0 18px rgba(255,255,255,.64);
}

#screen-ride #ride-progress-label {
  color: rgba(255,255,255,.74);
  font-size: 14px;
  font-weight: 800;
}

#screen-ride .route-remaining {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  color: rgba(255,255,255,.72);
  font-size: 12px;
  font-weight: 800;
}

.sticker-scan-btn {
  position: absolute;
  right: max(18px, var(--safe-right));
  top: calc(104px + var(--safe-top));
  z-index: 548;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 18px;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-scan-btn span {
  width: 26px;
  height: 26px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: url(assets/camera.png) center / contain no-repeat;
  mask: url(assets/camera.png) center / contain no-repeat;
}

#screen-ride .scout-card {
  top: calc(194px + var(--safe-top));
  left: max(18px, var(--safe-left));
  right: max(18px, var(--safe-right));
  z-index: 530;
  min-height: 118px;
  padding: 18px;
  border-radius: 34px;
  background: #fff;
  color: #050505;
  box-shadow: none;
  border: 1px solid rgba(0,0,0,.08);
}

#screen-ride .scout-card.searching {
  align-items: center;
}

#screen-ride .scout-spinner i {
  background: #050505;
}

#screen-ride .scout-top {
  color: rgba(0,0,0,.48);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

#screen-ride .scout-body b {
  color: #050505;
  font-size: 33px;
  line-height: .9;
  font-weight: 900;
  letter-spacing: -0.07em;
}

#screen-ride .scout-card.searching .scout-body b::after {
  content: none;
}

@keyframes loading-scan {
  0%, 100% { opacity: .22; transform: translateX(-5px) scaleX(.65); }
  50% { opacity: .95; transform: translateX(4px) scaleX(1); }
}

#screen-ride .scout-card.searching .scout-name,
#screen-ride #scout-name.shimmering {
  font-size: 33px;
  line-height: .9;
  filter: none;
  background: none;
  color: rgba(0,0,0,.72);
  animation: loading-breathe 1.35s ease-in-out infinite;
}

#screen-ride .scout-meta {
  color: rgba(0,0,0,.54);
  font-size: 13px;
}

#screen-ride .scout-actions button {
  border-radius: 50%;
  background: #111;
  color: #fff;
  box-shadow: none;
}

#screen-ride #btn-scout-close {
  background: #f1f1f3;
  color: #111;
}

#screen-ride .ride-panel {
  left: max(18px, var(--safe-left));
  right: max(18px, var(--safe-right));
  bottom: calc(84px + var(--safe-bottom));
  z-index: 520;
  padding: 22px 18px 16px;
  border-radius: 34px;
  background: #fff;
  color: #050505;
  box-shadow: none;
  border: 1px solid rgba(0,0,0,.08);
}

#app.navigating .tabbar {
  transform: translateY(calc(100% + 28px));
  opacity: 0;
  pointer-events: none;
}

#app.navigating #screen-ride .ride-panel {
  bottom: calc(16px + var(--safe-bottom));
}

#screen-ride .rp-stats {
  justify-content: space-between;
  gap: 10px;
}

#screen-ride .rp-stat {
  flex: 1;
}

#screen-ride .rp-stat b {
  color: #050505;
  font-size: 32px;
  line-height: .92;
  font-weight: 900;
  letter-spacing: -0.07em;
}

#screen-ride .rp-stat span {
  color: rgba(0,0,0,.48);
  font-size: 12px;
  font-weight: 700;
}

#screen-ride .rp-legend {
  margin: 18px 0 0;
  color: rgba(0,0,0,.54);
  font-size: 12px;
  font-weight: 700;
}

#screen-ride .dot {
  width: 9px;
  height: 9px;
  box-shadow: none;
}

#screen-ride .rp-buttons {
  gap: 10px;
  margin-top: 18px;
}

#screen-ride .demo-speed {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: rgba(0,0,0,.54);
  font-size: 12px;
  font-weight: 800;
}

#screen-ride .demo-speed input {
  width: 100%;
  accent-color: #111;
}

#screen-ride .demo-speed b {
  min-width: 42px;
  color: #050505;
  font-size: 12px;
  text-align: right;
}

#screen-ride .rp-btn {
  padding: 16px 14px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
}

#screen-ride .rp-btn-dark {
  background: #111;
  color: #fff;
}

#screen-ride .rp-btn-light {
  background: #fff;
  color: #111;
  border: 1.5px solid rgba(0,0,0,.14);
}

#btn-pause-ride {
  flex: .8;
}

#screen-ride .rp-status {
  max-width: 100%;
  margin-top: 13px;
  color: rgba(0,0,0,.46);
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#screen-ride .scout-pop {
  padding: 8px;
  border-radius: 24px;
  background: #fff;
  color: #050505;
  box-shadow: none;
  border: 1px solid rgba(0,0,0,.08);
}

#screen-ride .scout-pop-photo {
  height: 86px;
  border-radius: 18px;
}

#screen-ride .scout-pop-name {
  color: #050505;
  font-weight: 900;
}

#screen-ride .scout-pop-meta {
  color: rgba(0,0,0,.54);
}

#screen-ride .scout-pop-tail {
  background: #fff;
}

#screen-ride .scout-pop-btn {
  border-radius: 50%;
  background: #111;
  box-shadow: none;
}

#screen-ride .scout-pop-btn[data-act="close"] {
  background: #f1f1f3;
  color: #111;
}

/* ORB-style confirm dialog — flat, no shadow */
.confirm {
  position: absolute; top: 50%; left: max(22px, var(--safe-left)); right: max(22px, var(--safe-right)); z-index: 720;
  transform: translateY(-50%);
  background: #fff; border-radius: 28px; padding: 26px 24px 22px; text-align: left;
  animation: popIn .3s cubic-bezier(.2,1.4,.4,1);
  max-height: calc(var(--app-h) - var(--safe-top) - var(--safe-bottom) - 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.confirm-title { font-size: 26px; font-weight: 800; letter-spacing: -.8px; }
.confirm-desc { color: var(--ink-soft); font-size: 14.5px; margin-top: 6px; }
.confirm-actions { display: flex; gap: 10px; margin-top: 20px; }
.confirm-btn {
  flex: 1; border: none; font: inherit; font-weight: 800; font-size: 15px;
  padding: 15px; border-radius: 999px; cursor: pointer; letter-spacing: -.3px;
  transition: transform .15s ease;
}
.confirm-btn:active { transform: scale(.96); }
.confirm-btn-dark { background: var(--ink); color: #fff; }
.confirm-btn-light { background: #fff; color: var(--ink); border: 1.5px solid rgba(40,50,70,.2); }

/* destination photo reward */
.photo-capture {
  position: absolute;
  left: max(18px, var(--safe-left));
  right: max(18px, var(--safe-right));
  top: 50%;
  z-index: 720;
  transform: translateY(-50%);
  padding: 18px;
  border-radius: 32px;
  background: #fff;
  color: #050505;
  border: 1px solid rgba(0,0,0,.08);
  text-align: left;
  animation: popIn .3s cubic-bezier(.2,1.4,.4,1);
  max-height: calc(var(--app-h) - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.photo-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / .78;
  border-radius: 18px;
  margin-bottom: 16px;
  background: #eef1f6;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.photo-preview.camera-on video {
  display: block;
}
.photo-preview.has-photo video {
  display: none;
}
.photo-preview-ic {
  width: 42px;
  height: 42px;
  display: inline-block;
  background: rgba(5,5,5,.5);
  -webkit-mask: url(assets/camera.png) center / contain no-repeat;
  mask: url(assets/camera.png) center / contain no-repeat;
}
.photo-preview.camera-on .photo-preview-ic { display: none; }
.photo-preview.has-photo .photo-preview-ic { display: none; }
.sticker-scan-modal .photo-preview {
  aspect-ratio: 1 / 1;
}
.photo-eyebrow {
  display: block;
  color: rgba(0,0,0,.48);
  font-size: 12px;
  font-weight: 800;
}
.photo-capture h2 {
  margin-top: 4px;
  font-size: 32px;
  line-height: .95;
  font-weight: 900;
  letter-spacing: -0.06em;
}
.photo-capture p {
  margin-top: 8px;
  color: rgba(0,0,0,.54);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

/* ============ phone polish: iPhone safe areas + small Android screens ============ */
@supports (height: 100svh) {
  #app { min-height: 100svh; }
}

@media (max-width: 420px) {
  :root { --edge-x: max(12px, var(--safe-left), var(--safe-right)); }

  .topbar.floating {
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
  }
  .module-pill,
  .chip,
  .avatar {
    height: 50px;
    border-radius: 18px;
  }
  .module-pill {
    padding: 0 16px;
    font-size: 14px;
  }
  .chip-purple { width: 64px; }
  .chip-gray { width: 58px; }
  .avatar { width: 50px; }

  #screen-ride .ride-top {
    top: calc(12px + var(--safe-top));
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    padding: 11px 12px;
    border-radius: 16px;
  }
  #screen-ride .ride-mission-name {
    font-size: 16px;
  }
  #screen-ride #ride-progress-label {
    font-size: 13px;
    min-width: 30px;
  }
  .sticker-scan-btn {
    top: calc(92px + var(--safe-top));
    right: max(12px, var(--safe-right));
    width: 50px;
    height: 50px;
    border-radius: 16px;
  }
  #screen-ride .scout-card {
    top: calc(170px + var(--safe-top));
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    min-height: 104px;
    padding: 14px;
    border-radius: 28px;
  }
  #screen-ride .scout-body b,
  #screen-ride .scout-card.searching .scout-name,
  #screen-ride #scout-name.shimmering {
    font-size: 28px;
  }
  #screen-ride .ride-panel {
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    bottom: calc(78px + var(--safe-bottom));
    padding: 17px 14px 13px;
    border-radius: 28px;
  }
  #app.navigating #screen-ride .ride-panel {
    bottom: calc(12px + var(--safe-bottom));
  }
  #screen-ride .rp-stat b {
    font-size: clamp(25px, 8vw, 30px);
  }
  #screen-ride .rp-legend {
    gap: 10px;
    font-size: 11px;
  }
  #screen-ride .rp-buttons {
    gap: 8px;
    margin-top: 14px;
  }
  #screen-ride .rp-btn {
    min-height: 50px;
    padding: 13px 10px;
    font-size: 16px;
  }
  #screen-ride .demo-speed {
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
  }
  #screen-ride .demo-speed input {
    grid-column: 1 / -1;
    order: 3;
  }
  #screen-ride .rp-status {
    font-size: 11px;
  }

  .tabbar {
    left: max(10px, var(--safe-left));
    right: max(10px, var(--safe-right));
    bottom: calc(10px + var(--safe-bottom));
    border-radius: 24px;
  }
  .tab {
    height: 50px;
    border-radius: 18px;
  }
  .tab.active {
    flex: 2;
    gap: 6px;
  }
  .tab-label {
    font-size: 13px;
  }

  .screen {
    padding-left: max(14px, var(--safe-left));
    padding-right: max(14px, var(--safe-right));
  }
  .screen-header h1,
  .pf-title {
    font-size: 29px;
  }
  .pf-cover {
    height: min(330px, calc(var(--app-h) * .42));
    border-radius: 24px;
  }
  .pf-rows,
  .pf-collection,
  .journal-item {
    border-radius: 18px;
  }
  .modal,
  .confirm,
  .photo-capture {
    left: max(14px, var(--safe-left));
    right: max(14px, var(--safe-right));
    border-radius: 26px;
  }
  .photo-capture h2,
  .modal h2 {
    font-size: 29px;
  }
  .reward-actions,
  .confirm-actions {
    gap: 8px;
  }
  .reward-btn,
  .confirm-btn {
    min-height: 50px;
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (max-width: 360px) {
  .module-pill {
    max-width: 128px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chip-purple { width: 58px; }
  .chip-gray { width: 54px; }
  .chip-ic {
    width: 17px;
    height: 17px;
  }
  #screen-ride .rp-stats {
    gap: 4px;
  }
  #screen-ride .rp-stat b {
    font-size: clamp(22px, 7vw, 26px);
  }
  #screen-ride .rp-legend {
    gap: 7px;
    font-size: 10.5px;
  }
  #screen-ride .rp-btn {
    font-size: 15px;
  }
  .tab.active .tab-label {
    max-width: 64px;
  }
}

@media (max-height: 700px) {
  #screen-ride .scout-card:not(.hidden) {
    top: calc(142px + var(--safe-top));
  }
  #screen-ride .ride-panel {
    padding-top: 14px;
  }
  #screen-ride .rp-legend {
    margin-top: 12px;
  }
  #screen-ride .rp-buttons {
    margin-top: 12px;
  }
  #screen-ride .demo-speed {
    margin-top: 10px;
  }
  .photo-preview {
    aspect-ratio: 1 / .68;
  }
  .sticker-scan-modal .photo-preview {
    aspect-ratio: 1 / .82;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #app {
    max-width: none;
    height: var(--app-h);
    margin-top: 0;
    border-radius: 0;
    box-shadow: none;
  }
  #screen-ride .ride-top {
    max-width: 430px;
  }
  #screen-ride .ride-panel {
    left: auto;
    width: min(420px, calc(50vw - 18px));
    bottom: calc(12px + var(--safe-bottom));
  }
  #screen-ride .scout-card {
    right: auto;
    width: min(420px, calc(50vw - 18px));
  }
  .tabbar {
    width: min(430px, calc(52vw - 18px));
    left: max(12px, var(--safe-left));
    right: auto;
  }
  .photo-capture,
  .modal,
  .confirm {
    width: min(430px, calc(100vw - var(--safe-left) - var(--safe-right) - 28px));
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
  }
}
