/* ---------- theme tokens: theme (colors) x lighting (surface brightness) ---------- */
:root {
  --danger: #ff5d73;
  --ok: #3ddc97;
  --warn: #ffb547;
}
:root, :root[data-theme="purple"][data-mode="dark"] {
  --bg: #0f1020;
  --surface: #181a30;
  --surface2: #22254a;
  --text: #f3f4ff;
  --muted: #9a9dc2;
  --accent: #8b7bff;
  --accent2: #c06cff;
  --accent-rgb: 139, 123, 255;
  --gold: #ffcf4a;
  --gold-ink: #ffcf4a;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --on-accent: #fff;
  --lap1a: #ffd96b;
  --lap1b: #ff9f43;
  --lap2a: #ff7a8a;
  --lap2b: #ff4d8d;
  --lap3a: #5ee6c4;
  --lap3b: #3aa8ff;
  --color-scheme: dark;
}
:root[data-theme="purple"][data-mode="light"] {
  --bg: #f5f5fb;
  --surface: #ffffff;
  --surface2: #eceefa;
  --text: #17182b;
  --muted: #6a6d8f;
  --accent: #6a58f0;
  --accent2: #a04ae0;
  --accent-rgb: 106, 88, 240;
  --gold: #ffcf4a;
  --gold-ink: #d08a00;
  --line: rgba(20, 20, 60, 0.08);
  --shadow: 0 10px 30px rgba(40, 40, 100, 0.12);
  --on-accent: #fff;
  --lap1a: #f5b100;
  --lap1b: #ee7d12;
  --lap2a: #e8456a;
  --lap2b: #d12e78;
  --lap3a: #18b394;
  --lap3b: #2488e6;
  --color-scheme: light;
}
:root[data-theme="purple"][data-mode="night"] {
  --bg: #000000;
  --surface: #0b0b14;
  --surface2: #161728;
  --text: #f3f4ff;
  --muted: #8c8fb3;
  --accent: #8b7bff;
  --accent2: #c06cff;
  --accent-rgb: 139, 123, 255;
  --gold: #ffcf4a;
  --gold-ink: #ffcf4a;
  --line: rgba(255, 255, 255, 0.07);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --on-accent: #fff;
  --lap1a: #ffd96b;
  --lap1b: #ff9f43;
  --lap2a: #ff7a8a;
  --lap2b: #ff4d8d;
  --lap3a: #5ee6c4;
  --lap3b: #3aa8ff;
  --color-scheme: dark;
}
:root[data-theme="victini"][data-mode="dark"] {
  --bg: #1a1210;
  --surface: #271b16;
  --surface2: #37261d;
  --text: #fff4e8;
  --muted: #c9a894;
  --accent: #ff8a3d;
  --accent2: #ffc233;
  --accent-rgb: 255, 138, 61;
  --gold: #ffd75e;
  --gold-ink: #ffd75e;
  --line: rgba(255, 230, 200, 0.09);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --on-accent: #2a1208;
  --lap1a: #ff9a5c;
  --lap1b: #ff5a4a;
  --lap2a: #ff6a8e;
  --lap2b: #e03a7a;
  --lap3a: #7fd8ff;
  --lap3b: #4aa3ff;
  --color-scheme: dark;
}
:root[data-theme="victini"][data-mode="light"] {
  --bg: #fff6ea;
  --surface: #ffffff;
  --surface2: #ffe8cf;
  --text: #2a1710;
  --muted: #8a6650;
  --accent: #e8590c;
  --accent2: #f0a000;
  --accent-rgb: 232, 89, 12;
  --gold: #ffcf4a;
  --gold-ink: #b86e00;
  --line: rgba(90, 40, 10, 0.1);
  --shadow: 0 10px 30px rgba(120, 60, 20, 0.12);
  --on-accent: #2a1208;
  --lap1a: #ee3d2f;
  --lap1b: #c2185b;
  --lap2a: #a23bd1;
  --lap2b: #6a3bd1;
  --lap3a: #1b8fd1;
  --lap3b: #0f6fb5;
  --color-scheme: light;
}
:root[data-theme="victini"][data-mode="night"] {
  --bg: #000000;
  --surface: #0e0806;
  --surface2: #1d110b;
  --text: #fff4e8;
  --muted: #b8967f;
  --accent: #ff8a3d;
  --accent2: #ffc233;
  --accent-rgb: 255, 138, 61;
  --gold: #ffd75e;
  --gold-ink: #ffd75e;
  --line: rgba(255, 230, 200, 0.07);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --on-accent: #2a1208;
  --lap1a: #ff9a5c;
  --lap1b: #ff5a4a;
  --lap2a: #ff6a8e;
  --lap2b: #e03a7a;
  --lap3a: #7fd8ff;
  --lap3b: #4aa3ff;
  --color-scheme: dark;
}
:root[data-theme="mew"][data-mode="dark"] {
  --bg: #0b1719;
  --surface: #122528;
  --surface2: #1a3a3f;
  --text: #eafcff;
  --muted: #8fbcc3;
  --accent: #4fd6d0;
  --accent2: #ff9ecb;
  --accent-rgb: 79, 214, 208;
  --gold: #ffe08a;
  --gold-ink: #ffe08a;
  --line: rgba(220, 255, 255, 0.09);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --on-accent: #052a2c;
  --lap1a: #ffe08a;
  --lap1b: #ffb347;
  --lap2a: #b49bff;
  --lap2b: #7a8bff;
  --lap3a: #ff8fb0;
  --lap3b: #ff5c8a;
  --color-scheme: dark;
}
:root[data-theme="mew"][data-mode="light"] {
  --bg: #eefafa;
  --surface: #ffffff;
  --surface2: #d9f1f2;
  --text: #0f2a2e;
  --muted: #4f7a80;
  --accent: #0c8d93;
  --accent2: #e0568f;
  --accent-rgb: 12, 141, 147;
  --gold: #ffcf4a;
  --gold-ink: #b87800;
  --line: rgba(10, 60, 70, 0.1);
  --shadow: 0 10px 30px rgba(20, 90, 100, 0.12);
  --on-accent: #fff;
  --lap1a: #d99a00;
  --lap1b: #e0701a;
  --lap2a: #7a5ae0;
  --lap2b: #4f5fe0;
  --lap3a: #d93a6f;
  --lap3b: #b8245a;
  --color-scheme: light;
}
:root[data-theme="mew"][data-mode="night"] {
  --bg: #000000;
  --surface: #071012;
  --surface2: #0f2226;
  --text: #eafcff;
  --muted: #7fa9b0;
  --accent: #4fd6d0;
  --accent2: #ff9ecb;
  --accent-rgb: 79, 214, 208;
  --gold: #ffe08a;
  --gold-ink: #ffe08a;
  --line: rgba(220, 255, 255, 0.07);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --on-accent: #052a2c;
  --lap1a: #ffe08a;
  --lap1b: #ffb347;
  --lap2a: #b49bff;
  --lap2b: #7a8bff;
  --lap3a: #ff8fb0;
  --lap3b: #ff5c8a;
  --color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow-x: hidden; overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  -webkit-touch-callout: none;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 110px);
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; -webkit-user-select: none; user-select: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.topbar > div:first-child { min-width: 0; flex: 1 1 auto; }
.topbar .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#syncLabel { white-space: nowrap; }
/* phones: keep the whole header inside the screen (title + sync dot + 2-3 icon buttons) */
@media (max-width: 429px) {
  .topbar { gap: 8px; }
  .topbar h1 { font-size: 24px; }
  .top-actions { gap: 6px; }
  .top-actions .pill { padding: 12px; }
  .top-actions .pill #syncLabel { display: none; }
}
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.pill, .icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 14px; font-size: 14px; color: var(--muted);
}
.icon-btn { color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--danger); }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; background: var(--surface); padding: 5px; border-radius: 16px; border: 1px solid var(--line); margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border-radius: 12px; color: var(--muted); font-weight: 600; }
.tab .n { opacity: 0.7; font-weight: 500; margin-left: 4px; }
.tab.on { background: var(--surface2); color: var(--text); }

