/* Aincrad City: all styles. Stardust tokens and components ported to plain CSS (docs/village-spec.md §7),
   mobile first, then the §8 layout classes at the bottom: tablet, desktop, phone landscape (in that order, so the
   landscape rules win on wide phones). */

@font-face {
  font-family: 'Geist';
  src: url('../fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ----------
   Hex / rgba first (old browsers), oklch and color-mix inside @supports. Theme values sit on
   :root[data-theme=...] after every plain :root block, so the reference's burgundy :root primary never shows.
   Forest is the default (index.html sets data-theme before this file loads). */
:root,
:root[data-theme='forest'] {
  --hue: 150;
  --radius: 0.75rem;
  --background: #fcfefd;
  --foreground: #121813;
  --card: #ffffff;
  --card-foreground: #121813;
  --popover: #ffffff;
  --popover-foreground: #121813;
  --primary: #195c2e;
  --primary-foreground: #ffffff;
  --primary-highlight: rgba(142, 208, 156, 0.5);
  --secondary: #f0f5f1;
  --secondary-foreground: #1d241e;
  --muted: #f0f5f1;
  --muted-foreground: #5d665f;
  --accent: #e4f8e7;
  --accent-foreground: #00481b;
  --destructive: #d40c1a;
  --success: #00884b;
  --warning: #e38f00;
  --border: #dfe4e0;
  --input: #d6ddd7;
  --ring: #195c2e;
  /* derived: the tactile primary's gradient (top -> bottom, white text >= 4.5:1 on both), 1px darker edge,
     pressed fill and the low-alpha primary glow below; the glass card fill and scrims */
  --primary-top: #2c6d3e;
  --primary-bottom: #195c2e;
  --primary-edge: #05441d;
  --primary-press: #034e21;
  --primary-glow: rgba(25, 92, 46, 0.35);
  --glass: rgba(255, 255, 255, 0.92);
  --scrim: rgba(18, 24, 19, 0.36);
  --ink-fill: rgba(18, 24, 19, 0.86);
}
:root[data-theme='sky'] {
  --hue: 243;
  --background: #fcfeff;
  --foreground: #11171b;
  --card-foreground: #11171b;
  --popover-foreground: #11171b;
  --primary: #0079c9;
  --primary-highlight: rgba(131, 197, 249, 0.5);
  --secondary: #eff4f8;
  --secondary-foreground: #1c2328;
  --muted: #eff4f8;
  --muted-foreground: #5c646b;
  --accent: #e1f5ff;
  --accent-foreground: #003e6a;
  --border: #dfe4e8;
  --input: #d5dce1;
  --ring: #0079c9;
  /* sky's primary is light: the gradient runs from the primary (4.59:1 with white) down, never lighter */
  --primary-top: #0079c9;
  --primary-bottom: #006ab8;
  --primary-edge: #005598;
  --primary-press: #0061aa;
  --primary-glow: rgba(0, 121, 201, 0.35);
  --scrim: rgba(17, 23, 27, 0.36);
  --ink-fill: rgba(17, 23, 27, 0.86);
}
@supports (color: oklch(0 0 0)) {
  /* Stardust light theme (reference lines 54-91) */
  :root,
  :root[data-theme='forest'],
  :root[data-theme='sky'] {
    --hue: 15;
    --radius: 0.75rem;
    --background: oklch(0.995 0.002 var(--hue));
    --foreground: oklch(0.2 0.012 var(--hue));
    --card: oklch(1 0 var(--hue));
    --card-foreground: oklch(0.2 0.012 var(--hue));
    --popover: oklch(1 0 var(--hue));
    --popover-foreground: oklch(0.2 0.012 var(--hue));
    --primary: oklch(0.38 0.152 18.6);
    --primary-foreground: oklch(1 0 var(--hue));
    --primary-highlight: oklch(0.8 0.12 19.4 / 50%);
    --secondary: oklch(0.965 0.008 var(--hue));
    --secondary-foreground: oklch(0.25 0.015 var(--hue));
    --muted: oklch(0.965 0.008 var(--hue));
    --muted-foreground: oklch(0.5 0.015 var(--hue));
    --accent: oklch(0.96 0.03 var(--hue));
    --accent-foreground: oklch(0.347 0.104 1.4);
    --destructive: oklch(0.55 0.22 27);
    --success: oklch(0.55 0.14 155);
    --warning: oklch(0.72 0.16 70);
    --border: oklch(0.915 0.008 var(--hue));
    --input: oklch(0.89 0.01 var(--hue));
    --ring: oklch(0.38 0.152 18.6);
  }
  /* theme blocks (reference lines 93-114); forest also covers a missing attribute */
  :root[data-theme='sky'] {
    --hue: 243;
    --primary: oklch(0.55 0.17 240);
    --primary-highlight: oklch(0.8 0.1 243 / 50%);
    --accent-foreground: oklch(0.35 0.1 243);
    --ring: var(--primary);
  }
  :root[data-theme='forest'],
  :root:not([data-theme='sky']) {
    --hue: 150;
    --primary: oklch(0.42 0.1 150);
    --primary-highlight: oklch(0.8 0.1 150 / 50%);
    --accent-foreground: oklch(0.35 0.1 150);
    --ring: var(--primary);
  }
}
@supports (color: color-mix(in oklab, red, blue)) {
  :root,
  :root[data-theme='forest'],
  :root[data-theme='sky'] {
    --primary-top: color-mix(in oklab, var(--primary), white 10%);
    --primary-bottom: var(--primary);
    --primary-edge: color-mix(in oklab, var(--primary), black 26%);
    --primary-press: color-mix(in oklab, var(--primary), black 14%);
    --primary-glow: color-mix(in oklab, var(--primary) 35%, transparent);
    --glass: color-mix(in oklab, var(--card) 92%, transparent);
    --scrim: color-mix(in oklab, var(--foreground) 36%, transparent);
    --ink-fill: color-mix(in oklab, var(--foreground) 86%, transparent);
  }
  :root[data-theme='sky'] {
    --primary-top: var(--primary);
    --primary-bottom: color-mix(in oklab, var(--primary), black 12%);
    --primary-edge: color-mix(in oklab, var(--primary), black 30%);
    --primary-press: color-mix(in oklab, var(--primary), black 20%);
  }
}


:root {
  /* old names, kept as aliases so every module's markup keeps working */
  --ink: var(--foreground);
  --ink2: var(--secondary-foreground);
  --mute: var(--muted-foreground);
  --paper: var(--glass);
  --paper2: rgba(255, 255, 255, 0.62);
  --line: var(--border);
  --green: var(--primary);
  --red: var(--destructive);
  --gold: #e2b23a; /* coins only (.coin) */
  --gold2: #c9971f;
  --bg: #cfe3ee; /* the sky behind the canvas */
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.06), 0 8px 24px -6px rgba(16, 24, 20, 0.22);
  --shadow-sm: 0 1px 2px rgba(16, 24, 20, 0.08);
  --r: calc(var(--radius) + 4px); /* cards */
  --r-md: calc(var(--radius) - 2px);
  --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);
  --g: 8px; /* edge gutter */
  --hud: 40px; /* top bar control height (44 on touch) */
  --navH: 64px;
  --mileH: 40px;
  --row1: calc(var(--sat) + var(--g));
  --row2: calc(var(--row1) + var(--hud) + 8px);
  --row3: calc(var(--row2) + var(--hud) + 8px);
  --row4: calc(var(--row3) + var(--mileH) + 8px);
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Malayalam', sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
@media (pointer: coarse) {
  :root { --hud: 44px; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--foreground);
  font: 14px/1.5 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; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: var(--foreground); user-select: text; -webkit-user-select: text; }
a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }
b, strong { font-weight: 600; }
kbd {
  font: 500 11px/1 var(--font);
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--secondary);
  box-shadow: inset 0 -1px 0 var(--border), inset 0 0 0 1px var(--border);
  color: var(--muted-foreground);
}
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; }

