/* ═══════════════════════════════════════════════════════════════════════
   Capital Race — obsidian & gold
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #07080b;
  --bg-2:        #0b0d12;
  --panel:       rgba(255, 255, 255, 0.035);
  --panel-2:     rgba(255, 255, 255, 0.055);
  --line:        rgba(232, 181, 71, 0.14);
  --line-soft:   rgba(255, 255, 255, 0.07);

  --gold:        #e8b547;
  --gold-bright: #ffd479;
  --gold-deep:   #a87c1f;
  --jade:        #3fd8b0;
  --jade-bright: #7bf0d2;
  --jade-deep:   #1c8f74;

  --up:          #35d07f;
  --down:        #ff6b6b;

  --ink:         #f2ede3;
  --ink-2:       rgba(242, 237, 227, 0.68);
  --ink-3:       rgba(242, 237, 227, 0.42);
  --ink-4:       rgba(242, 237, 227, 0.24);

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "PingFang SC",
          "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: "SF Pro Display", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                "Songti SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must beat any display rule below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

/* Ambient light ------------------------------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 62% at 50% -14%, rgba(232, 181, 71, 0.16) 0%, transparent 62%),
    radial-gradient(80% 45% at 92% 8%,  rgba(63, 216, 176, 0.08) 0%, transparent 60%),
    radial-gradient(90% 50% at 6% 96%,  rgba(232, 181, 71, 0.06) 0%, transparent 65%),
    linear-gradient(180deg, #0a0c11 0%, var(--bg) 42%, #05060a 100%);
}
.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* ── Touch behaviour ─────────────────────────────────────────────────────
   Dragging the crosshair must not start a text selection or raise iOS's
   long-press callout. Selection stays available where it is actually useful:
   the written report, the numbers, and the history. */

.topbar,
.scoreboard,
.chart-card,
.legend,
.tooltip,
.push,
.toast,
.card-head,
.btn,
.chip,
.range-switch,
.hist-del,
.foot {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#chart,
#chart * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.verdict,
.notes,
.stat,
.history,
input {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

button, .chip, .range-btn, .hist-del, .time-toggle, .live {
  -webkit-tap-highlight-color: transparent;
}

/* ── Login ───────────────────────────────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.login-card {
  position: relative;
  width: min(380px, 100%);
  padding: 40px 26px 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(232, 181, 71, 0.07), rgba(255, 255, 255, 0.02) 40%, rgba(255,255,255,0.02)),
    rgba(10, 12, 17, 0.86);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.login-mark, .brand-mark {
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  color: #1a1206;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 8px 28px rgba(232, 181, 71, 0.32), inset 0 1px 1px rgba(255, 255, 255, 0.5);
}
.login-mark {
  width: 58px; height: 58px;
  margin: 0 auto 18px;
  border-radius: 17px;
  font-size: 30px;
  font-weight: 600;
}

.login-title {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  background: linear-gradient(180deg, #fff8e8, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-sub {
  margin: 8px 0 26px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}
.field > span {
  display: block;
  margin-bottom: 7px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}
.field input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field input:focus {
  outline: none;
  border-color: rgba(232, 181, 71, 0.5);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(232, 181, 71, 0.11);
}

.login-error, .form-error {
  min-height: 17px;
  margin: 2px 0 10px;
  font-size: 12.5px;
  color: var(--down);
}
.login-foot {
  margin: 16px 0 0;
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.btn-gold {
  color: #1c1305;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold) 50%, #c8952c);
  box-shadow: 0 10px 28px rgba(232, 181, 71, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-gold:active { transform: translateY(1px) scale(0.995); }
.btn:disabled { opacity: 0.55; cursor: default; }

.chip {
  padding: 8px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
.chip:active { border-color: var(--line); color: var(--ink); }
.chip-quiet { font-size: 11.5px; color: var(--ink-3); }

/* ── App shell ───────────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 6px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 600;
  flex: none;
}
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ink);
}
.brand-text p {
  margin: 3px 0 0;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  position: relative;
  padding: 18px 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.045);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(232, 181, 71, 0.42), transparent);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--ink);
}
.card-sub {
  margin: 5px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* ── Scoreboard ──────────────────────────────────────────────────────── */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score {
  position: relative;
  padding: 16px 14px 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(165deg, var(--panel-2), rgba(255, 255, 255, 0.015));
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
}
.score::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.9;
}
.score.is-leader {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.34),
              0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
              inset 0 0 34px color-mix(in srgb, var(--accent) 9%, transparent);
}

.score-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}
.score-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex: none;
}
.score-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.score-crown {
  margin-left: auto;
  font-size: 12px;
  filter: drop-shadow(0 0 6px rgba(232, 181, 71, 0.5));
}

.score-ratio {
  font-family: var(--font-serif);
  font-size: clamp(30px, 10.5vw, 40px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 32%, transparent);
}
.score-ratio small {
  font-family: var(--font);
  font-size: 0.4em;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-right: 3px;
  text-shadow: none;
  vertical-align: 0.35em;
}

