/* Fonts bundled with the game (SIL Open Font License, see fonts/), so
   nothing is fetched from a font service and they work offline. */
@font-face { font-family: 'Lilita One'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/lilita-one-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Lilita One'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/lilita-one-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/nunito-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/nunito-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 800; font-display: swap; src: url(../fonts/nunito-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 800; font-display: swap; src: url(../fonts/nunito-latin-ext-800-normal.woff2) format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }

:root {
  --ink: #3b2a14;
  --cream: #fff8e6;
  --cream-2: #fbefcf;
  --straw: #f5d36e;
  --straw-dark: #d9a93a;
  --barn: #d8432f;
  --barn-dark: #a92f20;
  --grass: #7cc35a;
  --grass-dark: #4f9a3a;
  --sky: #9fdcff;
  --good: #2fae4a;
  --warn: #e2412f;
  --shadow: 0 5px 0 var(--ink);
  --radius: 18px;
  --font-display: 'Lilita One', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* iPhone notch / Dynamic Island / home bar (zero elsewhere). The page
     runs edge to edge (viewport-fit=cover), so anything pinned to an edge
     keeps clear of these. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.35) 0 2px, transparent 3px) 0 0 / 38px 38px,
    linear-gradient(180deg, var(--sky) 0, #c9eeff 140px, var(--grass) 140px, var(--grass-dark) 100%);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.5px; margin: 0; }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* Clear of the notch / Dynamic Island when the page runs full screen. */
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
  background: var(--barn);
  border-bottom: 2.5px solid var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 32px; filter: drop-shadow(2px 2px 0 var(--ink)); }
.logo-text {
  font-family: var(--font-display);
  font-size: 26px;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 2px 3px 0 var(--ink);
}
.logo-text b { color: var(--straw); font-weight: 400; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 20px;
}

.wallet-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--straw);
  box-shadow: 0 3px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
}
.wallet-pill .unit { font-family: var(--font-body); font-size: 13px; font-weight: 800; opacity: 0.75; }
.wallet-pill .plus {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--good);
  color: #fff;
  border: 1.5px solid var(--ink);
}
.wallet-pill.bump { animation: bump 0.35s ease; }
@keyframes bump { 50% { transform: scale(1.08); } }

main { max-width: 1400px; margin: 0 auto; padding: 20px max(16px, var(--safe-r)) calc(48px + var(--safe-b)) max(16px, var(--safe-l)); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.5px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--good); color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.3); }
.btn-ghost { background: var(--cream); }
.btn-big { font-size: 22px; padding: 14px 20px; }
.btn-small { font-size: 14px; padding: 6px 12px; }

/* ---------- Lobby ---------- */

.hero { text-align: center; margin: 10px 0 28px; }
.hero h1 {
  font-size: clamp(30px, 5vw, 52px);
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 4px 0 var(--ink);
}
.hero p {
  display: inline-block;
  margin: 12px 0 0;
  padding: 8px 16px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 7px 0 var(--ink);
  overflow: hidden;
  transition: transform 0.15s;
}
.game-card.playable:hover { transform: translateY(-4px) rotate(-0.5deg); }
.game-card.soon { opacity: 0.85; }
.game-card.soon .game-art { filter: saturate(0.6); }

