/* MyTown design system: "toy town board game". See DESIGN.md for the rules.
   Layout: full-bleed map, floating HUD on top, tab bar on the bottom, panels slide up
   from the tab bar (side panel on wide screens). Chunky, toy-like controls with a
   pressed-down bottom edge; properties are drawn as board-game title deeds; rewards are
   coins, mint XP, rubber stamps and gold medals. */
:root {
  --paper: #eef3ec;
  --surface: #ffffff;
  --surface-2: #eef1ea;
  --surface-3: #e2e7dd;
  --ink: #172019;
  --muted: #5d6a62;
  --line: #d9dfd4;
  --accent: #087a5f;
  --accent-deep: #066048;
  --accent-ink: #ffffff;
  --gold: #f2b632;
  --gold-deep: #c4870c;
  --gold-ink: #3a2500;
  --gold-soft: #fdf0cc;
  --red: #cc3a2f;
  --red-deep: #a92a21;
  --warn: #c23128;
  --good: #127a40;
  --hot: #ff5a1f;
  --hot-ink: #b33808;    /* hot-spot text */
  --boom-ink: #6d4bd8;   /* booming text on light surfaces */
  --boom: #6d4bd8;
  --shadow: 0 8px 28px rgba(16, 30, 22, 0.18);
  --shadow-sm: 0 3px 10px rgba(16, 30, 22, 0.14);

  /* Rewards: coins are gold, XP is mint, medals are deep green with a gold rim */
  --coin-hi: #fff3c4;
  --coin-mid: #ffd25e;
  --coin-rim: rgba(120, 70, 0, 0.35);
  --xp: #0b7c5e;
  --xp-light: #5fe0b6;
  --xp-glow: #7cf0c8;
  --medal: #123329;
  --medal-ink: #ffffff;
  --medal-rim: var(--gold);
  /* Item rarity: lightness differs as well as hue, so they read without colour too */
  --common: #8a6a12;
  --common-glow: #f2b632;
  --rare: #2f6fd6;
  --rare-glow: #4f8ef0;
  --epic: #8d3fd6;
  --epic-glow: #b36cff;
  --on-color: #ffffff;   /* text on red, boom and category colours */
  --warn-ink: #ffffff;   /* text on --warn */
  --pin-ring: #ffffff;
  --deed-band-mix: 80%;  /* how much category colour vs black in a deed band, so white text passes 4.5:1 */
  --scrim: rgba(11, 21, 16, 0.55);

  /* Shape */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;
  --edge: 4px;           /* the pressed-down bottom edge on chunky controls */

  /* Type scale (Fredoka for display and numbers, Figtree for reading) */
  --t-xs: 11px;
  --t-sm: 13px;
  --t-md: 15px;
  --t-lg: 17px;
  --t-xl: 22px;
  --t-2xl: 26px;
  --t-hero: 58px;

  /* Space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* Motion: things pop in with a little overshoot, fly with a swoop, leave quickly */
  --ease-pop: cubic-bezier(.3, 1.6, .5, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-swoop: cubic-bezier(.45, 0, .6, 1);
  --dur-tap: 90ms;
  --dur-quick: 200ms;
  --dur-pop: 400ms;
  --dur-reward: 750ms;

  --g-food: #e05535;
  --g-drink: #8a45b8;
  --g-shop: #2f6fd6;
  --g-leisure: #2e9c50;
  --g-transport: #52606d;
  --g-culture: #c23a6c;
  --g-services: #b07405;
  --g-health: #0f948a;
  --g-education: #7a5442;

  --font-display: "Fredoka", "Avenir Next Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Figtree", -apple-system, "Segoe UI", system-ui, sans-serif;

  /* iOS home-screen apps can make the page shorter than the screen, by the status bar's height,
     with an undrawable strip below it that iOS fills with the page background (screen 874,
     page 812 on an iPhone 16 Pro). app.js measures that into --vh-gap and colours the strip to
     match the tab bar (html.short-viewport). The home bar sits in the strip then, so the tab bar
     drops its own home-bar padding by the same amount. */
  --vh-gap: 0px;
  --safe-bottom: max(0px, calc(env(safe-area-inset-bottom, 0px) - var(--vh-gap)));
  --tabs-h: calc(64px + var(--safe-bottom));
  --above-tabs: var(--tabs-h);
  --gutter-l: max(12px, env(safe-area-inset-left, 0px));
  --gutter-r: max(12px, env(safe-area-inset-right, 0px));
  --sheet-h: min(64vh, 580px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1411;
    --surface: #18211d;
    --surface-2: #212c27;
    --surface-3: #2a3731;
    --ink: #e8efea;
    --muted: #9aa9a1;
    --line: #2d3a34;
    --accent: #23b48f;
    --accent-deep: #137a60;
    --accent-ink: #04221a;
    --gold: #f4bf45;
    --gold-deep: #b37d10;
    --gold-ink: #2e1d00;
    --gold-soft: #3a2e12;
    --red: #cf3f35;
    --red-deep: #a8322a;
    --warn: #ff8a80;
    --good: #4cd38a;
    --hot: #ff7a45;
    --hot-ink: #ff9a6e;
    --boom-ink: #b9a3ff;
    --boom: #7a5ae0;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.4);
    --xp: #3fd3a4;
    --xp-light: #7cf0c8;
    --medal: #0a1f18;
    --common: #f4bf45;
    --rare: #6ea2ff;
    --epic: #c08bff;
    --pin-ring: #f4f7f2;
    --warn-ink: #3a0b07;
    --deed-band-mix: 70%;
    --scrim: rgba(0, 0, 0, 0.6);
    --g-food: #ee6b4b;
    --g-drink: #a463d0;
    --g-shop: #4f8ef0;
    --g-leisure: #43b867;
    --g-transport: #74838f;
    --g-culture: #dc5a8a;
    --g-services: #cf9216;
    --g-health: #22b3a6;
    --g-education: #9a7260;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* The strip iOS leaves under a short home-screen page takes the page background: match the tab bar */
html.short-viewport { background: var(--surface); }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 500 15px/1.4 var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.g-food { --g: var(--g-food); }
.g-drink { --g: var(--g-drink); }
.g-shop { --g: var(--g-shop); }
.g-leisure { --g: var(--g-leisure); }
.g-transport { --g: var(--g-transport); }
.g-culture { --g: var(--g-culture); }
.g-services { --g: var(--g-services); }
.g-health { --g: var(--g-health); }
.g-education { --g: var(--g-education); }

/* ---------- map ---------- */
#map {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: var(--above-tabs);
  z-index: 0;
  background: var(--surface-3);
}
.leaflet-container { font-family: var(--font-body); }
/* OpenStreetMap tiles are busy: mute them so the pins stand out, and flip them for dark mode */
.leaflet-tile-pane { filter: saturate(0.75) brightness(1.03); }
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.5); }
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 80%, transparent) !important;
  color: var(--muted) !important;
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.pin-wrap { background: none; border: 0; }
.pin {
  --rc: #fff;
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  background: var(--g, var(--g-services));
  border: 2.5px solid var(--pin-ring);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 4px 10px rgba(0, 0, 0, 0.25);
  display: grid; place-items: center;
  transition: transform 0.18s var(--ease-pop);
}
.pin-emoji { transform: rotate(45deg); font-size: 16px; line-height: 1; }
.pin.rival { border-color: var(--rc); border-width: 3px; }
.pin.owned { border: 3.5px solid var(--gold); box-shadow: 0 0 0 2px #fff, 0 0 14px 2px color-mix(in srgb, var(--gold) 70%, transparent), 0 4px 10px rgba(0, 0, 0, 0.3); }
.pin-badge {
  position: absolute;
  top: -9px; right: -9px;
  transform: rotate(45deg);
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--av, #333);
  border: 2px solid #fff;
  display: grid; place-items: center;
  font-size: 10px;
  font-style: normal;
  line-height: 1;
}
.pin.hot::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--hot);
  animation: ring 1.5s ease-out infinite;
}
.pin.near { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent), 0 4px 10px rgba(0, 0, 0, 0.25); animation: bob 1.4s ease-in-out infinite; }
.pin.sel { transform: rotate(-45deg) scale(1.35); animation: none; }
.far .pin:not(.owned):not(.hot):not(.sel) { transform: rotate(-45deg) scale(0.5); }
.far .pin:not(.owned):not(.hot):not(.sel) .pin-emoji,
.far .pin:not(.owned):not(.hot):not(.sel) .pin-badge { opacity: 0; }
.pin.inline { transform: rotate(-45deg) scale(0.85); animation: none; flex: none; }
@keyframes ring { from { transform: scale(0.75); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@keyframes bob { 50% { transform: rotate(-45deg) translate(3px, -3px); } }

.me-wrap { background: none; border: 0; }
.me {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--av, var(--accent));
  border: 3px solid #fff;
  display: grid; place-items: center;
  font-size: 21px;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--av, #0b8a6c) 55%, transparent), 0 4px 10px rgba(0, 0, 0, 0.3);
  animation: me 2s ease-out infinite;
}
.me span { animation: waddle 2.4s ease-in-out infinite; display: block; }
.me.explore { border-style: dashed; }
@keyframes me { to { box-shadow: 0 0 0 18px transparent, 0 4px 10px rgba(0, 0, 0, 0.3); } }
@keyframes waddle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

/* ---------- avatars & coins ---------- */
.avatar {
  --av: var(--accent);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--av);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  font-size: 18px;
  line-height: 1;
}
.avatar.xs { width: 22px; height: 22px; font-size: 12px; }
.avatar.sm { width: 28px; height: 28px; font-size: 15px; }
.avatar.lg { width: 64px; height: 64px; font-size: 36px; border: 3px solid var(--surface); box-shadow: var(--shadow-sm), inset 0 -5px 0 rgba(0, 0, 0, 0.18); }
.avatar.xl { width: 96px; height: 96px; font-size: 56px; border: 4px solid var(--surface); box-shadow: var(--shadow), inset 0 -6px 0 rgba(0, 0, 0, 0.18); }

