/* ============================================================
   Archer Racing Club — player app
   Vintage oil-painting trading-card style. Mobile portrait first.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  touch-action: manipulation;          /* no double-tap zoom */
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--edge);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

img { user-select: none; -webkit-user-drag: none; }
button {
  font-family: var(--serif);
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:disabled { cursor: default; opacity: 0.55; }

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* desktop testing: present as a phone-shaped card */
@media (min-width: 700px) {
  #app {
    max-width: 430px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
    border-left: 1px solid var(--gold-2);
    border-right: 1px solid var(--gold-2);
  }
}

/* ---------- panels & horizontal navigation ---------- */

#panels {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  --depth: 0;
}

.panel {
  position: absolute;
  inset: 0;
  transform: translateX(calc((var(--i) - var(--depth)) * 100%));
  transition: transform 0.42s cubic-bezier(0.22, 0.9, 0.32, 1.12);
  will-change: transform;
}
#panel-deck    { --i: 0; }
#panel-actions { --i: 1; }
#panel-detail  { --i: 2; }
#panels.nav-dragging .panel { transition: none; }

/* ============================================================
   DECK — full-screen horse cards
   ============================================================ */

.deck-panel { touch-action: none; overflow: hidden; }

.deck-track {
  height: 100%;
  --dy: 0px;
  --idx: 0;
  transform: translateY(calc(var(--dy) + var(--idx) * -100%));
  transition: transform 0.45s cubic-bezier(0.22, 0.9, 0.3, 1.14);
  will-change: transform;
}
.deck-track.dragging { transition: none; }

.horse-card {
  height: 100%;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
}

.horse-card-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--card-radius);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 235, 170, 0.07), transparent 60%),
    linear-gradient(170deg, #4a4a31 0%, #3d3d27 55%, #34341f 100%);
}

/* painting region */
.card-art {
  flex: 1 1 60%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 8px 0;
  container-type: size;
}

/* The art box must stay EXACTLY 2:3 (the painting's ratio) or the horse —
   face first — gets cropped and the name drifts off the baked plaque.
   Size it as the largest 2:3 rect fitting the container, never crop. */
.art-wrap {
  position: relative;
  height: 100%;
  aspect-ratio: 2 / 3;
  max-width: 100%;
  container-type: inline-size;
  --plaque-fs: 22px;
}
@supports (height: 1cqh) {
  .art-wrap { height: min(100cqh, 150cqw); }
}
@supports (width: 1cqw) {
  .art-wrap { --plaque-fs: clamp(15px, 8.6cqw, 34px); }
}

.art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* only matters on browsers without cq units: bias any crop toward the
     horse's head (upper right of both paintings) */
  object-position: 58% 15%;
  border-radius: 10px;
  display: block;
}

/* name rendered into the empty plaque baked into the art */
.plaque {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 83.2%;
  height: 12%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.plaque-name {
  font-size: var(--plaque-fs);
  font-weight: 700;
  color: #3a3122;
  letter-spacing: 0.05em;
  line-height: 1.05;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 248, 220, 0.4);
}
.plaque-sub {
  font-size: calc(var(--plaque-fs) * 0.42);
  color: #6d5e41;
  font-variant: small-caps;
  letter-spacing: 0.14em;
}

/* grade medallion */
.grade-medal {
  position: absolute;
  top: 4.5%;
  right: 6%;
  width: clamp(40px, 15cqw, 56px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 35% 30%, var(--gold-3), var(--gold) 45%, var(--gold-2) 80%, #7a611f 100%);
  border: 1.5px solid #6e571c;
  box-shadow:
    inset 0 0 0 2.5px rgba(255, 244, 200, 0.45),
    inset 0 0 0 5px rgba(110, 87, 28, 0.55),
    0 3px 8px rgba(20, 16, 6, 0.5);
}
.grade-medal span {
  font-size: clamp(18px, 7cqw, 26px);
  font-weight: 700;
  color: #463813;
  text-shadow: 0 1px 0 rgba(255, 248, 215, 0.55);
}

/* saddle-cloth silk chip */
.silk-chip {
  position: absolute;
  top: 4.5%;
  left: 6%;
  min-width: clamp(30px, 11cqw, 40px);
  height: clamp(30px, 11cqw, 40px);
  padding: 0 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f6efdb;
  font-weight: 700;
  font-size: clamp(15px, 6cqw, 21px);
  border: 1.5px solid rgba(243, 234, 210, 0.75);
  box-shadow: 0 2px 6px rgba(20, 16, 6, 0.5), inset 0 0 8px rgba(0, 0, 0, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* TO POST banner */
.to-post-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%) rotate(-2deg);
  padding: 9px 18px;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #463813;
  background: linear-gradient(180deg, var(--gold-3), var(--gold) 55%, var(--gold-2));
  border: 1.5px solid #6e571c;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(20, 16, 6, 0.55), inset 0 0 0 2px rgba(255, 246, 210, 0.5);
  animation: postPulse 1.6s ease-in-out infinite;
}
@keyframes postPulse {
  0%, 100% { box-shadow: 0 4px 14px rgba(20, 16, 6, 0.55), inset 0 0 0 2px rgba(255, 246, 210, 0.5); }
  50% { box-shadow: 0 4px 22px rgba(201, 166, 72, 0.85), inset 0 0 0 2px rgba(255, 246, 210, 0.9); }
}

/* stats panel under the painting */
.card-stats {
  flex: 0 0 auto;
  padding: 10px 16px calc(10px + 2px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--paper);
  border-top: 1px solid rgba(201, 166, 72, 0.45);
  margin-top: 8px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.14), transparent 30%);
}