/* focus: a 2px ring with a 2px gap on buttons, a soft ring on inputs */
:focus { outline: none; }
button:focus-visible, a:focus-visible, [role='button']:focus-visible, [role='tab']:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ---------- building blocks ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
  border-radius: var(--r);
}

/* buttons: .pill = secondary, .pill.gold / .pill.green = tactile primary, .pill.line = outline, .pill.dark = ink,
   .pill.ghost = ghost, .round = icon button. No scale on press: a darker fill (and the primary sinks 1px). */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius);
  background: var(--secondary); color: var(--secondary-foreground);
  font-size: 14px; font-weight: 550; line-height: 1.2; white-space: nowrap; text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background-color 0.1s ease-out, box-shadow 0.1s ease-out, color 0.15s, transform 0.1s ease-out;
}
.pill svg { width: 17.6px; height: 17.6px; }
.pill:hover { background: var(--border); }
.pill:active { background: var(--input); }
.pill.gold, .pill.green, #bottom button.main, #bootErr button {
  color: var(--primary-foreground);
  background: linear-gradient(180deg, var(--primary-top), var(--primary-bottom));
  /* soft top highlight, 1px darker edge, the primary glowing softly below */
  box-shadow: inset 0 1px 0 var(--primary-highlight), 0 0 0 1px var(--primary-edge), 0 4px 12px -4px var(--primary-glow);
}
.pill.gold:hover, .pill.green:hover, #bottom button.main:hover { background: linear-gradient(180deg, var(--primary-top), var(--primary-top)); }
/* press: 1px sink, darker fill, the glow tucks underneath */
.pill.gold:active, .pill.green:active, #bottom button.main:active, #bootErr button:active {
  background: var(--primary-press);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--primary-edge), 0 1px 3px -1px var(--primary-glow);
  transform: translateY(1px);
}
.pill.line { background: var(--background); color: var(--foreground); box-shadow: inset 0 0 0 1px var(--input), var(--shadow-sm); }
.pill.line:hover { background: var(--secondary); }
.pill.line:active { background: var(--border); }
.pill.dark { background: var(--ink-fill); color: #fff; box-shadow: none; }
.pill.dark:hover, .pill.dark:active { background: var(--foreground); }
.pill.ghost { background: transparent; box-shadow: none; }
.pill.ghost:hover { background: var(--secondary); }
.pill.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: var(--r-md); }
.pill.big { min-height: 48px; font-size: 15px; }
.pill.wide { width: 100%; }
.pill:disabled, .round:disabled, .pill[disabled] { opacity: 0.5; pointer-events: none; }

/* coin balances stay gold */
.coin, .pill.coin, .pill.gold.coin {
  color: #3b2a04;
  background: linear-gradient(180deg, #f2cf6b, var(--gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 0 0 1px var(--gold2), 0 4px 10px -5px rgba(201, 151, 31, 0.7);
  font-variant-numeric: tabular-nums;
}
.pill.coin:hover { background: linear-gradient(180deg, #f5d77f, #e8bd4d); }
.pill.coin:active { background: var(--gold2); transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--gold2); }

.round {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--glass); color: var(--foreground);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
  transition: background-color 0.1s ease-out, color 0.15s;
}
.round:hover { background: var(--card); }
.round:active { background: var(--secondary); }
.round.on, #runBtn.on, #radioPower.on { background: var(--primary); color: var(--primary-foreground); box-shadow: inset 0 1px 0 var(--primary-highlight), 0 0 0 1px var(--primary-edge); }
.round.sm { width: 32px; height: 32px; border-radius: var(--r-md); box-shadow: none; background: var(--secondary); -webkit-backdrop-filter: none; backdrop-filter: none; }
.round.sm:hover { background: var(--border); }
.round.sm svg { width: 16px; height: 16px; }
.round.big { width: 60px; height: 60px; border-radius: 50%; }
.round.big svg { width: 24px; height: 24px; }

/* badges: tinted pill, coloured border, heavier bottom edge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap;
  background: var(--accent); color: var(--accent-foreground);
  border: 1px solid var(--primary-highlight); border-bottom-width: 2px;
}
.badge svg { width: 14px; height: 14px; }
.badge.gold { background: #fdf3d8; color: #7a5208; border-color: rgba(227, 143, 0, 0.35); }
.badge.ink { background: var(--foreground); color: var(--background); border-color: var(--foreground); }

.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(min(140px, 100%), 1fr)); gap: 8px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; min-width: 0;
  border-radius: var(--radius); background: var(--card); box-shadow: inset 0 0 0 1px var(--border);
  text-align: left; transition: background-color 0.1s ease-out, box-shadow 0.1s ease-out;
}
.tile > b { line-height: 1.3; }
.tile > svg { color: var(--primary); }
button.tile:hover { background: var(--secondary); }
button.tile:active { background: var(--border); }
.tile.on { box-shadow: inset 0 0 0 2px var(--primary); background: var(--accent); }
.tile .pill { margin-top: auto; }
.fine { font-size: 12px; line-height: 1.35; color: var(--muted-foreground); }

/* inputs: 44px, soft 3px ring on focus */
.acInput {
  width: 100%; height: 44px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--input); background: var(--background); font-size: 16px;
  box-shadow: var(--shadow-sm); transition: border-color 0.1s ease-out, box-shadow 0.1s ease-out;
}
.acInput::placeholder { color: var(--muted-foreground); }
.acInput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-highlight); outline: none; }
select.acInput { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background: var(--background) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center; }
input[type='checkbox'] { accent-color: var(--primary); width: 18px; height: 18px; }
.acErr { color: var(--destructive); font-size: 13px; min-height: 18px; margin: 4px 0; }

.payBtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 8px; margin: 14px 0 4px; }
.payBtns button:not(.pill) {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px; border-radius: var(--radius); text-align: left;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
  transition: background-color 0.1s ease-out;
}
.payBtns button:not(.pill):hover { background: var(--secondary); }
.payBtns button:not(.pill):active { background: var(--border); }
.payBtns button b { font-size: 17px; font-variant-numeric: tabular-nums; }
.payBtns button span { color: var(--muted-foreground); font-size: 13px; }
.xBtn {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: var(--r-md); font-size: 22px; line-height: 1;
  display: grid; place-items: center; color: var(--muted-foreground); background: var(--secondary);
  transition: background-color 0.1s ease-out, color 0.15s;
}
.xBtn:hover { background: var(--border); color: var(--foreground); }
.xBtn:active { background: var(--input); }