.coin {
  display: inline-block;
  flex: none;
  width: 16px; height: 16px;
  margin-right: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--coin-hi) 0 18%, var(--coin-mid) 30%, var(--gold-deep) 100%);
  box-shadow: inset 0 0 0 1.5px var(--coin-rim), 0 1px 0 rgba(0, 0, 0, 0.15);
  vertical-align: -2px;
}
.coin.sm { width: 12px; height: 12px; margin-right: 2px; vertical-align: -1px; }
.flycoin {
  position: fixed;
  z-index: 5000;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--coin-hi) 0 18%, var(--coin-mid) 30%, var(--gold-deep) 100%);
  box-shadow: inset 0 0 0 1.5px var(--coin-rim), 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}
.floattext {
  position: fixed;
  z-index: 5000;
  pointer-events: none;
  font: 700 22px/1 var(--font-display);
  color: var(--gold);
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.25);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.floattext.xp { color: var(--xp-glow); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 4000; pointer-events: none; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  gap: 7px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  pointer-events: none;
}
.hud-chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--surface-3), var(--shadow-sm);
  font: 600 16px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: transform 0.1s ease;
}
.hud-chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--surface-3), var(--shadow-sm); }
.hud-level { flex: 1; min-width: 0; max-width: 230px; padding-left: 5px; }
.lv { font-size: 13px; color: var(--muted); }
.lv b { color: var(--ink); font-size: 17px; font-weight: 700; }
.xpbar {
  flex: 1;
  height: 10px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
  min-width: 24px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.xpbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--xp), var(--xp-light));
  transition: width 0.6s cubic-bezier(.3, 1.4, .5, 1);
}
.hud-coins { margin-left: auto; padding-right: 6px; }
.hud-coins .coin { width: 20px; height: 20px; }
.hud-coins b { font-weight: 700; min-width: 2ch; }
.plus {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--accent-deep);
}
.hud-coins.pulse { animation: pulse 0.35s ease; }
@keyframes pulse { 50% { transform: scale(1.1); } }
.deed-glyph {
  display: inline-block;
  width: 13px; height: 17px;
  border-radius: 3px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-top: 6px solid var(--gold);
}