.game-art {
  height: 150px;
  position: relative;
  display: grid;
  place-items: center;
  font-size: 56px;
  border-bottom: 2.5px solid var(--ink);
  overflow: hidden;
}
.art-hay { background: repeating-linear-gradient(0deg, #8fd16a 0 30px, #7fc45e 30px 60px); }
.art-pig { background: #ffc9d6; }
.art-egg { background: #fff1b8; }
.art-cow { background: #cfe9ff; }

.art-bale {
  position: absolute;
  width: 38px; height: 48px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, #b5862a, #f5d36e 35%, #e7bd52 65%, #a87a22);
  animation: roll 3.2s linear infinite;
}
.art-bale::before, .art-bale::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  background: var(--c, var(--barn));
}
.art-bale::before { top: 10px; }
.art-bale::after { bottom: 10px; }
.art-bale.b1 { top: 12px; --c: #e2412f; }
.art-bale.b2 { top: 52px; --c: #2f7de2; animation-delay: -1.1s; animation-duration: 2.8s; }
.art-bale.b3 { top: 92px; --c: #f4c20d; animation-delay: -2s; animation-duration: 3.6s; }
@keyframes roll { from { left: -50px; } to { left: 110%; } }
.art-critter { position: absolute; font-size: 38px; left: 55%; top: 50px; animation: wander 4s ease-in-out infinite alternate; }
.art-critter.c2 { left: 25%; top: 10px; font-size: 28px; animation-duration: 3s; }
@keyframes wander { to { transform: translateY(40px); } }

.game-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-body h2 { font-size: 26px; }
.game-body p { margin: 0 0 8px; flex: 1; }
.badge {
  align-self: flex-start;
  padding: 4px 12px;
  background: var(--cream-2);
  border: 2px dashed var(--ink);
  border-radius: 999px;
  font-weight: 800;
}

.disclaimer { text-align: center; color: #fff; text-shadow: 1px 1px 0 var(--ink); margin-top: 30px; font-weight: 800; }

/* ---------- Game view ---------- */

.game-header { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.game-header h1 {
  font-size: clamp(26px, 4vw, 40px);
  color: var(--straw);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
  flex: 1;
}
.race-no {
  font-family: var(--font-display);
  font-size: 18px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: 0 3px 0 var(--ink);
}

.race-frame {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink);
  overflow: hidden;
  background: #8fd16a;
}
#race-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1400 / 760; }

.race-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(30, 20, 5, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l));
}
.race-overlay.show { opacity: 1; pointer-events: auto; }

.results-card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 7px 0 var(--ink);
  padding: 18px 20px;
  text-align: center;
  animation: pop 0.35s cubic-bezier(.3,1.6,.6,1);
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.results-title { font-family: var(--font-display); font-size: 20px; opacity: 0.7; }
.winner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid var(--ink);
  border-left: 12px solid var(--lane);
  border-radius: 14px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 24px;
}
.winner small { display: block; font-family: var(--font-body); font-size: 12px; font-weight: 800; text-transform: uppercase; opacity: 0.6; }
.winner .odds-tag { margin-left: auto; font-size: 20px; color: var(--barn-dark); }
.verdict { font-size: 18px; margin: 8px 0 12px; }
.verdict.win { color: var(--good); font-size: 22px; }
.verdict.lose { color: var(--barn-dark); }
.placings { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; counter-reset: p; }
.placings li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; counter-increment: p; }
.placings li::before { content: counter(p); width: 20px; font-family: var(--font-display); text-align: right; }
.placings li em { margin-left: auto; font-style: normal; font-size: 13px; background: var(--straw); border-radius: 8px; padding: 2px 8px; border: 1.5px solid var(--ink); }

.ball {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--lane);
  color: #fff;
  border: 2px solid var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  text-shadow: 1px 1px 0 var(--ink);
}
.ball.sm { width: 24px; height: 24px; font-size: 13px; border-width: 2px; }

.race-status {
  margin: 18px 0 14px;
  padding: 10px 16px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800;
}

.game-panel { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }

.bet-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }

.bale-card {
  position: relative;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-top: 10px solid var(--lane);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--ink);
  padding: 10px 12px 12px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s, background 0.2s;
}
.bale-card:hover:not(.locked) { transform: translateY(-3px); }
.bale-card:active:not(.locked) { transform: translateY(2px); }
.bale-card:focus-visible { outline: 4px solid var(--straw-dark); outline-offset: 2px; }
.bale-card.locked { cursor: default; }
.bale-card.has-bet { background: #fff3c2; }
.bale-card.has-bet::after {
  content: '★';
  position: absolute;
  top: -18px; right: 10px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--straw);
  border: 2px solid var(--ink);
  font-size: 16px;
}

.bale-head { display: flex; align-items: center; gap: 8px; }
.bale-name { font-family: var(--font-display); font-size: 18px; line-height: 1.1; flex: 1; }
.odds {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--barn-dark);
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 2px 8px;
}

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  margin: 8px 0;
  font-size: 13px;
  font-weight: 800;
}
.pips { color: var(--lane); letter-spacing: 2px; -webkit-text-stroke: 0.5px var(--ink); }
.pip-off { color: #e3d6b4; -webkit-text-stroke: 0; }

.bet-line { display: flex; align-items: center; gap: 8px; min-height: 32px; font-weight: 800; }
.bet-line .hint { opacity: 0.55; font-size: 14px; }
.bet-line .stake { background: var(--straw); border: 1.5px solid var(--ink); border-radius: 8px; padding: 2px 8px; }
.bet-line .returns { color: var(--good); font-size: 14px; }
.minus {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}

.bet-controls {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(76px + max(10px, var(--safe-t)));
}
.panel-block h3 { font-size: 18px; margin-bottom: 8px; }

.chip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: repeating-conic-gradient(var(--barn) 0 30deg, #fff 30deg 60deg);
  box-shadow: 0 3px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  transition: transform 0.1s;
}
.chip::before {
  content: '';
  position: absolute;
  inset: 18%;
  z-index: -1;
  border-radius: 50%;
  background: var(--cream);
  border: 2px dashed var(--ink);
}
.chip.active { transform: translateY(-4px) scale(1.06); box-shadow: 0 6px 0 var(--ink), 0 0 0 4px var(--straw); }
.chip:disabled { opacity: 0.5; }

.totals { display: grid; gap: 4px; }
.totals div { display: flex; justify-content: space-between; }
.totals b { font-family: var(--font-display); font-size: 20px; font-weight: 400; }

.panel-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }

.live { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.live li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid transparent;
  font-size: 14px;
}
.live li.mine { border-color: var(--straw-dark); background: #fff3c2; }
.live .pos { font-family: var(--font-display); width: 16px; text-align: right; }
.live .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live .hits { font-size: 12px; }

/* ---------- Wallet modal ---------- */

.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(480px, calc(100vw - 32px - var(--safe-l) - var(--safe-r)));
  max-height: calc(100vh - 40px - var(--safe-t) - var(--safe-b));
}
.modal::backdrop { background: rgba(30, 20, 5, 0.55); }
.modal-inner {
  position: relative;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink);
  padding: 22px;
  color: var(--ink);
}
.modal-inner h2 { font-size: 30px; }
.modal-inner h3 { font-size: 18px; margin: 18px 0 8px; }
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: #fff;
  font-weight: 800;
}
.wallet-balance { font-family: var(--font-display); font-size: 40px; margin: 8px 0 2px; }
.muted { opacity: 0.7; margin: 0 0 14px; }

.packs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pack {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--straw);
  box-shadow: 0 4px 0 var(--ink);
}
.pack:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pack b { font-family: var(--font-display); font-weight: 400; font-size: 26px; }
.pack small { font-weight: 800; opacity: 0.75; }

.custom-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.custom-add label { grid-column: 1 / -1; font-weight: 800; }
.custom-add input {
  font: inherit;
  font-size: 18px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}

.history { list-style: none; margin: 0 0 14px; padding: 0; max-height: 220px; overflow: auto; display: grid; gap: 6px; }
.history li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: #fff; border-radius: 10px; border: 2px solid #eadfbf; font-size: 14px; }
.history li small { display: block; opacity: 0.6; font-size: 12px; }
.history li b { white-space: nowrap; }
.history li.deposit b, .history li.win b { color: var(--good); }
.history li.bet b { color: var(--barn-dark); }
.history li.empty { justify-content: center; opacity: 0.6; }

/* Gold coin: Apple's 🪙 is silver, so tint it (wrapped by goldCoins in app.js). */
.gc {
  font-style: normal;
  display: inline-block;
  filter: sepia(1) saturate(5) hue-rotate(-8deg) brightness(1.1);
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  bottom: calc(20px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(440px, calc(100vw - 32px - var(--safe-l) - var(--safe-r)));
  /* It's a popover (so it can sit above an open dialog): undo the defaults. */
  top: auto;
  right: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  color: inherit;
  pointer-events: none;
}
.toasts .toast { pointer-events: auto; }
.toast {
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--ink);
  background: var(--cream);
  font-weight: 800;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}