/* progress (4.4px track) */
.bar, #mile .track, #loader .bar { position: relative; height: 5px; border-radius: 99px; background: var(--secondary); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* tabs (Stardust TabsList): muted track, the active trigger raised as a card. Modules mark the active tab with
   .gold or .dark. */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.row.tabs { display: flex; width: fit-content; max-width: 100%; }
.tabs .pill, .tabs .pill.line, .tabs .pill.gold, .tabs .pill.dark {
  min-height: 34px; padding: 0 12px; border-radius: var(--r-md); font-size: 13.5px;
  background: transparent; color: var(--muted-foreground); box-shadow: none; transform: none;
}
.tabs .pill:hover { color: var(--foreground); }
.tabs .pill.gold, .tabs .pill.dark, .tabs .pill[aria-selected='true'] {
  background: var(--card); color: var(--foreground); box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}

/* ---------- 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(--primary); stroke-width: 3; }
#loader .logo b { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; }
#loader .logo span { color: var(--secondary-foreground); }
#loader .bar { width: min(280px, 70vw); height: 6px; background: rgba(255, 255, 255, 0.6); }
#loader .bar i {
  display: block; height: 100%; width: 4%; border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-top), var(--primary));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  transition: width 0.35s ease;
}
#loader .msg { color: var(--secondary-foreground); font-weight: 550; 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(--primary); stroke-width: 3; }
#bootErr h1 { font-size: 24px; margin: 12px 0; }
#bootErr .d { font-size: 12px; color: var(--muted-foreground); word-break: break-word; }
#bootErr button { margin-top: 8px; min-height: 44px; padding: 0 22px; border-radius: var(--radius); font-weight: 600; }
.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: var(--row1); left: calc(var(--sal) + var(--g)); right: calc(var(--sar) + var(--g));
  display: flex; align-items: center; gap: 6px; pointer-events: none;
}
#top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: var(--hud); min-width: var(--hud);
  padding: 0 12px; border-radius: var(--radius); flex: none;
}
.brand svg { color: var(--primary); stroke-width: 2.2; }
.brand b { font-size: 15px; font-weight: 650; white-space: nowrap; letter-spacing: -0.015em; }
#resCount { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; font-variant-numeric: tabular-nums; }
#gameHud { display: flex; align-items: center; gap: 6px; min-width: 0; }
#gameHud:empty { display: none; }
#gameHud .pill { min-height: var(--hud); height: var(--hud); padding: 0 12px; font-size: 14px; font-weight: 600; }
#gameHud svg { width: 17.6px; height: 17.6px; }
#gameHud .pill.badge, #gameHud .pill.line {
  border-radius: 999px; padding: 0 12px; border: 0;
  background: var(--glass); color: var(--foreground);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
}
.topBtns { margin-left: auto; display: flex; gap: 6px; align-items: center; }
#findBtn, #supportBtn, #menuBtn { height: var(--hud); min-height: var(--hud); }
#findBtn { padding: 0 12px; border-radius: var(--radius); }
#findBtn.pill.line.glass { background: var(--glass); box-shadow: 0 0 0 1px var(--border), var(--shadow); }
#findBtn.pill.line.glass:hover { background: var(--card); }
#findN { font-size: 12px; color: var(--muted-foreground); font-weight: 500; font-variant-numeric: tabular-nums; }
#supportBtn { padding: 0 14px; }
#menuBtn { width: var(--hud); }

/* ---------- search ---------- */
#searchWrap {
  position: absolute; top: var(--row2); left: calc(var(--sal) + var(--g)); right: calc(var(--sar) + var(--g));
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: var(--radius);
  transition: box-shadow 0.1s ease-out;
  z-index: 4; /* the results list drops over the milestone strip and the card */
}
#searchWrap svg { color: var(--muted-foreground); width: 18px; height: 18px; }
#q { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16px; }
#q::placeholder { color: var(--muted-foreground); }
#q::-webkit-search-cancel-button { -webkit-appearance: none; }
#searchWrap.spot, #searchWrap:focus-within { box-shadow: 0 0 0 1px var(--primary), 0 0 0 4px var(--primary-highlight), var(--shadow); }
#results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 50vh; overflow: auto;
  padding: 4px; border-radius: var(--radius); background: var(--popover); box-shadow: 0 0 0 1px var(--border), var(--shadow);
  -webkit-overflow-scrolling: touch;
}
#results button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px; border-radius: var(--r-md); text-align: left;
}
#results button:hover, #results button.sel { background: var(--accent); color: var(--accent-foreground); }
#results .no { font-weight: 600; min-width: 48px; color: var(--primary); 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(--muted-foreground); }

/* ---------- chips under the brand (mark + radio) ---------- */
body { --chipTop: var(--row2); }
#ui > .chip {
  position: absolute; left: calc(var(--sal) + var(--g)); top: var(--chipTop);
  display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: var(--r);
  max-width: calc(100vw - 16px); font-size: 13px;
}
#radioChip:not(.first) { top: calc(var(--chipTop) + var(--hud) + 16px); }
#markChip.solo, #radioChip.first { top: var(--chipTop); }
/* chat phrase chips share the class name: keep them in the flow of their sheet */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chips .chip { position: static; max-width: 100%; }
.chip .arrow { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--primary); color: var(--primary-foreground); 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.2; min-width: 0; padding: 0 2px; }
.mtxt b, .rtxt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.mtxt small, .rtxt small { color: var(--muted-foreground); font-size: 11px; }
body:not([data-mode='walk']):not([data-mode='drive']) #markArrow { display: none; }

/* ---------- house card ---------- */
#card {
  position: absolute; left: calc(var(--sal) + var(--g)); right: calc(var(--sar) + var(--g));
  bottom: calc(var(--sab) + var(--g) + var(--navH) + 8px);
  padding: 14px; overflow: auto; border-radius: var(--r);
  max-height: calc(100vh - var(--row4) - var(--navH) - var(--sab) - 24px);
  max-height: calc(100dvh - var(--row4) - var(--navH) - var(--sab) - 24px);
  animation: rise 0.2s var(--ease);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
#card .cNo { font-size: 12px; font-weight: 600; color: var(--primary); letter-spacing: 0.06em; text-transform: uppercase; }
#card h2 { font-size: 22px; letter-spacing: -0.02em; margin: 2px 0 6px; word-break: break-word; padding-right: 40px; }
#card .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
#card .style { color: var(--secondary-foreground); 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(--secondary-foreground); }
#card .xBtn { top: 10px; right: 10px; }

/* ---------- milestone strip (usage-quota pattern: numbers, 4.4px bar, caption) ---------- */
#mile {
  position: absolute; display: flex; align-items: center; gap: 8px; cursor: pointer;
  top: var(--row3); left: calc(var(--sal) + var(--g)); right: calc(var(--sar) + var(--g)); height: var(--mileH);
  padding: 4px 12px 4px 6px; border-radius: var(--radius);
  transition: background-color 0.1s ease-out;
}
#mile:hover { background: var(--card); }
#mile .mbody { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
#mile .mhead { order: 2; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted-foreground); }
#mile .mhead:empty { display: none; }
#mile .mnum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
#mile .mnum b { color: var(--foreground); font-weight: 600; }
#mile .track { flex: 1; min-width: 0; overflow: visible; }
#mile .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--primary); transition: width 0.6s var(--ease); }
#mile .ticks { position: absolute; inset: 0; }
#mile .ticks i { position: absolute; top: -2px; width: 2px; height: 9px; margin-left: -1px; background: var(--input); border-radius: 1px; }
#mile .ticks i.done { background: var(--primary); }
#mile .lbl { font-size: 12px; line-height: 16px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mile .lbl b { color: var(--foreground); font-weight: 600; }
#mile .mnum, #mile .lbl { display: none; }
#mile .mfig { flex: none; width: 40px; height: 30px; }
#mile .mfig svg { width: 40px; height: 30px; display: block; }
.preview {
  display: inline-flex; align-items: center; flex: none; padding: 0 7px; border-radius: 999px;
  font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.01em;
  background: #fdf3d8; color: #7a5208; border: 1px solid rgba(227, 143, 0, 0.35); border-bottom-width: 2px;
}