.subhud {
  position: fixed;
  z-index: 999;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  pointer-events: none;
}
.filters {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: auto;
  padding: 3px;
  margin: -3px;
  min-width: 0;
}
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-sm);
  font: 600 13px/1 var(--font-display);
  color: var(--muted);
}
.filter.on { background: var(--ink); color: var(--surface); }
.boosts { display: flex; gap: 5px; margin-left: auto; flex: none; }
.boost {
  height: 30px;
  padding: 0 10px;
  display: inline-flex; align-items: center;
  border-radius: 99px;
  background: var(--boom);
  color: #fff;
  font: 600 13px/1 var(--font-display);
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
}

/* ---------- banners & toasts ---------- */
.banners {
  position: fixed;
  z-index: 998;
  top: calc(env(safe-area-inset-top, 0px) + 100px);
  left: var(--gutter-l);
  right: var(--gutter-r);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.banner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 7px 8px 7px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.banner.explore { background: var(--gold-soft); color: var(--ink); border: 2px solid var(--gold); }
.banner.error { background: var(--warn); color: var(--warn-ink); }
.banner-btn {
  flex: none;
  border: 0;
  border-radius: 9px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 13px;
  background: color-mix(in srgb, currentColor 18%, transparent);
}

.toasts {
  position: fixed;
  z-index: 2900;  /* under dialogs, so a toast never covers a reward reveal */
  left: var(--gutter-l);
  right: var(--gutter-r);
  top: calc(env(safe-area-inset-top, 0px) + 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  box-shadow: var(--shadow);
  animation: toast-in 0.35s var(--ease-pop);
  text-wrap: balance;
}
.toast-icon { font-size: 20px; line-height: 1; }
.toast small { font-weight: 600; opacity: 0.85; }
.toast.warn { background: var(--warn); color: var(--warn-ink); }
.toast.big { background: var(--gold); color: var(--gold-ink); font: 700 18px/1.2 var(--font-display); box-shadow: 0 4px 0 var(--gold-deep), var(--shadow); }
/* Achievements: a gold-rimmed medal */
.toast.award { background: var(--medal); color: var(--medal-ink); box-shadow: inset 0 0 0 2px var(--medal-rim), 0 var(--edge) 0 color-mix(in srgb, var(--medal-rim) 60%, #000), var(--shadow); padding: 8px 16px 8px 8px; }
.toast.award .toast-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  font-size: 22px;
  background: radial-gradient(circle at 35% 30%, var(--coin-hi) 0 15%, var(--coin-mid) 35%, var(--gold-deep) 100%);
  box-shadow: inset 0 0 0 2px var(--coin-rim), 0 2px 0 rgba(0, 0, 0, 0.3);
  animation: medal-spin 0.7s var(--ease-pop) both;
}
.toast.award small { color: color-mix(in srgb, var(--medal-ink) 85%, transparent); opacity: 1; }
@keyframes medal-spin { from { transform: rotateY(180deg) scale(0.4); } }
.toast.out { opacity: 0; transform: translateY(-10px) scale(0.95); transition: 0.3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.9); } }

.fab {
  position: fixed;
  z-index: 997;
  right: var(--gutter-r);
  bottom: calc(var(--above-tabs) + 16px);
  width: 50px; height: 50px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 3px 0 var(--surface-3), var(--shadow);
  display: grid; place-items: center;
}
.fab:active { transform: translateY(2px); }
@media (max-width: 759px) { .sheet-open .fab { display: none; } }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed;
  z-index: 1002;
  left: 0; right: 0; bottom: 0;
  height: var(--tabs-h);
  padding-bottom: var(--safe-bottom);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}