/* ---------- list ---------- */
.list { display: grid; gap: 10px; }
.card {
  display: grid; grid-template-columns: 64px 1fr auto auto; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius, 20px);
  padding: 10px 12px 10px 8px; cursor: pointer; transition: transform 0.12s ease, border-color 0.12s;
}
.card:active { transform: scale(0.985); }
.card:hover { border-color: rgba(var(--accent-rgb), 0.45); }
.card.found { border-color: rgba(255, 207, 74, 0.35); }
.spr { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.spr, .hero-img, .sug-item img, .preview img { opacity: 0; transition: opacity 0.25s ease; }
.ready { opacity: 1 !important; }
.spr.ph, .hero-img.ph { display: grid; place-items: center; font-size: 28px; color: var(--muted); }
.card-main { min-width: 0; }
.card-name { font-weight: 700; font-size: 17px; }
.card-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-count { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.star { font-size: 22px; }
.chev { color: var(--muted); font-size: 26px; line-height: 1; padding: 0 4px 3px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; line-height: 1.5; }
.empty b { color: var(--text); }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent);
  font-weight: 700; font-size: 17px; padding: 16px 28px; border-radius: 999px; box-shadow: var(--shadow);
}
.fab:active { transform: translateX(-50%) scale(0.96); }

/* ---------- hunt view ---------- */
body[data-view="hunt"] #app { padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }
.hunt {
  display: flex; flex-direction: column;
  min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 36px);
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 36px);
}
.hunt-top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.top-title { flex: 1; font-weight: 700; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.circle {
  width: 52px; height: 52px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.circle:disabled { opacity: 0.35; cursor: default; }
.circle:not(:disabled):active { transform: scale(0.93); }
.tools .circle { color: var(--muted); }
.pill-btn {
  height: 52px; padding: 0 20px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.pill-btn svg { fill: currentColor; stroke: none; }

.hunt-grid {
  flex: 1; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(250px, 1fr) auto auto;
  grid-template-areas: "hero" "counter" "tools" "info";
}
.hero-block { grid-area: hero; text-align: center; }
.hero { position: relative; width: 112px; height: 112px; margin: 0 auto; display: grid; place-items: center; }
.hero::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.32), rgba(var(--accent-rgb), 0) 68%);
}
.hunt.found .hero::before { background: radial-gradient(circle, rgba(255, 207, 74, 0.5), rgba(255, 207, 74, 0) 68%); }
.hero-img { position: relative; width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.3)); }
.hero-block h2 { margin: 4px 0 2px; font-size: 28px; letter-spacing: -0.02em; }
.hero-block h2 small { color: var(--muted); font-weight: 500; font-size: 15px; margin-left: 6px; }
.game-line { margin: 0; color: var(--muted); font-size: 16px; }