.toast.show { transform: none; opacity: 1; }
.toast.good { background: #c9f2c4; }
.toast.warn { background: #ffd3c9; }

/* ---------- Lobby feature card ---------- */

.feature-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink);
  overflow: hidden;
  margin-bottom: 34px;
  transition: transform 0.15s;
}
.feature-card:hover { transform: translateY(-3px); }
.feature-art { background: #6fbf4f; border-right: 2.5px solid var(--ink); min-height: 220px; }
.feature-art canvas { display: block; width: 100%; height: 100%; }
.feature-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.feature-body h2 { font-size: 38px; }
.feature-body p { margin: 0 0 6px; font-size: 17px; }
.tag {
  padding: 3px 12px;
  background: var(--barn);
  color: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.section-title {
  font-size: 28px;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 2px 3px 0 var(--ink);
  margin: 0 0 14px;
}

/* ---------- Garage ---------- */

.garage-grid { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 18px; align-items: start; }
.g-card {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 var(--ink);
  padding: 16px;
}
.g-card h2 { font-size: 24px; margin-bottom: 10px; }
#tractor-preview {
  display: block;
  width: 100%;
  height: 170px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: repeating-linear-gradient(90deg, #d9a066 0 26px, #cf955a 26px 52px);
}
.paints { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.paint {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paint);
  box-shadow: 0 3px 0 var(--ink);
}
.paint.active { outline: 4px solid var(--straw); transform: translateY(-2px); }
.stat-bars { display: grid; gap: 6px; }
.sbar { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; }
.sbar-track { height: 12px; background: #eadfbf; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.sbar-fill { height: 100%; background: linear-gradient(90deg, var(--good), #8fe07a); }

.upgrade {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 2px dashed #e3d6b4;
}
.upgrade:last-of-type { border-bottom: 0; }
.u-icon { font-size: 28px; text-align: center; }
.u-info b { font-family: var(--font-display); font-weight: 400; font-size: 18px; display: block; }
.u-info small { display: block; opacity: 0.7; font-size: 13px; }
.pips { display: flex; gap: 4px; margin-top: 4px; }
.pips i { width: 16px; height: 8px; border-radius: 4px; background: #eadfbf; border: 1.5px solid var(--ink); }
.pips i.on { background: var(--straw-dark); }
.btn-buy { font-size: 15px; padding: 7px 10px; background: var(--straw); white-space: nowrap; }
.btn-buy.cant { opacity: 0.55; }
.u-max { font-family: var(--font-display); color: var(--good); font-size: 18px; padding: 0 8px; }
.earn-link {
  display: block;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff3c2;
  border: 2px dashed var(--ink);
  font-weight: 800;
  text-align: center;
}

#track-list { display: grid; gap: 10px; margin-bottom: 14px; max-height: 430px; overflow-y: auto; padding: 4px 6px 6px 4px; overscroll-behavior: contain; }
.track {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
}
.track.active { background: #fff3c2; outline: 4px solid var(--straw-dark); }
.track.locked { opacity: 0.6; }
.track-thumb { width: 120px; height: 68px; border-radius: 8px; border: 1.5px solid var(--ink); }
.t-info b { font-family: var(--font-display); font-weight: 400; font-size: 18px; display: block; }
.t-info small { display: block; font-size: 12px; opacity: 0.75; }
.t-info .t-meta { opacity: 1; font-weight: 800; margin-top: 2px; }
.race-btn { width: 100%; font-size: 26px; }
.unlock-all { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 10px; border: 2px dashed #b9a77a; border-radius: 10px; font-weight: 800; font-size: 14px; cursor: pointer; }
.unlock-all input { width: 20px; height: 20px; accent-color: var(--good); }
.unlock-all small { opacity: 0.6; }
.bonus-tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: #8e44c9; color: #fff; font-family: var(--font-body); font-weight: 800; font-size: 11px; vertical-align: middle; }

/* ---------- Awards ---------- */

.trophy-btn { cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.trophy-btn span { font-family: var(--font-body); font-weight: 800; font-size: 15px; }
.track { position: relative; }
.t-trophy { position: absolute; top: -10px; right: -6px; font-size: 26px; filter: drop-shadow(1px 2px 0 var(--ink)); }

.cabinet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(30, 20, 5, 0.55);
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l));
}
.cabinet.hidden { display: none; }
.cabinet-card {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - max(16px, var(--safe-t)) - max(16px, var(--safe-b)));
  overflow: auto;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 8px 0 var(--ink);
  padding: 20px;
  animation: pop 0.3s cubic-bezier(.3,1.6,.6,1);
}
.cabinet-card h2 { font-size: 30px; text-align: center; }
.cab-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 6px; }
.cab-totals div {
  display: grid;
  justify-items: center;
  padding: 10px 4px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--ink);
}
.cab-totals span { font-size: 34px; line-height: 1; }
.cab-totals b { font-family: var(--font-display); font-weight: 400; font-size: 28px; }
.cab-totals small { font-weight: 800; font-size: 12px; opacity: 0.7; }
.cab-sub { text-align: center; font-weight: 800; opacity: 0.7; margin: 6px 0 12px; }
.cab-rows { display: grid; gap: 4px; }
.cab-row {
  display: grid;
  grid-template-columns: 1fr 48px repeat(4, 34px) 78px;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  text-align: center;
}
.cab-row.head { background: transparent; font-size: 12px; opacity: 0.7; }
.cab-row.locked { opacity: 0.45; }
.cab-name { text-align: left; }
.cab-best { font-size: 20px; }

/* Badges in the cabinet: icon, name and next target, tier medals, progress. */
.cab-h { font-size: 22px; margin: 16px 0 8px; }
.cab-h small { font-family: var(--font-body, inherit); font-size: 13px; font-weight: 800; opacity: 0.65; margin-left: 6px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.badge-tile {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-areas: 'icon text' 'icon tiers' 'bar bar';
  column-gap: 8px;
  row-gap: 4px;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
}
.badge-tile.none { border-style: dashed; }
.badge-tile.none .b-icon { filter: grayscale(1); opacity: 0.5; }
.badge-tile.bronze { background: #f6dcc4; }
.badge-tile.silver { background: #eef0f2; }
.badge-tile.gold { background: #fff1b0; }
.b-icon { grid-area: icon; font-size: 30px; text-align: center; }
.b-text { grid-area: text; }
.b-text b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 15px; }
.b-text small { display: block; font-size: 11.5px; font-weight: 800; opacity: 0.75; }
.b-tiers { grid-area: tiers; font-size: 15px; letter-spacing: 2px; }
.b-tiers i { font-style: normal; filter: grayscale(1); opacity: 0.3; }
.b-tiers i.on { filter: none; opacity: 1; }
.b-bar { grid-area: bar; position: relative; height: 14px; background: rgba(0,0,0,0.08); border-radius: 7px; overflow: hidden; }
.b-bar i { position: absolute; inset: 0 auto 0 0; background: #7cc56a; border-radius: 7px; }
.b-bar em { position: relative; display: block; text-align: center; font-style: normal; font-size: 10.5px; font-weight: 800; line-height: 14px; }
.award.badge-won { background: #ffe7a8; }

.awards { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.award {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  animation: pop 0.4s cubic-bezier(.3,1.6,.6,1) backwards;
}
.award:nth-child(2) { animation-delay: 0.15s; }
.award:nth-child(3) { animation-delay: 0.3s; }
.award:nth-child(4) { animation-delay: 0.45s; }
.award.gold { background: #fff1b0; }
.award.silver { background: #eef0f2; }
.award.bronze { background: #f6dcc4; }
.award.fastest { background: #d9f0ff; }
.award.record, .award.unlocked { background: #c9f2c4; }
.award.miss { opacity: 0.75; border-style: dashed; }
.a-icon { font-size: 28px; }
.award b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 16px; }
.award small { display: block; font-size: 12px; font-weight: 800; opacity: 0.75; }
.hud-time { min-width: 64px; }
.hud-time.flash { background: #c9f2c4; }

@media (max-width: 560px) {
  .cab-row { grid-template-columns: 1fr 34px repeat(4, 22px) 58px; font-size: 12px; gap: 3px; padding: 5px 6px; }
  .cab-totals span { font-size: 26px; }
}

/* ---------- Race screen (full screen, landscape) ---------- */

body.in-race { overflow: hidden; overscroll-behavior: none; }
body.in-race .topbar { display: none; }

.race-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #5aa83f;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#tractor-canvas { display: block; }

.hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }
.hud-pos {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 2px 3px 0 var(--ink);
}
.hud-pos small { font-size: 18px; margin-left: 2px; vertical-align: top; }
.hud-lap, .hud-chip {
  font-family: var(--font-display);
  font-size: 17px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 3px 9px;
  box-shadow: 0 3px 0 var(--ink);
}
.hud-pause {
  pointer-events: auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: 0 3px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.hud-view {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: 0 3px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  white-space: nowrap;
}
.hud-view:active { transform: translate(-50%, 2px); box-shadow: 0 1px 0 var(--ink); }
.hud-view .cam { font-size: 18px; line-height: 1; }
.hud-pause i { width: 5px; height: 14px; background: var(--ink); border-radius: 2px; }

.stick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 70%;
}
.stick-hint {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,248,230,0.75);
  border: 1.5px solid var(--ink);
  font-weight: 800;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 0.3s;
}
.stick-base {
  position: absolute;
  width: 176px; height: 60px;
  margin: -30px 0 0 -88px;
  border-radius: 999px;
  background: rgba(255,248,230,0.3);
  border: 3px solid rgba(59,42,20,0.7);
  display: none;
  place-items: center;
  pointer-events: none;
}
.stick-base.active { display: grid; }
.stick-zone.used .stick-hint { opacity: 0; }
.slide-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: rgba(59, 42, 20, 0.7);
}
.slide-arrow.l { left: 10px; }
/* The straight-ahead zone in the middle of the slider. */
.slide-centre {
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 28px;
  margin-left: -14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}
.slide-arrow.r { right: 10px; }
.stick-knob {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--straw);
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

/* Optional left/right steering buttons (instead of the slider). */
.steer-pad {
  display: none;
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  gap: 14px;
  padding-top: 40px; /* a little extra catch area above the buttons */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.race-screen.steer-buttons .steer-pad { display: flex; }
.race-screen.steer-buttons .stick-zone { pointer-events: none; }
.race-screen.steer-buttons .stick-hint { display: none; }
.sbtn {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff3c4, var(--straw));
  color: var(--ink);
  font-size: 30px;
  display: grid;
  place-items: center;
  opacity: 0.88;
  pointer-events: none; /* the pad handles touches */
}
.sbtn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); opacity: 1; }

.race-buttons {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.rbtn {
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  font-family: var(--font-display);
  color: #fff;
  text-shadow: 1px 2px 0 rgba(0,0,0,0.35);
  opacity: 0.88;
  touch-action: none;
}
.rbtn.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); opacity: 1; }
.rbtn-nitro { width: 84px; height: 84px; font-size: 17px; background: radial-gradient(circle at 35% 30%, #ffb36b, #f05a1b); margin-bottom: 40px; }
.rbtn-nitro.empty { filter: grayscale(1); opacity: 0.5; }
.rbtn-brake { width: 70px; height: 70px; font-size: 15px; background: radial-gradient(circle at 35% 30%, #8a8a8a, #4a4a4a); margin-bottom: 70px; }
.rbtn-drift { width: 92px; height: 92px; font-size: 18px; background: radial-gradient(circle at 35% 30%, #c79bff, #7a3fd0); }

.rotate-hint {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20; /* above the pause menu, so it's clear why the race is waiting */
  place-items: center;
  align-content: center;
  text-align: center;
  background: rgba(30, 20, 5, 0.85);
  color: #fff;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.5;
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l));
}
.race-screen.portrait .rotate-hint { display: grid; }

.race-modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(30, 20, 5, 0.5);
  padding: max(12px, var(--safe-t)) max(12px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l));
}
.race-modal.hidden { display: none; }
.rmodal-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 7px 0 var(--ink);
  padding: 16px 20px;
  display: grid;
  gap: 10px;
  text-align: center;
  animation: pop 0.3s cubic-bezier(.3,1.6,.6,1);
}
.rmodal-card h2 { font-size: 34px; }
.rmodal-card .small { font-size: 13px; opacity: 0.7; margin: 0; }
.results { width: min(560px, 100%); grid-template-columns: 1fr 1fr; text-align: left; align-items: start; }
.results .place, .results .r-sub, .results .unlock, .results .r-actions { grid-column: 1 / -1; text-align: center; }
.place {
  font-family: var(--font-display);
  font-size: 56px;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 4px 0 var(--ink);
}
.place-1 { color: #ffd23f; }
.r-sub { font-weight: 800; opacity: 0.7; margin-top: -6px; }
.r-order { margin: 0; padding-left: 22px; font-weight: 800; }
.r-order li { padding: 2px 0; }
.r-order li.me { color: var(--barn-dark); }
.r-order .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); margin-right: 6px; vertical-align: -1px; }
.r-money { display: grid; gap: 4px; }
.r-money div { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; }
.r-money .r-drift span { text-align: left; }
.r-money .r-drift small { display: block; font-size: 11.5px; opacity: 0.7; }
.r-money .total { border-top: 2px dashed var(--ink); padding-top: 6px; font-size: 16px; }
.r-money .total b { color: var(--good); font-family: var(--font-display); font-weight: 400; font-size: 22px; }
.controls-card { width: min(520px, 100%); text-align: left; }
.controls-card h2 { text-align: center; }
.controls-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.controls-list li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; }
.controls-list li > span > b { font-family: var(--font-display); font-weight: 400; font-size: 17px; display: block; }
.controls-list small { display: block; font-size: 14px; line-height: 1.35; }
.c-key { text-align: center; font-size: 22px; white-space: nowrap; }
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 2px 6px;
  border: 1.5px solid var(--ink);
  border-bottom-width: 4px;
  border-radius: 6px;
  background: #fff;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
}
.c-key kbd { font-size: 15px; }
.c-tip { margin: 0; padding: 8px 10px; background: #fff3c2; border: 2px dashed var(--ink); border-radius: 10px; font-size: 13px; }
.link-btn { border: 0; background: none; padding: 2px; font-weight: 800; text-decoration: underline; font-size: 13px; justify-self: center; }
.unlock { margin: 0; padding: 8px; background: #c9f2c4; border: 1.5px solid var(--ink); border-radius: 10px; font-weight: 800; }
.r-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.r-actions.three { grid-template-columns: auto auto 1fr; }
/* Keep Garage / Race again reachable even when the card has to scroll. */
.results .r-actions { position: sticky; bottom: -16px; margin: 0 -20px -16px; padding: 8px 20px 12px; background: var(--cream); border-top: 2px dashed #e3d6b4; }

/* Short landscape phones: shrink the chrome so the track gets the space. */
@media (max-height: 500px) {
  #track-list { max-height: 260px; }
  .topbar { padding: max(6px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left)); }
  .hero { margin: 0 0 14px; }
  .hero h1 { font-size: 30px; }
  .hero p { margin-top: 6px; padding: 4px 12px; }
  main .feature-card { grid-template-columns: 1fr 1fr; }
  main .feature-art { border-right: 2.5px solid var(--ink); border-bottom: 0; min-height: 0; }
  .feature-body { padding: 14px 16px; gap: 6px; }
  .feature-body h2 { font-size: 26px; }
  .feature-body p { font-size: 14px; }
  .hud-pos { font-size: 30px; }
  .hud-pos small { font-size: 14px; }
  .hud-lap, .hud-chip { font-size: 14px; padding: 2px 7px; border-width: 2px; }
  .awards { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .award { padding: 3px 6px; }
  .a-icon { font-size: 20px; }
  .award b { font-size: 13px; }
  .award small { font-size: 10px; }
  .hud-pause { width: 34px; height: 34px; }
  .hud-view { height: 34px; font-size: 14px; padding: 0 10px 0 8px; }
  .rbtn-nitro { width: 70px; height: 70px; font-size: 14px; margin-bottom: 30px; }
  .rbtn-brake { width: 58px; height: 58px; font-size: 12px; margin-bottom: 56px; }
  .rbtn-drift { width: 78px; height: 78px; font-size: 15px; }
  .sbtn { width: 70px; height: 70px; font-size: 26px; }
  .results .place { font-size: 34px; }
  .r-order { font-size: 13px; }
  .r-order li { padding: 0; }
  .results .r-actions { bottom: -10px; margin: 0 -14px -10px; padding: 6px 14px 8px; }
  .results .r-actions .btn { padding: 6px 14px; font-size: 16px; }
  .rmodal-card { padding: 10px 14px; gap: 6px; }
  .controls-card { width: min(720px, 100%); }
  .controls-list { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .controls-list li { grid-template-columns: 54px 1fr; gap: 6px; }
  .controls-list small { font-size: 12px; }
  .c-tip { padding: 5px 8px; font-size: 12px; }
}

.swipe-hint, .race-dock { display: none; }

@media (max-width: 1000px) {
  .garage-grid { grid-template-columns: 1fr 1fr; }
  .g-tracks { grid-column: 1 / -1; }

  /* Grid columns must be allowed to shrink, or the track row widens the page. */
  .garage-grid > * { min-width: 0; }
  /* Tracks become a sideways swipe row, so they never fight page scrolling. */
  #track-list {
    display: flex;
    gap: 12px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding: 12px 4px 10px;
    margin: 0 -4px 4px;
    -webkit-overflow-scrolling: touch;
  }
  .track {
    flex: 0 0 min(64vw, 260px);
    grid-template-columns: 1fr;
    align-content: start;
    scroll-snap-align: start;
  }
  .track-thumb { width: 100%; height: auto; aspect-ratio: 240 / 136; }
  .swipe-hint { display: inline; font-family: var(--font-body); font-size: 13px; font-weight: 800; opacity: 0.6; margin-left: 6px; }
  .race-btn { display: none; }

  /* Race bar pinned to the bottom of the garage. */
  .garage { padding-bottom: 96px; }
  .race-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px max(16px, var(--safe-r)) calc(10px + var(--safe-b)) max(16px, var(--safe-l));
    background: var(--cream);
    border-top: 2.5px solid var(--ink);
    box-shadow: 0 -4px 0 rgba(0,0,0,0.12);
  }
  .garage.hidden .race-dock { display: none; }
  .dock-track {
    flex: 1;
    min-width: 0;
    display: grid;
    text-align: left;
    padding: 6px 10px;
    border-radius: 12px;
    border: 2px dashed var(--ink);
    background: #fff;
  }
  .dock-track small { font-size: 11px; font-weight: 800; opacity: 0.6; text-transform: uppercase; }
  .dock-track b { font-family: var(--font-display); font-weight: 400; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock-change { font-size: 12px; font-weight: 800; color: var(--barn-dark); }
  .race-dock .btn-big { flex: 0 0 auto; font-size: 22px; padding: 12px 22px; }
}
/* Landscape phones: keep the race bar to one slim line. */
@media (max-width: 1000px) and (max-height: 500px) {
  .garage { padding-bottom: 64px; }
  .race-dock { padding: 6px max(16px, var(--safe-r)) calc(6px + var(--safe-b)) max(16px, var(--safe-l)); }
  .dock-track { display: flex; align-items: baseline; gap: 8px; padding: 4px 10px; }
  .dock-track b { font-size: 16px; }
  .race-dock .btn-big { font-size: 18px; padding: 6px 18px; }
  .track { flex-basis: 200px; }
  .t-info small:not(.t-meta) { display: none; }
}

/* ---------- Piggy Bank Slots ---------- */

.art-reels { font-size: 46px; letter-spacing: 6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 6px 14px; }
.art-egg { position: relative; }
.art-hen { font-size: 64px; }
.art-eggs { position: absolute; bottom: 12px; font-size: 26px; letter-spacing: 6px; }

.slots-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.slot-machine {
  --cell: 96px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 30% 20%, #ffc1d0, #f283a3);
  border: 3px solid var(--ink);
  border-radius: 40px 40px 26px 26px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 18px 22px 22px;
  display: grid;
  gap: 14px;
  justify-items: center;
}
.slot-top { position: relative; width: 100%; text-align: center; }
.slot-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 32px);
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 2px 3px 0 var(--ink);
}
.slot-ear { position: absolute; top: -8px; width: 34px; height: 30px; background: #f06a91; border: 2.5px solid var(--ink); border-radius: 6px 26px 6px 26px; }
.slot-ear.l { left: 10px; transform: rotate(-10deg); }
.slot-ear.r { right: 10px; transform: scaleX(-1) rotate(-10deg); }
.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  gap: 10px;
  padding: 10px;
  background: var(--ink);
  border-radius: 18px;
}
.reel {
  height: calc(var(--cell) * 3);
  overflow: hidden;
  background: linear-gradient(180deg, #d9d2c0, #fff 30%, #fff 70%, #d9d2c0);
  border-radius: 10px;
}
.reel.spinning .reel-strip { filter: blur(1.5px); }
.reel-strip { will-change: transform; }
.reel-cell { height: var(--cell); display: grid; place-items: center; font-size: calc(var(--cell) * 0.6); line-height: 1; }
.reel-cell.hit { animation: hit 0.6s ease-in-out 3; }
@keyframes hit { 50% { transform: scale(1.25) rotate(-6deg); } }
.payline {
  position: absolute;
  left: 4px;
  right: 4px;
  top: calc(10px + var(--cell) * 1.5);
  height: 0;
  border-top: 4px dashed rgba(226, 65, 47, 0.75);
  pointer-events: none;
}
.slot-machine.win .reels { box-shadow: 0 0 0 5px var(--straw); }
.slot-machine.big-win .reels { animation: glow 0.5s ease-in-out 6 alternate; }
@keyframes glow { to { box-shadow: 0 0 0 8px #ffd23f, 0 0 30px 10px #fff3a0; } }
.slot-readout { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 420px; text-align: center; }
.slot-readout div, .bet-stepper div {
  display: grid;
  justify-items: center;
  min-width: 96px;
  padding: 4px 12px;
  background: var(--ink);
  color: #ffd23f;
  border-radius: 12px;
}
.slot-readout small, .bet-stepper small { color: #fff; opacity: 0.7; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.slot-readout b, .bet-stepper b { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.slot-readout p { margin: 0; font-weight: 800; color: var(--ink); min-height: 1.4em; }
.slot-controls { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.bet-stepper { display: flex; align-items: center; gap: 8px; }
.bet-stepper .btn { width: 46px; height: 46px; padding: 0; font-size: 26px; }
#slots-spin { min-width: 190px; font-size: 26px; }
.paytable h2 { margin-bottom: 8px; }
.pt-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 6px 0; border-bottom: 2px dashed #e3d6b4; }
.pt-icons { font-size: 24px; letter-spacing: 2px; }
.pt-row b { font-family: var(--font-display); font-weight: 400; font-size: 22px; color: var(--barn-dark); }
.pt-row small { grid-column: 1 / -1; font-weight: 800; color: var(--good); }
.pt-note { font-size: 13px; opacity: 0.8; margin: 10px 0 0; }
.coin-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.coin-drop { position: absolute; top: -40px; animation: drop 1.8s ease-in forwards; }
@keyframes drop { to { transform: translateY(700px) rotate(540deg); } }

/* ---------- Egg Roulette ---------- */

.egg-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.egg-wheel { display: grid; gap: 12px; justify-items: center; }
#egg-canvas { width: min(100%, 520px); aspect-ratio: 1; border-radius: 50%; box-shadow: 0 8px 0 var(--ink); }
.egg-msg {
  margin: 0;
  width: 100%;
  padding: 10px 14px;
  text-align: center;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800;
}
.egg-history { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; color: #fff; font-weight: 800; text-shadow: 1px 1px 0 var(--ink); }
#egg-history { display: flex; gap: 4px; flex-wrap: wrap; }
.h-egg {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 30px;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  border: 1.5px solid var(--ink);
  font-size: 12px;
  color: var(--ink);
  text-shadow: none;
}
.h-egg.brown { background: #c98a4b; color: #fff; }
.h-egg.white { background: #fffaf0; }
.h-egg.gold { background: #ffd23f; }
.egg-side { display: grid; gap: 14px; }
.egg-grid { display: grid; grid-template-columns: 54px repeat(4, minmax(0, 1fr)) minmax(0, 1.3fr); gap: 6px; }
.egg-zero { grid-row: 1 / span 3; display: grid; }
.egg-outside { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.egg-bet {
  position: relative;
  min-height: 52px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 4px;
  background: #fff;
}
.egg-bet:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.egg-bet.nest .egg-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 38px;
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  border: 1.5px solid var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
}
.egg-bet.brown .egg-num, .egg-bet.outside.brown { background: #c98a4b; color: #fff; }
.egg-bet.white .egg-num { background: #fffaf0; }
.egg-bet.gold { background: #fff1b0; }
.egg-bet.gold .egg-num { background: #ffd23f; }
.egg-bet.nest.brown, .egg-bet.nest.white { background: #f7ead0; }
.egg-bet.outside span { font-size: 14px; line-height: 1.1; }
.egg-bet.outside small { font-size: 11px; opacity: 0.7; }
.egg-bet.coop { background: #e7f5df; }
.egg-bet.won { outline: 4px solid var(--good); animation: hit 0.6s ease-in-out 2; }
.stake-badge {
  position: absolute;
  top: -9px;
  right: -7px;
  min-width: 26px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--barn);
  color: #fff;
  border: 1.5px solid var(--ink);
  font-size: 12px;
  font-weight: 800;
  z-index: 1;
}
.egg-controls { display: grid; gap: 12px; }
.egg-controls .chip-row { grid-template-columns: repeat(5, minmax(0, 64px)); justify-content: space-between; }
.egg-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.egg-total small { display: block; font-size: 12px; opacity: 0.7; font-weight: 800; }
.egg-total b { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.small-print { margin: 0; font-size: 12px; opacity: 0.75; }

@media (max-width: 900px) {
  .slots-layout, .egg-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .slot-machine { --cell: 72px; padding: 14px 12px 18px; }
  .egg-grid { grid-template-columns: 40px repeat(4, minmax(0, 1fr)) minmax(0, 1.2fr); gap: 4px; }
  .egg-bet { min-height: 46px; border-width: 2px; }
  .egg-bet.outside span { font-size: 12px; }
}
@media (max-height: 500px) {
  .slot-machine { --cell: 64px; }
}

/* ---------- Hay Bale Derby: scroll helpers ---------- */

.bet-prompt {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--straw);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  white-space: nowrap;
  animation: nudge 1.2s ease-in-out infinite;
}
.bet-prompt.hidden { display: none; }
@keyframes nudge { 50% { transform: translate(-50%, 6px); } }
.derby-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(16px, var(--safe-r)) calc(10px + var(--safe-b)) max(16px, var(--safe-l));
  background: var(--cream);
  border-top: 2.5px solid var(--ink);
  box-shadow: 0 -4px 0 rgba(0,0,0,0.12);
  font-weight: 800;
}
.derby-dock.hidden { display: none; }
.derby-dock b { font-family: var(--font-display); font-weight: 400; font-size: 22px; margin-left: 4px; }
.derby-dock .btn { flex: 1; max-width: 260px; font-size: 20px; }
@media (prefers-reduced-motion: reduce) { .bet-prompt { animation: none; } }
@media (max-width: 900px) { #view-hay-derby { padding-bottom: 90px; } }
@media (max-width: 560px) { .bet-prompt { font-size: 14px; padding: 5px 12px; bottom: 8px; } }

/* ---------- Monetisation: Gold, store, free Hay, ads ---------- */

.gold-pill { background: #ffe9a8; padding: 6px 14px; }
.wallet-pill.gold-pill .coin { font-size: 20px; }
.w-section { padding: 12px 0; border-bottom: 2px dashed #e3d6b4; }
.wallet-balance.gold { color: #a87600; }
.free-hay { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.free-card {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #c9f2c4;
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
}
.free-card:disabled { background: #eee6d0; box-shadow: 0 2px 0 var(--ink); opacity: 0.8; }
.free-card:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.free-card .f-icon { font-size: 28px; }
.free-card b { font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.free-card small { font-weight: 800; font-size: 13px; opacity: 0.75; }
.dev-topup { margin-top: 10px; padding: 8px; border: 2px dashed #aaa; border-radius: 10px; }
.dev-topup small { display: block; margin-bottom: 6px; opacity: 0.7; }
.test-mode { margin: 0 0 10px; padding: 8px 10px; background: #e5f0ff; border: 2px dashed #2f6fe2; border-radius: 10px; font-size: 13px; }
#store-packs { grid-template-columns: repeat(3, 1fr); }
.gold-pack { position: relative; background: #ffe9a8; }
.gold-pack b { font-size: 20px; white-space: nowrap; }
/* Coin above the amount on every card, and the price pinned to the bottom,
   so the three cards line up however their names wrap. */
.gold-pack .pack-coin { font-size: 22px; line-height: 1; }
.gold-pack .price { margin-top: auto; padding-top: 6px; }
.pack-tag {
  position: absolute;
  top: -10px;
  right: -6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--good);
  color: #fff;
  border: 1.5px solid var(--ink);
  font-size: 11px;
  font-weight: 800;
}
.price { font-family: var(--font-display); font-size: 16px; margin-top: 2px; }
.store-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 var(--ink);
  text-align: left;
  font-size: 22px;
}
.store-row b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.store-row small { display: block; font-size: 12px; font-weight: 800; opacity: 0.7; }
.store-row.owned { background: #c9f2c4; box-shadow: none; }

.paint { position: relative; }
.paint.locked { opacity: 0.85; }
.paint.locked::after { content: '🔒'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; }
.paint-price {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 4px;
  border-radius: 6px;
  background: #ffe9a8;
  border: 1.5px solid var(--ink);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.paints { row-gap: 18px; }

/* The App Store ships updates, not the in-page update check. */
html.native-app .web-only { display: none; }
/* The iPhone app leaves out the casino-style mini games (App Store age rating). */
.native-only { display: none; }
html.native-app .native-only { display: inline; }
/* The play-in-browser copy on the website: nothing sold, no ads. */
.web-play-only { display: none; }
html.web-play .web-play-only { display: block; }
html.web-play #store-packs, html.web-play #store-extras, html.web-play #ad-btn, html.web-play #restore-purchases { display: none !important; }

/* Cosmetics (Gold): a row each for decals, hats and trails. */
.looks { display: grid; gap: 14px; margin: 4px 0 16px; }
.look-row { display: grid; gap: 4px; }
.look-label { font-weight: 800; font-size: 13px; }
.look-items { display: flex; flex-wrap: wrap; gap: 7px; row-gap: 18px; }
.look {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fff8e6;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.look.active { outline: 4px solid var(--straw); transform: translateY(-2px); }
.look.locked { background: #efe3c4; }
/* Upgrades: the Hay price first, Gold as the optional shortcut. */
.u-buy { display: grid; gap: 4px; justify-items: stretch; }
.btn-buy-gold {
  padding: 4px 10px;
  font-size: 13px;
  background: #ffe9a8;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}
.spare-nitro {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 2px dashed #e3d6b4;
}
.spare-nitro .u-icon { font-size: 26px; text-align: center; }
.arm-nitro { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; font-weight: 800; }

.btn-ad { margin-top: 6px; width: 100%; font-size: 15px; background: #2f6fe2; color: #fff; }
.doubled { margin: 6px 0 0; text-align: center; font-weight: 800; color: var(--good); }

/* Home-page banner: pinned to the bottom of the lobby only. */
.ad-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  justify-content: center;
  padding: 6px max(12px, var(--safe-r)) calc(6px + var(--safe-b)) max(12px, var(--safe-l));
  background: rgba(59, 42, 20, 0.92);
}
.ad-banner.hidden { display: none; }
/* In the app the real banner is a native view laid over this strip, which
   just keeps its space (the height is set to the ad's). */
.ad-banner.ad-native { padding: 0; min-height: 50px; box-sizing: content-box; padding-bottom: env(safe-area-inset-bottom); }
body.has-banner main { padding-bottom: calc(96px + var(--safe-b)); }
.ad-label {
  align-self: flex-start;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: #ffd23f;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.ad-house {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(728px, 100%);
  height: 50px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--cream);
  border: 2px solid #ffd23f;
}
.ad-icon { font-size: 28px; }
.ad-house b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 16px; }
.ad-house small { display: block; font-size: 12px; font-weight: 800; opacity: 0.7; }
.ad-cta { margin-left: auto; padding: 4px 12px; border-radius: 999px; background: var(--good); color: #fff; font-weight: 800; border: 1.5px solid var(--ink); }

.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.85);
  padding: max(16px, var(--safe-t)) max(16px, var(--safe-r)) max(16px, var(--safe-b)) max(16px, var(--safe-l));
}
.ad-video {
  position: relative;
  width: min(560px, 100%);
  background: #111;
  color: #fff;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid #333;
}
.ad-video .ad-label { position: absolute; top: 8px; left: 8px; z-index: 1; }
.ad-screen { aspect-ratio: 16 / 9; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; padding: 16px; background: linear-gradient(135deg, #2f6fe2, #2fae4a); }
.ad-screen p { margin: 0; font-weight: 800; }
.ad-tractor { font-size: 54px; animation: drive 1.2s ease-in-out infinite alternate; }
@keyframes drive { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
.ad-bar { height: 5px; background: #333; }
.ad-progress { height: 100%; width: 0; background: #ffd23f; }
.ad-actions { display: flex; justify-content: space-between; gap: 10px; padding: 10px; }
.ad-actions .btn-ghost { background: #333; color: #ddd; border-color: #555; box-shadow: none; }

@media (max-width: 560px) {
  .topbar-right { gap: 6px; }
  .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .wallet-pill .plus { width: 26px; height: 26px; }
  .free-hay { grid-template-columns: 1fr; }
  .wallet-pill.gold-pill { padding: 6px 10px; font-size: 16px; }
  .ad-house small { display: none; }
}
@media (max-height: 500px) {
  .ad-screen { aspect-ratio: auto; height: 150px; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .feature-card { grid-template-columns: 1fr; }
  .feature-art { border-right: 0; border-bottom: 2.5px solid var(--ink); min-height: 160px; }
  .game-panel { grid-template-columns: 1fr; }
  .bet-controls { position: static; order: -1; }
  .chip-row { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 560px) {
  main { padding: 14px max(12px, var(--safe-r)) calc(40px + var(--safe-b)) max(12px, var(--safe-l)); }
  .topbar { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .logo-text { font-size: 20px; }
  .logo-icon { font-size: 26px; }
  .wallet-pill { font-size: 18px; }
  .wallet-pill .unit { display: none; }
  .game-header { gap: 10px; }
  .game-header .btn { padding: 6px 10px; font-size: 15px; }
  .race-no { font-size: 15px; padding: 4px 8px; }
  .race-frame { border-width: 3px; border-radius: 12px; box-shadow: 0 5px 0 var(--ink); }
  .bet-board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .bale-card { padding: 8px 9px 10px; }
  .bale-head { gap: 6px; }
  .bale-name { font-size: 15px; }
  .odds { font-size: 16px; padding: 1px 5px; }
  .ball { width: 28px; height: 28px; font-size: 15px; }
  .stats { font-size: 12px; gap: 0 6px; }
  .chip-row { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  .chip { font-size: 13px; border-width: 2px; }
  .bet-controls { padding: 12px; gap: 10px; }
  .garage-grid { grid-template-columns: 1fr; }
  .feature-body h2 { font-size: 30px; }
  /* Results get the whole screen rather than the small canvas. */
  .race-overlay { position: fixed; z-index: 50; }
}

@media (prefers-reduced-motion: reduce) {
  .art-bale, .art-critter { animation: none; }
}

/* Narrow phones: the two currency pills need the room more than the wordmark. */
@media (max-width: 440px) {
  .logo-text { display: none; }
}

/* ---------- Updates ---------- */
.version-line { text-align: center; color: #fff; text-shadow: 1px 1px 0 var(--ink); font-size: 13px; font-weight: 800; margin: 6px 0 0; }
.version-line .link-btn { color: #fff; font-size: 13px; text-shadow: 1px 1px 0 var(--ink); }
.update-banner {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100vw - 24px - var(--safe-l) - var(--safe-r));
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #c9f2c4;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 15px;
  animation: pop 0.35s cubic-bezier(.3,1.6,.6,1);
}
/* Never interrupt a race; it appears again once you're back in the menus. */
body.in-race .update-banner { display: none; }

/* Farmyard Frenzy */
.hud-lap.hurry { background: #e2412f; color: #fff; animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.frenzy-results .place small { font-size: 0.5em; opacity: 0.7; }

/* Race series tabs (Tractor Cup / Quad Cup / Motorbike Cup) */
.series-tabs { display: flex; gap: 8px; margin: 0 0 12px; overflow-x: auto; }
.series-tab {
  flex: 1 0 auto; display: flex; align-items: center; gap: 8px; text-align: left;
  padding: 8px 14px; border: 2px solid var(--ink); border-radius: 14px;
  background: var(--cream); box-shadow: 0 3px 0 var(--ink); font: inherit; color: var(--ink); cursor: pointer;
}
.series-tab .s-icon { font-size: 24px; }
.series-tab b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 17px; }
.series-tab small { display: block; font-size: 12px; opacity: 0.75; }
.series-tab.active { background: var(--straw); }
.series-tab.locked { opacity: 0.55; cursor: default; }
.cabinet-card h2 small { font-size: 0.6em; opacity: 0.7; }
.race-screen.modal-open:not(.paused) .rotate-hint { display: none !important; }
.race-screen.paused .rotate-hint { background: rgba(30, 20, 5, 0.96); }
.rbtn-drift.on { box-shadow: 0 0 0 5px #e3c8ff, 0 0 22px 8px rgba(160, 90, 255, 0.8); opacity: 1; }

/* Track pack switcher */
.pack-tabs { display: flex; gap: 6px; margin: 0 0 8px; }
.pack-tab { flex: 1; padding: 6px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--cream); font: inherit; font-weight: 800; font-size: 13px; color: var(--ink); cursor: pointer; }
.pack-tab.active { background: var(--straw); }
