/* ───────────── Theme ───────────── */
:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #141824;
  --muted: #5f6678;
  --border: #dde2ec;
  --accent: #ff5a36;
  --accent-2: #ff8a3d;
  --accent-text: #ffffff;
  --success: #17a34a;
  --success-bg: #e8f7ee;
  --danger: #d33a2c;
  --gold: #d9a400;
  --gold-bg: linear-gradient(135deg, #fff8dc 0%, #fff1b8 100%);
  --gold-border: #f0d36b;

  --t-common: #22a559;
  --t-uncommon: #2f6fe4;
  --t-rare: #8b4ae0;
  --t-epic: #e0457b;
  --t-legendary: #d99a00;
  --t-quirky: #0f9b9b;

  --shadow: 0 1px 2px rgb(20 24 36 / 6%), 0 4px 14px rgb(20 24 36 / 6%);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #182030;
    --surface-2: #222b3d;
    --text: #eef1f7;
    --muted: #9aa3b8;
    --border: #2c3649;
    --accent: #ff6b47;
    --accent-2: #ff9a52;
    --success: #3ccf72;
    --success-bg: #15301f;
    --danger: #ff6a5c;
    --gold: #f2c230;
    --gold-bg: linear-gradient(135deg, #2e2710 0%, #3a2f0b 100%);
    --gold-border: #6b5617;

    --t-common: #3ccf72;
    --t-uncommon: #5b93ff;
    --t-rare: #b07cff;
    --t-epic: #ff6f9f;
    --t-legendary: #f2c230;
    --t-quirky: #2fd0d0;

    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
  }
}

[data-tier="common"] { --tier: var(--t-common); }
[data-tier="uncommon"] { --tier: var(--t-uncommon); }
[data-tier="rare"] { --tier: var(--t-rare); }
[data-tier="epic"] { --tier: var(--t-epic); }
[data-tier="legendary"] { --tier: var(--t-legendary); }
[data-tier="quirky"] { --tier: var(--t-quirky); }

/* ───────────── Base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 600; font-size: 16px;
  box-shadow: var(--shadow);
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; box-shadow: none; }
.btn-small { min-height: 44px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--accent-text);
  border-color: transparent;
}
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 140px; }
.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--surface-2);
  font-size: 18px; font-weight: 700;
}

/* ───────────── Header ───────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(8px + var(--safe-top)) calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-row { display: flex; align-items: center; gap: 8px; }
.topbar-spacer { flex: 0 0 72px; }

.trip-name {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  border: 0; background: none;
  font-weight: 700; font-size: 16px; text-align: left;
}
.trip-name-text {
  overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  line-height: 1.2; overflow-wrap: anywhere;
}
.trip-name-edit { color: var(--muted); font-size: 15px; flex: none; }
.view-title { flex: 1; margin: 0; font-size: 18px; text-align: center; }

.pill {
  flex: none;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.pill[data-status="synced"] { color: var(--success); background: var(--success-bg); border-color: transparent; }
.pill[data-status="syncing"] { color: var(--t-uncommon); }
.pill[data-status="offline"] { color: #b26b00; background: color-mix(in srgb, #ffb020 16%, var(--surface)); border-color: transparent; }
.pill[data-status="error"] { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: transparent; }
@media (prefers-color-scheme: dark) { .pill[data-status="offline"] { color: #ffc560; } }

.score-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin: 2px 4px 8px; }
.score-main { line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score-points { display: inline-block; font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.score-unit { font-size: 18px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.score-points.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.15); } }
.score-side { display: flex; gap: 14px; align-items: flex-end; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat-value { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-btn {
  min-height: 44px; justify-content: center;
  padding: 4px 10px; margin: -4px -6px -4px 0;
  border: 1px solid var(--gold-border); border-radius: 12px;
  background: var(--gold-bg);
}

.progress {
  position: relative;
  height: 10px;
  margin: 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--t-common), var(--t-uncommon), var(--t-rare), var(--t-epic), var(--t-legendary));
  background-size: 360px 100%;
  transition: width .4s cubic-bezier(.2, .8, .2, 1);
}
.progress-tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bg); opacity: .8; }

/* ───────────── Content ───────────── */
.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px calc(12px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(12px + var(--safe-left));
}
.controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }

.search { position: relative; display: block; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-52%);
  font-size: 22px; color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 16px; /* ≥16px avoids iOS zoom */
  box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
.search input:focus { outline: none; border-color: var(--accent); }