/* the big card IS the + button */
.counter {
  grid-area: counter; position: relative; overflow: hidden; container-type: inline-size;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 44px 20px 34px; border-radius: 32px; text-align: center; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 0.08s ease; -webkit-user-select: none; user-select: none;
}
.counter:not(:disabled):active { transform: scale(0.992); }
.counter:disabled { cursor: default; opacity: 1; }
.hunt.found .counter { border-color: rgba(255, 207, 74, 0.4); }
.step-tag { position: absolute; top: 16px; right: 22px; color: var(--accent); font-weight: 700; font-size: 20px; }
.fl { position: absolute; inset: 0; opacity: 0; pointer-events: none; border-radius: inherit; background: linear-gradient(135deg, rgba(61, 220, 151, 0.55), rgba(47, 181, 166, 0.55)); }
.counter.down .fl { background: linear-gradient(135deg, rgba(255, 181, 71, 0.5), rgba(255, 143, 90, 0.5)); }
.flash .fl { animation: washfade 0.6s ease-out; }
@keyframes washfade { 0% { opacity: 1; } 100% { opacity: 0; } }

.count {
  position: relative; display: flex; justify-content: center; width: 100%;
  font-size: clamp(56px, 19vw, 120px); line-height: 1.1; height: 1.1em; font-weight: 800;
  font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: 0;
}
@supports (width: 1cqw) {
  /* fit the number to the card: --em is the width of the digits in em, set from JS */
  .count { font-size: min(150px, calc((100cqw - 44px) / var(--em, 4))); }
}
.hunt.found .count { color: var(--gold-ink); }
.odo { display: inline-flex; height: 1.1em; }
.col { display: block; width: 0.64em; height: 1.1em; overflow: hidden; text-align: center; }
.strip { display: block; will-change: transform; }
.strip i { display: block; height: 1.1em; line-height: 1.1em; font-style: normal; }
.sep { display: block; width: 0.26em; height: 1.1em; line-height: 1.1em; text-align: center; opacity: 0.6; transform: scale(0.55); transform-origin: 50% 83%; }
.count.pop { animation: milestone 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes milestone {
  0% { transform: scale(1); color: var(--gold-ink); text-shadow: 0 0 0 rgba(255, 207, 74, 0); }
  30% { transform: scale(1.08); color: var(--gold-ink); text-shadow: 0 0 28px rgba(255, 207, 74, 0.7); }
  100% { transform: scale(1); text-shadow: 0 0 0 rgba(255, 207, 74, 0); }
}
.stats { display: grid; gap: 3px; color: var(--muted); font-size: 15px; line-height: 1.35; }
.stats span:last-child { font-size: 13px; opacity: 0.9; }
/* progress toward the odds. Past 100% the bar wraps: the finished lap stays as the track in its colour
   and the next lap fills over it in a new colour. Ticks mark each quarter (where the count pops). */
.bar { position: relative; width: min(100%, 380px); height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--pa, var(--surface2)), var(--pb, var(--surface2))); }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--fa, var(--accent)), var(--fb, var(--accent2))); transition: width 0.3s ease; }
.bar.nt i { transition: none; }
.hunt.found .bar i { background: linear-gradient(90deg, #ffd96b, var(--gold)); }
.hunt.found .bar { background: linear-gradient(90deg, rgba(255, 217, 107, 0.3), rgba(255, 207, 74, 0.3)); }
.tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--surface); border-radius: 1px; }
.lap-tag { position: absolute; top: 16px; left: 22px; font-weight: 700; font-size: 14px; padding: 3px 10px; border-radius: 999px; color: var(--on-accent); background: linear-gradient(90deg, var(--fa, var(--accent)), var(--fb, var(--accent2))); }
.lap-tag[hidden] { display: none; }
.hide-odds #oddsLine, .hide-chance #oddsLine2 { display: none; }
.hide-bar .bar { display: none; }
.hide-marks .tick { display: none; }

