/* BOPSC on a Boat: "Turf by Day". Light, high-contrast day mode by default on the water; turf-at-night for evenings. */
:root {
  --bg: #f7f4ec; --surface: #ffffff; --surface-2: #efeadc;
  --text: #141210; --muted: #4a4a44; --faint: #8a877c; --rule: #d9d3c2;
  --green: #12392c; --green-text: #f6f1e4;
  --amber: #f2b632; --amber-text: #8a5b00; --on-amber: #141210;
  --good: #1c6b3e; --bad: #b3202a; --warn: #8a5b00;
  --brew: #b3202a; --oggie: #1f3fa8; --proko: #1c6b3e; --scopes: #f07a1a; --clarke: #0f6e73;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --tab-h: 64px;
  color-scheme: light;
}
:root[data-theme="night"] {
  --bg: #0d1f19; --surface: #12392c; --surface-2: #18493a;
  --text: #f6f1e4; --muted: rgba(246,241,228,.72); --faint: rgba(246,241,228,.45); --rule: rgba(246,241,228,.18);
  --green: #12392c; --amber-text: #f2b632; --good: #6fd08c; --bad: #ff8a7a; --warn: #f2b632;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); height: 100%; }
/* App frame: header on top, tab bar on the bottom, only the middle scrolls. */
body { font-family: var(--body); font-size: 17px; font-weight: 500; line-height: 1.35; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.scroller { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.silk { width: 32px; height: 32px; flex: none; }

/* header */
.top { flex: none; position: relative; z-index: 5; background: var(--green); color: var(--green-text); padding-top: env(safe-area-inset-top, 0px); }
.top-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: flex-end; gap: 8px; text-decoration: none; color: inherit; flex: none; }
.top-right { flex: 0 1 auto; min-width: 0; }
.who { min-width: 0; }
.who span { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 440px) { .subtxt { display: none; } .icon { width: 44px; height: 44px; } .top-in { gap: 6px; } .who { padding-right: 10px; } }
.mark { height: 34px; width: auto; display: block; }
.mark-text { font-family: var(--display); font-weight: 900; letter-spacing: -0.01em; }
.sub { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .08em; display: inline-flex; align-items: center; gap: 5px; padding-bottom: 3px; white-space: nowrap; }
.bigmark { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto 6px; }
.flag { width: 20px; height: 15px; }
.top-right { display: flex; align-items: center; gap: 6px; }
.who { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px 0 6px; border-radius: 999px; background: rgba(246,241,228,.12); color: inherit; font-weight: 700; font-size: 15px; white-space: nowrap; }
.who .silk { width: 36px; height: 36px; }
.icon { width: 48px; height: 48px; border-radius: 50%; font-size: 22px; color: inherit; background: rgba(246,241,228,.08); }
.strip { font-size: 14px; font-weight: 600; text-align: center; padding: 8px 16px; background: var(--amber); color: var(--on-amber); }
.strip.bad { background: var(--bad); color: #fff; }
.strip button { text-decoration: underline; font-weight: 700; margin-left: 8px; }

/* bottom tabs */
.tabs { flex: none; position: relative; z-index: 6; height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--green); display: flex; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: rgba(246,241,228,.7); text-decoration: none; font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.tab[aria-current="page"] { color: var(--amber); }
.tab-ic { font-size: 20px; line-height: 1; }

/* generic blocks */
.view { padding-block: 14px 24px; display: grid; gap: 14px; align-content: start; }
.eyebrow { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card { background: var(--surface); border-radius: 12px; padding: 14px; border: 1px solid var(--rule); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 18px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 17px; border: 1px solid var(--rule); }
.btn.primary { background: var(--amber); color: var(--on-amber); border-color: var(--amber); min-height: 64px; font-size: 19px; width: 100%; }
.btn.green { background: var(--green); color: var(--green-text); border-color: var(--green); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { min-height: 44px; font-size: 15px; padding: 0 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.msg { font-weight: 600; color: var(--amber-text); min-height: 1.3em; }
.msg.bad { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }

/* hero (my next race) */
.hero { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 16px; border-radius: 14px; background: var(--surface); border: 2px solid var(--c, var(--rule)); border-left-width: 10px; color: var(--text); }
.hero.mine { background: var(--amber); color: var(--on-amber); border-color: var(--amber); }
.hero .silk { width: 56px; height: 56px; }
.hero .lbl, .hero .what, .hero .pick, .race .where, .race .sel { display: block; }
.hero .lbl { font-family: var(--mono); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.hero .what { font-family: var(--display); font-weight: 900; font-size: 32px; line-height: .95; text-transform: uppercase; margin-top: 2px; }
.hero .pick { font-size: 16px; margin-top: 6px; font-weight: 600; }
.hero .cd { font-family: var(--mono); font-weight: 700; font-size: 30px; font-variant-numeric: tabular-nums; grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid rgba(0,0,0,.12); padding-top: 8px; margin-top: 4px; }
.hero .cd small { font-size: 14px; font-family: var(--body); font-weight: 600; opacity: .75; }
.hero .cd.soon { color: var(--bad); }
.hero.mine .cd.soon { color: #7a0d14; }

/* race rows */
.list { display: grid; gap: 8px; }
.race { display: grid; grid-template-columns: 58px 34px 1fr auto; gap: 10px; align-items: center; width: 100%; min-height: 64px; text-align: left; padding: 8px 12px 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--rule); border-left: 8px solid var(--c); color: var(--text); }
.race.jumped { opacity: .62; }
.race.is-next { border-color: var(--amber); border-left-color: var(--c); opacity: 1; box-shadow: 0 0 0 2px var(--amber) inset; }
.race .t { font-family: var(--mono); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.race .t small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.race .silk { width: 34px; height: 34px; }
.race .body { min-width: 0; }
.race .where { font-weight: 800; font-size: 16px; }
.race .where span { font-weight: 500; color: var(--muted); font-size: 13px; }
.race .sel { font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race .sel.has { color: var(--text); font-weight: 600; }
.tag { font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 5px 8px; border-radius: 6px; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.tag.none { border: 2px dashed var(--faint); color: var(--muted); }
.tag.in { background: var(--surface-2); color: var(--text); }
.tag.won { background: var(--good); color: #fff; }
.tag.lost { background: rgba(179,32,42,.12); color: var(--bad); }
.tag.late { background: var(--bad); color: #fff; }
.tag.abd { background: var(--faint); color: #fff; }
.tag.pending { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--faint); }
:root[data-theme="night"] .tag.lost { background: rgba(255,138,122,.18); }
.tag .tick { margin-right: 3px; }

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 8px; border-radius: 999px; border: 2px solid var(--rule); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 700; }
.chip.all { padding-left: 14px; }
.chip[aria-pressed="true"] { background: var(--green); color: var(--green-text); border-color: var(--green); }
.chip .silk { width: 26px; height: 26px; }

/* ladder */
.rung { display: grid; grid-template-columns: 30px 44px minmax(0, 1fr) max-content; gap: 10px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--rule); border-left: 8px solid var(--c); }
.rung > div { min-width: 0; }
.rung .pos { font-family: var(--display); font-weight: 900; font-size: 30px; color: var(--faint); text-align: center; }
.rung:first-child .pos { color: var(--amber-text); }
.rung .silk { width: 44px; height: 44px; }
.rung .name { font-weight: 800; font-size: 18px; }
.rung .sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.rung .net { font-family: var(--mono); font-weight: 700; font-size: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.rung .net small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.rung .sub { overflow-wrap: anywhere; white-space: normal; display: block; letter-spacing: normal; font-family: inherit; padding-bottom: 0; }
.pos-good { color: var(--good); } .pos-bad { color: var(--bad); }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.totals div { padding: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--rule); }
.totals dt { font-family: var(--mono); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.totals dd { margin-top: 2px; font-family: var(--mono); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }

/* sheet */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(13,31,25,.6); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 94%; overflow-y: auto; background: var(--bg); border-top: 6px solid var(--c, var(--amber)); border-radius: 18px 18px 0 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 0; }
.sheet-in { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }
.sheet-head { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; }
.sheet-head .silk { width: 52px; height: 52px; }
.sheet-head h2 { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1; text-transform: uppercase; }
.sheet-head p { font-size: 15px; color: var(--muted); font-weight: 600; }
.sheet-head .cd { font-family: var(--mono); font-weight: 700; font-size: 22px; text-align: right; }
.sheet-head .cd.soon { color: var(--bad); }
.horses { display: grid; grid-auto-rows: max-content; gap: 8px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.horse { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; min-height: 64px; padding: 6px 10px 6px 6px; border-radius: 10px; background: var(--surface); border: 2px solid var(--rule); text-align: left; color: var(--text); }
.horse .no { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 26px; background: var(--surface-2); }
.horse .nm { font-weight: 800; font-size: 17px; }
.horse .jk { font-size: 13px; color: var(--muted); font-weight: 600; }
.horse .br { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.horse[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.horse[aria-pressed="true"] .no { background: var(--c); color: #fff; }
.horse.scr { opacity: .45; text-decoration: line-through; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .group-label { font-family: var(--mono); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.field input { width: 100%; min-height: 56px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--rule); background: var(--surface); font-size: 20px; font-weight: 600; }
.field input.mono { font-family: var(--mono); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { min-height: 48px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--rule); background: var(--surface); color: var(--text); font-size: 16px; font-weight: 700; flex: 1 1 auto; }
.seg button[aria-pressed="true"] { background: var(--green); color: var(--green-text); border-color: var(--green); }
.seg.big button { min-height: 60px; font-size: 18px; }
.seg button.pl-1[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
:root[data-theme="night"] .seg button[aria-pressed="true"]:not(.pl-1), :root[data-theme="night"] .chip[aria-pressed="true"] { background: var(--amber); color: var(--on-amber); border-color: var(--amber); }
:root[data-theme="night"] .seg button.pl-1[aria-pressed="true"] { color: #0d1f19; }
.lockbar { position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.sheet-in > :last-child:not(.lockbar) { margin-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.fine { font-size: 13px; color: var(--muted); font-weight: 600; }
.official { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 15px; display: grid; gap: 4px; }
.official b { font-family: var(--mono); }

/* sign-in */
.silkgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.silkgrid button { display: grid; justify-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px; background: var(--surface); border: 2px solid var(--rule); color: var(--text); font-weight: 800; font-size: 16px; }
.silkgrid button[aria-pressed="true"] { border-color: var(--amber); background: var(--amber); color: var(--on-amber); box-shadow: 0 0 0 3px var(--amber); }
.silkgrid .silk { width: 56px; height: 56px; }
.pin { display: flex; justify-content: center; gap: 16px; margin: 10px 0 14px; }
.pin span { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--amber-text); }
.pin span.on { background: var(--amber); border-color: var(--amber); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; width: 100%; }
.keypad button { min-height: 64px; border-radius: 12px; background: var(--surface); border: 2px solid var(--rule); color: var(--text); font-family: var(--mono); font-weight: 700; font-size: 28px; }
.keypad button.fn { font-family: var(--body); font-size: 16px; background: var(--surface-2); }
.keypad button:active, .keypad button.pressed { background: var(--amber); color: var(--on-amber); border-color: var(--amber); transform: scale(.94); }
.keypad button { transition: transform .08s ease-out, background-color .08s; }
.pin span { transition: background-color .1s, transform .1s; }
.pin span.on { transform: scale(1.15); }
.pin span.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
/* every tappable thing gets a visible press */
.btn:active, .seg button:active, .horse:active, .race:active, .hero:active, .chip:active, .silkgrid button:active { filter: brightness(.88); transform: scale(.985); }

/* admin */
.admin-grid { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 15px; }
textarea.log { width: 100%; min-height: 160px; font-family: var(--mono); font-size: 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 8px; }
input[type="date"] { min-height: 56px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--rule); background: var(--surface); font-size: 18px; }

@media (max-width: 380px) { .race { grid-template-columns: 52px 30px 1fr auto; gap: 8px; } .hero .what { font-size: 28px; } }

/* bet slip */
.seg.mode button { min-height: 44px; }
.slip-sum { display: grid; gap: 10px; }
.slip-sum .totals div { background: var(--surface-2); border: 0; }
.totals dd small { font-size: 14px; color: var(--muted); }
.warn { color: var(--warn); }
.meet { display: grid; gap: 8px; }
.meet-h { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 6px 2px 0; border-top: 4px solid var(--c); padding-top: 10px; }
.meet-h .silk { width: 34px; height: 34px; }
.meet-h b { display: block; font-size: 19px; font-weight: 800; }
.meet-h small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.meet-h .amt { font-family: var(--mono); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.slip { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 60px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 2px solid var(--rule); text-align: left; color: var(--text); }
.slip .rn { font-family: var(--mono); font-weight: 700; font-size: 17px; line-height: 1.1; }
.slip .rn small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.slip .what { min-width: 0; }
.slip .what b { display: block; font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
.slip .what small { display: block; font-size: 14px; color: var(--muted); font-weight: 600; }
.slip .what em { font-style: normal; color: var(--warn); font-weight: 800; }
.slip .stk { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.slip .stk i { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; font-style: normal; font-size: 18px; }
.slip.done { background: var(--surface-2); border-color: transparent; }
.slip.done .what b, .slip.done .rn { opacity: .55; }
.slip.done .stk { color: var(--muted); }
.slip.done .what b { text-decoration: line-through; }
.slip.done .stk i { background: var(--good); border-color: var(--good); color: #fff; }
:root[data-theme="night"] .slip.done .stk i { color: #0d1f19; }
.slip.changed { border-color: var(--amber); }
.slip.changed .stk i { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.slip.off { border-style: dashed; color: var(--muted); min-height: 48px; }
.slip.off .what { font-weight: 600; }

/* form guide in the pick sheet */
.horse .l10 { display: block; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: .02em; margin-top: 2px; }
.horse .l10:empty { display: none; }
.formx { margin: -4px 4px 4px; padding: 10px 12px; border-radius: 0 0 10px 10px; background: var(--surface-2); display: grid; gap: 10px; }
.formx:empty { display: none; }
.fstats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--mono); font-size: 13px; }
.fstats b { font-family: var(--sans, inherit); font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.fstarts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fstarts li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.fstarts .fp { font-family: var(--mono); font-weight: 700; font-size: 16px; line-height: 1.05; }
.fstarts .fp small, .fstarts .fd small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.fstarts .fd { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.fstarts .fd i { font-style: normal; color: var(--muted); }
.fstarts .fsp { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.fstarts li.won .fp { color: var(--good); }

/* Betfair odds */
.ainput { width: 100%; min-height: 56px; border-radius: 10px; border: 2px solid var(--rule); padding: 0 12px; background: var(--surface); color: var(--text); font-size: 17px; }
.horse .br { display: grid; justify-items: end; gap: 1px; }
.horse .od { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--text); }
.horse .od:empty, .horse .odp:empty { display: none; }
.horse .odp { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); }
#oddsnote { display: block; margin: 2px 0 6px; }
#oddsnote[hidden] { display: none; }