.tabs button {
  position: relative;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: 600 12px/1 var(--font-display);
  letter-spacing: 0.01em;
  color: var(--muted);
}
.tabs svg { width: 25px; height: 25px; transition: transform 0.2s var(--ease-pop); }
.tabs button.active { color: var(--accent); }
.tabs button.active svg { transform: translateY(-2px) scale(1.12); }
.badge {
  position: absolute;
  top: 6px;
  left: calc(50% + 6px);
  min-width: 19px; height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font: 700 11px/19px var(--font-display);
  font-style: normal;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  animation: pop 0.3s var(--ease-pop);
}
@keyframes pop { from { transform: scale(0); } }

/* ---------- sheet ---------- */
.sheet {
  position: fixed;
  z-index: 1001;
  left: 0; right: 0;
  bottom: var(--above-tabs);
  max-height: var(--sheet-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  padding-block: 18px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: sheet-in 0.3s cubic-bezier(.3, 1.3, .5, 1);
}
@keyframes sheet-in { from { transform: translateY(40px); } }
@media (min-width: 760px) {
  .sheet {
    left: max(16px, env(safe-area-inset-left, 0px));
    right: auto;
    top: calc(env(safe-area-inset-top, 0px) + 104px);
    bottom: calc(var(--above-tabs) + 16px);
    width: 410px;
    max-height: none;
    border-radius: 24px;
    box-shadow: var(--shadow);
  }
}
.sheet-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 3;
  width: 36px; height: 36px;
  margin: -6px -4px 0 8px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid; place-items: center;
  box-shadow: 0 2px 0 var(--surface-3);
}
.sheet h2 {
  margin: 0 0 3px;
  font: 700 26px/1.1 var(--font-display);
  text-wrap: balance;
}
.sheet h3 {
  margin: 24px 0 10px;
  font: 600 13px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.sub { margin: 0; color: var(--muted); font-size: 14px; }
.good { color: var(--good); }
.bad { color: var(--warn); }
.empty {
  margin: 14px 0 0;
  padding: 22px 18px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}
.empty p { margin: 0; }
.empty .big { display: block; font-size: 40px; margin-bottom: 6px; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--surface);
  --b-edge: var(--surface-3);
  --b-ink: var(--ink);
  position: relative;
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-radius: 16px;
  background: var(--b);
  color: var(--b-ink);
  box-shadow: 0 4px 0 var(--b-edge), inset 0 0 0 2px var(--b-edge);
  font: 700 17px/1.1 var(--font-display);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  margin-bottom: 4px;
}
.btn-main { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.btn small { font: 600 11px/1.2 var(--font-body); opacity: 0.85; text-align: center; }
.btn.primary { --b: var(--accent); --b-edge: var(--accent-deep); --b-ink: var(--accent-ink); box-shadow: 0 4px 0 var(--b-edge); }
.btn.gold { --b: var(--gold); --b-edge: var(--gold-deep); --b-ink: var(--gold-ink); box-shadow: 0 4px 0 var(--b-edge); }
.btn.danger-fill { --b: var(--red); --b-edge: var(--red-deep); --b-ink: var(--on-color); box-shadow: 0 4px 0 var(--b-edge); }
.btn.danger { --b-ink: var(--warn); }
.btn.danger.armed { --b: var(--red); --b-edge: var(--red-deep); --b-ink: var(--on-color); box-shadow: 0 4px 0 var(--b-edge); animation: wobble 0.4s ease; }
.btn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--b-edge); }
.btn.primary:not(:disabled), .btn.gold:not(:disabled) { overflow: hidden; }
.btn.primary:not(:disabled)::after, .btn.gold:not(:disabled)::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: shine 3.2s ease-in-out infinite;
}
.btn:disabled { opacity: 0.45; cursor: default; filter: saturate(0.6); }
.btn.small { min-height: 40px; font-size: 15px; border-radius: 13px; padding: 6px 14px; }
.wide-btn { width: 100%; margin-top: 12px; }
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
@keyframes wobble { 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.link { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 700; font-size: 14px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- title deed ---------- */
.deed {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 5px 0 var(--ink);
  margin: 2px 0 8px;
}
.deed-band {
  background-color: color-mix(in srgb, var(--g, var(--g-services)) var(--deed-band-mix), #000);
  color: var(--on-color);
  text-align: center;
  padding: 10px 44px 12px;
  border-bottom: 3px solid var(--ink);
  /* Darker stripes, not lighter ones, so white text keeps its contrast everywhere on the band */
  background-image: repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.08) 0 10px, transparent 10px 20px);
}
.deed-eyebrow { font: 700 10px/1.2 var(--font-body); letter-spacing: 0.18em; text-transform: uppercase; }
.deed-band h2 { color: var(--on-color); margin: 4px 0 0; font-size: 23px; text-transform: uppercase; letter-spacing: 0.02em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.deed-body { padding: 10px 14px 12px; }
.deed-top { display: grid; grid-template-columns: 108px 1fr; gap: 12px; align-items: center; }
.deed-art { position: relative; }
.deed-emoji {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--ink);
  font-size: 16px;
  line-height: 1;
}
.building { width: 108px; height: 108px; display: block; }
.b-shadow { fill: rgba(0, 0, 0, 0.12); }
.b-wall { fill: var(--g); stroke: var(--ink); stroke-width: 1.5; }
.b-win { fill: color-mix(in srgb, var(--ink) 55%, var(--g)); }
.b-lit { fill: #ffd76a; }
.b-door { fill: var(--ink); }
.b-awning { fill: #fff; stroke: var(--ink); stroke-width: 1; }
.b-roof { fill: color-mix(in srgb, var(--ink) 35%, var(--g)); stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.b-pole { stroke: var(--ink); stroke-width: 1.8; }
.deed-rent { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.deed-rent td { padding: 3px 0; font-size: 13.5px; }
.deed-rent td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.deed-rent .per { font-weight: 500; color: var(--muted); font-size: 12px; }
.deed-rent tr.cur td { color: var(--accent); font-weight: 800; }
.deed-rent tr.cur td:first-child::before { content: "▸ "; }
.deed-owner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
}
.deed-owner .stars { margin-left: auto; }
.forsale { font: 700 14px/1 var(--font-display); color: var(--good); letter-spacing: 0.04em; text-transform: uppercase; }
.deed-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  font-size: 13px;
  color: var(--muted);
}
.deed-foot b { color: var(--ink); }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; white-space: nowrap; }
.stars .off { color: var(--surface-3); }

.stamp {
  position: fixed;
  z-index: 3400;
  transform: translate(-50%, -50%) rotate(-14deg);
  padding: 8px 18px 6px;
  border: 5px solid var(--accent);
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  font: 700 30px/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  animation: stamp 0.35s cubic-bezier(.2, 1.8, .4, 1) both;
}
.stamp small { display: block; font: 700 12px/1.3 var(--font-body); letter-spacing: 0.1em; }
.stamp.gold { color: var(--gold-deep); border-color: var(--gold-deep); }
.stamp.red { color: var(--red); border-color: var(--red); }
.stamp.fade { opacity: 0; transition: opacity 0.5s ease; }
@keyframes stamp {
  from { transform: translate(-50%, -50%) rotate(-14deg) scale(2.4); opacity: 0; }
  to { transform: translate(-50%, -50%) rotate(-14deg) scale(1); opacity: 1; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip.here { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.chip.hot { background: color-mix(in srgb, var(--hot) 15%, transparent); color: var(--hot-ink); }
.chip.boom { background: color-mix(in srgb, var(--boom) 15%, transparent); color: var(--boom-ink); }
.chip.yours { background: var(--gold-soft); color: var(--ink); }
.chip.full { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.chip.new { background: color-mix(in srgb, var(--g-shop) 14%, transparent); color: var(--g-shop); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.actions .btn:only-child { grid-column: 1 / -1; }
.actions .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.list li:last-child .row { border-bottom: 0; }
.row:active { background: var(--surface-2); }
.row-main { min-width: 0; }
.row-name { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-end b { color: var(--ink); font-size: 14px; }
.row-tags { display: flex; gap: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.stat { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); min-width: 0; margin: 0; }
.stat dt { font: 600 11px/1 var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin: 4px 0 0; font: 700 19px/1.15 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* offers */
.offer {
  --av: var(--accent);
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--av) 10%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--av) 40%, transparent);
}
.offer-head { display: flex; align-items: center; gap: 10px; }
.offer-head p { margin: 0; }
.offer-quote { margin: 8px 0 4px; font-style: italic; color: var(--muted); }
.offer-terms { margin: 0; font-size: 13px; }

/* ---------- quests ---------- */
.missions { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.mission {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px transparent;
}
.mission.done { box-shadow: inset 0 0 0 2px var(--gold); background: var(--gold-soft); }
.mission.claimed { opacity: 0.6; }
.mission-icon { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--surface); }
.mission-main { min-width: 0; }
.mission-text { margin: 0 0 6px; font-weight: 700; }
.mission-meta { display: flex; justify-content: space-between; margin: 5px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--xp), var(--xp-light)); }
.mission.done .bar i { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }
.tick { font: 700 22px/1 var(--font-display); color: var(--good); padding: 0 8px; }

.chest {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 2px dashed var(--line);
}
.chest p { margin: 0; flex: 1; }
.chest small { color: var(--muted); }
.chest-icon { font-size: 34px; }
.chest.ready { border: 2px solid var(--gold); background: var(--gold-soft); }
.chest.ready .chest-icon { animation: shake 1.2s ease-in-out infinite; }
@keyframes shake { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-6deg); } }

.achvs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.achv {
  position: relative;
  padding: 12px 10px 10px;
  border-radius: 16px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.achv-icon { font-size: 28px; filter: grayscale(1); opacity: 0.5; margin-bottom: 4px; }
.achv b { font: 600 15px/1.2 var(--font-display); }
.achv small { color: var(--muted); font-size: 12px; line-height: 1.3; }
.achv-reward { position: absolute; top: 10px; right: 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.achv.on { background: linear-gradient(160deg, var(--gold-soft), var(--surface-2)); box-shadow: inset 0 0 0 2px var(--gold); }
.achv.on .achv-icon { filter: none; opacity: 1; }

/* ---------- me ---------- */
.profile { display: flex; align-items: center; gap: 14px; padding-right: 40px; }
.profile-main { min-width: 0; }
.profile h2 { margin: 0; font-size: 23px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-worth { margin: 4px 0 0; font-size: 14px; }
.seg {
  display: flex;
  gap: 4px;
  margin: 16px 0 14px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  position: relative;
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  font: 600 14px/1 var(--font-display);
  color: var(--muted);
  white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 0 var(--surface-3); }
.seg .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.collections { display: grid; gap: 10px; margin-top: 12px; }
.collection { padding: 12px; border-radius: 18px; background: var(--surface-2); }
.collection.ready { box-shadow: inset 0 0 0 2px var(--gold); background: var(--gold-soft); }
.collection.claimed { box-shadow: inset 0 0 0 2px var(--good); }
.collection-head { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.collection-head b { font: 600 16px/1 var(--font-display); }
.collection-head .count { margin-left: auto; font: 600 14px/1 var(--font-display); color: var(--muted); }
.collection > small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.collection > .btn { margin-top: 10px; width: 100%; }
.slots { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.slot {
  position: relative;
  aspect-ratio: 1;
  max-width: 100%;
  border-radius: 14px;
  background: var(--surface);
  display: grid; place-items: center;
  font-size: 26px;
  color: var(--surface-3);
  font-family: var(--font-display);
  box-shadow: inset 0 -3px 0 var(--surface-3);
}
.slot.got.r-rare { box-shadow: inset 0 0 0 2px var(--rare-glow), inset 0 -3px 0 var(--rare); background: color-mix(in srgb, var(--rare-glow) 12%, var(--surface)); }
.slot.got.r-epic { box-shadow: inset 0 0 0 2px var(--epic-glow), inset 0 -3px 0 var(--epic); background: linear-gradient(140deg, color-mix(in srgb, var(--epic-glow) 18%, var(--surface)), color-mix(in srgb, var(--gold) 18%, var(--surface))); }
.slot i { position: absolute; bottom: 2px; right: 4px; font: 700 11px/1 var(--font-display); font-style: normal; color: var(--muted); }

.shop { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.shop-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 18px; background: var(--surface-2); }
.shop-icon { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--surface); }
.shop-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.shop-main b { font: 600 16px/1.1 var(--font-display); }
.shop-main small { color: var(--muted); font-size: 13px; line-height: 1.3; }

.ranks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.rank { display: grid; grid-template-columns: 30px 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: var(--surface-2); }
.rank.you { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); }
.rank-medal { font-size: 22px; text-align: center; }
.rank-n { font: 700 16px/1 var(--font-display); color: var(--muted); }
.rank-main { min-width: 0; }
.rank-main b { display: block; font: 600 15px/1.2 var(--font-display); }
.rank-main small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.rank-worth { font: 700 15px/1 var(--font-display); white-space: nowrap; font-variant-numeric: tabular-nums; }

.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: start; }
.log-icon { text-align: center; }
.log time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }

.field { display: block; }
.field span { display: block; font: 600 13px/1 var(--font-display); color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: 600 17px/1 var(--font-display);
}
.av-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.av-pick {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 22px;
  display: grid; place-items: center;
  box-shadow: inset 0 -3px 0 var(--surface-3);
}
.av-pick.on { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); transform: scale(1.08); }
.col-grid { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.col-pick { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); background: var(--av); box-shadow: 0 0 0 2px var(--line); }
.col-pick.on { box-shadow: 0 0 0 3px var(--ink); }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.setting p { margin: 0; font-weight: 700; }
.setting small { display: block; color: var(--muted); font-weight: 500; }
.setting .btn { margin-bottom: 0; }
.switch {
  flex: none;
  width: 54px; height: 32px;
  border-radius: 99px;
  border: 0;
  background: var(--surface-3);
  position: relative;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease-pop);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.backup textarea {
  width: 100%;
  min-height: 80px;
  margin-top: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: 12px/1.35 ui-monospace, Menlo, monospace;
  resize: vertical;
}

/* ---------- modals ---------- */
.modal, .welcome {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  background: var(--scrim);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}
.welcome { z-index: 2500; background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 60%, var(--paper)), var(--paper)); }
.modal-card, .welcome-card {
  width: 100%;
  min-width: 0;
  max-width: 380px;
  padding: 24px 20px 18px;
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--surface-3), var(--shadow);
  text-align: center;
}
.modal-card.pop { animation: modal-pop 0.4s var(--ease-pop); }
@keyframes modal-pop { from { transform: scale(0.7); opacity: 0; } }
.modal-card h2, .welcome-card h2 { margin: 4px 0 6px; font: 700 26px/1.15 var(--font-display); text-wrap: balance; }
.eyebrow { margin: 0; font: 600 13px/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.reveal {
  --glow: #c9d3cc;
  width: 132px; height: 132px;
  margin: 16px auto 8px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle, color-mix(in srgb, var(--glow) 45%, transparent), transparent 70%);
  position: relative;
}
.reveal::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: repeating-conic-gradient(color-mix(in srgb, var(--glow) 35%, transparent) 0 12deg, transparent 12deg 30deg);
  animation: spin 9s linear infinite;
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
}
.reveal span { position: relative; font-size: 72px; line-height: 1; animation: reveal 0.7s var(--ease-pop) both; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.12)); }
.reveal.r-rare { --glow: var(--rare-glow); }
.reveal.r-epic { --glow: var(--epic-glow); }
.reveal.r-common { --glow: var(--common-glow); }
.reveal.takeover { --glow: var(--red); }
.rarity { margin: 0 0 6px; font: 600 14px/1 var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; }
.rarity.r-common { color: var(--muted); }
.rarity.r-rare { color: var(--rare); }
.rarity.r-epic { color: var(--epic); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
.level-burst {
  width: 130px; height: 130px;
  margin: 14px auto 6px;
  display: grid; place-items: center;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 12%, 75% 6%, 79% 21%, 94% 25%, 88% 39%, 100% 50%, 88% 61%, 94% 75%, 79% 79%, 75% 94%, 61% 88%, 50% 100%, 39% 88%, 25% 94%, 21% 79%, 6% 75%, 12% 61%, 0% 50%, 12% 39%, 6% 25%, 21% 21%, 25% 6%, 39% 12%);
  animation: reveal 0.6s var(--ease-pop) both, spin 14s linear 0.6s infinite;
}
.level-burst span { font: 700 56px/1 var(--font-display); color: var(--gold-ink); animation: spin 14s linear 0.6s infinite reverse; }

