/* ==========================================================================
   CHALLENGE SPINE - onboarding, home, challenge card, result, leaderboard, settings.
   Owned by src/ui-challenges.js.

   Everything structural (.screen, .card, .btn, .btn-flat, .dot, .flag-img) comes from
   styles.css and styles-tour.css; only layout that is genuinely new lives here. The palette,
   the radius scale and the tier colours are all variables declared in styles.css, so nothing
   below hard-codes a colour that could drift.
   ========================================================================== */

.ch-root { position: absolute; inset: 0; pointer-events: none; }
.ch-root .screen.is-open { pointer-events: auto; }

/* Every challenge screen is a full-height card: the content scrolls, the frame does not. */
.screen-ch { align-items: stretch; justify-content: center; }
.ch-card {
  width: min(440px, 100%);
  margin: auto;
  max-height: 100%;
  align-items: stretch;
  text-align: left;
  gap: clamp(9px, 1.9vmin, 14px);
}

/* ---- shared card header: back chevron, cap, title ---- */

.ch-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ch-titles { flex: 1; min-width: 0; }
.ch-cap {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}
.ch-title {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(19px, 5.2vmin, 26px);
  line-height: 1.02;
  letter-spacing: 0.012em;
  color: var(--white);
  overflow-wrap: anywhere;
}
/* Kept in the layout so the title never jumps when the back arrow comes and goes. */
.ch-head .btn-sheet-back.is-hidden { visibility: hidden; pointer-events: none; }

/* ==========================================================================
   1. ONBOARDING
   ========================================================================== */

.ob-card { min-height: min(560px, 100%); }

.ob-rail { display: flex; gap: 6px; }
.ob-pip {
  flex: 1;
  height: 4px;
  border-radius: var(--r-pill);
  background: rgba(196, 224, 255, .18);
  transition: background .22s ease;
}
.ob-pip.is-done { background: rgba(184, 255, 42, .5); }
.ob-pip.is-on { background: var(--lime); box-shadow: 0 0 10px rgba(184, 255, 42, .5); }

/* Each step centres in the space the tallest one needs, so the card keeps one height and
   nothing jumps between NEXT taps. */
.ob-step { display: flex; flex-direction: column; justify-content: center; gap: 10px; flex: 1 1 auto; min-height: 0; }

/* ---- step 1: name ---- */

.ob-field { display: flex; flex-direction: column; gap: 7px; }
.ob-label {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--dim);
}
.ob-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px 12px;
  border-radius: var(--r-l);
  border: 1.5px solid var(--line);
  background: rgba(5, 10, 36, .55);
  color: var(--white);
  font-family: var(--display);
  font-size: clamp(21px, 6vmin, 30px);
  line-height: 1.1;
  letter-spacing: 0.014em;
  text-transform: uppercase;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .4);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.ob-input::placeholder { color: rgba(226, 240, 255, .26); }
.ob-input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .4), 0 0 0 3px rgba(41, 224, 255, .22);
}
.ob-note {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim-2);
  min-height: 12px;
}
.ob-note.is-ok { color: var(--lime); }
.ob-note.is-bad { color: var(--yellow); }

/* ---- step 2: the flag grid ---- */