.stat-rows { display: flex; flex-direction: column; gap: 6px; }

.stat-row, .cond-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-label {
  flex: 0 0 96px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--gold-3);
}
.stat-val {
  flex: 0 0 28px;
  text-align: right;
  font-size: 13px;
  color: var(--paper-2);
  font-variant-numeric: tabular-nums;
}

.stat-bar, .cond-meter {
  flex: 1 1 auto;
  height: 10px;
  border-radius: 5px;
  background: rgba(15, 13, 6, 0.55);
  border: 1px solid rgba(201, 166, 72, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.stat-fill {
  position: relative;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #8a6f2f, var(--gold) 70%, var(--gold-3));
  box-shadow: 0 0 6px rgba(201, 166, 72, 0.35);
  transition: width 0.6s ease;
}
.stat-tip {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255, 246, 210, 0.85);
}

.cond-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #46622f, #6f8a3c 60%, #9aa44e);
  transition: width 0.6s ease;
}
.cond-fill.cond-mid { background: linear-gradient(90deg, #7a6428, var(--gold)); }
.cond-fill.cond-low { background: linear-gradient(90deg, #6e2d22, var(--red)); }

.record-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-top: 2px;
  border-top: 1px dashed rgba(201, 166, 72, 0.3);
  margin-top: 2px;
}
.record-caption { font-size: 11px; color: rgba(227, 200, 122, 0.75); letter-spacing: 0.12em; }
.record-figures { font-size: 15px; color: var(--paper-2); letter-spacing: 0.06em; }
.record-earn { margin-left: auto; font-size: 15px; color: var(--gold-3); }

.swipe-hint {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(233, 221, 192, 0.4);
}

/* deck position dots */
.deck-dots {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 7px;
  pointer-events: none;
}
.deck-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(201, 166, 72, 0.3);
}
.deck-dot.on { background: var(--gold); box-shadow: 0 0 5px rgba(201, 166, 72, 0.8); }

/* empty stable */
.empty-card {
  background: var(--paper);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  gap: 14px;
  color: var(--ink-2);
}
.empty-card h2 { color: var(--olive-2); letter-spacing: 0.1em; }
.empty-card p { max-width: 30ch; line-height: 1.5; }
.empty-art { font-size: 40px; color: var(--gold-2); }

/* ============================================================
   ACTION MENU — vintage mini-cards
   ============================================================ */

.actions-panel {
  display: flex;
  flex-direction: column;
  background-color: var(--paper-3);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.25), transparent 60%),
    repeating-linear-gradient(2deg, transparent 0 3px, rgba(120, 100, 60, 0.03) 3px 4px);
}

.actions-header, .detail-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid rgba(168, 134, 46, 0.5);
  background: linear-gradient(180deg, rgba(243, 234, 210, 0.6), rgba(243, 234, 210, 0));
}
.actions-title, .detail-title {
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--olive-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actions-back, .actions-fwd {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold-2);
  white-space: nowrap;
}

.actions-scroller {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.actions-scroller::-webkit-scrollbar { display: none; }
.actions-spacer { height: calc(50% - 26dvh); flex: 0 0 auto; }

.mini-card {
  position: relative;
  display: block;
  height: 52dvh;
  aspect-ratio: 2 / 3;
  max-width: 86vw;
  margin: 10px auto;
  scroll-snap-align: center;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(30, 24, 12, 0.4);
  transform: scale(0.93);
  filter: saturate(0.85) brightness(0.94);
  transition: transform 0.3s ease, filter 0.3s ease, box-shadow 0.3s ease;
}
.mini-card.selected {
  transform: scale(1);
  filter: none;
  box-shadow: 0 10px 30px rgba(30, 24, 12, 0.55), 0 0 0 2px var(--gold);
}
.mini-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* the CSS-composed Racing card (matches the painted action cards) */
.mini-race-frame {
  position: absolute;
  inset: 0;
  background: #ece4cf;
  padding: 5.5%;
  display: flex;
}
.mini-race-frame::before {
  content: '';
  position: absolute;
  inset: 4.2%;
  border-radius: 14px;
  background: linear-gradient(168deg, #73734d, #5e5e3c 70%, #55552f);
  box-shadow:
    inset 0 0 0 2px var(--gold-2),
    inset 0 0 0 3.5px rgba(255, 240, 190, 0.55),
    inset 0 0 14px rgba(20, 16, 6, 0.35);
}
.mini-race-window {
  position: absolute;
  inset: 9% 9% 26% 9%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px var(--gold-2), inset 0 0 0 3.5px rgba(255, 240, 190, 0.5);
}
.mini-race-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}
.mini-race-plaque {
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: 9.5%;
  height: 12.5%;
  border-radius: 9px;
  background: linear-gradient(180deg, #f6eed7, #e9ddc0);
  box-shadow:
    inset 0 0 0 1.5px var(--gold-2),
    inset 0 0 0 3px rgba(255, 240, 190, 0.5),
    0 1px 4px rgba(20, 16, 6, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini-race-plaque span {
  font-size: clamp(20px, 9cqw, 30px);
  font-weight: 700;
  color: #3a3122;
  letter-spacing: 0.02em;
}

/* ============================================================
   DETAIL SCREENS
   ============================================================ */

.detail-panel {
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255, 255, 255, 0.3), transparent 55%),
    repeating-linear-gradient(2deg, transparent 0 3px, rgba(120, 100, 60, 0.025) 3px 4px);
}
.detail-back {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold-2);
  padding: 6px 8px 6px 0;
  white-space: nowrap;
}
.detail-header-pad { width: 56px; }

.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: none;
}
.detail-body::-webkit-scrollbar { display: none; }