/* ---------- 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(min(140px, 100%), 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(--primary); background: var(--accent); }
.sheet.miles .tile.locked b { color: var(--muted-foreground); }
.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) + var(--g)); right: calc(var(--sar) + var(--g)); bottom: calc(var(--sab) + var(--g));
  display: flex; align-items: stretch; justify-content: space-around; gap: 4px;
  height: var(--navH); padding: 5px; border-radius: calc(var(--radius) + 6px);
}
#bottom button {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: var(--radius); font-size: 11.5px; font-weight: 550; color: var(--secondary-foreground);
  transition: background-color 0.1s ease-out, color 0.15s;
}
#bottom button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#bottom button:hover { background: var(--secondary); color: var(--foreground); }
#bottom button:active { background: var(--border); }
#bottom button.main { flex-grow: 1.25; }
#bottom svg { width: 22px; height: 22px; }
#bottom .l { display: none; }

#policyLink {
  position: absolute; right: calc(var(--sar) + 12px); bottom: calc(var(--sab) + var(--g) + var(--navH) + 8px);
  font-size: 11px; line-height: 20px; color: var(--secondary-foreground); text-decoration: none;
  background: var(--glass); padding: 0 8px; border-radius: 99px; box-shadow: 0 0 0 1px var(--border);
}
#card:not(.hide) ~ #policyLink { display: none; }

/* the guide spotlight on a real button */
#ui .spot { z-index: 3; box-shadow: 0 0 0 2px var(--ring), 0 0 0 8px var(--primary-highlight) !important; animation: spotPulse 1.4s ease-in-out infinite; }
@keyframes spotPulse { 50% { box-shadow: 0 0 0 2px var(--ring), 0 0 0 13px rgba(255, 255, 255, 0); } }

/* ---------- 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:not(.pill), 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(--card); box-shadow: 0 0 0 1px var(--border), 0 4px 14px rgba(16, 24, 20, 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: 600; line-height: 1; margin-top: -2px; }
#actBtn { min-height: 52px; padding: 0 22px; font-size: 16px; font-weight: 600; animation: pop 0.15s var(--ease); }
#actBtn kbd { display: none; background: rgba(255, 255, 255, 0.18); color: inherit; box-shadow: none; }
@keyframes pop { from { 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: var(--radius); font-size: 12px; font-weight: 700; 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(var(--primary-top), var(--primary-edge)); }
#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: var(--ink-fill); color: #fff; box-shadow: inset 0 0 0 3px var(--primary-highlight), 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: var(--radius); text-align: center;
  background: var(--ink-fill); color: #fff; font-size: 13px; animation: rise 0.25s var(--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) + var(--g)); top: var(--row2);
  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.15s var(--ease); }
.wbtns.more #moreBtn, #exitWalk { background: var(--ink-fill); color: #fff; box-shadow: var(--shadow); }
#chatDot { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--destructive); 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: 8px 8px 8px 14px; border-radius: var(--r);
  width: max-content; max-width: calc(100vw - 16px);
}
#busChip > svg { color: var(--primary); width: 26px; height: 26px; }
#busChip .bc { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
#busChip small { color: var(--muted-foreground); font-size: 12px; }
#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: var(--r);
  background: var(--ink-fill); 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.75; font-size: 12px; display: block; }
#tripHud b { font-size: 16px; }
#tripHud .thBar { height: 5px; border-radius: 99px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
#tripHud .thBar i { display: block; height: 100%; width: 0; background: var(--primary-highlight); border-radius: inherit; }
#tripHud .pill { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
#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: var(--scrim); animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }
#tripCard .tc { width: min(440px, 100%); max-height: calc(100% - 20px); overflow: auto; padding: 0 0 18px; border-radius: calc(var(--r) + 4px); background: #fffaf0; box-shadow: 0 0 0 1px var(--border), 0 20px 60px rgba(0, 0, 0, 0.35); animation: rise 0.3s var(--ease); }
#tripCard .art svg { display: block; width: 100%; height: auto; stroke: none; border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0; }
#tripCard .tcIn { padding: 16px 20px 0; }
#tripCard h2 { font-size: 24px; letter-spacing: -0.02em; }
#tripCard .stamp { display: inline-flex; gap: 6px; align-items: center; margin: 4px 0 12px; }
#tripCard .pill { width: 100%; min-height: 48px; font-size: 16px; }

/* ---------- sheets: #modal, #settings, #studio ----------
   Phone: full-width bottom sheets (88% high). Tablet: bottom sheets up to 560 px, centred. Desktop: a 440 px panel
   on the right, full height under the top bar. Phone landscape: bottom sheets up to 92% high. */
#studio, #settings {
  position: absolute; z-index: 30; left: 0; right: 0; bottom: 0;
  max-height: 88vh; max-height: 88dvh; overflow: auto; padding: 18px 16px calc(var(--sab) + 18px);
  border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0; animation: rise 0.2s var(--ease);
  background: var(--popover); -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: 0 0 0 1px var(--border), 0 -10px 40px rgba(16, 24, 20, 0.18);
  -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
}
#studio .stHead, #settings .stHead { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding-right: 48px; min-height: 36px; }
#studio .stHead b, #settings .stHead b { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
#settings .sRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
#settings .sRow > span:first-child { min-width: 0; font-weight: 550; }
#settings .sRow.col { flex-direction: column; align-items: stretch; }
#settings .sRow span small { display: block; color: var(--muted-foreground); font-size: 12px; font-weight: 400; line-height: 1.4; }
#settings .todV { color: var(--primary); font-variant-numeric: tabular-nums; margin-left: 4px; }
#settings .sRow .pill.sm { flex: none; }
input[type='range'] { width: 100%; accent-color: var(--primary); }
/* segmented control (Stardust toggle group) */
.seg { display: inline-flex; flex: none; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.seg button { min-height: 32px; padding: 0 12px; border-radius: var(--r-md); font-size: 13px; font-weight: 550; color: var(--muted-foreground); transition: background-color 0.1s ease-out, color 0.15s; }
.seg button:hover { color: var(--foreground); }
.seg button.on { background: var(--card); color: var(--foreground); box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }
.seg .dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
/* switch: a rounded square, not a pill */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; border-radius: 8px; background: var(--input); transition: background-color 0.1s ease-out; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 6px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.1s ease-out; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--ring); outline-offset: 2px; }

#modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: transparent; transition: background-color 0.2s ease-out;
}
#modal.on { background: var(--scrim); }
.sheet {
  position: relative; width: 100%; max-height: 88vh; max-height: 88dvh; overflow: auto; overflow-x: hidden;
  padding: 20px 16px calc(var(--sab) + 20px); border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0;
  background: var(--popover); color: var(--popover-foreground);
  box-shadow: 0 0 0 1px var(--border), 0 -10px 40px rgba(16, 24, 20, 0.2);
  transform: translateY(100%); transition: transform 0.22s var(--ease);
  -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain;
  user-select: text; -webkit-user-select: text;
}
#modal.on .sheet { transform: none; }
/* 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; }
.sheet h2 { font-size: 22px; line-height: 28px; letter-spacing: -0.02em; padding-right: 44px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet h2 svg { width: 22px; height: 22px; color: var(--primary); }
.sheet h2 .fine { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.sheet h3 { font-size: 15px; line-height: 22px; margin: 18px 0 6px; padding-right: 44px; display: flex; align-items: center; gap: 6px; }
.sheet > h3:first-child, .sheet > .sheet > h3:first-child { margin-top: 0; }
.sheet h4 { font-size: 15px; }
.sheet .lead { color: var(--secondary-foreground); }
.sheet p.big { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0; font-variant-numeric: tabular-nums; }
.sheet img.selfie { display: block; width: 100%; border-radius: var(--radius); margin: 6px 0 12px; box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.sheet > .row, .sheet > .sheet > .row { margin-bottom: 8px; }
.sheet .grid { margin: 4px 0 8px; }
/* trips */
.sheet .place { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--card); box-shadow: inset 0 0 0 1px var(--border); margin-bottom: 8px; }
.sheet .place svg { width: 96px; height: 64px; border-radius: var(--r-md); stroke: none; }
.sheet .place h4 { margin: 0 0 2px; }
.sheet .place p { margin: 0 0 8px; font-size: 13px; color: var(--muted-foreground); }
.sheet .place s { opacity: 0.7; margin-right: 4px; }
.sheet .place .visited { font-size: 11px; }
/* play: level bar, daily tiles, quests */
.sheet.play > .row:first-of-type { justify-content: space-between; margin-bottom: 6px; }
.sheet.play .bar { margin-bottom: 14px; }
.sheet .tile.big { padding: 14px; }
.sheet .tile.gold { box-shadow: inset 0 0 0 1px var(--primary-highlight); background: var(--accent); }
.sheet .tile.gold > svg { color: var(--primary); }
.sheet .tile.done { opacity: 0.7; }
.sheet .tile > .badge { align-self: flex-start; margin-top: 2px; }
.sheet .quest { justify-content: space-between; flex-wrap: nowrap; padding: 9px 2px; margin: 0 !important; border-bottom: 1px solid var(--border); }
.sheet .quest:last-of-type { border-bottom: 0; }
.sheet .quest > span:first-child { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sheet .quest > .fine { flex: none; font-variant-numeric: tabular-nums; }
.sheet .quest.done > span:first-child { color: var(--muted-foreground); }
.sheet .quest.done svg { color: var(--success); width: 16px; height: 16px; }
/* leaderboard + support packs */
.sheet.board > .row:not(.tabs), .sheet.coins > .row { justify-content: space-between; flex-wrap: nowrap; padding: 9px 2px; margin: 0 !important; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.sheet.board > .row.me { background: var(--accent); border-radius: var(--r-md); padding: 9px 8px; }
.sheet.board .tabs { margin-bottom: 8px; }
.sheet.coins .tile > svg { color: var(--gold2); }
/* shop */
.sheet.shop > .row:first-of-type { justify-content: space-between; }
/* mini games */
.sheet.games .tile, .sheet .grid.two > button.tile { font-size: 15px; }
.sheet .q { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sheet.quiz .tile { min-height: 56px; justify-content: center; font-weight: 550; }
.sheet .tile.right { box-shadow: inset 0 0 0 2px var(--success); background: #e3f6ea; color: #0b5a32; opacity: 1; }
.sheet .tile.wrong { box-shadow: inset 0 0 0 2px var(--destructive); background: #fde7e8; color: #8d0f19; opacity: 1; }
.sheet .tile.dim { opacity: 0.55; }
.sheet .grid.cards { gap: 6px; }
.sheet .tile.card { aspect-ratio: 1; align-items: center; justify-content: center; padding: 0; font-size: 28px; background: linear-gradient(180deg, var(--primary-top), var(--primary-bottom)); box-shadow: inset 0 1px 0 var(--primary-highlight), 0 0 0 1px var(--primary-edge); }
.sheet .tile.card.up { background: var(--card); box-shadow: inset 0 0 0 1px var(--border); }
.sheet .tile.card.got { background: var(--accent); box-shadow: inset 0 0 0 2px var(--primary-highlight); }
.sheet .fishBar { position: relative; height: 48px; margin: 12px 0; border-radius: var(--radius); background: linear-gradient(180deg, #bfe3f2, #7fc0de); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.sheet .fishBar .zone { position: absolute; top: 0; bottom: 0; background: rgba(47, 179, 107, 0.45); box-shadow: inset 0 0 0 2px rgba(0, 136, 75, 0.6); }
.sheet .fishBar .float { position: absolute; top: 50%; left: 0; font-style: normal; font-size: 24px; transform: translate(-50%, -50%); }
.sheet .grid.four .tile.sticker { align-items: center; text-align: center; }
.sheet .tile.sticker .big { font-size: 28px; line-height: 1.2; }
.sheet .tile.sticker.locked { opacity: 0.6; }
.sheet .tile.sticker .big svg { width: 24px; height: 24px; }
/* account */
.sheet .acInput + .acInput { margin-top: 8px; }
.sheet label.row { gap: 8px; margin: 10px 0; }

/* chat */
.sheet.chat .tabs { margin-bottom: 10px; }
.sheet.chat .msgs { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow: auto; margin: 0 0 10px; padding: 2px; }
.sheet.chat .msgs .empty { margin: 6px 0; }
.sheet.chat .msg { align-self: flex-start; max-width: 88%; padding: 7px 11px 8px; border-radius: 4px var(--radius) var(--radius) var(--radius); background: var(--secondary); box-shadow: inset 0 0 0 1px var(--border); }
.sheet.chat .msg.you { align-self: flex-end; border-radius: var(--radius) 4px var(--radius) var(--radius); background: var(--accent); box-shadow: inset 0 0 0 1px var(--primary-highlight); }
.sheet.chat .msg .who { font-size: 12px; font-weight: 600; color: var(--primary); }
.sheet.chat .msg .when { font-size: 11px; color: var(--muted-foreground); margin-left: 6px; font-variant-numeric: tabular-nums; }
.sheet.chat .msg .txt { overflow-wrap: anywhere; }
.sheet.chat .msg .menu { margin-top: 6px; gap: 6px; }
.sheet.chat .compose { flex-wrap: nowrap; }
.sheet.chat .compose .acInput { flex: 1; min-width: 0; }
.sheet .chips .pill.line { min-height: 32px; font-size: 13px; padding: 0 10px; border-radius: 999px; font-weight: 500; }
.sheet .groups .row { flex-wrap: nowrap; margin-top: 8px; }
.sheet .groups .acInput { flex: 1; min-width: 0; }

/* ---------- 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: 600;
  background: rgba(18, 24, 19, 0.72); color: #fff;
}
#labels .name.me { background: var(--primary); color: var(--primary-foreground); }
#labels .local { padding: 1px 6px; border-radius: 6px; font-size: 10.5px; font-weight: 550; background: rgba(255, 255, 255, 0.88); color: var(--secondary-foreground); }
#labels .tag { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: rgba(18, 24, 19, 0.72); color: #fff; }
#labels .tag.npc { background: var(--primary); opacity: 0.92; }
#labels .tag.small { padding: 1px 6px; font-size: 10.5px; font-weight: 550; background: rgba(255, 255, 255, 0.88); color: var(--secondary-foreground); }
#labels .live { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: rgba(43, 95, 168, 0.85); color: #fff; }
#labels .cat { padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--gold); color: #3b2a04; }
#labels .spot { padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, 0.94); color: var(--foreground); box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(16, 24, 20, 0.18); }
#labels .bubble {
  max-width: 240px; white-space: normal; padding: 8px 12px; margin-top: -14px;
  border-radius: var(--radius); background: #fff; color: var(--foreground); font-size: 13.5px; line-height: 1.35;
  box-shadow: 0 0 0 1px var(--border), 0 4px 16px rgba(16, 24, 20, 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(--primary); }

/* ---------- guide ---------- */
#guide {
  position: absolute; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + var(--g) + var(--navH) + 18px);
  width: min(380px, calc(100vw - 24px)); padding: 14px 16px 12px; border-radius: var(--r);
  background: var(--popover); box-shadow: 0 0 0 1px var(--border), 0 10px 34px rgba(16, 24, 20, 0.28); animation: rise 0.2s var(--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: var(--popover); }
#guide.up::after { top: -9px; border-top: 0; border-bottom-color: var(--popover); }
#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: var(--r-md); background: var(--primary); color: var(--primary-foreground); font-style: normal; font-weight: 700; }
#guide .gWho small { color: var(--muted-foreground); }
#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: var(--input); }
#guide .gBtns .dots i.on { background: var(--primary); }

/* ---------- 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: var(--r); max-width: 300px;
  animation: pop 0.2s ease;
}
#turnTip svg { width: 34px; height: 34px; color: var(--primary); 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(--g) + var(--navH) + 20px);
  transform: translate(-50%, 8px); opacity: 0;
  max-width: calc(100vw - 32px); width: max-content; padding: 10px 16px; border-radius: var(--radius);
  background: var(--popover); color: var(--popover-foreground); font-weight: 550; font-size: 14px; text-align: center;
  box-shadow: 0 0 0 1px var(--border), 0 10px 30px -6px rgba(16, 24, 20, 0.3);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out; pointer-events: none;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
body:not([data-mode='map']) #toast { bottom: auto; top: var(--row2); }

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; } }

/* ===== avatars + studio ===== */
.lookStudio .lookActions { margin: 0 0 10px; }
.lookStudio .lookActions .pill[disabled] { opacity: 0.6; cursor: progress; }
.lookStudio .tabs { margin-bottom: 10px; }
.lookStudio h4 { margin: 12px 0 6px; font-size: 13px; color: var(--secondary-foreground); }
.lookStudio .studioBody > .row { margin: 6px 0; }
.lookStudio .lookChips .pill { padding: 0 11px; font-size: 13px; }
.lookStudio .lookChips .pill.gold { color: var(--accent-foreground); background: var(--accent); box-shadow: inset 0 0 0 1.5px var(--primary); transform: none; }
.lookStudio .grid.lookPats { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.lookStudio .lookPats .tile { padding: 8px; align-items: center; text-align: center; font-size: 12px; }
.lookStudio .lookPats .tile svg { width: 36px; height: 36px; flex: none; }
#studio .sw.on { border-color: var(--primary) !important; box-shadow: 0 0 0 2px var(--primary-highlight) !important; }

/* ===== co-op: buddies, party, offers, name tags ===== */

/* riding along in someone's auto: the walk HUD without the stick and jump/run */
body[data-mode='ride'] #walkHud { display: block; }
body[data-mode='ride'] #stick, body[data-mode='ride'] #walkHud .actRow, body[data-mode='ride'] #steer,
body[data-mode='ride'] #pedals, body[data-mode='ride'] #speedo,
body[data-mode='ride'] #waveBtn, body[data-mode='ride'] #danceBtn, body[data-mode='ride'] #lookBtn { display: none !important; }
body[data-mode='ride'] #markArrow { display: grid !important; }

#buddyDot {
  position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--destructive); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  border: 2px solid #fff; box-sizing: content-box;
}
#buddyBtn.party { box-shadow: 0 0 0 2px #7a4fb0, var(--shadow); }

/* remote players' name tags: per-user hue (inline background), badges, clickable */
#labels .live.ptag {
  display: inline-flex; align-items: center; gap: 4px; pointer-events: auto; cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, 0.55); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
#labels .live.ptag b { font-weight: 600; }
#labels .ptag .tb { font-style: normal; font-size: 11px; line-height: 1; }
#labels .ptag .tb.f { color: #ffd65a; }
#labels .ptag .tb.b { color: #ff8fa8; }
#labels .ptag .tb.p { color: #d7c2ff; }
#labels .pmark {
  padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff;
  background: rgba(122, 79, 176, 0.9); border: 1.5px solid #fff; box-shadow: 0 2px 8px rgba(16, 24, 20, 0.25);
}

/* offer cards (stack, non-blocking, expire) */
#offers {
  position: fixed; z-index: 45; left: calc(var(--sal) + var(--g)); top: var(--chipTop); /* above #modal (40) */
  width: min(340px, calc(100vw - 72px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
#offers .offer {
  position: relative; overflow: hidden; pointer-events: auto; padding: 10px 12px 12px; border-radius: var(--r);
  display: flex; flex-direction: column; gap: 8px; animation: rise 0.2s var(--ease); transition: opacity 0.2s, transform 0.2s;
}
#offers .offer.out { opacity: 0; transform: translateX(-20px); }
#offers .oTxt { font-size: 13.5px; line-height: 1.35; }
#offers .oBtns { display: flex; gap: 8px; }
#offers .oBar {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--primary);
  transform-origin: left; animation: offerT linear forwards;
}
@keyframes offerT { to { transform: scaleX(0); } }

/* buddies / party / player sheets */
.sheet.coop h3 { color: var(--secondary-foreground); }
.sheet.coop h3 svg { width: 16px; height: 16px; }
.sheet.coop .tabs { margin-bottom: 8px; }
.sheet.coop .warn { color: #7a5208; }
.sheet.coop .brow {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.sheet.coop .bname { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sheet.coop .bname b { overflow: hidden; text-overflow: ellipsis; }
.sheet.coop .bname small { color: var(--muted-foreground); font-size: 12px; }
.sheet.coop .bacts { display: flex; gap: 6px; flex-wrap: wrap; }
.sheet.coop .bacts svg { width: 14px; height: 14px; }
.sheet.coop .odot { width: 9px; height: 9px; border-radius: 50%; background: var(--input); flex: none; }
.sheet.coop .odot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(0, 136, 75, 0.2); }
.sheet.coop .add, .sheet.coop .acts { margin-top: 10px; }
.sheet.coop .add { flex-wrap: nowrap; }
.sheet.coop .add .acInput { flex: 1; min-width: 0; }
.sheet.coop .pdot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.sheet.coop .badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sheet.coop .badge.buddy { background: #fce8ef; color: #a3335a; border-color: rgba(232, 126, 161, 0.4); }
.sheet.coop .badge.party { background: #f1eafa; color: #5b3590; border-color: rgba(122, 79, 176, 0.35); }
.sheet.coop .pill svg { width: 16px; height: 16px; }
.sheet.coop .emos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sheet.coop .emo { align-items: center; text-align: center; padding: 8px 4px; gap: 2px; }
.sheet.coop .emo span { font-size: 22px; line-height: 1; }
.sheet.coop .emo b { font-size: 11px; font-weight: 600; }
.sheet.coop .give .acInput, .sheet.coop .trade .acInput { flex: 1; min-width: 110px; }
.sheet.coop .trade { margin-top: 10px; }
.sheet.coop .trade summary { cursor: pointer; font-weight: 600; color: var(--secondary-foreground); padding: 10px 0; }
.sheet.coop .trade .row { margin: 6px 0; }
.sheet.coop .trade .row .fine { width: 58px; }
.sheet.coop .safety { margin-top: 14px; justify-content: flex-end; }

/* ---------- touch targets: 44 x 44 on coarse pointers ---------- */
@media (pointer: coarse) {
  #ui button, #modal button, #offers button { min-height: 44px; min-width: 44px; }
  .pill, .pill.sm, .tabs .pill, .tabs .pill.gold, .tabs .pill.dark, .seg button, .sheet .chips .pill.line { min-height: 44px; }
  .round.sm, .xBtn { width: 44px; height: 44px; }
  #results button { min-height: 44px; }
  /* chat names stay compact in the bubble but keep a 44 px hit box */
  .sheet.chat .msg .who { min-height: 44px; margin: -14px 0 -14px -6px; padding: 0 6px; }
  .switch { width: 52px; height: 32px; }
  .switch i::after { width: 26px; height: 26px; }
  .switch input:checked + i::after { transform: translateX(20px); }
  .sheet.coop .emos { grid-template-columns: repeat(3, 1fr); }
}
@media (pointer: fine) {
  .sheet.coop .emos { grid-template-columns: repeat(5, 1fr); }
}

/* ======================================================================================
   Layout classes (spec §8). Base rules above are phone portrait (max-width 599px).
   ====================================================================================== */

/* phone portrait: icon-only top bar, compact milestone strip, chips under the strip */
@media (max-width: 599px) {
  .brand { padding: 0; width: var(--hud); }
  .brand b, #resCount { display: none; }
  #gameHud .pill.badge, #gameHud .pill.line { display: none; }
  #findBtn { width: var(--hud); padding: 0; }
  #findBtn span, #findN, #supportBtn span { display: none; }
  #supportBtn { width: var(--hud); padding: 0; }
  body[data-mode='map'] { --chipTop: var(--row4); }
  .sheet .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet .grid.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* tablet and up (phone landscape overrides below) */
@media (min-width: 600px) {
  :root { --mileH: 62px; }
  #searchWrap { left: 50%; right: auto; transform: translateX(-50%); width: min(460px, calc(100vw - 16px)); }
  #findBtn span { display: inline; }
  #supportBtn span { display: inline; }
  .brand b { display: inline; }
  #resCount { display: none; }

  /* bottom nav: a centred floating bar with full labels */
  #bottom { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 16px); gap: 4px; padding: 5px; }
  #bottom button { flex: 0 0 auto; min-width: 88px; padding: 0 14px; font-size: 12px; }
  #bottom button.main { padding: 0 18px; }
  #bottom .s { display: none; }
  #bottom .l { display: inline; }

  /* milestone strip: centred above the nav, numbers + bar + caption */
  #mile {
    top: auto; bottom: calc(var(--sab) + var(--g) + var(--navH) + 10px);
    left: 50%; right: auto; transform: translateX(-50%); width: min(400px, calc(100vw - 16px));
    padding: 8px 14px 8px 8px; gap: 10px;
  }
  #mile .mbody { flex-direction: column; align-items: stretch; gap: 5px; }
  #mile .mhead { order: 0; justify-content: space-between; }
  #mile .mhead:empty { display: flex; }
  #mile .mnum, #mile .lbl { display: block; }
  #mile .mfig { width: 56px; height: 42px; }
  #mile .mfig svg { width: 56px; height: 42px; }

  /* house card: a 360 px floating card at the top left, under the search row */
  #card {
    left: calc(var(--sal) + var(--g)); right: auto; top: var(--row3); bottom: auto; width: 360px;
    max-height: calc(100vh - var(--row3) - var(--navH) - var(--mileH) - var(--sab) - 44px);
    max-height: calc(100dvh - var(--row3) - var(--navH) - var(--mileH) - var(--sab) - 44px);
  }
  body[data-mode='map'] #ui > .chip { left: auto; right: calc(var(--sar) + var(--g)); }
  body[data-mode='map'] { --chipTop: var(--row3); }
  #offers { width: 340px; }
  #policyLink { bottom: calc(var(--sab) + var(--g) + 4px); }
  #toast { bottom: calc(var(--sab) + var(--g) + var(--navH) + var(--mileH) + 22px); }
  #guide { bottom: calc(var(--sab) + var(--g) + var(--navH) + var(--mileH) + 26px); }

  /* sheets: bottom sheets up to 560 px wide, centred */
  .sheet, #studio, #settings { padding-left: 20px; padding-right: 20px; }
  #modalBody { width: min(560px, 100%); }
  .sheet .sheet { padding: 0; }
  #studio, #settings { width: min(560px, 100%); margin: 0 auto; }
}

/* desktop: search in the top row, dock at the bottom, the card top left, sheets as a right-hand panel */
@media (min-width: 1100px) {
  :root { --mileH: 62px; }
  #resCount { display: inline; }
  #searchWrap { top: var(--row1); height: var(--hud); width: clamp(260px, calc(100vw - 840px), 420px); }
  #bottom { bottom: calc(var(--sab) + 12px); }
  #mile {
    left: calc(var(--sal) + 16px); transform: none; bottom: calc(var(--sab) + 12px);
    width: min(340px, calc(50vw - 330px)); height: var(--navH); padding: 6px 14px 6px 8px;
  }
  #card {
    left: calc(var(--sal) + var(--g)); top: var(--row2); width: 360px;
    max-height: calc(100vh - var(--row2) - var(--navH) - var(--sab) - 32px);
    max-height: calc(100dvh - var(--row2) - var(--navH) - var(--sab) - 32px);
  }
  body[data-mode='map'] { --chipTop: var(--row2); }
  #policyLink { bottom: calc(var(--sab) + 12px); right: calc(var(--sar) + 16px); }
  #toast { bottom: calc(var(--sab) + var(--navH) + 28px); }
  #guide { bottom: calc(var(--sab) + var(--navH) + 30px); }

  #modal { align-items: stretch; justify-content: flex-end; padding: var(--row2) calc(var(--sar) + var(--g)) calc(var(--sab) + var(--g)) 0; }
  #modal.on { background: rgba(16, 24, 20, 0.16); }
  #modalBody {
    width: 440px; max-height: none; border-radius: var(--r); padding: 22px 22px 22px;
    box-shadow: 0 0 0 1px var(--border), 0 18px 48px -12px rgba(16, 24, 20, 0.35);
    transform: translateX(24px); opacity: 0; transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
  }
  #modal.on #modalBody { transform: none; opacity: 1; }
  #studio, #settings {
    left: auto; right: calc(var(--sar) + var(--g)); top: var(--row2); bottom: calc(var(--sab) + var(--g));
    width: 440px; margin: 0; max-height: none; padding: 22px; border-radius: var(--r);
    box-shadow: 0 0 0 1px var(--border), 0 18px 48px -12px rgba(16, 24, 20, 0.35);
    animation-name: slideIn;
  }
  @keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }
}

/* phone landscape (short touch screens): one top row with the search, no milestone strip, a slim nav, bottom
   sheets. It comes last so it beats the tablet (and desktop) rules a wide phone also matches; every piece those
   rules set is re-stated here. A short desktop window (fine pointer) keeps the desktop layout. */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  :root { --navH: 52px; --mileH: 0px; }
  .brand { padding: 0; width: var(--hud); }
  .brand b, #resCount { display: none; }
  #findBtn { width: var(--hud); padding: 0; }
  #findBtn span, #findN, #supportBtn span { display: none; }
  #supportBtn { width: var(--hud); padding: 0; }
  #searchWrap {
    top: var(--row1); left: 50%; right: auto; transform: translateX(-50%);
    height: var(--hud); width: clamp(200px, calc(100vw - 440px), 340px);
  }
  #mile { display: none !important; }

  /* nav: centred, one row, icon + one-word label */
  #bottom {
    left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--sab) + 6px);
    width: max-content; max-width: calc(100vw - 16px); height: var(--navH); padding: 4px; gap: 4px;
  }
  #bottom button { flex: 0 0 auto; flex-direction: row; gap: 6px; min-width: 0; padding: 0 12px; font-size: 12px; }
  #bottom button.main { padding: 0 16px; }
  #bottom .s { display: inline; }
  #bottom .l { display: none; }
  #bottom svg { width: 20px; height: 20px; }

  /* house card: right column between the top row and the nav */
  #card {
    left: auto; right: calc(var(--sar) + var(--g)); top: var(--row2); bottom: calc(var(--sab) + var(--navH) + 14px);
    width: min(340px, calc(100vw - 16px)); max-height: none;
  }
  body[data-mode='map'] #ui > .chip { left: calc(var(--sal) + var(--g)); right: auto; }
  body[data-mode='map'] { --chipTop: var(--row2); }
  #policyLink { right: calc(var(--sar) + 12px); bottom: calc(var(--sab) + 10px); }
  #toast { bottom: calc(var(--sab) + var(--navH) + 18px); }
  #guide { bottom: calc(var(--sab) + var(--navH) + 18px); }

  /* walking: the action buttons run along the top row, so Find and the chaya button step aside */
  body:not([data-mode='map']) #findBtn, body:not([data-mode='map']) #supportBtn { display: none; }
  .wbtns { top: var(--row1); right: calc(var(--sar) + var(--g) + var(--hud) + 8px); flex-direction: row; }
  #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; }
  #walkHint { bottom: calc(var(--sab) + 12px); max-width: 40vw; }
  #speedo { width: 70px; height: 70px; bottom: calc(var(--sab) + 12px); }
  #speedo b { font-size: 22px; }

  /* sheets: bottom sheets up to 92% high, centred, at most 600 px wide */
  #modal { align-items: flex-end; justify-content: center; padding: 0; }
  #modal.on { background: var(--scrim); }
  #modalBody {
    width: min(600px, 100%); max-height: 92vh; max-height: 92dvh;
    padding: 18px 20px calc(var(--sab) + 18px); border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0;
    box-shadow: 0 0 0 1px var(--border), 0 -10px 40px rgba(16, 24, 20, 0.2);
    transform: translateY(100%); opacity: 1; transition: transform 0.22s var(--ease);
  }
  #modal.on #modalBody { transform: none; }
  #studio, #settings {
    left: 0; right: 0; top: auto; bottom: 0; margin: 0 auto; width: min(600px, 100%);
    max-height: 92vh; max-height: 92dvh; padding: 16px 20px calc(var(--sab) + 16px);
    border-radius: calc(var(--r) + 4px) calc(var(--r) + 4px) 0 0; animation-name: rise;
  }
}