.chips {
  display: flex; gap: 8px;
  overflow-x: auto;
  margin: 0 -12px; padding: 2px 12px 4px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px; font-weight: 600;
  white-space: nowrap;
  scroll-snap-align: start;
}
.chip-count { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.active .chip-count { color: inherit; opacity: .7; }
.chip-tier::before { content: ""; width: 10px; height: 10px; border-radius: 50%; margin-right: 2px; background: var(--tier); }

.list-meta {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 15px; padding: 0 4px;
}
.sort select {
  min-height: 44px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 16px;
  -webkit-appearance: none; appearance: none;
}

/* ───────────── Car cards ───────────── */
.car-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.car {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 12px 10px 12px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--tier);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .08s ease, background .2s ease;
}
.car:active { transform: scale(.985); }
.car[data-tier="legendary"] { background: var(--gold-bg); border-color: var(--gold-border); border-left-color: var(--tier); }
.car.found { background: var(--success-bg); border-color: transparent; border-left-color: var(--tier); }

.swatch {
  flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid rgb(127 127 127 / 35%);
  background: var(--sw, transparent);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 15%);
  font-size: 18px; font-weight: 800; color: var(--muted);
}
.swatch.blank { border: 2px dashed color-mix(in srgb, var(--tier, var(--muted)) 60%, transparent); box-shadow: none; }
.swatch.unknown { background: var(--surface-2); }
.swatch.quirky { background: var(--surface-2); }
.swatch.wrap, .opt-swatch.wrap { background: conic-gradient(#ff5a5a, #ffb03a, #ffe14a, #5ad17a, #4aa8ff, #9a6bff, #ff5a5a); }
.pop .swatch { animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }

.car-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.car-name { font-size: 17px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.car-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.car-seen { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-weight: 600; }
.car-time { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.flag { font-size: 17px; line-height: 1; }
.badge {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--tier);
  background: color-mix(in srgb, var(--tier) 14%, transparent);
}
.badge-retro { background: #7a5c2e; color: #fff8ec; }
.car-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; min-width: 44px; }
.car-points { font-weight: 800; font-size: 19px; color: var(--tier); font-variant-numeric: tabular-nums; line-height: 1.1; }
.car-points.earned { color: var(--success); }
.car-unit { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-emoji { font-size: 40px; }
.empty p { margin: 8px 0 16px; font-size: 17px; }

.finish-wrap { margin-top: 28px; display: flex; justify-content: center; }
.btn-finish { min-height: 56px; padding: 0 28px; font-size: 17px; }

/* ───────────── Dialogs & sheets ───────────── */
.dialog {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 24px 20px calc(20px + var(--safe-bottom));
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 35%);
  text-align: center;
}
.dialog::backdrop { background: rgb(10 14 24 / 55%); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog[open] { animation: rise .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.dialog h2 { margin: 6px 0 8px; font-size: 22px; }
.dialog p { margin: 0 0 18px; }
.dialog-emoji { font-size: 42px; line-height: 1; }
.dialog-actions { display: flex; flex-direction: column; gap: 10px; }

/* Bottom sheet */
.sheet-dialog {
  width: 100%; max-width: 640px;
  height: auto; max-height: calc(100dvh - 32px - var(--safe-top));
  margin: auto auto 0;
  padding: 0;
  border-radius: 22px 22px 0 0;
  text-align: left;
  overflow: hidden;
}
.sheet-dialog[open] { display: flex; animation: slide-up .25s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }
.sheet { display: flex; flex-direction: column; width: 100%; min-height: 0; max-height: inherit; }
.sheet-head {
  flex: none;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  border-top: 6px solid var(--tier, var(--gold));
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.sheet-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 14px; }
.sheet-spotted { color: var(--success); font-weight: 700; }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.opt-section h3, .coll-group h3 {
  margin: 14px 0 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 76px;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
}
.opt[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.opt-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--sw);
  border: 1px solid rgb(127 127 127 / 45%);
}
.opt-swatch.unknown { background: repeating-linear-gradient(45deg, var(--surface-2) 0 4px, var(--border) 4px 8px); }
.opt-flag { font-size: 26px; line-height: 1; }
.opt-label { font-size: 13px; font-weight: 600; line-height: 1.15; }
.opt-mult { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt[aria-pressed="true"] .opt-mult { color: var(--accent); }

.preview { min-height: 42px; }
.preview-text { font-size: 17px; font-weight: 800; }
.preview-math { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-spot { min-height: 56px; font-size: 18px; }
.btn-spot.upgrade { background: linear-gradient(135deg, #17a34a, #3ccf72); }

/* Collections */
.coll-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.coll {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.coll.unlocked { background: var(--gold-bg); border-color: var(--gold-border); }
.coll-emoji { flex: none; font-size: 24px; width: 32px; text-align: center; }
.coll:not(.unlocked) .coll-emoji { filter: grayscale(.8); opacity: .7; }
.coll-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.coll-name { font-weight: 700; }
.coll-bar { display: block; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.coll-bar span { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.coll-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.coll-progress { font-weight: 800; }
.coll.unlocked .coll-progress { color: var(--success); }
.coll-bonus { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ───────────── History ───────────── */
.topbar-simple { padding-bottom: 10px; }
.section-title {
  margin: 26px 4px 10px;
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted);
}
.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel p { margin: 0 0 12px; }

.current-summary { display: flex; align-items: center; gap: 14px; }
.cs-label { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.cs-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-body { flex: 1; min-width: 0; }
.cs-score { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.cs-main { display: block; font-size: 22px; font-weight: 800; }
.cs-sub { display: block; font-size: 13px; color: var(--muted); }

.trip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.trip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.trip.best { border-color: var(--gold-border); }
.trip-head {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border: 0; background: none;
  text-align: left;
}
.trip.best .trip-head { background: var(--gold-bg); }
.trip-info { flex: 1; min-width: 0; }
.trip-title, .trip-date, .trip-meta, .trip-best, .ts-main, .ts-sub { display: block; }
.trip-title { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-date, .trip-meta { font-size: 14px; color: var(--muted); }
.trip-best { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.trip-stats { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.trip-stats .ts-main { font-size: 22px; font-weight: 800; }
.trip-stats .ts-sub { font-size: 13px; color: var(--muted); }
.trophy { font-size: 24px; flex: none; }
.chev { flex: none; color: var(--muted); transition: transform .2s ease; font-size: 18px; }
.trip.open .chev { transform: rotate(90deg); }

.trip-detail { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.spotted { list-style: none; margin: 0 0 12px; padding: 0; }
.spotted li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.spotted li:last-child { border-bottom: 0; }
.spotted .swatch { width: 24px; height: 24px; border-radius: 7px; font-size: 13px; }
.spotted .sp-time { flex: none; width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.spotted .sp-name { flex: 1; min-width: 0; }
.spotted .sp-pts { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }
.trip-colls h4 { margin: 4px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.trip-colls ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.trip-colls li { padding: 4px 10px; border-radius: 999px; background: var(--gold-bg); border: 1px solid var(--gold-border); font-size: 14px; font-weight: 600; }
.history-empty { padding: 4px 4px 0; }

.garage-code-line { margin-bottom: 14px; }
.garage-code {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 19px; font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  word-break: break-all;
}
.garage-code.none { font-family: var(--font); color: var(--muted); font-weight: 600; font-size: 17px; }

.big-code {
  margin: 0 0 18px;
  padding: 16px 10px;
  border-radius: 14px;
  background: var(--surface-2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 24px; font-weight: 800; letter-spacing: .02em;
  word-break: break-all;
  user-select: all; -webkit-user-select: all;
}
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin: 10px 0 14px; font-weight: 600; font-size: 15px; }
.field input {
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.error { color: var(--danger); font-weight: 600; text-align: left; margin: -6px 0 14px !important; }

/* ───────────── Toast ───────────── */
.toast {
  position: fixed; left: 50%; z-index: 50;
  bottom: calc(22px + var(--safe-bottom));
  max-width: calc(100vw - 32px);
  padding: 14px 20px;
  border-radius: 14px;
  background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 16px; text-align: center;
  box-shadow: 0 10px 30px rgb(0 0 0 / 30%);
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.2), opacity .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.big { font-size: 19px; padding: 18px 24px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.toast.gold { font-size: 18px; background: linear-gradient(135deg, #e0a800, #f7cf3b); color: #2a2000; }

/* ───────────── Confetti ───────────── */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span {
  position: absolute; top: -20px;
  width: 9px; height: 14px;
  border-radius: 2px;
  opacity: .95;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 540deg)); } }

/* ───────────── Splash ───────────── */
.splash { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .5rem; transition: opacity .25s ease;
  background: var(--bg); color: var(--text);
  /* Backstop: hide even if no JS runs (ui/splash.js caps it at 5 s). Delay-only, so reduced motion keeps it. */
  animation: splash-backstop 0s 5.5s forwards; }
.splash-hide { opacity: 0; pointer-events: none; }
@keyframes splash-backstop { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.splash-icon { width: 96px; height: 96px; animation: splash-bob 1.2s ease-in-out infinite; }
.splash-title { margin: .5rem 0 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.splash-status { margin: 0; color: var(--muted); font-size: 15px; }
.splash-version { position: absolute; bottom: calc(1rem + env(safe-area-inset-bottom)); margin: 0; font-size: .75rem; opacity: .6; }
@keyframes splash-bob { 50% { transform: translateY(-6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .splash { transition: none; }
  .splash-icon { animation: none; }
}

@media (max-width: 380px) {
  .score-points { font-size: 38px; }
  .score-side { gap: 10px; }
  .stat-value { font-size: 15px; }
}
@media (min-width: 640px) {
  .score-points { font-size: 52px; }
  .sheet-dialog { margin: auto; border-radius: 22px; }
}
