:root {
  --green: #0f3d2e; --green2: #16523e; --green3: #1f6b51; --cream: #f4ecd8; --paper: #fbf6ea; --ink: #1d1a14;
  --muted: #7a7062; --gold: #c9a227; --gold2: #e8c65a; --red: #b3261e; --ok: #2e7d32; --warn: #b26a00; --line: #e2d7bd;
  --shadow: 0 2px 10px rgba(20, 15, 5, .12); --r: 14px;
  --head: 'Oswald', 'Arial Narrow', sans-serif; --body: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--green); color: var(--ink); font-family: var(--body); font-size: 15px; }
body { overscroll-behavior: none; }
button { font: inherit; cursor: pointer; border: 0; }
input, select { font: inherit; }
h1, h2, h3, .head { font-family: var(--head); letter-spacing: .02em; margin: 0; font-weight: 600; }

#app { max-width: 720px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; background: var(--cream); position: relative; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--green); color: #fff; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.brand { font-family: var(--head); font-size: 22px; letter-spacing: .08em; color: var(--gold2); display: flex; align-items: center; gap: 8px; }
.brand small { color: #cfe3d8; font-size: 10px; letter-spacing: .14em; display: block; line-height: 1; }
.wallet { margin-left: auto; display: flex; gap: 6px; }
.chip { background: rgba(255,255,255,.12); border-radius: 20px; padding: 6px 10px; font-weight: 700; font-size: 14px; display: flex; gap: 5px; align-items: center; color: #fff; }
.chip.neg { background: var(--red); }
.chip.tok { color: var(--gold2); }
main { flex: 1; padding: 14px 14px 100px; }
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px; z-index: 30; background: #fff;
  display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { background: none; padding: 8px 0 9px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 600; }
.nav button .i { font-size: 21px; filter: grayscale(.6); }
.nav button.on { color: var(--green); }
.nav button.on .i { filter: none; }

.card { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.dark { background: var(--green2); color: #fff; border-color: transparent; }
.card.gold { background: linear-gradient(135deg, #fff6d6, #f2dc93); border-color: #d9bd62; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.b { font-weight: 700; }
.center { text-align: center; }
.sp { height: 10px; }
.sec { font-family: var(--head); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--green3); margin: 18px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn { background: var(--green); color: #fff; padding: 11px 16px; border-radius: 11px; font-weight: 700; font-size: 14.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.gold { background: var(--gold); color: #241b00; }
.btn.red { background: var(--red); }
.btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green3); }
.btn.light { background: #fff; color: var(--green); border: 1px solid var(--line); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 700; background: #ece3cc; color: var(--ink); }
.pill.ok { background: #dcefdc; color: var(--ok); }
.pill.warn { background: #fbe7c8; color: var(--warn); }
.pill.gold { background: #f5e2a0; color: #6a5100; }
.pill.red { background: #f7d6d3; color: var(--red); }
.pill.muted { background: #e8e3d8; color: var(--muted); }
.style { font-family: var(--head); font-size: 12px; background: var(--ink); color: #fff; border-radius: 5px; padding: 1px 5px; letter-spacing: .04em; }

.bar { height: 7px; background: #e7dcc2; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green3); border-radius: 4px; }
.bar.f i { background: var(--warn); }
.stat { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; margin: 5px 0; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; }

.horse { display: flex; gap: 12px; align-items: center; }
.silk { flex: none; width: 40px; height: 40px; }
.hname { font-family: var(--head); font-size: 18px; line-height: 1.1; }

.saddle { flex: none; width: 30px; height: 30px; border-radius: 6px; font-family: var(--head); font-weight: 700; font-size: 17px; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.25); }
.entry { padding: 10px 0; border-top: 1px dashed var(--line); }
.entry:first-child { border-top: 0; }
.entry.mine { background: #fff4cf; margin: 0 -14px; padding: 10px 14px; }
.odds { font-family: var(--head); font-size: 18px; min-width: 52px; text-align: right; }
.pp { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.pp td, .pp th { padding: 3px 3px; border-bottom: 1px solid #eee3c8; text-align: left; white-space: nowrap; }
.pp th { color: var(--muted); font-weight: 600; font-size: 10.5px; }
.pp .fig { font-weight: 800; }
.ppwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.racerow { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.racerow:first-child { border-top: 0; }
.rnum { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--green); color: #fff; font-family: var(--head); font-size: 18px; display: grid; place-items: center; }
.rnum.done { background: #b8ad95; }
.rnum.next { background: var(--gold); color: #2a1f00; }

.sheet-bg { position: fixed; inset: 0; background: rgba(10, 20, 15, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--cream); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .grab { width: 44px; height: 5px; background: #cfc3a6; border-radius: 3px; margin: -6px auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.tabs button { flex: none; background: #fff; border: 1px solid var(--line); padding: 7px 11px; border-radius: 20px; font-weight: 700; font-size: 13px; color: var(--ink); }
.tabs button.on { background: var(--green); color: #fff; border-color: var(--green); }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: #fff; border: 2px solid transparent; margin-bottom: 6px; cursor: pointer; }
.pick.on { border-color: var(--gold); background: #fffaea; }
.pick.dis { opacity: .5; }
.amounts { display: flex; gap: 6px; flex-wrap: wrap; }
.amounts button { background: #fff; border: 1px solid var(--line); padding: 8px 12px; border-radius: 9px; font-weight: 700; }
.amounts button.on { background: var(--gold); border-color: var(--gold); }
.input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid #d3c6a7; background: #fff; font-size: 16px; }

.toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: #1d1a14; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 90;
  font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 92vw; animation: up .2s; }

/* race view */
#raceview { position: fixed; inset: 0; z-index: 70; background: #0a1a12; display: flex; flex-direction: column; color: #fff; }
#raceview .rv-top { padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; display: flex; align-items: center; gap: 10px; font-family: var(--head); }
#raceview canvas { width: 100%; height: clamp(260px, 80vw, 540px); flex: none; display: block; }
.rv-list { flex: 1; overflow-y: auto; padding: 6px 12px; font-size: 14px; }
.rv-list .r { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.rv-list .r.me { color: var(--gold2); font-weight: 700; }
.rv-list .gap { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .8; }
.rv-board { display: flex; gap: 3px; overflow: hidden; padding: 0 12px 6px; }
.rv-board .saddle { width: 24px; height: 24px; font-size: 13px; transition: transform .3s; }
.rv-call { min-height: 54px; padding: 8px 14px; font-size: 16px; background: rgba(0,0,0,.5); font-weight: 700; display: flex; align-items: center; border-left: 4px solid var(--gold2); flex: none; }
.rv-call.flash { animation: rvflash .9s ease-out; }
@keyframes rvflash { 0% { background: rgba(242,201,76,.55); color: #1a1405; } 100% { background: rgba(0,0,0,.5); color: #fff; } }
.rv-stage { position: relative; flex: none; }
.rv-moment { position: absolute; left: 0; right: 0; top: 16%; display: flex; justify-content: center; pointer-events: none; z-index: 2; }
.rv-m { background: rgba(6,12,20,.78); border: 2px solid rgba(255,255,255,.25); border-radius: 14px; padding: 8px 18px 9px; text-align: center; max-width: 88%; opacity: 0; transform: scale(.7); transition: opacity .25s, transform .35s cubic-bezier(.2,1.6,.4,1); }
.rv-m.on { opacity: 1; transform: scale(1); }
.rv-m.gold { border-color: var(--gold2); box-shadow: 0 0 18px rgba(242,201,76,.45); }
.rv-m b { display: block; font: 700 clamp(22px, 7vw, 34px) Oswald, 'Arial Narrow', sans-serif; letter-spacing: .03em; color: var(--gold2); line-height: 1.1; }
.rv-m span { display: block; font-size: 13px; font-weight: 600; margin-top: 3px; color: #fff; }
.rv-live { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; background: rgba(255,255,255,.06); flex: none; min-height: 34px; overflow: hidden; white-space: nowrap; }
.rv-live .lbl { font: 700 11px Oswald, sans-serif; letter-spacing: .06em; background: var(--gold2); color: #1a1405; border-radius: 5px; padding: 1px 5px; }
.rv-live .lbl.you { margin-left: auto; background: #ffd400; }
.rv-live .nm { max-width: 32vw; font-weight: 700; }
.rv-live .gp { font-variant-numeric: tabular-nums; font-weight: 700; }
.rv-live .saddle { width: 20px; height: 20px; font-size: 11px; }
.rv-ctl { display: flex; gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.rv-ctl .btn { flex: 1; }
.clock { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 18px; color: var(--gold2); }

.result td { padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.result { width: 100%; border-collapse: collapse; }
.payoff { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.payoff td { padding: 5px 4px; border-bottom: 1px dashed var(--line); }
.payoff td.n { text-align: right; font-weight: 700; }
.big { font-family: var(--head); font-size: 30px; }
.win-flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #ffe58a; } 100% { background: var(--paper); } }

.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #d8ccb0; display: block; }
.dots i.on { background: var(--gold); box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.wbtn { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 8px 6px; text-align: center; font-size: 12px; font-weight: 700; color: var(--ink); }
.wbtn .i { font-size: 20px; display: block; }
.wgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }

.hero { background: radial-gradient(120% 90% at 50% 0%, #1f6b51 0%, #0f3d2e 60%); color: #fff; border-radius: 0 0 26px 26px; margin: -14px -14px 14px; padding: 28px 18px 22px; text-align: center; }
.hero h1 { font-size: 44px; color: var(--gold2); letter-spacing: .1em; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0,0,0,.2); }
.swatches button.on { outline: 3px solid var(--gold); outline-offset: 1px; }
.lot.select { border: 2px solid var(--gold); }
.price { font-family: var(--head); font-size: 20px; }
a { color: var(--green3); }

.rv-photo { position: absolute; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,.72); padding: 10px; gap: 8px; animation: fade .4s; z-index: 2; }
.rv-photo img { max-width: 100%; max-height: 82%; border: 3px solid #fff; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
.rv-photo div { font-family: var(--head); font-size: 18px; color: var(--gold2); }
#raceview { position: fixed; }

.result { table-layout: fixed; }
.result td:nth-child(1) { width: 22px; } .result td:nth-child(2) { width: 36px; } .result td:nth-child(4) { width: 44px; }
.result td:nth-child(5) { width: 46px; } .result td:nth-child(6) { width: 34px; }
.result td.nm { overflow: hidden; } .result td.nm .ell { display: block; }
.tabs { flex-wrap: wrap; overflow: visible; }
.gl dt { font-weight: 700; margin-top: 10px; } .gl dd { margin: 2px 0 0; color: var(--ink); font-size: 14px; }

/* 1.5 */
.monthbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 10px 0; }
.monthbar button { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; font-size: 12px; font-weight: 700; color: var(--green); }
.monthbar button.now { border-color: var(--gold); }
.monthbar button.on { background: var(--green); color: #fff; }
.racerow.past { opacity: .7; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.quick button { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 4px; font-weight: 700; font-size: 13px; color: var(--green); display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow); }
.quick button span { font-size: 22px; }
.quick button small { font-weight: 500; font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.2; }
.bigday { margin-top: 10px; background: linear-gradient(90deg, #8e1b1b, #c62828); color: #fff; font-family: var(--head); letter-spacing: .04em; padding: 8px 10px; border-radius: 9px; font-size: 14px; }
.card.dark.major { background: linear-gradient(135deg, #5a0f12, #8e1b1b 60%, #0f3d2e); }
.eqc { font-size: 9px; font-weight: 800; color: var(--red); }
.wnav { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.wnav button { background: rgba(255,255,255,.14); color: #fff; border-radius: 9px; padding: 7px 9px; font-weight: 700; font-size: 12.5px; }
.card.bign { background: linear-gradient(135deg, #3b0b0e, #8e1b1b); color: #fff; border-color: transparent; }
.rv-replay { position: absolute; top: 96px; right: 10px; z-index: 3; background: rgba(0,0,0,.55); color: var(--gold2); font: 600 11px var(--head); letter-spacing: .14em; padding: 3px 10px; border-radius: 10px; }
.wbtn:disabled { opacity: .45; }
.regpick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.regpick button { background: rgba(255,255,255,.12); color: #fff; border-radius: 10px; padding: 8px 6px; border: 2px solid transparent; font-size: 13px; }
.regpick button small { display: block; font-size: 10.5px; opacity: .8; line-height: 1.25; margin-top: 2px; }
.regpick button.on { border-color: var(--gold2); background: rgba(232,198,90,.18); }

/* survey */
.svstars { display: flex; justify-content: center; gap: 6px; margin: 10px 0 2px; }
.svstar { font-size: 38px; line-height: 1; background: none; border: 0; color: #d9cfb6; cursor: pointer; padding: 2px 4px; }
.svstar.on { color: var(--gold); text-shadow: 0 1px 0 rgba(0,0,0,.15); }
textarea.input { resize: vertical; font-family: inherit; }

/* cover screen */
#cover { position: fixed; inset: 0; z-index: 200; background: #0f1d3a; color: #fff; overflow: hidden; transition: opacity .45s ease, transform .45s ease; }
#cover.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
#cover canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cover .cv-top { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 5vh); text-align: center; padding: 0 16px; }
#cover .cv-pre { font: 600 11px/1 Inter, sans-serif; letter-spacing: .35em; color: #e8dcc0; opacity: .9; }
#cover .cv-logo { font: 700 clamp(50px, 15vw, 92px)/1 Oswald, 'Arial Narrow', sans-serif; letter-spacing: .05em; margin-top: 10px; white-space: nowrap;
  background: linear-gradient(180deg, #fff6cf 0%, #f2c94c 45%, #b8861b 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 rgba(60,30,0,.55)) drop-shadow(0 10px 22px rgba(0,0,0,.55)); animation: cvIn .9s ease-out both; }
#cover .cv-tag { margin-top: 10px; font: 600 15px/1.35 Inter, sans-serif; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.7); animation: cvIn 1.1s .2s ease-out both; }
#cover .cv-bot { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5vh); text-align: center; padding: 0 28px; animation: cvIn 1s .5s ease-out both; }
#cover .cv-go { width: 100%; max-width: 360px; font: 700 19px/1 Oswald, sans-serif; letter-spacing: .08em; padding: 18px 0; border-radius: 16px; box-shadow: 0 8px 26px rgba(0,0,0,.45), 0 0 0 2px rgba(255,240,190,.35) inset; animation: cvPulse 2.2s 1.6s ease-in-out infinite; }
#cover .cv-small { margin-top: 10px; font: 600 13px Inter, sans-serif; color: #f4ead0; text-shadow: 0 1px 6px rgba(0,0,0,.8); }
@keyframes cvIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes cvPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
img.trophy { vertical-align: middle; }
.hero-img { display: block; width: calc(100% + 36px); margin: 16px -18px -22px; height: 150px; object-fit: cover; object-position: center 78%; border-radius: 0 0 26px 26px; }
.style-card { padding: 10px 12px; }
.traits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.trait { font: 600 12px/1 var(--body); background: #f3ecd8; color: #4a3a12; border: 1px solid #e2d3a6; border-radius: 999px; padding: 5px 9px; }
.regpick.ng button { background: #f3ecd8; color: var(--ink); border-color: #e2d3a6; }
.regpick.ng button.on { background: #fff4cf; border-color: var(--gold); }
.card.ws { background: linear-gradient(135deg, #0d2a52, #1b4f8a); color: #fff; border: 1px solid rgba(242,201,76,.5); }
.help { border-top: 1px solid var(--line); }
.helpq { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: 0; padding: 12px 2px; font: 700 15px/1.2 var(--body); color: var(--ink); text-align: left; }
.helpq span { font-size: 20px; color: var(--gold); }
.help.on .helpq { color: var(--green3, #1d5a39); }
.helpa { padding: 0 2px 10px; }
.helpa p { margin: 0 0 8px; }

/* walk-through tips (guide.js) */
#guide { position: fixed; inset: 0; z-index: 65; pointer-events: none; }
#guide .g-dim { position: fixed; inset: 0; background: rgba(10,20,15,.5); }
#guide .g-ring { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(10,20,15,.55), 0 0 0 3px var(--gold2, #e3b54d); transition: all .2s; }
#guide .g-tip { position: fixed; left: 50%; transform: translateX(-50%); width: min(320px, calc(100% - 32px)); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; background: #fffdf7; color: #1d1a14; border-radius: 16px; padding: 14px 16px 12px; box-shadow: 0 12px 34px rgba(0,0,0,.35); pointer-events: auto; animation: fade .2s; }
#guide .g-t { font-weight: 800; font-size: 16px; padding-right: 26px; }
#guide .g-b { font-size: 14px; line-height: 1.45; padding-right: 28px; }
#guide .g-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#guide .g-skip { font-size: 12px; color: #8a8270; }
#guide .g-x { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #efe9da; color: #5a5240; font-size: 15px; cursor: pointer; }
/* cross-promotion: our boxing game Title Shot (green accent) */
.card.xpromo { border: 1.5px solid #22c55e; border-left: 5px solid #16a34a; background: linear-gradient(135deg, #f0fdf4, #ffffff); }
a.btn { text-decoration: none; }
.btn.xpgo { background: #16a34a; color: #fff; }
/* horse flags (1.12.1) */
.flg { display: inline-block; width: 1.25em; height: .94em; vertical-align: -.08em; margin-right: .3em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.18); object-fit: cover; }
.flg.big { width: 1.5em; height: 1.12em; }