.ob-flags {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px;
  padding: 2px;
  align-content: start;
}
.ob-flag {
  -webkit-appearance: none;
  appearance: none;
  min-height: 76px;
  padding: 8px 5px 7px;
  border-radius: var(--r-m);
  border: 1.5px solid var(--line-soft);
  background: rgba(9, 18, 56, .72);
  color: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, border-color .16s ease, background .16s ease;
}
.ob-flag:active { transform: scale(.96); }
.ob-flag.is-on {
  border-color: var(--lime);
  background: rgba(184, 255, 42, .12);
  box-shadow: 0 0 0 1px rgba(184, 255, 42, .35);
}
.ob-flag-name {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* ---- step 3: the jersey back, drawn in CSS ---- */

.ob-number { align-items: center; }
.jersey {
  --jersey-shape: polygon(
    33% 0%, 41% 7%, 59% 7%, 67% 0%,
    100% 15%, 93% 44%, 80% 37%,
    83% 100%, 17% 100%, 20% 37%,
    7% 44%, 0% 15%);
  /* One length drives the whole garment, so the name and the number scale with the shirt
     rather than with the root font size. */
  --jw: min(196px, 52vw);
  width: var(--jw);
  aspect-ratio: 1 / 0.99;
  margin: 2px auto 0;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .55));
}
.jersey-trim {
  width: 100%;
  height: 100%;
  clip-path: var(--jersey-shape);
  background: linear-gradient(170deg, #ffffff, #c9d8ee);
  position: relative;
}
.jersey-body {
  position: absolute;
  inset: 3px;
  clip-path: var(--jersey-shape);
  background:
    repeating-linear-gradient(100deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 15px),
    linear-gradient(168deg, #1b2f7a 0%, var(--navy) 58%, #0a1540 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.jersey-name {
  margin-top: 15.5%;
  max-width: 76%;
  /* Short names get the cap size; a fourteen-letter one shrinks to fit the shoulder band. */
  font-size: min(calc(var(--jw) * 0.128), calc(var(--jw) * 0.80 / var(--len, 6)));
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1;
  color: var(--white);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
}
.jersey-num {
  margin-top: 3%;
  font-family: var(--display);
  font-size: calc(var(--jw) * 0.42);
  line-height: 1;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 2.5px #0a1030;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(5, 8, 30, .55);
}
.jersey-flag {
  position: absolute;
  left: 50%;
  bottom: 11%;
  transform: translateX(-50%);
  width: calc(var(--jw) * 0.19);
  height: calc(var(--jw) * 0.127);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
}
.jersey-flag:empty { display: none; }
.jersey-flag img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ob-numrow { display: flex; align-items: center; justify-content: center; gap: 10px; }
.numstep {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: var(--r-m);
  border: 1.5px solid var(--line);
  background: rgba(9, 18, 56, .82);
  color: var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, background .12s ease;
}
/* Drawn rather than typed: a hyphen and a plus never optically match at this size. */
.numstep svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.numstep:active { transform: scale(.92); background: rgba(41, 224, 255, .2); }
.ob-numinput {
  -webkit-appearance: none;
  appearance: none;
  width: 104px;
  height: 56px;
  text-align: center;
  border-radius: var(--r-l);
  border: 1.5px solid var(--line);
  background: rgba(5, 10, 36, .55);
  color: var(--white);
  font-family: var(--display);
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .4);
}
.ob-numinput:focus { outline: none; border-color: var(--cyan); }
.ob-numinput::-webkit-outer-spin-button,
.ob-numinput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ob-numinput { -moz-appearance: textfield; }

.ob-go { width: 100%; margin-top: auto; }
/* Not-yet, rather than broken: the button drops back to the quiet panel treatment instead of
   sitting there as a dimmed lime slab. */
.ob-go.is-off {
  pointer-events: none;
  background: rgba(20, 34, 95, .8);
  border-color: var(--line-soft);
  color: var(--dim-2);
  box-shadow: 0 4px 0 rgba(5, 8, 30, .5);
}

/* ==========================================================================
   2. HOME - the player's scorecard is the start screen
   ========================================================================== */

.home-card { gap: clamp(10px, 2vmin, 15px); }

.home-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.home-flag {
  width: 40px;
  height: 27px;
  flex: 0 0 auto;
  border-radius: var(--r-s);
  overflow: hidden;
  background: var(--navy-3);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
.home-flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home-name {
  font-family: var(--display);
  font-size: clamp(18px, 4.9vmin, 24px);
  line-height: 1;
  letter-spacing: 0.014em;
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-nation {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--cyan);
}
.home-nation:empty { display: none; }
.home-num {
  flex: 0 0 auto;
  padding: 4px 10px 5px;
  border-radius: var(--r-m);
  border: 1.5px solid rgba(184, 255, 42, .5);
  background: rgba(184, 255, 42, .1);
  color: var(--lime);
  font-family: var(--display);
  font-size: 17px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 10px 13px;
  border-radius: var(--r-l);
  border: 1.5px solid var(--line-soft);
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(41, 224, 255, .14), transparent 62%),
    rgba(5, 10, 36, .45);
}
.home-hero-cap {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.13em;
  color: var(--cyan);
}
.home-runs {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(46px, 13vmin, 70px);
  line-height: .96;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 5px 0 rgba(5, 8, 30, .5), 0 0 30px rgba(41, 224, 255, .3);
}
.home-hero-sub {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.062em;
  color: var(--dim);
  font-style: normal;
}
.home-hero-sub em { font-style: normal; font-variant-numeric: tabular-nums; }
.home-hero-sub i { width: 3px; height: 3px; border-radius: 50%; background: var(--dim-2); }

.home-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.home-stat {
  min-width: 0;
  padding: 6px 3px 7px;
  border-radius: var(--r-m);
  border: 1.2px solid var(--line-soft);
  background: rgba(9, 18, 56, .6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
}
.hs-cap {
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.052em;
  color: var(--dim-2);
  line-height: 1.1;
}
.hs-val {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.hs-star { display: block; width: 11px; height: 11px; color: var(--yellow); }
.hs-star svg { width: 100%; height: 100%; fill: currentColor; display: block; }

/* One tidy line that scrolls, rather than a ragged second row with a single chip on it. */
.home-badges {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-bottom: 1px;
  /* The cut edge fades, so a clipped chip reads as "scroll me" and not as a rendering bug. */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
}
.home-badges::-webkit-scrollbar { display: none; }
.home-badge { flex: 0 0 auto; }
.home-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 5px;
  border-radius: var(--r-pill);
  border: 1.2px solid var(--line-soft);
  background: rgba(5, 10, 36, .4);
  color: var(--dim-2);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.052em;
}
.home-badge em { font-style: normal; }
.home-badge svg { width: 10px; height: 10px; fill: currentColor; display: block; }
.home-badge.is-on {
  border-color: rgba(184, 255, 42, .55);
  background: rgba(184, 255, 42, .12);
  color: var(--lime);
}

.home-acts { display: flex; flex-direction: column; gap: 7px; margin-top: auto; }
.home-next { width: 100%; min-height: 60px; }
.home-daily { width: 100%; min-height: 50px; }
.home-daily .btn-main { font-size: clamp(11.5px, 2.8vmin, 14px); }
.home-daily .btn-sub { color: rgba(255, 255, 255, .82); }
.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.home-links .btn-flat { border-color: transparent; background: none; box-shadow: none; }
.home-links .btn-flat:active { transform: scale(.96); box-shadow: none; }

/* ==========================================================================
   3. CHALLENGE CARD
   ========================================================================== */

.cc-card { text-align: left; }

.cc-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r-l);
  border: 1.5px solid var(--line-soft);
  background:
    radial-gradient(110% 140% at 0% 0%, rgba(255, 47, 179, .2), transparent 60%),
    rgba(5, 10, 36, .45);
}
.cc-flag {
  width: 62px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: var(--r-s);
  overflow: hidden;
  background: var(--navy-3);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
.cc-flag img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-bowler { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cc-name {
  font-family: var(--display);
  font-size: clamp(19px, 5vmin, 25px);
  line-height: 1.02;
  letter-spacing: 0.012em;
  color: var(--white);
}
.cc-nation { font-size: 8.5px; font-weight: 800; letter-spacing: 0.096em; color: var(--cyan); }
.cc-pace { font-size: 9px; font-weight: 800; letter-spacing: 0.062em; color: var(--dim); }

.cc-sig {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px 6px;
  border-radius: var(--r-pill);
  background: var(--magenta);
  color: var(--white);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  transform: skewX(var(--skew));
  box-shadow: 0 4px 14px rgba(255, 47, 179, .38);
}
.cc-sig em, .cc-sig svg { transform: skewX(calc(-1 * var(--skew))); }
.cc-sig em { font-style: normal; }
.cc-sig svg { width: 11px; height: 11px; fill: currentColor; display: block; }

.cc-rule {
  margin: 0;
  padding: 10px 13px 11px;
  border-left: 3px solid var(--lime);
  border-radius: 0 var(--r-m) var(--r-m) 0;
  background: rgba(184, 255, 42, .08);
  font-size: clamp(12.5px, 3.2vmin, 15px);
  font-weight: 700;
  line-height: 1.34;
  color: var(--white);
}

.cc-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.cc-tier {
  padding: 8px 4px 9px;
  border-radius: var(--r-m);
  border: 1.5px solid var(--tier, var(--line-soft));
  background: rgba(5, 10, 36, .45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cc-tier.t-bronze { --tier: var(--bronze); }
.cc-tier.t-silver { --tier: var(--silver); }
.cc-tier.t-gold { --tier: var(--gold); }
.cc-tier-cap {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.096em;
  color: var(--tier);
}
.cc-tier-val {
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.cc-go { width: 100%; min-height: 60px; margin-top: 2px; }

/* ==========================================================================
   4. RESULT
   ========================================================================== */

.res-card { align-items: center; text-align: center; gap: clamp(8px, 1.7vmin, 12px); }

/* The outlined pop slab, same construction as the level-end headline. */
.res-tier {
  position: relative;
  align-self: center;
  max-width: 100%;
  padding: 4px 26px 5px;
  border-radius: var(--r-pill);
  background: var(--tier, var(--magenta));
  color: var(--white);
  font-size: clamp(20px, 5.6vmin, 29px);
  font-weight: 800;
  letter-spacing: 0.028em;
  text-transform: uppercase;
  transform: skewX(var(--skew));
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  --otl-w: 5px;
  --otl-c: #0a1030;
}
.res-tier::before {
  content: attr(data-t);
  position: absolute;
  left: 26px;
  top: 4px;
  z-index: -1;
  color: var(--otl-c);
  -webkit-text-stroke: var(--otl-w) var(--otl-c);
}
.screen-result.is-bronze { --tier: var(--bronze); }
.screen-result.is-silver { --tier: var(--silver); }
.screen-result.is-gold { --tier: var(--gold); }
.screen-result.is-missed { --tier: var(--magenta); }
.screen-result.is-silver .res-tier,
.screen-result.is-gold .res-tier { color: #1b1400; }
.screen-result.is-gold .res-card { border-color: rgba(255, 210, 63, .55); }
.screen-result.is-silver .res-card { border-color: rgba(201, 216, 238, .5); }
.screen-result.is-bronze .res-card { border-color: rgba(226, 133, 58, .5); }
.screen-result.is-missed .res-card { border-color: rgba(255, 47, 179, .45); }

.res-line { display: flex; align-items: baseline; justify-content: center; gap: 9px; }
.res-value {
  font-family: var(--display);
  font-size: clamp(48px, 13.5vmin, 72px);
  line-height: .9;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 5px 0 rgba(5, 8, 30, .5);
}
.res-metric {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--cyan);
}

.res-added { display: flex; align-items: baseline; justify-content: center; gap: 7px; flex-wrap: wrap; }
.res-added b {
  font-family: var(--display);
  font-size: 21px;
  line-height: 1;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
}
.res-added em, .res-added i {
  font-style: normal;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--dim);
}
.res-added i { color: var(--dim-2); }
.res-added u {
  flex-basis: 100%;
  text-decoration: none;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--gold, #ffcf3d);
  margin-top: -2px;
}

.res-out {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.062em;
  color: var(--magenta);
}

.res-balls { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; }
.res-balls .dot { width: 30px; height: 30px; border-radius: var(--r-m); }
.res-balls .dot > b { font-size: 14px; }
.res-balls .dot.kwd > b { font-size: 10px; }

.res-block {
  width: 100%;
  padding: 9px 11px 10px;
  border-radius: var(--r-m);
  border: 1.2px solid var(--line-soft);
  background: rgba(5, 10, 36, .42);
  text-align: left;
}
.res-cap {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-bottom: 6px;
}
.res-bestlist { display: flex; flex-direction: column; gap: 5px; }
.res-best { display: flex; align-items: baseline; gap: 7px; }
.rb-cap {
  flex: 1;
  min-width: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.052em;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rb-before {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: var(--dim-2);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}
.rb-after {
  font-family: var(--display);
  font-size: 15.5px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.rb-after.is-up { color: var(--lime); }
.rb-up { display: block; width: 11px; height: 11px; color: var(--lime); }
.rb-up svg { width: 100%; height: 100%; fill: currentColor; display: block; }

.res-rankline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rr-before {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  color: var(--dim-2);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}
.rr-after {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.rr-move {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding: 3px 8px 4px;
  border-radius: var(--r-pill);
  background: rgba(196, 224, 255, .12);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.052em;
  color: var(--dim);
}
.rr-move svg { width: 10px; height: 10px; fill: currentColor; display: block; }
.rr-move.is-up { background: rgba(184, 255, 42, .16); color: var(--lime); }
.rr-move.is-down { background: rgba(255, 47, 179, .16); color: var(--pink); }

.res-miles { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.res-mile {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px 5px;
  border-radius: var(--r-pill);
  border: 1.2px solid rgba(255, 210, 63, .5);
  background: rgba(255, 210, 63, .14);
  color: var(--yellow);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.052em;
}
.res-mile em { font-style: normal; }
.res-mile svg { width: 10px; height: 10px; fill: currentColor; display: block; }

.res-streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--dim);
}
.res-streak b { font-family: var(--display); font-size: 15px; color: var(--lime); }
.res-streak em { font-style: normal; }
.res-streak svg { width: 12px; height: 12px; fill: var(--yellow); display: block; }

/* Quiet, above the two decisions: sharing is never the thing to do next. */
.res-share { width: 100%; min-height: 44px; flex-direction: row; gap: 8px; }
.res-share svg { width: 14px; height: 14px; fill: var(--cyan); display: block; }
.res-share .btn-main { font-size: clamp(9.5px, 2.4vmin, 11px); letter-spacing: 0.054em; }
.res-share.is-busy { opacity: .55; pointer-events: none; }

.res-acts { width: 100%; display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 2px; }
.res-acts .btn { height: 100%; min-height: 54px; }
.res-home { width: 100%; border-color: transparent; background: none; box-shadow: none; }
.res-home:active { transform: scale(.97); box-shadow: none; }

/* ==========================================================================
   5. LEADERBOARD
   ========================================================================== */

.lb-card { height: 100%; }
.lb-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lb-tab { min-height: 44px; padding: 6px 4px; }
.lb-tab .btn-main { font-size: clamp(8.5px, 2.2vmin, 10px); letter-spacing: 0.048em; }
.lb-tab.is-on { border-color: var(--lime); background: rgba(184, 255, 42, .14); }
.lb-tab.is-on .btn-main { color: var(--lime); }
.lb-tab.is-off { opacity: .45; }

.lb-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 2px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 11px;
  border-radius: var(--r-m);
  border: 1.2px solid var(--line-soft);
  background: rgba(9, 18, 56, .62);
}
.lb-row.is-me { border-color: var(--lime); background: rgba(184, 255, 42, .1); }
.lb-rank {
  flex: 0 0 22px;
  font-family: var(--display);
  font-size: 14px;
  line-height: 1;
  color: var(--dim-2);
  font-variant-numeric: tabular-nums;
}
.lb-row.is-me .lb-rank { color: var(--lime); }
.lb-row .flag-img.sm { flex: 0 0 auto; }
.lb-row .flag-img.is-blank { background: rgba(5, 10, 36, .6); }
.lb-who {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  /* Names are stored as typed and shown in the house style, here as everywhere else. */
  text-transform: uppercase;
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-num { font-style: normal; font-size: 9px; font-weight: 800; color: var(--dim-2); }
.lb-val {
  font-family: var(--display);
  font-size: 17px;
  line-height: 1;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.lb-empty {
  margin: auto;
  padding: 26px 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--dim-2);
}
.lb-note {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.052em;
  text-transform: uppercase;
  color: var(--dim-2);
}

/* ==========================================================================
   6. SETTINGS
   ========================================================================== */

.set-list, .set-player { display: flex; flex-direction: column; gap: 6px; }
.set-cap {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cyan);
  margin-top: 4px;
}
.set-row {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 13px;
  border-radius: var(--r-m);
  border: 1.5px solid var(--line-soft);
  background: rgba(9, 18, 56, .62);
  color: var(--white);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, border-color .16s ease;
}
.set-row:active { transform: scale(.985); }
.sr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sr-cap { font-size: 11.5px; font-weight: 800; letter-spacing: 0.052em; }
.sr-sub {
  font-style: normal;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--dim);
}
.sr-switch {
  flex: 0 0 auto;
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: rgba(5, 10, 36, .8);
  box-shadow: inset 0 0 0 1.5px var(--line-soft);
  transition: background .18s ease, box-shadow .18s ease;
}
.sr-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--dim-2);
  transition: transform .18s cubic-bezier(.2, 1.4, .4, 1), background .18s ease;
}
.sr-switch.is-on { background: rgba(184, 255, 42, .22); box-shadow: inset 0 0 0 1.5px var(--lime); }
.sr-switch.is-on::after { transform: translateX(20px); background: var(--lime); }
.sr-go {
  flex: 0 0 auto;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.086em;
  color: var(--cyan);
}
.set-profile .flag-img.sm { flex: 0 0 auto; }
.set-note {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.052em;
  text-transform: uppercase;
  color: var(--dim-2);
  margin-top: auto;
}

/* ==========================================================================
   Short phones: everything above assumes 780 px of height. Below that the hero
   numbers give up size first, because the buttons cannot.
   ========================================================================== */

@media (max-height: 700px) {
  .home-runs { font-size: clamp(38px, 11vmin, 52px); }
  .res-value { font-size: clamp(40px, 11.5vmin, 56px); }
  .jersey { width: min(160px, 52%); }
  .home-next { min-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .sr-switch, .sr-switch::after, .ob-pip { transition: none; }
}