/* reduced motion: keep colour and opacity changes, drop movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .pill:active, .pill.gold:active, .pill.coin:active, #bottom button.main:active, #pedals button:active { transform: none !important; }
}

/* studio: the module marks picks with an inline gold outline; selection is the primary ring here */
#studio .tile.on { outline: none !important; }
.lookStudio .tabs { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.lookStudio .tabs .pill { padding: 0 6px; }

/* ---------- heritage site HUD (trips.js + heritage.js): place name, Back to town, one-line hint ---------- */
/* phone portrait: under the chips row, clear of the right-hand button column */
#siteHud {
  position: absolute; top: var(--row3); left: calc(var(--sal) + var(--g)); right: calc(var(--sar) + var(--g) + var(--hud) + 8px);
  max-width: 460px; padding: 10px 12px; border-radius: var(--r);
  background: var(--ink-fill); color: #fff;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 6px;
  animation: fadeIn 0.3s ease-out;
}
#siteHud .shTop { display: flex; align-items: center; gap: 10px; }
#siteHud .shName { flex: 1; min-width: 0; line-height: 1.2; }
#siteHud .shName small { display: block; opacity: 0.75; font-size: 12px; }
#siteHud .shName b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#siteHud .pill { flex: none; }
#siteHud .shHint { margin: 0; font-size: 13px; line-height: 1.35; opacity: 0.92; }
#siteHud .shHint b { color: #fff; }
#siteHud .shRead { display: inline-block; margin-left: 4px; opacity: 0.7; white-space: nowrap; }
body:not([data-mode='walk']) #siteHud { display: none; }
/* tablet and desktop: centred under the top bar */
@media (min-width: 600px) {
  #siteHud { left: 50%; right: auto; transform: translateX(-50%); width: min(460px, calc(100vw - 2 * var(--hud) - 4 * var(--g) - 16px)); }
  #siteHud .shName b { font-size: 16px; }
}
/* phone landscape: short screen, keep it to two lines */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  #siteHud { top: var(--row3); left: 50%; right: auto; transform: translateX(-50%); width: min(420px, calc(100vw - 2 * var(--hud) - 6 * var(--g))); padding: 6px 10px; gap: 4px; }
  #siteHud .shName small { display: none; }
  #siteHud .shHint { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
#siteFade {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: #f6efdc; opacity: 0; transition: opacity 0.35s ease;
}
#siteFade.on { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { #siteFade { transition: none; } #siteHud { animation: none; } }

/* home claim: the code to send by Instagram DM (account.js, server/claims.js) */
.claimCode {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px 0; padding: 12px 14px; border-radius: 12px;
  border: 2px dashed var(--primary); background: var(--muted, transparent);
}
.claimCode b { font: 700 22px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em; color: var(--foreground); user-select: all; }
.claimWait { display: flex; gap: 8px; align-items: flex-start; }
.claimWait .dot {
  flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary);
  animation: claimPulse 1.4s ease-in-out infinite;
}
@keyframes claimPulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .claimWait .dot { animation: none; } }
@media (max-width: 599px) { .claimCode b { font-size: 19px; } }