.detail-lede { font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.detail-note { font-size: 13px; line-height: 1.45; color: var(--ink-2); opacity: 0.85; }
.detail-warn { font-size: 13.5px; line-height: 1.45; color: var(--red); }
.detail-section {
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--olive-2);
  border-bottom: 1px solid rgba(168, 134, 46, 0.4);
  padding-bottom: 4px;
  margin-top: 6px;
}

.paper-inset {
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 1px solid rgba(168, 134, 46, 0.55);
  border-radius: 12px;
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 205, 0.5), 0 2px 8px rgba(60, 48, 22, 0.18);
}

.empty-note { padding: 18px 16px; text-align: center; color: var(--ink-2); line-height: 1.5; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 16px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-small { padding: 8px 14px; font-size: 14px; border-radius: 8px; }

.btn-gold {
  color: #463813;
  background: linear-gradient(180deg, var(--gold-3), var(--gold) 55%, var(--gold-2));
  border: 1.5px solid #6e571c;
  box-shadow: inset 0 0 0 2px rgba(255, 246, 210, 0.5), 0 3px 10px rgba(40, 32, 14, 0.35);
  text-shadow: 0 1px 0 rgba(255, 248, 215, 0.5);
}
.btn-ghost {
  color: var(--olive-2);
  background: rgba(243, 234, 210, 0.5);
  border: 1.5px solid var(--olive);
  box-shadow: inset 0 0 0 2px rgba(255, 244, 205, 0.4);
}
.btn-danger {
  color: var(--paper-2);
  background: linear-gradient(180deg, #a04a3a, var(--red) 60%, #6e2d22);
  border: 1.5px solid #571f15;
  box-shadow: inset 0 0 0 2px rgba(255, 230, 210, 0.25), 0 3px 10px rgba(40, 14, 8, 0.35);
}
.btn.busy { opacity: 0.6; pointer-events: none; }

.text-input, .login-input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1.5px solid var(--gold-2);
  border-radius: 10px;
  box-shadow: inset 0 2px 5px rgba(60, 48, 22, 0.18);
  outline: none;
}
.text-input:focus, .login-input:focus {
  border-color: var(--gold);
  box-shadow: inset 0 2px 5px rgba(60, 48, 22, 0.18), 0 0 0 3px rgba(201, 166, 72, 0.3);
}

/* training focus picker */
.focus-list { display: flex; flex-direction: column; gap: 10px; }
.focus-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.focus-card:active { transform: scale(0.985); }
.focus-icon {
  flex: 0 0 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--gold-2);
  border: 1.5px solid rgba(168, 134, 46, 0.6);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 244, 205, 0.9), rgba(233, 221, 192, 0.6));
}
.focus-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.focus-label { font-size: 17px; letter-spacing: 0.08em; color: var(--ink); font-weight: 700; }
.focus-desc { font-size: 12.5px; color: var(--ink-2); }
.focus-stat {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--gold-2);
  white-space: nowrap;
}

/* race list */
.race-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.race-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.race-name { font-size: 17px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }
.race-meta { font-size: 13px; color: var(--ink-2); }
.race-status { font-size: 12px; letter-spacing: 0.12em; color: var(--red); white-space: nowrap; }
.race-empty { font-size: 13px; font-style: italic; color: var(--ink-2); opacity: 0.8; }