.rules { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; display: grid; gap: 10px; }
.rules li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; }
.rules li > span { font-size: 24px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); }
.rules p { margin: 0; font-size: 14px; }
.rules.compact { gap: 8px; }

.logo { margin: 6px 0 4px; font: 700 58px/0.95 var(--font-display); letter-spacing: -0.02em; color: var(--accent); text-shadow: 0 4px 0 var(--accent-deep); }
.logo span { color: var(--gold); text-shadow: 0 4px 0 var(--gold-deep); }
.welcome-art { display: flex; justify-content: center; align-items: flex-end; gap: 0; margin: 4px 0 0; }
.welcome-art .building { width: 76px; height: 76px; margin: 0 -8px; }
.welcome-art .building:nth-child(1) { --g: var(--g-leisure); }
.welcome-art .building:nth-child(2) { --g: var(--g-food); }
.welcome-art .building:nth-child(3) { --g: var(--g-shop); }
.welcome-art .building:nth-child(4) { --g: var(--g-drink); }
.welcome-me { margin: 14px 0 16px; }
.welcome-card .field { text-align: left; }
.welcome-actions { display: grid; gap: 4px; margin-top: 16px; }
.welcome-actions .btn { min-height: 64px; margin-top: 4px; }
.fine { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.fine a, .account-card a { color: var(--accent); font-weight: 700; }

/* ---------- accounts ---------- */
.auth { display: grid; gap: 12px; margin-top: 14px; text-align: left; }
.auth .wide-btn { margin-top: 2px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); font-size: 14px; font-weight: 600; }
.field input:focus-visible { outline: none; border-color: var(--accent); }
.link {
  display: block;
  margin: 10px auto 0;
  padding: 8px 10px;
  border: 0;
  background: none;
  color: var(--accent);
  font: 700 15px/1.2 var(--font-display);
}
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 8px; margin-top: 4px; }
.auth-links .link { margin: 0; }
.modal-card > .link[data-modal-close] { color: var(--muted); }
.account-card { padding: 14px; border-radius: 16px; background: var(--surface-2); }
.account-card p { margin: 0; font-size: 14px; }
.account-email { overflow-wrap: anywhere; }
.sync { flex: none; max-width: 52%; font-size: 12px; font-weight: 700; text-align: right; color: var(--muted); }
.sync.s-saved { color: var(--good); }
.sync.s-error, .sync.s-offline { color: var(--warn); }
.save-choice { display: grid; gap: 6px; margin-top: 12px; }
.save-choice .btn { min-height: 64px; margin-top: 4px; }