.tools { grid-area: tools; display: flex; justify-content: flex-end; gap: 12px; }
.info-card { grid-area: info; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 18px; display: grid; gap: 14px; }
.started, .timed { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 16px; }
.timed svg { flex: none; }
.started em { display: block; font-style: normal; font-size: 13px; opacity: 0.85; margin-top: 2px; }
.found-pill {
  width: 100%; padding: 16px; border-radius: 999px; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface2); color: var(--accent);
}
.found-pill:active { transform: scale(0.985); }
.notes { margin: 0; padding: 12px 14px; border-radius: 14px; background: var(--surface2); color: var(--muted); font-size: 14px; text-align: left; white-space: pre-wrap; }
.keys { display: none; margin: 0; color: var(--muted); font-size: 13px; text-align: center; }

/* amount-per-tap sheet */
.steps { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { padding: 10px 18px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); font-weight: 600; min-width: 52px; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.sheet .chip-input, .chip-input { width: 104px; padding: 10px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font-size: 16px; text-align: center; }

/* desktop: much more room, counter on the left, details on the right */
@media (min-width: 900px) {
  body[data-view="hunt"] #app { max-width: 1080px; padding-top: 32px; }
  .hunt { min-height: calc(100vh - 100px); }
  .hunt-grid {
    gap: 20px; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); grid-template-rows: auto auto 1fr;
    grid-template-areas: "counter hero" "counter tools" "counter info";
  }
  .counter { min-height: 560px; border-radius: 36px; padding: 56px 32px 44px; gap: 18px; }
  .count { font-size: min(190px, calc((100cqw - 64px) / var(--em, 4))); }
  .stats { font-size: 17px; }
  .stats span:last-child { font-size: 15px; }
  .hero-block { text-align: left; }
  .hero, .hero-img { width: 168px; height: 168px; margin: 0; }
  .hero-block h2 { font-size: 34px; margin-top: 10px; }
  .tools { justify-content: flex-start; }
  .info-card { align-self: start; }
  .keys { display: block; }
  .top-title { display: none; }
  .hunt-top { justify-content: space-between; }
}