/* ---------- race conditions: track / surface / going / weather ---------- */
.cond-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 6px;
}
.cond-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--ink-2);
  background: rgba(168, 134, 46, 0.12);
  border: 1px solid rgba(168, 134, 46, 0.4);
}
.cond-chip.cond-track {
  color: var(--olive-2);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.cond-chip.cond-weather { font-style: italic; }

/* going is the headline modifier — colour-coded by severity, slightly bolder */
.cond-chip.cond-going {
  font-variant: small-caps;
  letter-spacing: 0.09em;
  font-weight: 700;
  border-width: 1.5px;
}
.cond-going.going-firm,
.cond-going.going-good {
  color: #3f5a2c;
  background: rgba(74, 107, 58, 0.16);
  border-color: rgba(74, 107, 58, 0.55);
}
.cond-going.going-soft {
  color: #7a5a16;
  background: rgba(201, 166, 72, 0.22);
  border-color: var(--gold-2);
}
.cond-going.going-heavy {
  color: #fff2e6;
  background: linear-gradient(180deg, #7a3326, var(--red));
  border-color: #571f15;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.cond-going.going-unknown {
  color: var(--ink-2);
  background: rgba(120, 100, 60, 0.12);
  border-color: rgba(120, 100, 60, 0.4);
}

.cond-blurb {
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.4;
  color: var(--ink-2);
  opacity: 0.9;
}

.race-entries { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.race-entries li, .parade-field li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  padding: 3px 6px;
  border-radius: 6px;
}
.race-entries li.mine, .parade-field li.mine {
  background: rgba(201, 166, 72, 0.18);
  box-shadow: inset 0 0 0 1px rgba(201, 166, 72, 0.5);
}
.entry-silk {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f6efdb;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(243, 234, 210, 0.7);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}
.entry-name { font-weight: 700; color: var(--ink); }
.entry-stable { margin-left: auto; font-size: 12px; color: var(--ink-2); font-style: italic; }

.result-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; font-size: 13.5px; }
.result-name { color: var(--ink); letter-spacing: 0.06em; }
.result-winner { color: var(--ink-2); font-style: italic; text-align: right; }

/* breeding */
.breed-list { display: flex; flex-direction: column; gap: 8px; }
.breed-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  text-align: left;
  transition: box-shadow 0.15s ease, transform 0.12s ease;
}
.breed-pick:active { transform: scale(0.985); }
.breed-pick.picked {
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 4.5px rgba(255, 244, 205, 0.6), 0 2px 10px rgba(201, 166, 72, 0.35);
}
.breed-pick.ineligible { opacity: 0.55; }
.breed-pick-name { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.breed-pick-name .smallcaps { font-size: 16px; font-weight: 700; }
.breed-pick-sub { font-size: 12px; color: var(--ink-2); }
.breed-check { color: var(--gold-2); font-size: 18px; width: 20px; text-align: center; }
.breed-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.breed-btn { width: 100%; }

.foal-reveal .foal-art {
  width: 150px;
  margin: 0 auto 10px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(30, 24, 12, 0.45);
}
.foal-reveal .foal-art img { width: 100%; display: block; }
.foal-name { font-size: 21px; text-align: center; letter-spacing: 0.06em; }

/* sell / retire */
.sale-card { padding: 16px; display: flex; flex-direction: column; gap: 9px; }
.sale-name { font-size: 20px; letter-spacing: 0.07em; color: var(--ink); }
.sale-line { font-size: 14px; color: var(--ink-2); }
.sale-quote {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0 6px;
  border-top: 1px dashed rgba(168, 134, 46, 0.5);
  border-bottom: 1px dashed rgba(168, 134, 46, 0.5);
}
.sale-quote .smallcaps { font-size: 12px; letter-spacing: 0.16em; color: var(--olive-2); }
.sale-price { font-size: 26px; font-weight: 700; color: var(--gold-2); }

/* ============================================================
   FOOTER
   ============================================================ */

#footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--olive-2), #4b4b2e);
  border-top: 1.5px solid var(--gold-2);
  box-shadow: inset 0 1px 0 rgba(255, 240, 190, 0.25);
  color: var(--paper);
  z-index: 10;
}
/* the stable name is a button: tap to sign out / switch stable */
#ft-stable {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  letter-spacing: 0.1em;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#ft-stable:not(:empty)::after {
  content: ' ⎋';
  font-size: 11px;
  opacity: 0.55;
}
#ft-stable:active { opacity: 0.7; }

/* small recovery-email control — separate from the stable sign-out button */
#ft-recovery {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: var(--gold-3);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(201, 166, 72, 0.5);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 240, 190, 0.18);
  -webkit-tap-highlight-color: transparent;
}
#ft-recovery:active { opacity: 0.7; transform: translateY(1px); }

#ft-coins { font-size: 16px; color: var(--gold-3); font-variant-numeric: tabular-nums; }
#ft-coins.coin-flash { animation: coinFlash 0.9s ease; }
@keyframes coinFlash {
  0% { text-shadow: 0 0 0 transparent; transform: scale(1); }
  30% { text-shadow: 0 0 12px rgba(227, 200, 122, 1); transform: scale(1.12); }
  100% { text-shadow: 0 0 0 transparent; transform: scale(1); }
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #888;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.conn-dot.ok { background: #7da75a; box-shadow: 0 0 6px rgba(125, 167, 90, 0.9); }
.conn-dot.down { background: var(--red); animation: connPulse 1.2s ease-in-out infinite; }
@keyframes connPulse { 50% { opacity: 0.35; } }

/* ============================================================
   LOGIN
   ============================================================ */

.login-wrap {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity 0.45s ease;
}
.login-wrap.login-in { opacity: 1; }

.login-card {
  width: min(380px, 100%);
  padding: 30px 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.35), transparent 55%),
    linear-gradient(180deg, var(--paper-2), var(--paper));
}
.login-crest { color: var(--gold-2); width: 86px; }
.club-crest { width: 100%; height: auto; display: block; }
.login-title {
  font-size: 27px;
  letter-spacing: 0.1em;
  color: var(--olive-2);
  text-align: center;
  line-height: 1.15;
}
.login-flourish { color: var(--gold-2); width: 150px; }
.flourish { width: 100%; height: auto; display: block; }
.login-sub { font-size: 14px; color: var(--ink-2); font-style: italic; text-align: center; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.login-input {
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  font-variant: small-caps;
  text-transform: uppercase;
}
.login-error { font-size: 13.5px; color: var(--red); text-align: center; min-height: 1em; }
.login-btn { width: 100%; }
.login-foot { font-size: 11px; letter-spacing: 0.22em; color: rgba(74, 67, 52, 0.55); margin-top: 6px; }

/* "Forgot your code?" — quiet text link under the Enter button */
.login-forgot {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--olive-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(168, 134, 46, 0.6);
  padding: 4px 6px;
  margin-top: 2px;
  background: none;
  border: none;
}
.login-forgot:active { opacity: 0.65; }
.login-forgot:disabled { opacity: 0.4; }

/* ---------- forgot / recovery overlay forms ---------- */
.forgot-form, .recovery-form { text-align: left; gap: 12px; }
.forgot-note, .recovery-note { text-align: left; min-height: 0; }
.forgot-ok { color: var(--olive-2); font-style: italic; }
.recovery-current {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--olive-2);
}