.score-cap {
  margin-top: 9px;
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.score-delta {
  margin-top: 5px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.up   { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-3); }

/* ── Chart ───────────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  touch-action: pan-y;
}
#chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.range-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  flex: none;
}
.range-btn {
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.range-btn.is-active {
  background: linear-gradient(145deg, rgba(232, 181, 71, 0.2), rgba(232, 181, 71, 0.09));
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px rgba(232, 181, 71, 0.26);
}

.tooltip {
  position: absolute;
  z-index: 5;
  min-width: 200px;
  max-width: min(280px, 92vw);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(8, 10, 15, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translate(-50%, -100%);
  transition: opacity 0.12s;
}
.tt-time {
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.tt-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tt-row i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex: none;
}
.tt-name { color: var(--ink-2); white-space: nowrap; }
.tt-val  { margin-left: auto; font-weight: 600; color: var(--ink); font-family: var(--font-num); }
.tt-ratio { color: var(--accent); font-weight: 600; min-width: 46px; text-align: right; }
.tt-gap {
  white-space: nowrap;
  margin-top: 9px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
}
.legend-line {
  width: 18px; height: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.legend-item b {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}

/* ── Report ──────────────────────────────────────────────────────────── */
.verdict {
  margin: 0 0 15px;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.verdict em {
  font-style: normal;
  font-weight: 600;
  color: var(--gold-bright);
}
.verdict .jade { color: var(--jade-bright); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}
.stat {
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.22);
}
.stat-k {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.stat-v {
  margin-top: 6px;
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.notes li {
  position: relative;
  padding-left: 16px;
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink-2);
}
.notes li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold-deep));
  box-shadow: 0 0 8px rgba(232, 181, 71, 0.55);
}
.notes b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Entry form ──────────────────────────────────────────────────────── */
.amount-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.amount-row:focus-within {
  border-color: rgba(232, 181, 71, 0.5);
  box-shadow: 0 0 0 3px rgba(232, 181, 71, 0.11);
}
.currency {
  font-family: var(--font-serif);
  font-size: 21px;
  color: var(--gold);
  line-height: 1;
}
#amount {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-num);
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
#amount:focus { outline: none; }
#amount::placeholder { color: var(--ink-4); font-weight: 500; letter-spacing: 0; }

.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 11px 0 4px;
}
.time-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
}
.time-toggle input { accent-color: var(--gold); width: 15px; height: 15px; }
#entry-time {
  flex: 1;
  min-width: 190px;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
}

/* ── History ─────────────────────────────────────────────────────────── */
.history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  font-size: 13px;
}
.hist-row:last-child { border-bottom: 0; }
.hist-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex: none;
}
.hist-time {
  font-size: 11.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hist-cap {
  margin-left: auto;
  font-family: var(--font-num);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}
.hist-ratio {
  min-width: 52px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}
.hist-del {
  padding: 3px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-4);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.hist-del:active { color: var(--down); }
.hist-spacer { width: 27px; flex: none; }

/* ── Live indicator ──────────────────────────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color 0.3s, border-color 0.3s;
}
.live i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
  flex: none;
  transition: background 0.3s, box-shadow 0.3s;
}
.live.is-on {
  color: rgba(53, 208, 127, 0.9);
  border-color: rgba(53, 208, 127, 0.26);
}
.live.is-on i {
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
  animation: pulse 2.4s ease-in-out infinite;
}
.live.is-off i { background: var(--down); box-shadow: 0 0 8px rgba(255, 107, 107, 0.5); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ── Push banner ─────────────────────────────────────────────────────── */
.push {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 60;
  width: min(430px, calc(100vw - 24px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: var(--r-md);
  background: rgba(10, 12, 17, 0.95);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.66),
              inset 0 0 26px color-mix(in srgb, var(--accent) 8%, transparent);
  cursor: pointer;
  animation: push-in 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.push.is-leaving { animation: push-out 0.3s ease-in forwards; }

.push-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex: none;
}
.push-body { flex: 1; min-width: 0; }
.push-title {
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.push-title b { color: var(--accent); font-weight: 600; }
.push-detail {
  margin-top: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}
.push-detail b { color: var(--ink-2); font-weight: 600; }

@keyframes push-in {
  from { opacity: 0; transform: translate(-50%, -18px) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes push-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -14px); }
}

/* A card briefly lights up when its owner's number moves */
.score.is-fresh {
  animation: score-flash 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes score-flash {
  0%   { box-shadow: 0 14px 36px rgba(0,0,0,0.3), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  35%  { box-shadow: 0 14px 36px rgba(0,0,0,0.3), 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { box-shadow: 0 14px 36px rgba(0,0,0,0.3), 0 0 0 0 transparent; }
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%);
  padding: 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 12, 17, 0.95);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  color: var(--ink);
  animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  max-width: calc(100vw - 40px);
  text-align: center;
}

.foot {
  margin-top: 6px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}

/* ── Motion ──────────────────────────────────────────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Narrow phones ───────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px 13px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .range-btn { padding: 6px 8px; font-size: 10.5px; }
  .score { padding: 14px 11px 13px; }
}

/* ── Wide screens ────────────────────────────────────────────────────── */
@media (min-width: 720px) {
  .app { padding-top: 28px; gap: 16px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 22px 20px; }
}