/* ---------- dialogs & forms ---------- */
dialog {
  border: 0; padding: 0; border-radius: 26px; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 20px)); max-height: 92vh; max-height: 92dvh; box-shadow: var(--shadow);
  overflow-x: hidden; overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(5, 5, 15, 0.62); backdrop-filter: blur(4px); }
.sheet { padding: 20px; display: grid; gap: 14px; }
.sheet h3 { margin: 0; font-size: 22px; }
.sheet h4 { margin: 6px 0 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sheet label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sheet input, .sheet select, .sheet textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface2);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.sheet textarea { resize: vertical; }
.sheet input:not([type=checkbox]):not([type=range]), .sheet select { min-height: 48px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.row2 > label { min-width: 0; }
.sheet input[type="date"] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; min-height: 48px; display: block; text-align: left; }
.sheet input[type="date"]::-webkit-date-and-time-value { text-align: left; min-height: 1.2em; }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; font-size: 15px; color: var(--text) !important; font-weight: 600; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.odds-field { display: flex; align-items: center; gap: 10px; }
.odds-field input { flex: 1; }
.poke-field { position: relative; }
.sug { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.sug:empty { display: none; }
.sug-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 12px; text-align: left; color: var(--text); }
.sug-item:hover { background: rgba(var(--accent-rgb), 0.18); }
.sug-item img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.sug-item small { color: var(--muted); margin-left: auto; }
.preview { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; min-height: 0; }
.preview:empty { display: none; }
.preview img { width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.grow { flex: 1; }
.primary, .ghost, .danger { padding: 12px 18px; border-radius: 14px; font-weight: 700; }
.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); }
.ghost { background: var(--surface2); }
.danger { color: var(--danger); background: rgba(255, 93, 115, 0.12); }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint code { background: var(--surface2); padding: 1px 6px; border-radius: 6px; }
.sheet p { margin: 0; }
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translate(-50%, 20px);
  background: var(--surface2); color: var(--text); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: 0.2s; z-index: 50; max-width: calc(100vw - 32px); font-size: 14px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  #app { padding-top: 40px; }
}

/* ---------- screen transitions ---------- */
#app.enter-right > :not(.fab) { animation: slideInRight 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
#app.enter-left > :not(.fab) { animation: slideInLeft 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes slideInRight { from { opacity: 0; transform: translateX(28px); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-28px); } }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* Only applied when Settings > Animations is set to follow the device's reduce-motion option */
.motion-off *, .motion-off *::before, .motion-off *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }

/* ---------- password gate ---------- */
.gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--bg); padding: 24px; overflow: auto; }
.gate[hidden], #app[hidden] { display: none; }
.gate-card { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; justify-items: center; }
.gate-card img { border-radius: 18px; box-shadow: var(--shadow); }
.gate-card h1 { margin: 4px 0 0; font-size: 28px; letter-spacing: -0.02em; }
.gate-card input[type=password] { width: 100%; font: inherit; font-size: 18px; text-align: center; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.gate-card .primary { width: 100%; padding: 16px; font-size: 17px; border-radius: 16px; }
.gate-card .primary:disabled { opacity: 0.6; }
.gate-msg { min-height: 1.5em; }

/* ---------- settings page ---------- */
#settingsDialog .sheet { gap: 12px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.sec-h h4 { margin: 0; }
.scope { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--muted); letter-spacing: 0.02em; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface2); }
.seg button { padding: 10px 4px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-card { display: grid; gap: 8px; justify-items: center; padding: 12px 6px; border-radius: 16px; background: var(--surface2); border: 2px solid transparent; font-weight: 600; font-size: 14px; }
.theme-card.on { border-color: var(--accent); }
.sw { display: flex; }
.sw i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface2); margin-left: -6px; }
.sw i:first-child { margin-left: 0; }
.row-set { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0; font-size: 15px; font-weight: 600; color: var(--text); }
.row-set small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }
.vol { display: flex; align-items: center; gap: 10px; }
.vol input[type=range] { width: 96px; min-height: 0 !important; padding: 0; accent-color: var(--accent); background: none; border: 0; }
.num-set { width: 90px !important; text-align: center; }
.circle.sm { width: 44px; height: 44px; }
.top-actions .circle { color: var(--muted); }
[hidden] { display: none !important; }
.row-set > span:first-child { min-width: 0; }