/* ---------- reset landing (?reset=TOKEN) ---------- */
.reset-wrap .login-card { gap: 10px; }
.reset-region {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.reset-stable {
  font-size: 24px;
  letter-spacing: 0.07em;
  color: var(--olive-2);
  text-align: center;
  line-height: 1.15;
}
.reset-fine {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
  text-align: center;
  max-width: 32ch;
}
.reset-btn { width: 100%; }

/* the new code, shown big */
.reset-code-plate {
  width: 100%;
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
}
.reset-code {
  font-family: var(--serif);
  font-variant: small-caps;
  font-weight: 700;
  font-size: clamp(34px, 13vw, 48px);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--gold-2);
  text-shadow: 0 1px 0 rgba(255, 248, 215, 0.6);
}

/* ============================================================
   RACE CALL RIBBON — pinned above every screen but the race
   ============================================================ */

#race-call[hidden] { display: none; }
#race-call {
  position: fixed;
  top: calc(6px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 55; /* above live views (40), below modals (60) */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1.5px solid var(--edge);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--gold-3), var(--gold) 55%, var(--gold-2));
  color: #3a2f14;
  font-family: var(--serif);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 225, 0.8),
    0 4px 14px rgba(30, 24, 12, 0.45);
  -webkit-tap-highlight-color: transparent;
}
#race-call-text {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#race-call-time {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#race-call[data-phase='parading'] { animation: callPulse 1.6s ease-in-out infinite; }
#race-call[data-phase='running'] { animation: callPulse 0.9s ease-in-out infinite; }
@keyframes callPulse {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 250, 225, 0.8), 0 4px 14px rgba(30, 24, 12, 0.45); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 250, 225, 0.8), 0 0 18px rgba(227, 200, 122, 0.95), 0 4px 14px rgba(30, 24, 12, 0.45); }
}
#race-call:active { filter: brightness(0.94); }

/* shift content below the ribbon so nothing is covered */
body.has-racecall #panels { padding-top: calc(44px + env(safe-area-inset-top)); }
body.has-racecall .live-view { padding-top: calc(44px + env(safe-area-inset-top)); }

@media (prefers-reduced-motion: reduce) {
  #race-call[data-phase] { animation: none; }
}

/* ============================================================
   TOASTS — vintage banners
   ============================================================ */