/* ---------- location help ---------- */
.steps { margin: 12px 0 0; padding-left: 22px; text-align: left; font-size: 14px; }
.steps li { margin: 0 0 6px; }
.steps b { white-space: nowrap; }

/* The rent shortcut on the map */
.boost.rent {
  border: 0;
  background: var(--gold);
  color: var(--gold-ink);
  box-shadow: 0 3px 0 var(--gold-deep), var(--shadow-sm);
  font-weight: 700;
  animation: reveal 0.4s var(--ease-pop);
}
.boost.rent:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gold-deep); }
.screen-check { width: 100%; margin: var(--s-3) 0 0; border-collapse: collapse; font-size: var(--t-sm); text-align: left; }
.screen-check th, .screen-check td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.screen-check th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.screen-check td { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- rewards & motion ---------- */
.xporb {
  position: fixed;
  z-index: 5000;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 20%, var(--xp-glow) 45%, var(--xp) 100%);
  box-shadow: 0 0 10px var(--xp-glow);
  pointer-events: none;
}
.spark {
  position: fixed;
  z-index: 5000;
  pointer-events: none;
  color: var(--gold);
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 1px 0 var(--gold-deep);
}
.floattext.small { font-size: 16px; }
.floattext.small.xp { color: var(--xp); -webkit-text-stroke: 0; text-shadow: 0 1px 0 var(--surface); }
/* The XP bar glows as orbs land */
.xpbar.gain { animation: xp-gain 0.6s var(--ease-out); }
.xpbar.gain i { filter: brightness(1.25); }
@keyframes xp-gain { 30% { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), 0 0 0 3px color-mix(in srgb, var(--xp-glow) 60%, transparent); transform: scaleY(1.3); } }
/* Level up: the level chip rings like a bell */
.hud-level.ding { animation: ding 0.8s var(--ease-pop); }
@keyframes ding { 15% { transform: scale(1.12) rotate(-4deg); } 35% { transform: scale(1.08) rotate(3deg); } 55% { transform: scale(1.04) rotate(-2deg); } }
/* A generic squash and stretch for anything that just paid out */
.bump { animation: bump 0.45s var(--ease-pop); }
@keyframes bump { 30% { transform: scale(1.08, 0.92); } 60% { transform: scale(0.96, 1.05); } }
/* Pins drop onto the map as an area loads, and pop when they become yours */
.pin-wrap.drop .pin { animation: pin-drop 0.5s var(--ease-pop) both; animation-delay: var(--d, 0ms); }
@keyframes pin-drop { from { transform: rotate(-45deg) translate(14px, -14px) scale(0.3); opacity: 0; } }
.pin.pop { animation: pin-pop 0.7s var(--ease-pop); }
.pin.pop::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  animation: ring 0.7s ease-out;
}
@keyframes pin-pop { 30% { transform: rotate(-45deg) scale(1.6); } 60% { transform: rotate(-45deg) scale(1.1); } }
/* The daily chest rattles, then bursts open */
.reveal.chest span { position: absolute; }
.reveal.chest .closed { animation: chest-shake 0.9s ease-in-out both; }
.reveal.chest .prize { animation: reveal 0.7s var(--ease-pop) 0.9s both; }
@keyframes chest-shake {
  10%, 30%, 50%, 70% { transform: rotate(-12deg) scale(1.05); }
  20%, 40%, 60%, 80% { transform: rotate(12deg) scale(1.1); }
  90% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}
/* Big numbers in reward dialogs */
.reward-line { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-2) 0 0; }
.reward-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font: 700 var(--t-lg)/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  animation: reveal 0.5s var(--ease-pop) both;
}
.reward-chip.xp { color: var(--xp); }
.reward-chip:nth-child(2) { animation-delay: 0.12s; }
.reward-chip:nth-child(3) { animation-delay: 0.24s; }

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