/* ---------- stats page ---------- */
body[data-view="stats"] #app { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }
.stats-page .hunt-top { margin-bottom: 14px; }
.sp-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.sp-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px; display: grid; gap: 4px; }
.sp-tile b { font-size: 28px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sp-tile span { color: var(--muted); font-size: 13px; }
.sp-grid { display: grid; gap: 12px; }
.sp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; display: grid; gap: 10px; align-content: start; }
.sp-card h3 { margin: 0; font-size: 17px; }
.sp-card .hint { margin: -4px 0 2px; }
.sp-big { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sp-two { display: grid; gap: 8px; }
.sp-link, .sp-bar-row, .sp-find { text-align: left; color: var(--text); }
.sp-link { display: grid; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface2); width: 100%; }
.sp-k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.sp-v { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.sp-spr { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; flex: none; opacity: 0; transition: opacity 0.25s; }
.sp-spr.ready, .sp-big-spr.ready { opacity: 1; }
.sp-rec { display: grid; }
.sp-bar-row { display: grid; grid-template-columns: 36px minmax(70px, 110px) 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 2px 0; }
.sp-bar-row.static { grid-template-columns: minmax(90px, 140px) 1fr auto; }
.sp-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-track { position: relative; height: 10px; border-radius: 999px; background: var(--surface2); }
.sp-track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.sp-track i.over { background: linear-gradient(90deg, var(--lap1a, var(--accent)), var(--lap1b, var(--accent2))); }
.sp-track b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--muted); border-radius: 1px; opacity: 0.8; }
.sp-val { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; display: grid; }
.sp-val small { color: var(--muted); font-weight: 500; font-size: 11px; }
.sp-avg { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px; color: var(--muted); font-size: 14px; }
.sp-avg b { color: var(--text); text-align: right; }
.sp-avg small { color: var(--muted); font-weight: 500; }
.sp-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.sp-find { display: grid; justify-items: center; gap: 2px; font-size: 12px; color: var(--muted); flex: none; width: 76px; }
.sp-big-spr { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; opacity: 0; transition: opacity 0.25s; }
@media (min-width: 900px) {
  body[data-view="stats"] #app { max-width: 1000px; padding-top: 32px; }
  .sp-tiles { grid-template-columns: repeat(4, 1fr); }
  .sp-grid { grid-template-columns: 1fr 1fr; }
}
.ov-preview { width: 100%; height: 220px; border: 1px solid var(--line); border-radius: 14px; background: #2a2a2e; }
#ovLink { font-size: 13px; }
@media (max-width: 899px) { .deskonly { display: none !important; } }
/* overlay page (desktop) */
.ovp .hunt-top { margin-bottom: 14px; }
.ovp-title { margin: 0; font-size: 22px; flex: 1; }
.ovp-grid { display: grid; gap: 14px; }
.ovp-sub { margin: 10px 0 0; }
.sp-card .sec-h { margin-top: 0; }
.sp-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sp-card select, .sp-card input:not([type=checkbox]):not([type=range]) { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 46px; }
body[data-view="overlay"] #app { padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }
@media (min-width: 900px) {
  body[data-view="overlay"] #app { max-width: 1000px; padding-top: 32px; }
  .ovp-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}