#toasts {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(94%, 420px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 1.5px solid var(--gold-2);
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 205, 0.55), 0 6px 18px rgba(30, 24, 12, 0.4);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.35;
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast-rule { flex: 0 0 14px; height: 1.5px; background: var(--gold-2); opacity: 0.7; }
.toast-msg { flex: 1 1 auto; text-align: center; }
.toast-error { border-color: var(--red); }
.toast-error .toast-rule { background: var(--red); }
.toast-win {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 205, 0.55), 0 0 22px rgba(201, 166, 72, 0.6);
}
.toast-out { opacity: 0; transform: translateY(-12px); transition: all 0.32s ease; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   MODALS — confirm / result plaques
   ============================================================ */

.modal-wrap {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(36, 30, 16, 0.55);
  opacity: 0;
  transition: opacity 0.26s ease;
}
.modal-wrap.modal-in { opacity: 1; }
.modal-wrap.modal-out { opacity: 0; }

.modal-card {
  width: min(380px, 100%);
  max-height: 86%;
  overflow-y: auto;
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  transform: translateY(8px) scale(0.97);
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-wrap.modal-in .modal-card { transform: none; }
.modal-title {
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--olive-2);
  padding-bottom: 8px;
  border-bottom: 1.5px solid rgba(168, 134, 46, 0.5);
}
.modal-danger .modal-title { color: var(--red); border-bottom-color: rgba(140, 59, 46, 0.5); }
.modal-body { font-size: 16px; line-height: 1.5; color: var(--ink); display: flex; flex-direction: column; gap: 8px; }
.modal-fine { font-size: 13px; color: var(--ink-2); }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.modal-actions .btn { flex: 1 1 0; }

/* ============================================================
   LIVE VIEWS (shared chrome)
   ============================================================ */

.live-view {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.live-view.live-in { opacity: 1; transform: none; }
.live-view.live-out { opacity: 0; transform: translateY(12px); }

.live-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1.5px solid var(--gold-2);
  background: linear-gradient(180deg, var(--olive-2), rgba(92, 92, 58, 0.92));
  color: var(--paper);
}
.live-exit {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold-3);
  padding: 6px 8px;
  border: 1px solid rgba(201, 166, 72, 0.5);
  border-radius: 8px;
  white-space: nowrap;
}
.live-title-wrap { flex: 1 1 auto; min-width: 0; text-align: center; }
.live-title {
  font-size: 18px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-sub { font-size: 12px; color: rgba(233, 221, 192, 0.8); font-style: italic; }
.live-clock {
  font-size: 17px;
  color: var(--gold-3);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

/* ============================================================
   LIVE TRAINING — the brass gauge
   ============================================================ */

.train-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 6px;
  padding: 18px 10px;
  touch-action: none;
}

.gauge-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.gauge-brass {
  height: 100%;
  max-height: 100%;
  width: 74px;
  padding: 8px;
  border-radius: 38px;
  background:
    linear-gradient(100deg, #8a6f2f 0%, var(--gold-3) 18%, var(--gold) 40%, #8a6f2f 65%, var(--gold-2) 85%, #6e571c 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(70, 56, 19, 0.8),
    inset 0 2px 6px rgba(255, 246, 210, 0.5),
    0 8px 24px rgba(20, 16, 6, 0.5);
}

.gauge-track {
  position: relative;
  height: 100%;
  border-radius: 30px;
  background: linear-gradient(180deg, #221e12, #2e2a1a 50%, #221e12);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(201, 166, 72, 0.3);
  overflow: hidden;
}

.gauge-ticks { position: absolute; inset: 0; pointer-events: none; }
.gauge-tick {
  position: absolute;
  left: 10%;
  width: 14%;
  height: 1px;
  background: rgba(201, 166, 72, 0.35);
}
.gauge-tick.major { width: 26%; background: rgba(201, 166, 72, 0.6); }

.gauge-zone {
  position: absolute;
  left: 5%;
  right: 5%;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(227, 200, 122, 0.25), rgba(201, 166, 72, 0.45) 50%, rgba(227, 200, 122, 0.25));
  border-top: 1.5px solid rgba(227, 200, 122, 0.8);
  border-bottom: 1.5px solid rgba(227, 200, 122, 0.8);
  transition: bottom 0.2s linear, height 0.2s linear;
}
.gauge-zone.in-zone {
  background: linear-gradient(180deg, rgba(227, 200, 122, 0.4), rgba(201, 166, 72, 0.7) 50%, rgba(227, 200, 122, 0.4));
  box-shadow: 0 0 18px rgba(201, 166, 72, 0.7);
}
.gauge-zone.surge { animation: surgeFlash 0.5s ease-in-out infinite; }
@keyframes surgeFlash {
  0%, 100% { box-shadow: 0 0 14px rgba(227, 200, 122, 0.6); filter: brightness(1); }
  50% { box-shadow: 0 0 34px rgba(255, 226, 140, 1); filter: brightness(1.7); }
}

.gauge-needle {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  transition: bottom 0.18s linear;
}
.needle-arm {
  position: absolute;
  left: 8%;
  right: 8%;
  top: -1.25px;
  height: 2.5px;
  background: linear-gradient(90deg, var(--paper-2), #f8f2dd);
  box-shadow: 0 0 6px rgba(255, 248, 220, 0.8);
  border-radius: 2px;
}
.needle-tip {
  position: absolute;
  right: 2%;
  top: -5px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 9px solid var(--paper-2);
}
.gauge-needle.in-zone .needle-arm { background: var(--gold-3); box-shadow: 0 0 10px rgba(227, 200, 122, 1); }
.gauge-needle.in-zone .needle-tip { border-right-color: var(--gold-3); }

.surge-label {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #463813;
  background: linear-gradient(180deg, var(--gold-3), var(--gold));
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #6e571c;
  animation: surgeFlash 0.5s ease-in-out infinite;
}

/* thumb buttons */
.thumb-btn {
  align-self: end;
  justify-self: center;
  margin-bottom: 8dvh;
  width: clamp(84px, 24vw, 108px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  letter-spacing: 0.1em;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.thumb-btn svg { width: 38%; height: 38%; }

.drive-btn {
  color: #463813;
  background: radial-gradient(circle at 35% 28%, var(--gold-3), var(--gold) 55%, var(--gold-2) 90%);
  border: 2px solid #6e571c;
  box-shadow: inset 0 0 0 3px rgba(255, 246, 210, 0.5), 0 6px 18px rgba(40, 32, 14, 0.5);
}
.ease-btn {
  color: var(--paper-2);
  background: radial-gradient(circle at 35% 28%, var(--olive-3), var(--olive) 55%, var(--olive-2) 90%);
  border: 2px solid #3c3c24;
  box-shadow: inset 0 0 0 3px rgba(233, 221, 192, 0.3), 0 6px 18px rgba(24, 24, 12, 0.5);
}
.thumb-btn.pressed { animation: btnPress 0.25s ease; }
@keyframes btnPress {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); filter: brightness(1.25); }
  100% { transform: scale(1); }
}

.train-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 0 16px calc(14px + env(safe-area-inset-bottom));
}
.score-box {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 26px;
}
.score-box .smallcaps { font-size: 12px; letter-spacing: 0.18em; color: var(--olive-2); }
.score-num {
  font-size: 30px;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
}
.score-num.big { font-size: 44px; }

.train-result-score { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.train-result-gain { font-size: 24px; font-weight: 700; color: var(--green-ok); }
.train-result-cond { font-size: 16px; color: var(--red); }
.train-result-cond.good { color: var(--green-ok); }

/* ============================================================
   LIVE RACE
   ============================================================ */

.race-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* --- post parade --- */
.parade-card {
  margin: 8px 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.parade-head { font-size: 16px; letter-spacing: 0.2em; color: var(--olive-2); }
.parade-count {
  font-size: 46px;
  font-weight: 700;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
  min-height: 54px;
}
.parade-card .cond-line,
.results-card .cond-line { justify-content: center; }
.parade-card .cond-blurb { text-align: center; }
.parade-field { list-style: none; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.parade-gate { flex: 0 0 52px; font-size: 11px; letter-spacing: 0.1em; color: var(--ink-2); }
.parade-note { font-size: 13px; font-style: italic; color: var(--ink-2); }

/* --- running HUD --- */
.race-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 18px;
}
.race-rank { font-size: 22px; font-weight: 700; letter-spacing: 0.08em; color: var(--olive-2); }
.race-remain { font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* --- third-person race scene --- */
.race-scene {
  position: relative;
  flex: 1 1 auto;
  min-height: clamp(220px, 38dvh, 360px);
  margin: 0 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--gold-2);
  box-shadow: inset 0 0 0 2.5px rgba(255, 244, 205, 0.35), inset 0 4px 18px rgba(30, 24, 12, 0.35), 0 4px 14px rgba(30, 24, 12, 0.3);
  background: #b08c58;
  touch-action: none;
}
.race-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- rear radar: the field behind you --- */
.rear-radar {
  position: relative;
  height: clamp(66px, 11dvh, 92px);
  margin: 0 10px;
  border-radius: 0 0 16px 16px / 0 0 22px 22px;
  overflow: hidden;
  border: 1.5px solid var(--gold-2);
  border-top-width: 1px;
  background:
    linear-gradient(180deg, #8d7448 0%, #a98a55 30%, #bd9c63 100%);
  box-shadow: inset 0 6px 14px rgba(30, 24, 12, 0.4), 0 3px 10px rgba(30, 24, 12, 0.25);
  touch-action: none;
}
/* converging side rails hint that this strip looks backward */
.rear-radar::before,
.rear-radar::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(243, 234, 210, 0.55);
}
.rear-radar::before { left: 4%; transform: skewX(7deg); }
.rear-radar::after { right: 4%; transform: skewX(-7deg); }

.radar-frame {
  position: absolute;
  inset: 0 4% auto 4%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 3px;
  pointer-events: none;
}
.radar-lbl { font-size: 9px; letter-spacing: 0.14em; color: rgba(243, 234, 210, 0.8); }
.radar-cap {
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: rgba(46, 42, 31, 0.45);
  pointer-events: none;
}

/* your-lane guide line + top marker — line up a block by lane */
.radar-you-guide {
  position: absolute;
  top: 16px;
  bottom: 2px;
  width: 0;
  border-left: 2px dashed rgba(243, 234, 210, 0.5);
  transform: translateX(-50%);
  z-index: 5;            /* behind the chasing chips (z 10+) */
  pointer-events: none;
  transition: border-color 0.2s ease, left 0.12s linear;
}
.radar-you {
  position: absolute;
  top: 0;
  z-index: 40;           /* above the chips */
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
  transition: left 0.12s linear;
}
.radar-you-tag {
  font: 700 9px Georgia, serif;
  letter-spacing: 0.1em;
  color: #3a2f14;
  background: linear-gradient(180deg, var(--gold-3), var(--gold-2));
  border: 1px solid var(--edge);
  border-radius: 5px;
  padding: 0 5px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(30, 24, 12, 0.5);
}
.radar-you-tip {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--gold-2);
  margin-top: -1px;
}
/* a chaser sitting in your lane within blocking range — line up / block now */
.radar-chip.inline .radar-silk {
  border-color: #e8be57;
  box-shadow: 0 0 7px rgba(232, 190, 87, 0.9), 0 2px 4px rgba(30, 24, 12, 0.45);
}
.rear-radar.has-target .radar-you-guide { border-color: rgba(232, 190, 87, 0.95); }
.rear-radar.has-target .radar-you-tag {
  background: linear-gradient(180deg, #f1cb62, #d89a2e);
  box-shadow: 0 0 8px rgba(232, 190, 87, 0.8), 0 1px 3px rgba(30, 24, 12, 0.5);
}
.rear-radar.has-target .radar-you-tip { border-top-color: #d89a2e; }

.radar-chips { position: absolute; inset: 0; }
.radar-chip {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: opacity 0.25s ease;
  will-change: transform, top, left;
}
.radar-silk {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f7f2e2;
  font: 700 12px Georgia, serif;
  border: 1.5px solid rgba(243, 234, 210, 0.85);
  box-shadow: 0 2px 4px rgba(30, 24, 12, 0.45);
}
.radar-gap {
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: rgba(46, 42, 31, 0.85);
  background: rgba(243, 234, 210, 0.65);
  padding: 0 4px;
  border-radius: 6px;
}
.radar-chip.held .radar-silk {
  border-color: var(--gold-3);
  box-shadow: 0 0 8px rgba(227, 200, 122, 0.9), 0 2px 4px rgba(30, 24, 12, 0.45);
}
.radar-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(46, 42, 31, 0.5);
}

.boxed-flag {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--paper-2);
  background: var(--red);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid #571f15;
  animation: connPulse 0.9s ease-in-out infinite;
  white-space: nowrap;
}

/* --- energy / stamina gauge --- */
.energy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
}
.energy-label { font-size: 12px; letter-spacing: 0.16em; color: var(--olive-2); }
.energy-gauge {
  flex: 1 1 auto;
  height: 16px;
  border-radius: 8px;
  padding: 2.5px;
  background: linear-gradient(100deg, #8a6f2f, var(--gold-3) 25%, var(--gold) 50%, var(--gold-2) 80%, #6e571c);
  box-shadow: inset 0 0 0 1px rgba(70, 56, 19, 0.8), 0 2px 6px rgba(40, 32, 14, 0.35);
}
.energy-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #46622f, #6f8a3c 60%, #9aa44e);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: width 0.25s linear;
}
.energy-fill.low {
  background: linear-gradient(90deg, #6e2d22, var(--red));
  animation: connPulse 1s ease-in-out infinite;
}

/* --- controls --- */
.race-controls {
  flex: 1 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 16px 6px;
  touch-action: none;
}

.guide-cluster { display: flex; flex-direction: column; gap: 10px; }
.guide-zones { display: flex; gap: 10px; }
.guide-btn {
  width: clamp(58px, 17vw, 72px);
  height: clamp(58px, 17vw, 72px);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--paper-2);
  background: linear-gradient(180deg, var(--olive-3), var(--olive-2));
  border: 1.5px solid #3c3c24;
  box-shadow: inset 0 0 0 2px rgba(233, 221, 192, 0.25), 0 4px 12px rgba(24, 24, 12, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.guide-lbl { font-size: 10px; letter-spacing: 0.16em; color: rgba(233, 221, 192, 0.8); }
.guide-btn.pressed { animation: btnPress 0.25s ease; }

.block-btn {
  padding: 11px 10px;
  border-radius: 12px;
  font-size: 14px;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: var(--paper-2);
  background: linear-gradient(180deg, #5a5a3a, #44442a);
  border: 1.5px solid #32321e;
  box-shadow: inset 0 0 0 2px rgba(233, 221, 192, 0.2), 0 4px 12px rgba(24, 24, 12, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.block-btn.on {
  color: #463813;
  background: linear-gradient(180deg, var(--paper-2), var(--paper-3));
  box-shadow: inset 0 0 0 2px rgba(110, 87, 28, 0.4), 0 0 12px rgba(233, 221, 192, 0.4);
}
.block-btn.on.engaged {
  background: linear-gradient(180deg, var(--gold-3), var(--gold));
  box-shadow: 0 0 18px rgba(227, 200, 122, 0.9), inset 0 0 0 2px rgba(110, 87, 28, 0.6);
}

.whip-btn {
  position: relative;
  width: clamp(92px, 27vw, 118px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #5d4a18;
  background: radial-gradient(circle at 35% 28%, #d8c184, #b89544 55%, #93732a 90%);
  border: 2px solid #6e571c;
  box-shadow: inset 0 0 0 3px rgba(255, 246, 210, 0.4), 0 6px 18px rgba(40, 32, 14, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: filter 0.2s ease;
}
.whip-btn:not(.ready) { filter: saturate(0.55) brightness(0.85); }
.whip-btn.ready {
  background: radial-gradient(circle at 35% 28%, var(--gold-3), var(--gold) 55%, var(--gold-2) 90%);
  color: #463813;
}
.whip-btn svg.ico-whip { width: 34%; height: 34%; }
.whip-lbl { font-size: 13px; letter-spacing: 0.14em; font-weight: 700; }
.whip-btn.fired { animation: btnPress 0.3s ease; }

.cd-ring {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  transform: rotate(-90deg);
  pointer-events: none;
}
.cd-track { fill: none; stroke: rgba(70, 56, 19, 0.35); stroke-width: 4; }
.cd-arc {
  fill: none;
  stroke: var(--gold-3);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 4px rgba(227, 200, 122, 0.8));
}

/* --- results --- */
.results-card {
  margin: 8px 16px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.results-head { font-size: 15px; letter-spacing: 0.18em; color: var(--olive-2); }
.my-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(201, 166, 72, 0.14);
  box-shadow: inset 0 0 0 1.5px rgba(201, 166, 72, 0.5);
}
.my-result.won {
  background: linear-gradient(180deg, rgba(227, 200, 122, 0.4), rgba(201, 166, 72, 0.25));
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 18px rgba(201, 166, 72, 0.5);
}
.my-pos { font-size: 38px; font-weight: 700; color: var(--gold-2); }
.my-result.won .my-pos { color: #7a611f; text-shadow: 0 1px 0 rgba(255, 248, 215, 0.7); }
.my-line { font-size: 15px; color: var(--ink); }

.results-list { list-style: none; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.results-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14.5px;
  padding: 4px 8px;
  border-radius: 6px;
}
.results-list li.mine { background: rgba(201, 166, 72, 0.18); box-shadow: inset 0 0 0 1px rgba(201, 166, 72, 0.5); }
.res-pos { flex: 0 0 38px; font-weight: 700; color: var(--olive-2); }
.res-name { font-weight: 700; }
.res-stable { font-size: 12px; font-style: italic; color: var(--ink-2); }
.res-earn { margin-left: auto; color: var(--gold-2); font-variant-numeric: tabular-nums; }
.results-btn { margin-top: 4px; }

/* ============================================================
   accessibility / motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .panel, .deck-track { transition-duration: 0.01s; }
  .to-post-banner, .gauge-zone.surge, .surge-label { animation: none; }
}
