@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  font-family: Manrope, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: #f4f5eb;
  background: #121713;
  color-scheme: dark;
  font-synthesis: none;
  --lime: #d4f56b;
  --muted: #94a18b;
  --number: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --panel: #1c251c;
}
* { box-sizing: border-box; }
body { margin: 0; padding-top: env(safe-area-inset-top, 0px); }
button, input { font: inherit; }
button { padding: 0; border: 0; color: inherit; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
button:hover:not(:disabled) { filter: brightness(1.12); }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.svg-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; clip: rect(0, 0, 0, 0); width: 1px; height: 1px; overflow: hidden; }
.icon-button { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 5px; color: #b6c4ac; }
.icon-button svg { width: 18px; height: 18px; }

.app-header { width: min(1200px, 100%); height: 56px; margin: 0 auto; padding: 0 12px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid #2c382a; }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; font: 700 24px/1 var(--number); letter-spacing: 1px; }
.brand-mark { width: 29px; height: 31px; display: grid; place-items: center; color: #1b2914; background: var(--lime); border-radius: 5px; transform: skew(-7deg); }
.brand-mark svg { width: 23px; height: 23px; transform: skew(7deg); }
.app-header nav { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.app-header nav button { width: 32px; height: 32px; display: grid; place-items: center; color: #a5b29d; border-radius: 5px; }
.wallet { display: flex; align-items: center; gap: 6px; min-width: 0; }
.balance-button { width: 84px; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; border-radius: 6px; white-space: nowrap; color: inherit; font-variant-numeric: tabular-nums; }
.balance-button small { color: #97a58c; font-size: 12px; line-height: 1.2; }
.balance-button strong { font: 600 30px/1 var(--number); letter-spacing: .3px; }
.balance-button.crediting { animation: balance-credit 1.7s ease-out; }
.balance-button.crediting strong { animation: balance-number .85s cubic-bezier(.16, 1, .3, 1); transform-origin: right center; }
.balance-button.crediting small { color: #ead399; }
.wallet > .icon-button { width: 29px; height: 29px; color: var(--lime); background: #2a3823; border: 1px solid #435239; }

main { width: min(1200px, 100%); height: calc(100vh - 56px - env(safe-area-inset-top, 0px)); height: calc(100svh - 56px - env(safe-area-inset-top, 0px)); min-height: 440px; margin: 0 auto; padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 6px; }
.play-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr) 140px; gap: 10px; }
.race-panel { grid-column: 1 / -1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border: 1px solid #42513a; border-radius: 10px; }
.race-toolbar { height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; background: #243024; }
.recent-races { min-width: 0; height: 28px; display: flex; align-items: center; gap: 7px; text-align: left; color: #b6c5a7; }
.recent-icon { width: 16px; height: 16px; color: #94a78b; }
.recent-results { min-width: 0; display: flex; align-items: center; gap: 4px; }
.recent-empty { font-size: 12px; white-space: nowrap; }
.recent-chip { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border: 1px solid #5d6853; border-radius: 4px; color: var(--winner-color); background: #18241c; font: 700 16px/1 var(--number); }
.recent-chip.latest { box-shadow: 0 0 0 1px #243024, 0 0 0 2px #e0e7c770; }
.race-tools { display: flex; align-items: center; gap: 9px; }
.race-time { display: flex; align-items: center; gap: 5px; font: 600 18px/1 var(--number); font-variant-numeric: tabular-nums; color: #ccd8bb; }
.race-time svg { width: 14px; height: 14px; }
.race-tools .icon-button { width: 26px; height: 26px; }

.race-scene { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; isolation: isolate; background: #557c3d; }
.race-scene.is-celebrating::before { content: ''; position: absolute; inset: 0; z-index: 8; pointer-events: none; background: radial-gradient(ellipse at center, #fff3b012, #ffd56a40 60%, #ffdb7470); box-shadow: inset 0 0 0 3px #ffe29c, inset 0 0 65px #ffd36b99; animation: course-reward 3.2s ease-out both; }
.stadium { position: relative; height: clamp(34px, 7svh, 72px); flex-shrink: 0; overflow: hidden; isolation: isolate; background: linear-gradient(180deg, #abd1c3, #d0dfb4); }
.sun { position: absolute; width: 38px; height: 38px; top: 8px; left: 16%; border-radius: 50%; background: #f4edb7; box-shadow: 0 0 30px #ffed9f44; }
.cloud { position: absolute; width: 84px; height: 12px; top: 17px; border-radius: 50%; background: #f4f4dd99; }
.cloud::after { content: ''; position: absolute; left: 17px; bottom: 3px; width: 43px; height: 16px; border-radius: 50%; background: inherit; }
.cloud-one { left: 30%; transform: scale(.8); }
.cloud-two { right: 10%; top: 10px; transform: scale(.65); }
.hill { position: absolute; bottom: -27px; width: 52%; height: 68px; z-index: -1; border-radius: 50% 50% 0 0; background: #89ad78; }
.hill-one { left: -12%; transform: rotate(4deg); }
.hill-two { right: -12%; height: 78px; background: #98b783; transform: rotate(-6deg); }
.grandstand { position: absolute; left: 37%; bottom: 9px; width: 39%; height: 39px; background: #6b8868; transform: skew(-4deg); border-bottom: 5px solid #dad7b1; box-shadow: 0 4px 0 #4a6844; }
.stand-roof { position: absolute; left: -12px; right: -12px; top: -5px; height: 7px; border-top: 2px solid #496f59; background: #e7e6cb; box-shadow: 0 3px 0 #365c4e; }
.stand-crowd { height: 24px; margin: 2px 6px; background-image: radial-gradient(circle, #e0d8ac 1.5px, transparent 2px), radial-gradient(circle, #b87b68 1.5px, transparent 2px), linear-gradient(transparent 70%, #45654e 70%); background-position: 0 0, 5px 5px, 0 0; background-size: 10px 9px, 12px 8px, 100% 9px; }
.grandstand > span { display: none; }
.trees { position: absolute; width: 15px; height: 45px; bottom: 4px; border-radius: 60% 60% 35% 35%; background: #3c7650; box-shadow: 18px 6px 0 -3px #548451, 37px 2px 0 1px #487c50, -18px 8px 0 -3px #5f8e5d; }
.trees-left { left: 7%; transform: scale(.8); }
.trees-right { right: 8%; transform: scale(.85); }
.rail { position: absolute; bottom: 0; left: 0; right: 0; height: 12px; border-top: 3px solid #f1e7c1; border-bottom: 2px solid #e9deb1; background: repeating-linear-gradient(90deg, transparent 0 57px, #f2e7c6 57px 61px); filter: drop-shadow(0 2px 0 #2c532744); }
.track { position: relative; flex: 1; min-height: 0; padding: 6px 0; background: #527b3a; isolation: isolate; }
.lanes { position: relative; z-index: 1; height: 100%; display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)); }
.lane { position: relative; min-height: 0; border-bottom: 1px dashed #d3e5a243; transition: background .2s; }
.lane:last-child { border-bottom: 0; }
.lane:nth-child(even) { background: #1f4b190f; }
.lane.selected { background: #d4f51213; box-shadow: inset 3px 0 0 var(--horse-color); }
.lane-number { position: absolute; left: 12px; top: 50%; width: 26px; height: 26px; transform: translateY(-50%); z-index: 5; border: 1px solid #f0e3b24a; border-radius: 5px; color: #e8edc8; background: #294e2780; font: 600 18px/1 var(--number); }
.lane.selected .lane-number { color: #182314; background: var(--horse-color); border-color: var(--horse-color); }
.running-space { position: absolute; inset: 0 34px 0 56px; container-type: inline-size; --horse-width: clamp(96px, 15svh, 150px); }
.runner { position: absolute; top: 50%; width: var(--horse-width); height: calc(var(--horse-width) * .625); z-index: 2; transform: translate3d(calc(var(--p, 0) * (100cqw - var(--horse-width))), -56%, 0); will-change: transform; }
.runner > svg { display: block; width: 100%; height: 100%; overflow: visible; stroke: none; filter: drop-shadow(0 4px 1px #28491a55); }
.runner-label { position: absolute; left: 25px; top: -3px; padding: 1px 5px; border-radius: 3px; color: #192213; background: var(--horse-color); font-size: 12px; line-height: 1.3; font-weight: 700; white-space: nowrap; opacity: 0; }
.lane.selected .runner-label { opacity: 1; }
.is-racing .runner-label { opacity: 0; }
.runner-rank { position: absolute; top: 30%; right: -6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #f0db8c; color: #263020; font: 800 16px/1 var(--number); box-shadow: 0 1px 4px #0003; }
.runner-dust { position: absolute; bottom: 0; left: 9px; width: 25px; height: 7px; border-radius: 50%; background: #e6e5af5c; opacity: 0; }
.start-line { position: absolute; left: calc(56px + clamp(96px, 15svh, 150px) * .9); top: 0; bottom: 0; z-index: 0; border-left: 2px dashed #ede9ce6b; }
.start-line > span { display: none; }
.finish-line { position: absolute; right: 34px; top: 0; bottom: 0; width: 12px; z-index: 0; background: conic-gradient(#eeedce 25%, #30462b 0 50%, #eeedce 0 75%, #30462b 0) 0 0 / 12px 12px; box-shadow: 0 0 0 1px #e7e7ba44; }
.finish-line > span { position: absolute; top: 9px; right: 18px; writing-mode: vertical-rl; color: #f5f1cf; font: 600 12px/1 var(--number); letter-spacing: 2px; }
.field-edge { height: 18px; flex-shrink: 0; border-top: 4px solid #e4e1ba; box-shadow: inset 0 2px 0 #496b34; background: repeating-linear-gradient(85deg, transparent 0 19px, #bad78219 20px, transparent 22px), #3c602f; }
.field-edge > span { display: none; }
.distance-hud { position: absolute; top: 7px; right: 10px; z-index: 5; display: flex; align-items: baseline; gap: 4px; padding: 3px 7px; border: 1px solid #e2edc93b; border-radius: 4px; color: #edf3c9; background: #263d2ee0; font-family: var(--number); font-variant-numeric: tabular-nums; }
.distance-hud strong { min-width: 29px; font-size: 22px; line-height: 1; font-weight: 600; }
.distance-hud span { font-size: 12px; }
.countdown { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; pointer-events: none; color: #efffba; background: #182f1826; font: 800 italic 84px/1 var(--number); text-shadow: 0 3px 0 #183819, 0 0 30px #112b1777; }
.countdown.pop { animation: count-pop .28s ease-out; }
.lane.winner { background: #e2ef7e25; }
.lane.winner .runner { filter: drop-shadow(0 0 6px #f6e4a366); }

.race-caption { height: 32px; flex-shrink: 0; display: flex; align-items: center; min-width: 0; padding: 0 11px; color: #c4d1b8; font-size: 14px; }
#race-commentary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-strip { width: 100%; min-width: 0; height: 100%; display: flex; align-items: center; gap: 7px; }
.result-icon { display: flex; align-items: center; color: var(--lime); }
.result-icon svg { width: 17px; height: 17px; }
.result-copy { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 7px; }
.result-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.result-copy small { color: #a0b092; font-size: 12px; white-space: nowrap; }
.result-amount { margin-left: auto; color: var(--lime); white-space: nowrap; font: 600 23px/1 var(--number); }
.result-amount small { margin-left: 4px; color: #a0b092; font: 400 12px/1 Manrope, sans-serif; }
.result-strip.loss .result-icon, .result-strip.loss .result-amount { color: #e0c292; }

.horse-selection { grid-row: 2; grid-column: 1; min-width: 0; min-height: 0; }
.horse-cards { height: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.horse-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid #384631; border-radius: 8px; background: linear-gradient(145deg, var(--horse-glow), transparent 75%), #1d271c; text-align: left; transition: border-color .15s, background .15s; }
.horse-card.selected { border-color: var(--horse-color); box-shadow: inset 0 0 0 1px var(--horse-color); }
.horse-card:disabled { opacity: .68; }
.horse-card.selected:disabled { opacity: 1; }
.horse-card-number { position: absolute; top: 7px; left: 9px; color: var(--horse-color); font: 600 17px/1 var(--number); }
.horse-card-type, .horse-card-bottom > span { display: none; }
.horse-card-art { position: absolute; top: 7px; bottom: 26px; left: 4px; right: 4px; }
.horse-card-art svg { width: 100%; height: 100%; overflow: visible; stroke: none; }
.horse-card-name { display: contents; }
.horse-card h3 { position: absolute; bottom: 9px; left: 9px; margin: 0; color: #edf2e5; font: 600 22px/1 var(--number); }
.card-check { position: absolute; top: 8px; right: 8px; width: 15px; height: 15px; display: grid; place-items: center; border: 1px solid #5d6f4c; border-radius: 50%; color: transparent; }
.card-check svg { width: 10px; height: 10px; stroke-width: 3; }
.selected .card-check { color: #1c2714; border-color: var(--horse-color); background: var(--horse-color); }
.horse-card-bottom { position: absolute; right: 9px; bottom: 8px; }
.horse-card-bottom strong { display: block; color: var(--horse-color); font: 600 26px/1 var(--number); }
.horse-card-bottom small { font-size: 15px; margin-left: 2px; }

.bet-panel { grid-row: 2; grid-column: 2; min-width: 0; min-height: 0; padding: 10px; display: grid; align-content: center; grid-template-rows: 18px 40px 26px 14px; gap: 4px; border: 1px solid #3e4f33; border-radius: 8px; background: #1e291d; }
.bet-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; }
.amount-label { color: #d7e1ce; font-size: 14px; }
.return-total { min-width: 0; display: flex; align-items: baseline; gap: 6px; color: #a8b99b; font-size: 12px; white-space: nowrap; }
.return-total strong { color: var(--lime); font: 600 27px/.85 var(--number); }
.return-total small { color: #96a789; font: 400 12px/1 Manrope, sans-serif; }
.bet-action { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; min-width: 0; }
.amount-input { min-width: 0; display: flex; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid #4b5e3c; border-radius: 5px; background: #121d13; }
.amount-input:focus-within { border-color: var(--lime); }
.amount-input:has(input[aria-invalid=true]) { border-color: #dc9f81; }
.amount-input svg { width: 17px; height: 17px; color: #b6c891; }
.amount-input input { min-width: 0; width: 100%; padding: 0; border: 0; outline: none; background: transparent; color: #f1f6e8; font: 600 32px/1 var(--number); }
.amount-input > span { font-size: 12px; color: #93a680; }
.start-button { min-width: 0; display: flex; justify-content: center; align-items: center; gap: 6px; padding: 0 7px; border-radius: 5px; color: #1d2b13; background: var(--lime); font-size: 14px; font-weight: 700; white-space: nowrap; }
.start-button svg { width: 16px; height: 16px; stroke-width: 2; }
.start-button:disabled { color: #9eae89; background: #3a4c2a; }
.start-button.running { color: #d8e8c0; background: #35492a; }
.stake-shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stake-shortcuts button { border: 1px solid #405334; border-radius: 4px; background: #293722; color: #b6c5a8; font: 500 16px/1 var(--number); }
.stake-shortcuts button.active { color: var(--lime); background: #3a4c29; border-color: #7b9651; }
.stake-shortcuts button:disabled { opacity: .5; }
.stake-error { min-width: 0; min-height: 14px; margin: 0; color: #edb496; font-size: 12px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
footer { height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #7e9172; font-size: 12px; line-height: 1; }

.toast { position: fixed; left: 50%; top: 60px; z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 14px; transform: translateX(-50%); border: 1px solid #667b4c; border-radius: 7px; background: #293c22; color: #e6efdc; box-shadow: 0 6px 24px #0006; font-size: 14px; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
dialog { width: min(570px, calc(100% - 28px)); max-height: 84svh; padding: 20px; border: 1px solid #4c643a; border-radius: 12px; background: #202d1e; color: #edf4df; box-shadow: 0 20px 100px #0007; }
dialog::backdrop { background: #081108bb; backdrop-filter: blur(5px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid #3c5031; }
.dialog-heading h2 { margin: 0; font-size: 18px; }
#dialog-body { color: #bdccad; font-size: 14px; line-height: 1.8; }
#dialog-body p { margin: 0 0 14px; }
#dialog-body strong { color: #e6efd5; }
.rules-odds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 18px 0; }
.rules-odds > div { padding: 8px 2px; border: 1px solid #536d3d; border-radius: 5px; background: #ffffff04; color: var(--horse-color); text-align: center; font-size: 12px; }
.rules-odds strong { display: block; color: var(--horse-color) !important; font: 600 25px/1.3 var(--number); }
.rules-note { color: #93a780; font-size: 12px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; align-items: center; gap: 10px; padding: 8px 0 14px; border-bottom: 1px solid #3b4c2e; }
.history-row:last-child { border-bottom: 0; }
.history-number { width: 25px; flex-shrink: 0; color: #91a67a; font: 500 22px/1 var(--number); }
.history-copy { flex: 1; min-width: 0; }
.history-copy strong { font-size: 14px; }
.history-copy small { display: block; color: #9aaf86; font-size: 12px; line-height: 1.6; }
.history-change { color: #bdcba8; font: 500 24px/1 var(--number); white-space: nowrap; }
.history-change.win { color: var(--lime); }
.history-empty { padding: 18px 0; text-align: center; }
.confetti { position: absolute; inset: 0; z-index: 9; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -18px; left: var(--x); width: var(--size, 7px); height: calc(var(--size, 7px) * 1.6); border-radius: 1px; background: var(--c); transform: rotate(var(--rot)); animation: confetti-fall var(--life, 2.8s) var(--delay) cubic-bezier(.18, .5, .55, 1) forwards; }
.payout-flash { position: absolute; top: 50%; left: 50%; z-index: 10; width: min(460px, calc(100% - 40px)); padding: 20px 34px 18px; display: grid; justify-items: center; gap: 9px; overflow: hidden; transform: translate(-50%, -50%); pointer-events: none; text-align: center; border: 2px solid #fff0b5; border-radius: 15px; color: #3a290e; background: linear-gradient(145deg, #fff2be, #ffda75 52%, #e9ae41); box-shadow: 0 0 0 5px #ffe4a12e, 0 0 70px #ffdf8a80, 0 15px 35px #10241070; animation: payout-arrive .65s cubic-bezier(.16, 1, .3, 1) both; }
.payout-flash > * { position: relative; z-index: 1; }
.payout-flash::before { content: ''; position: absolute; inset: 5px; border: 1px solid #fff8d9a6; border-radius: 9px; pointer-events: none; }
.payout-flash::after { content: ''; position: absolute; inset: -10%; pointer-events: none; background: linear-gradient(115deg, transparent 30%, #fffbeab3 49%, transparent 65%); animation: payout-shine .85s .5s ease-out both; }
.payout-kicker { display: flex; align-items: center; justify-content: center; gap: 8px; color: #644311; font-size: 15px; font-weight: 800; line-height: 1.2; letter-spacing: 3px; animation: reward-copy .4s .08s ease-out both; }
.payout-kicker svg { width: 23px; height: 23px; stroke-width: 2; }
.payout-value { color: #39250b; font: 800 96px/.95 var(--number); font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 #fff4c6b3; white-space: nowrap; animation: reward-amount .6s .12s cubic-bezier(.16, 1, .3, 1) both; }
.payout-value small { display: block; margin-top: 6px; color: #72501b; font: 700 14px/1 var(--number); letter-spacing: 3px; text-shadow: none; }
.payout-detail { display: block; color: #62471c; font-size: 12px; line-height: 1.4; font-weight: 700; letter-spacing: .6px; white-space: nowrap; animation: reward-copy .4s .28s ease-out both; }

.is-racing .horse-body { animation: gallop-body .36s ease-in-out infinite; }
.is-racing .horse-rider { animation: jockey-bounce .36s ease-in-out infinite; }
.is-racing .leg-front-near { animation: leg-front .36s ease-in-out infinite; }
.is-racing .leg-front-far { animation: leg-front .36s ease-in-out -.18s infinite; }
.is-racing .leg-back-near { animation: leg-back .36s ease-in-out infinite; }
.is-racing .leg-back-far { animation: leg-back .36s ease-in-out -.18s infinite; }
.is-racing .horse-tail { animation: tail-wave .36s ease-in-out infinite; }
.is-racing .runner-dust { animation: dust .36s ease-out infinite; }
@keyframes gallop-body { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-1deg); } }
@keyframes jockey-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes leg-front { 0%, 100% { transform: rotate(-23deg); } 50% { transform: rotate(28deg); } }
@keyframes leg-back { 0%, 100% { transform: rotate(27deg); } 50% { transform: rotate(-25deg); } }
@keyframes tail-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-9deg); } }
@keyframes dust { from { opacity: .6; transform: translate(10px, -1px) scale(.6); } to { opacity: 0; transform: translate(-22px, -5px) scale(1.6); } }
@keyframes count-pop { from { transform: scale(1.25); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@keyframes confetti-fall { 0% { opacity: 1; } 75% { opacity: 1; } 100% { top: 112%; transform: translateX(var(--drift, 40px)) rotate(calc(var(--rot, 0deg) + 540deg)); opacity: 0; } }
@keyframes balance-credit { 0%, 25% { color: #ffe298; background: #ffe1a126; box-shadow: 0 0 0 5px #ffe1a112, 0 0 25px #ffd98755; text-shadow: 0 0 16px #ffd98699; } 100% { color: #f4f5eb; background: transparent; box-shadow: 0 0 0 0 transparent; text-shadow: none; } }
@keyframes balance-number { 0% { scale: .9; } 40% { scale: 1.13; } 100% { scale: 1; } }
@keyframes payout-arrive { 0% { opacity: 0; scale: .65; rotate: -3deg; } 65% { opacity: 1; scale: 1.055; rotate: 1deg; } 100% { opacity: 1; scale: 1; rotate: 0deg; } }
@keyframes reward-amount { 0% { opacity: 0; scale: .6; translate: 0 10px; } 65% { opacity: 1; scale: 1.08; translate: 0 -2px; } 100% { opacity: 1; scale: 1; translate: 0 0; } }
@keyframes reward-copy { from { opacity: 0; translate: 0 7px; } to { opacity: 1; translate: 0 0; } }
@keyframes payout-shine { from { transform: translateX(-110%); opacity: 0; } 20% { opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
@keyframes course-reward { 0% { opacity: 0; } 15% { opacity: 1; } 40% { opacity: .62; } 100% { opacity: 0; } }

@media (max-width: 700px) {
  .app-header { height: 52px; padding: 0 10px; gap: 9px; }
  .brand { gap: 6px; font-size: 22px; letter-spacing: .6px; }
  .brand-mark { width: 25px; height: 28px; }
  .brand-mark svg { width: 21px; height: 21px; }
  .app-header nav { gap: 2px; }
  .app-header nav button { width: 28px; height: 30px; }
  .app-header nav svg { width: 18px; height: 18px; }
  .wallet { gap: 5px; }
  .balance-button { width: 84px; }
  .balance-button strong { font-size: 29px; }
  .wallet > .icon-button { width: 26px; height: 26px; }
  main { height: calc(100vh - 52px - env(safe-area-inset-top, 0px)); height: calc(100svh - 52px - env(safe-area-inset-top, 0px)); min-height: 490px; padding: 8px 10px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 5px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 92px 118px; gap: 8px; }
  .race-panel { grid-column: 1; grid-row: 1; border-radius: 8px; }
  .race-toolbar { padding: 0 10px; }
  .race-tools { gap: 5px; }
  .running-space { left: 42px; right: 24px; --horse-width: clamp(82px, 13svh, 118px); }
  .lane-number { left: 8px; width: 25px; height: 25px; }
  .start-line { left: calc(42px + clamp(82px, 13svh, 118px) * .9); }
  .finish-line { right: 24px; width: 10px; background-size: 10px 10px; }
  .finish-line > span { right: 15px; }
  .runner-label { left: 17px; top: -2px; padding: 1px 4px; font-size: 12px; }
  .runner-rank { width: 19px; height: 19px; right: -4px; font-size: 14px; }
  .distance-hud { top: 5px; right: 8px; padding: 2px 6px; }
  .distance-hud strong { font-size: 21px; }
  .race-caption { padding: 0 9px; font-size: 12px; }
  .result-copy strong { font-size: 12px; }
  .result-copy small { display: none; }
  .result-amount { font-size: 22px; }
  .horse-selection { grid-column: 1; grid-row: 2; }
  .horse-cards { gap: 6px; }
  .horse-card { border-radius: 6px; }
  .horse-card-number { top: 6px; left: 7px; font-size: 14px; }
  .horse-card-art { top: 6px; bottom: 43px; left: 0; right: 0; }
  .horse-card h3 { bottom: 25px; left: 6px; right: 6px; font-size: 16px; text-align: center; }
  .card-check { top: 6px; right: 6px; width: 12px; height: 12px; }
  .card-check svg { width: 8px; height: 8px; }
  .horse-card-bottom { left: 0; right: 0; bottom: 3px; text-align: center; }
  .horse-card-bottom strong { font-size: 20px; }
  .horse-card-bottom small { font-size: 12px; margin-left: 1px; }
  .bet-panel { grid-column: 1; grid-row: 3; padding: 8px; grid-template-rows: 16px 36px 22px 14px; }
  .return-total strong { font-size: 26px; }
  .amount-input input { font-size: 32px; }
  .stake-shortcuts button { font-size: 14px; }
  .toast { top: 57px; }
  .payout-flash { width: min(320px, calc(100% - 28px)); padding: 17px 20px 15px; gap: 8px; }
  .payout-value { font-size: 64px; }
  .payout-kicker { font-size: 14px; letter-spacing: 2.5px; }
  footer { height: 14px; }
}
@media (max-width: 359px) {
  .app-header { gap: 6px; padding: 0 8px; }
  .brand { font-size: 21px; letter-spacing: .3px; }
  .brand-mark { display: none; }
  .balance-button { width: 84px; }
  .horse-card h3 { left: 6px; font-size: 14px; }
  .horse-card-bottom { right: 0; }
  .horse-card-bottom strong { font-size: 18px; }
  .amount-input svg { display: none; }
  .start-button { gap: 4px; padding: 0 5px; }
  .amount-input svg { display: none; }
  .amount-input input { font-size: 30px; }
  .recent-races { gap: 6px; }
  .payout-flash { padding: 15px 16px 13px; }
  .payout-value { font-size: 54px; }
}
/* Keep the full game usable on small phones; shorter screens scroll naturally. */
@media (max-width: 700px) and (max-height: 650px) {
  main { padding-top: 6px; gap: 4px; }
  .play-layout { grid-template-rows: minmax(0, 1fr) 84px 112px; }
  .race-toolbar { height: 30px; }
  .race-caption { height: 28px; }
  .stadium { height: 32px; }
  .grandstand { height: 27px; }
  .stand-crowd { height: 16px; }
  .field-edge { height: 12px; }
  .track { padding: 4px 0; }
  .running-space { --horse-width: 74px; }
  .start-line { left: 109px; }
  .runner-label { display: none; }
  .bet-panel { padding: 5px 8px; }
  footer { height: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
  .runner { will-change: auto; }
  .race-scene.is-celebrating::before { opacity: .55; }
  .balance-button.crediting { color: #ffe298; background: #ffe1a126; box-shadow: 0 0 0 3px #ffe1a126; }
}
