:root {
  --bg: #F6F1EA;
  --card: #FFFFFF;
  --ink: #23161B;
  --muted: #7A6A70;
  --line: #EAE0D6;
  --soft: #F3EBE2;
  --brand: #4A1426;
  --brand-2: #6E2340;
  --gold: #D9A93A;
  --gold-ink: #3B2A06;
  --good: #1E7A4C;
  --good-bg: #E3F3EA;
  --bad: #B3261E;
  --bad-bg: #FBE5E3;
  --warn: #A86A00;
  --warn-bg: #FCF0D9;
  --blue: #2F6FA3;
  --blue-bg: #E2EEF8;
  --orange: #D2600A;
  --orange-bg: #FDEBDC;
  --shadow: 0 1px 2px rgba(35,22,27,.06), 0 6px 20px rgba(35,22,27,.06);
  --radius: 18px;
  --num: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #160C10; --card: #22151A; --ink: #F5ECEF; --muted: #B5A2A9; --line: #3A2930; --soft: #2C1C22;
    --brand: #2A0B16; --brand-2: #5A1C33; --gold: #E5B850; --gold-ink: #2A1E03;
    --good: #5CC98E; --good-bg: #173326; --bad: #FF8A80; --bad-bg: #3A1714; --warn: #F2B84B; --warn-bg: #3A2A0E;
    --blue: #6FB6F2; --blue-bg: #13283A; --orange: #FF9E52; --orange-bg: #3A2210;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #160C10; --card: #22151A; --ink: #F5ECEF; --muted: #B5A2A9; --line: #3A2930; --soft: #2C1C22;
  --brand: #2A0B16; --brand-2: #5A1C33; --gold: #E5B850; --gold-ink: #2A1E03;
  --good: #5CC98E; --good-bg: #173326; --bad: #FF8A80; --bad-bg: #3A1714; --warn: #F2B84B; --warn-bg: #3A2A0E;
  --blue: #6FB6F2; --blue-bg: #13283A; --orange: #FF9E52; --orange-bg: #3A2210;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff; padding: calc(env(safe-area-inset-top) + 12px) 16px 14px;
  display: flex; align-items: center; gap: 12px;
}
.top .logo { width: 34px; height: 34px; flex: none; }
.top .ttl { flex: 1; min-width: 0; }
.top .ttl b { display: block; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ttl span { font-size: 12.5px; opacity: .8; }
.top .live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.12); border-radius: 999px; padding: 5px 10px; }
.top .live i { width: 8px; height: 8px; border-radius: 50%; background: #6EE7A1; box-shadow: 0 0 0 0 rgba(110,231,161,.7); animation: pulse 2s infinite; }
.top .live.off i { background: #F59E9E; animation: none; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(110,231,161,.6); } 70% { box-shadow: 0 0 0 8px rgba(110,231,161,0); } 100% { box-shadow: 0 0 0 0 rgba(110,231,161,0); } }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ---------- identity ---------- */
.who { display: flex; gap: 12px; align-items: center; }
.bib { display: inline-grid; place-items: center; min-width: 46px; height: 38px; padding: 0 8px; border-radius: 11px; background: var(--brand-2); color: #fff; font: 700 22px/1 var(--num); flex: none; }
.bib.sm { min-width: 36px; height: 28px; font-size: 17px; border-radius: 8px; }
.who .nm { min-width: 0; flex: 1; }
.startc { padding: 12px 16px; }
.startc b { font-size: 15px; }
/* home: one list, a row per rider with small GPS / Vet Card squares on the right */
.rlist { display: flex; flex-direction: column; gap: 8px; }
.rrow { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 16px; padding: 8px; background: var(--card); }
.rmain { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 0; }
.rmain .nm { min-width: 0; flex: 1; }
.rmain .nm b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmain .nm > span:not(.chip) { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rmain .nm .chip { margin-top: 4px; }
.rbtns { display: flex; gap: 6px; flex: none; }
.sq.sm { width: 54px; height: 50px; border-radius: 12px; font-size: 10px; }
.sq.sm svg { width: 19px; height: 19px; }
.ph.sm { width: 46px; height: 46px; border-radius: 12px; }
.ph.sm.has { width: 52px; height: 52px; }
/* loops: one horizontal row per loop, scrolls sideways on phones */
.lwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
table.loops { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 13.5px; white-space: nowrap; }
table.loops th { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.loops td { padding: 10px; border-bottom: 1px solid var(--line); font: 700 16px/1.1 var(--num); }
table.loops td .chip { font-family: Inter, system-ui, sans-serif; }
table.loops .lp { position: sticky; left: 0; background: var(--card); z-index: 1; padding-left: 4px; }
table.loops td.lp { font-size: 18px; }
table.loops .lc { display: inline-block; width: 6px; height: 22px; border-radius: 3px; vertical-align: middle; margin-right: 8px; }
table.loops .car { font-style: normal; color: var(--muted); margin-left: 6px; display: inline-block; transition: transform .15s; }
table.loops tr.more { cursor: pointer; }
table.loops tr.more:hover td { background: var(--soft); }
table.loops tr.open .car { transform: rotate(90deg); }
table.loops td.hrc svg { width: 13px; height: 13px; color: var(--bad); margin-right: 3px; vertical-align: -1px; }
table.loops tr.open td { background: var(--soft); }
.ldet { margin-top: 10px; background: var(--soft); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.ldet .checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; margin-top: 6px; }
.ldet .checks div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }
/* loops: calm background and a plain, easy-to-read font */
:root { --loop-bg: #FBF7F0; --loop-alt: #F3ECE1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --loop-bg: #1E1317; --loop-alt: #281B21; } }
:root[data-theme="dark"] { --loop-bg: #1E1317; --loop-alt: #281B21; }
.lwrap { background: var(--loop-bg); border-radius: 14px; }
table.loops td { font: 600 15px/1.3 Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--ink); }
table.loops td.lp { font-size: 16px; font-weight: 700; }
table.loops .lp { background: var(--loop-bg); }
table.loops tbody tr:nth-child(even) td { background: var(--loop-alt); }
table.loops tbody tr.open td, table.loops tbody tr.more:hover td { background: var(--soft); }
.ldet { background: var(--loop-bg); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.45; }
/* phone: each loop is a card (no sideways swiping); the wide table stays for tablets and laptops */
/* loops are cards on every screen (phone, tablet, laptop): same look everywhere, no sideways swiping */
.lwrap, .lnote, .ldet.wide { display: none; }
.lcards { display: flex; flex-direction: column; gap: 10px; }
.lcard { background: var(--loop-bg); border: 1px solid var(--line); border-left: 6px solid var(--lc, #999); border-radius: 14px; padding: 10px 12px; }
.lcard.more { cursor: pointer; }
.lcard.open { background: var(--loop-alt); }
.lch { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.lch .lnum { font-weight: 800; font-size: 17px; color: var(--ink); }
.lch .lkm { font-size: 13px; color: var(--muted); }
.lch .chip { margin-left: auto; }
.lch .car { font-style: normal; color: var(--muted); font-size: 18px; transition: transform .15s; }
.lcard.open .lch .car { transform: rotate(90deg); }
.lgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.lgrid > div > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.lgrid > div > b { display: block; font: 700 16.5px/1.25 Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; color: var(--ink); }
.lgrid .hrv svg { width: 13px; height: 13px; color: var(--bad); margin-right: 3px; vertical-align: -1px; }
.lcard .ldet { margin-top: 10px; background: var(--card); }
@media (min-width: 560px) { .lgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* phone held sideways: little height, so the header stops sticking and the rider card gets compact */
@media (max-height: 500px) and (orientation: landscape) {
  .top { position: static; padding: calc(env(safe-area-inset-top) + 6px) 16px 6px; }
  .top .logo { width: 26px; height: 26px; }
  .top .ttl b { font-size: 15px; }
  main { padding-top: 8px; gap: 8px; }
  .card { padding: 10px 14px; }
  .ph.has { width: 52px; height: 52px; border-radius: 12px; }
  .hrow .side { flex-direction: row; }
  .sq { width: 60px; height: 52px; }
  .hmain .who + .who { margin-top: 6px !important; }
}
/* rider list: full names (two lines), bigger button labels */
.rmain .nm b { white-space: normal; overflow: visible; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.rmain .nm > span:not(.chip) { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.sq.sm { font-size: 11.5px; width: 56px; height: 54px; }
.sq.sm span { font-weight: 700; }
.who .nm b { white-space: normal; line-height: 1.25; }
table.loops th { font-size: 11.5px; }
/* rider and horse photo frames: always shown, an outline until a photo is added in the Library */
.ph.frame { width: 76px; height: 76px; border-radius: 16px; box-shadow: var(--shadow);
  background: var(--brand-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff' fill-opacity='.5'%3E%3Ccircle cx='12' cy='8' r='4.2'/%3E%3Cpath d='M3.5 22c0-4.8 3.8-7.6 8.5-7.6s8.5 2.8 8.5 7.6z'/%3E%3C/svg%3E") center 70% / 64% no-repeat; }
.ph.frame.horse { background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233B2A06' fill-opacity='.42'%3E%3Cpath d='M15.2 2.2l-1.3 2.6c-3.4.4-6.4 2.9-7.6 6.7L4 17.6l2.7 2.2 3.2-3.6 2.9.9.9 4.7h5.1l-.9-6.6c-.1-2.7-.9-4.6-2-5.9l.8-6.3z'/%3E%3C/svg%3E") center 65% / 66% no-repeat; }
.ph.frame b { position: absolute; left: 4px; bottom: 4px; font-size: 15px; background: var(--brand); border-radius: 7px; padding: 3px 6px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.ph.frame b:empty { display: none; }
@media (max-height: 500px) and (orientation: landscape) { .ph.frame { width: 56px; height: 56px; border-radius: 12px; } }
/* map: a modest size, with a corner button for full screen */
.mapwrap { position: relative; }
.mapwrap .map { height: 260px; }
.mapwrap .map.big { height: min(40vh, 300px); min-height: 220px; }
.mapwrap.full { position: fixed; inset: 0; z-index: 60; background: var(--bg); padding: calc(env(safe-area-inset-top) + 8px) 8px calc(env(safe-area-inset-bottom) + 8px); }
.mapwrap.full .map { height: 100% !important; min-height: 0; border-radius: 12px; }
html.mapfull, html.mapfull body { overflow: hidden; }
.mapbtn { position: absolute; left: 10px; bottom: 10px; z-index: 500; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 12px;
  padding: 9px 12px; background: var(--brand-2); color: #fff; font: 700 13px/1 Inter, system-ui, sans-serif; box-shadow: 0 2px 8px rgba(0,0,0,.35); cursor: pointer; }
.mapwrap.full .mapbtn { left: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); }
/* supervisor: photo frames are upload buttons */
.phup { position: relative; display: inline-block; cursor: pointer; flex: none; }
.phup > i { position: absolute; right: -6px; bottom: -6px; width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: var(--gold-ink);
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-style: normal; }
.phup > i svg { width: 16px; height: 16px; }
/* races: home button, calendar, race rows, entries and results */
.racesbtn { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; text-align: start; cursor: pointer; color: var(--ink); }
.racesbtn > svg { width: 30px; height: 30px; color: var(--gold); flex: none; }
.racesbtn span { flex: 1; min-width: 0; } .racesbtn b { display: block; font-size: 16px; } .racesbtn small { color: var(--muted); font-size: 13px; }
.racesbtn > i { font-style: normal; font-size: 22px; color: var(--muted); }
html[dir="rtl"] .racesbtn > i, html[dir="rtl"] .flipx svg { transform: scaleX(-1); display: inline-block; }
.flipx svg { transform: scaleX(-1); }
html[dir="rtl"] .flipx svg { transform: none; }
.cal .row b { font-size: 16px; }
.cgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.cgrid.wd span { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; }
.cgrid .cd { position: relative; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: 600 14.5px/1 Inter, system-ui, sans-serif; }
.cgrid .cd:disabled { color: var(--muted); opacity: .6; cursor: default; }
.cgrid .cd.has { background: var(--brand-2); color: #fff; cursor: pointer; }
.cgrid .cd.has i { position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--gold); }
.cgrid .cd.today { box-shadow: inset 0 0 0 2px var(--gold); }
.cgrid .cd.sel { background: var(--gold); color: var(--gold-ink); }
.races { display: flex; flex-direction: column; gap: 8px; }
.race-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: var(--loop-bg); }
.dbadge { flex: none; width: 52px; height: 56px; border-radius: 12px; background: var(--brand-2); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dbadge b { font: 800 22px/1 var(--num); } .dbadge span { font-size: 12px; opacity: .85; }
.rinfo { flex: 1; min-width: 0; } .rinfo b { display: block; font-size: 15px; } .rinfo span { display: block; font-size: 12.5px; color: var(--muted); margin: 2px 0 4px; }
.rbtns2 { display: flex; flex-direction: column; gap: 6px; flex: none; }
.elist { display: flex; flex-direction: column; gap: 8px; }
.erow { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: var(--loop-bg); }
.erow .bib { flex: none; }
.erow .rank { flex: none; width: 30px; text-align: center; font: 800 20px/1 var(--num); color: var(--gold); }
.enm { flex: 1; min-width: 0; } .enm b { display: block; font-size: 14.5px; overflow-wrap: anywhere; } .enm b.eh { margin-top: 4px; }
.enm span { display: block; font-size: 12.5px; color: var(--muted); }
.eres { flex: none; text-align: end; } .eres b { display: block; font: 700 16px/1.2 var(--num); } .eres span { font-size: 12px; color: var(--muted); }
.eres b.bad { color: var(--bad); }
.tvrun { text-align: center; } .tvrun span { display: block; font-size: clamp(11px, .8vw, 14px); opacity: .85; } .tvrun b { font: 800 clamp(20px, 2vw, 34px)/1 var(--num); }
/* printable page (#/print/...): white paper */
html.printmode, html.printmode body { background: #fff !important; color: #111; }
.paper { max-width: 1100px; margin: 0 auto; padding: 20px; background: #fff; color: #111; font-family: Inter, Tajawal, Arial, sans-serif; }
.paper .pbar { display: flex; gap: 8px; margin-bottom: 14px; }
.phead { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid #4A1426; padding-bottom: 10px; }
.phead img { height: 60px; width: auto; object-fit: contain; }
.phead div { flex: 1; text-align: center; } .phead b { display: block; font-size: 20px; } .phead span { font-size: 13px; color: #555; }
.paper h1 { font-size: 17px; letter-spacing: .04em; margin: 14px 0 10px; color: #4A1426; }
.ptab { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ptab th { background: #4A1426; color: #fff; text-align: start; padding: 6px 7px; font-size: 11.5px; }
.ptab td { border-bottom: 1px solid #ddd; padding: 6px 7px; vertical-align: top; }
.ptab tr:nth-child(even) td { background: #f7f3ee; }
.ptab tr.out td { color: #8a2a22; }
.pfoot { display: flex; justify-content: space-between; margin-top: 12px; font-size: 11px; color: #666; }
@media print { .noprint, #alerts, .toast { display: none !important; } .paper { padding: 0; max-width: none; } .ptab th, .ptab tr:nth-child(even) td { -webkit-print-color-adjust: exact; print-color-adjust: exact; } @page { margin: 10mm; } }
/* photo frame button and the photo window */
.phbtn { border: 0; background: none; padding: 0; color: inherit; font: inherit; }
.pmodal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pbox { background: var(--card); color: var(--ink); border-radius: 18px; padding: 16px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px;
  align-items: center; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.pbox > b { font-size: 17px; }
.pimg { position: relative; width: min(260px, 70vw); aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: var(--brand-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff' fill-opacity='.5'%3E%3Ccircle cx='12' cy='8' r='4.2'/%3E%3Cpath d='M3.5 22c0-4.8 3.8-7.6 8.5-7.6s8.5 2.8 8.5 7.6z'/%3E%3C/svg%3E") center 70% / 60% no-repeat; }
.pimg.horse { background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233B2A06' fill-opacity='.42'%3E%3Cpath d='M15.2 2.2l-1.3 2.6c-3.4.4-6.4 2.9-7.6 6.7L4 17.6l2.7 2.2 3.2-3.6 2.9.9.9 4.7h5.1l-.9-6.6c-.1-2.7-.9-4.6-2-5.9l.8-6.3z'/%3E%3C/svg%3E") center 65% / 62% no-repeat; }
.pimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pbtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pbtns .btn svg { width: 16px; height: 16px; vertical-align: -3px; }
.pbtns [hidden] { display: none !important; }
/* follow button and alerts */
.sq.fol { background: var(--soft); color: var(--ink); }
.sq.fol.on { background: var(--brand-2); color: #fff; }
#alerts { position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 10px); z-index: 80; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 520px; margin: 0 auto; }
#alerts .alert { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-left: 6px solid var(--gold); border-radius: 14px; padding: 12px 10px 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.35); cursor: pointer; animation: alin .25s ease-out; }
#alerts .alert div { flex: 1; min-width: 0; }
#alerts .alert b { display: block; font-size: 15.5px; }
#alerts .alert span { display: block; font-size: 14px; color: var(--muted); }
#alerts .alert small { font-size: 11.5px; color: var(--muted); }
#alerts .alert button { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
#alerts .alert.ok { border-left-color: var(--good); }
#alerts .alert.bad { border-left-color: var(--bad); }
#alerts .alert.arr { border-left-color: var(--blue); }
@keyframes alin { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #alerts .alert { animation: none; } }
/* big screen (#/tv) */
html.tvmode, html.tvmode body { overflow: hidden; }
.tv { height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); }
.tvh { display: flex; align-items: center; gap: 18px; padding: 12px 22px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; }
.tvh .logo { width: 46px; height: 46px; flex: none; }
.tvh .ttl { flex: 1; min-width: 0; }
.tvh .ttl b { display: block; font-size: clamp(20px, 2.2vw, 36px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tvh .ttl span { font-size: clamp(13px, 1.1vw, 19px); opacity: .85; }
.tvstats { display: flex; gap: 10px; }
.tvstats div { background: rgba(255,255,255,.12); border-radius: 12px; padding: 6px 14px; text-align: center; }
.tvstats b { display: block; font: 800 clamp(20px, 2vw, 34px)/1.05 var(--num); }
.tvstats span { font-size: clamp(11px, .8vw, 14px); opacity: .85; }
.tvh .clock { font: 800 clamp(24px, 2.6vw, 46px)/1 var(--num); min-width: 3.2em; text-align: right; }
.tvbody { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 34vw); gap: 14px; padding: 14px; }
.tvmap { min-height: 0; border-radius: 16px; overflow: hidden; }
.tvmap .map.tvm { height: 100%; border-radius: 16px; }
.tv .pin { transform: scale(1.25); transform-origin: 50% 100%; }
.tvlist { background: var(--card); border-radius: 16px; padding: 12px 14px; overflow: hidden; display: flex; flex-direction: column; }
.tvlist h3 { margin: 0 0 6px; font-size: clamp(14px, 1.2vw, 21px); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tvlist table { width: 100%; border-collapse: collapse; }
.tvlist th { font-size: clamp(10px, .75vw, 13px); color: var(--muted); text-align: left; padding: 4px 6px; text-transform: uppercase; letter-spacing: .04em; }
.tvlist td { padding: 7px 6px; border-top: 1px solid var(--line); font-size: clamp(13px, 1.05vw, 19px); vertical-align: middle; }
.tvlist td.num { font: 700 clamp(15px, 1.35vw, 24px)/1 var(--num); font-variant-numeric: tabular-nums; }
.tvlist td.rk { font: 800 clamp(16px, 1.45vw, 26px)/1 var(--num); width: 2.2em; }
.tvlist tr.lead td { background: var(--loop-alt); }
.tvlist .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 15vw; }
.tvlist .nm span { display: block; font-size: .8em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 15vw; }
.tvlist .r { text-align: right; }
.tvfoot { margin: auto 0 0; padding-top: 8px; font-size: clamp(11px, .85vw, 15px); color: var(--muted); }
@media (max-width: 900px) {
  .tvbody { grid-template-columns: 1fr; grid-template-rows: 55vh auto; overflow: auto; }
  .tvstats { display: none; }
  .tvlist .nm b, .tvlist .nm span { max-width: 46vw; }
}
/* narrow phones: more room for the title in the header */
@media (max-width: 460px) {
  .top { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .top .live { font-size: 0; gap: 0; padding: 7px; }
  .top .icon-btn { width: 34px; height: 34px; }
  .top .ttl b { font-size: 15.5px; }
  .top .ttl span { font-size: 11.5px; }
}
.card .who .nm b { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.25; }
/* Arabic: right-to-left, Arabic font; the map stays left-to-right */
.icon-btn.lang { font: 800 15px/1 Tajawal, Inter, system-ui, sans-serif; }
html[lang="ar"] body, html[lang="ar"] button, html[lang="ar"] input, html[lang="ar"] select, html[lang="ar"] textarea { font-family: Tajawal, Inter, system-ui, sans-serif; }
html[lang="ar"] .lgrid > div > b, html[lang="ar"] .num { font-family: var(--num); }
html[dir="rtl"] .leaflet-container { direction: ltr; }
html[dir="rtl"] .flip { transform: scaleX(-1); }
html[dir="rtl"] .lcard { border-left: 1px solid var(--line); border-right: 6px solid var(--lc, #999); }
html[dir="rtl"] .lch .chip { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .mapbtn { left: auto; right: 10px; }
html[dir="rtl"] .mapwrap.full .mapbtn { left: auto; right: 18px; }
html[dir="rtl"] .phup > i { right: auto; left: -6px; }
html[dir="rtl"] .ph.frame b, html[dir="rtl"] .ph.has b { left: auto; right: 4px; }
html[dir="rtl"] #alerts .alert { border-left: 1px solid var(--line); border-right: 6px solid var(--gold); padding: 12px 14px 12px 10px; }
html[dir="rtl"] #alerts .alert.ok { border-right-color: var(--good); }
html[dir="rtl"] #alerts .alert.bad { border-right-color: var(--bad); }
html[dir="rtl"] #alerts .alert.arr { border-right-color: var(--blue); }
html[dir="rtl"] .tvlist th, html[dir="rtl"] .rmain { text-align: right; }
html[dir="rtl"] .tvlist .r { text-align: left; }
html[dir="rtl"] .tvh .clock { text-align: left; }
html[dir="rtl"] .lgrid > div > span, html[dir="rtl"] .lch .lnum { letter-spacing: 0; }
@media print { .lcards { display: none !important; } .lwrap { display: block !important; } }
@media print { .lwrap { overflow: visible; } table.loops { font-size: 11px; } }
/* library photo editor */
.libpic { display: flex; gap: 14px; align-items: center; }
.libpic .pv { width: 110px; height: 110px; border-radius: 18px; background: var(--soft); position: relative; overflow: hidden; display: grid; place-items: center; flex: none; border: 1.5px dashed var(--line); }
.libpic .pv img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.libpic .pv b { font: 700 30px/1 var(--num); color: var(--muted); }
/* rider header with the small square GPS / Vet Card buttons on the right */
.hrow { display: flex; gap: 12px; align-items: flex-start; }
.hmain { flex: 1; min-width: 0; }
.hmain .nm .chip { margin-top: 5px; display: inline-flex; }
.hmain .nm > span:not(.chip) { display: block; }
.side { display: flex; flex-direction: column; gap: 8px; flex: none; }
.sq { width: 66px; height: 60px; border-radius: 14px; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: 700 11px/1 Inter, system-ui, sans-serif; text-decoration: none; box-shadow: var(--shadow); cursor: pointer; }
.sq svg { width: 22px; height: 22px; }
.sq.gps { background: var(--good); color: #fff; }
.sq.gps.off { background: var(--soft); color: var(--muted); box-shadow: none; cursor: default; opacity: .75; }
.sq.vc { background: var(--gold); color: var(--gold-ink); }
/* rider / horse photo from racetest, number badge on top; without a photo it is a plain badge */
.ph { position: relative; flex: none; width: 46px; height: 38px; border-radius: 11px; background: var(--brand-2); display: grid; place-items: center; overflow: hidden; }
.ph b { color: #fff; font: 700 22px/1 var(--num); }
.ph.horse { background: var(--gold); } .ph.horse b { color: var(--gold-ink); }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.ph.has { width: 76px; height: 76px; border-radius: 16px; box-shadow: var(--shadow); }
.ph.has img { opacity: 1; }
.ph.has b { position: absolute; left: 4px; bottom: 4px; font-size: 15px; background: var(--brand-2); border-radius: 7px; padding: 3px 6px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.ph.horse.has b { background: var(--gold); }
.who .nm b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .nm span { color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--ink); white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.gold { background: var(--gold); color: var(--gold-ink); }

/* ---------- hero speed ---------- */
.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }
.speed { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.speed .lbl { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.speed .val { font: 700 64px/1 var(--num); margin-top: 6px; }
.speed .val small { font-size: 20px; font-weight: 600; opacity: .8; margin-left: 4px; }
.speed .sub { font-size: 12.5px; opacity: .85; margin-top: 6px; }
.speed svg.ring { position: absolute; right: -28px; bottom: -28px; width: 130px; height: 130px; opacity: .14; }
.pos { display: flex; flex-direction: column; gap: 10px; }
.stat { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat b { font: 700 30px/1.05 var(--num); }
.stat b small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 3px; }

/* ---------- progress ---------- */
.prog { display: flex; gap: 4px; margin: 10px 0 8px; }
.prog div { height: 10px; border-radius: 6px; background: var(--soft); position: relative; overflow: hidden; }
.prog div i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.legend { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.mini { background: var(--soft); border-radius: 12px; padding: 10px; }
.mini span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.mini b { font: 700 22px/1.1 var(--num); }

/* ---------- comparison ---------- */
.vs { display: grid; gap: 10px; }
.opp { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; background: var(--card); }
.opp .tag { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.opp.behind .tag { color: var(--blue); }
.opp.ahead .tag { color: var(--warn); }
.opp .nm b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp .nm span { font-size: 12.5px; color: var(--muted); }
.opp .nums { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opp .nums div { background: var(--soft); border-radius: 12px; padding: 8px 10px; }
.opp .nums span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.opp .nums b { font: 700 24px/1.1 var(--num); }
.opp .nums b small { font-size: 13px; color: var(--muted); margin-left: 2px; font-weight: 600; }
.trend { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; text-transform: none; letter-spacing: 0; }
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.nobody { color: var(--muted); font-size: 13.5px; padding: 6px 2px; }

/* ---------- map ---------- */
.map { height: 320px; border-radius: 14px; overflow: hidden; background: var(--soft); }
.map.big { height: calc(100vh - 220px); min-height: 360px; }
.pin { width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin b { transform: rotate(45deg); font: 700 14px/1 var(--num); color: #fff; }
.pin.me { background: var(--gold); width: 40px; height: 40px; }
.pin.me b { color: var(--gold-ink); font-size: 16px; }
.pin.behind { background: var(--blue); }
.pin.ahead { background: var(--warn); }
.pin.other { background: #8C7B82; width: 26px; height: 26px; }
.pin.other b { font-size: 11px; }

/* ---------- vet card ---------- */
.gate { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.gate + .gate { margin-top: 10px; }
.gate .hd { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-weight: 700; }
.gate .bd { padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; }
.gate .bd div span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.gate .bd div b { font: 700 19px/1.15 var(--num); }
.gate details { border-top: 1px solid var(--line); padding: 10px 12px; font-size: 13.5px; }
.gate details summary { cursor: pointer; font-weight: 600; color: var(--brand-2); }
.gate .checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; }
.gate .checks div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.heart { display: inline-flex; align-items: center; gap: 4px; }
.heart svg { width: 16px; height: 16px; color: var(--bad); }

/* ---------- forms ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; }
.login .brand { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; padding: calc(env(safe-area-inset-top) + 48px) 24px 70px; text-align: center; }
.login .brand svg { width: 72px; height: 72px; }
.login .brand h1 { font: 700 34px/1.05 var(--num); letter-spacing: .02em; margin: 14px 0 6px; }
.login .brand p { margin: 0; opacity: .82; font-size: 14px; }
.login form { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); margin: -44px 16px 24px; padding: 18px; max-width: 440px; width: calc(100% - 32px); align-self: center; display: flex; flex-direction: column; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 16px; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(110,35,64,.15); }
input.big { font: 700 26px/1 var(--num); letter-spacing: .12em; text-align: center; }
.btn { border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; background: var(--brand-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.gold { background: var(--gold); color: var(--gold-ink); }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.err { background: var(--bad-bg); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; font-weight: 500; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; font-weight: 500; }
.okmsg { background: var(--good-bg); color: var(--good); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; font-weight: 500; }

/* ---------- tables (supervisor) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--soft); }
.tbl .r { text-align: right; }
.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.pins { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pins div { border: 1px dashed var(--line); border-radius: 12px; padding: 10px; }
.pins b { font: 700 26px/1 var(--num); letter-spacing: .1em; display: block; margin-top: 4px; }
.radio { display: grid; gap: 8px; }
.radio label { flex-direction: row; align-items: flex-start; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); font-weight: 500; }
.radio label.on { border-color: var(--brand-2); background: var(--soft); }
.radio input { width: auto; margin-top: 3px; }
.radio label small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.nav div { display: flex; width: 100%; max-width: 760px; }
.nav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; font-size: 11.5px; font-weight: 600; color: var(--muted); border-radius: 12px; }
.nav button svg { width: 23px; height: 23px; }
.nav button.on { color: var(--brand-2); background: var(--soft); }

/* ---------- home: rider buttons ---------- */
.riders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.rbtn { display: flex; align-items: center; gap: 12px; text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 16px; padding: 12px; min-height: 64px; transition: transform .08s, border-color .15s; }
.riders > * { min-width: 0; }   /* long names must not push the status off the screen */
.rbtn .chip { flex: none; }
.rbtn:active { transform: scale(.98); }
.rbtn:hover { border-color: var(--brand-2); }
.rbtn.me { border-color: var(--gold); background: var(--soft); }
.rbtn .bib { min-width: 54px; height: 44px; font-size: 25px; }
.rbtn .nm { flex: 1; min-width: 0; }
.rbtn .nm b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbtn .nm span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #C9BDB4; flex: none; }
.dot.on { background: #2FB36B; box-shadow: 0 0 0 3px rgba(47,179,107,.18); }
.mine { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; text-align: left; border-radius: var(--radius); padding: 14px 16px; background: var(--gold); color: var(--gold-ink); box-shadow: var(--shadow); }
.mine .bib { background: var(--brand); min-width: 58px; height: 48px; font-size: 27px; }
.mine .nm { flex: 1; min-width: 0; }
.mine .nm small { display: block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.mine .nm b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine .go { font-weight: 700; }
.searchbox { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; margin-bottom: 12px; color: var(--muted); }
.searchbox input { border: 0; padding: 11px 0; box-shadow: none !important; }
.searchbox.big { background: var(--card); box-shadow: var(--shadow); border-color: transparent; border-radius: 14px; margin: 0; padding: 0 14px; }
.searchbox.big input { font-size: 17px; padding: 14px 0; }
@media (max-width: 420px) { .tbl .wide { display: none; } .riders { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 14px; border-radius: 12px; font-size: 13.5px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: var(--line); }

@media (max-width: 420px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .speed .val { font-size: 54px; }
  .grid3 { gap: 8px; }
  .opp .nums b { font-size: 21px; }
  .gate .bd { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .top, .nav, .noprint { display: none !important; }
  main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* races added by the supervisor */
.evform { display: flex; flex-direction: column; gap: 10px; }
.evform .fld > span { display: block; }
.evform textarea { font: inherit; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; font-size: 16px; color: var(--ink); width: 100%; resize: vertical; }
.evform textarea:focus { outline: none; border-color: var(--brand-2); }
.evrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .evrow { grid-template-columns: 1fr 1fr; } .evrow .fld:last-child { grid-column: 1 / -1; } }
.cgrid .cd:not(.has):not([disabled]) { cursor: pointer; }
.btn.evadd { width: 100%; justify-content: center; gap: 8px; white-space: nowrap; }
.btn.evadd svg { width: 20px; height: 20px; flex: none; }

/* compare two riders */
.cmpick { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; }
.cmpick select { font-size: 15px; padding: 10px 12px; }
.cmpick .vs { font: 800 15px/1 var(--num); color: var(--gold, #D9A93A); padding-bottom: 14px; }
.cmgap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
.cmg span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.cmg b { font-size: 40px; line-height: 1.1; }
.cmg small, .cmspd small { font-size: 14px; margin-inline-start: 4px; color: var(--muted); font-weight: 600; }
.cmgline { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13.5px; }
.cmgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.cmcol { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cmcol.lead { border-color: var(--good, #2e9e5b); }
.cmhead { display: flex; justify-content: space-between; align-items: center; }
.cmname { font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.cmhorse { font-size: 12.5px; min-height: 15px; }
.cmspd b { font-size: 38px; line-height: 1; }
.cmkm { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; }
.cmkm b { color: var(--ink); font-size: 13.5px; }
.sarrow { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 14px; border-radius: 999px; padding: 3px 10px; width: fit-content; }
.sarrow svg { width: 16px; height: 16px; }
.sarrow.up { color: #1f9d55; background: rgba(31, 157, 85, .14); }
.sarrow.down { color: #e03131; background: rgba(224, 49, 49, .14); }
.sarrow.flat { color: var(--muted); background: rgba(127, 127, 127, .12); }
.cmnote { text-align: center; font-size: 12.5px; margin: 0 0 12px; }
@media (max-width: 380px) { .cmg b { font-size: 32px; } .cmspd b { font-size: 30px; } .cmcol { padding: 11px; } }
/* best condition (lowest recovery) */
.bcond { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 9px 3px 6px; font-size: 11.5px; font-weight: 800; white-space: nowrap; vertical-align: middle;
  background: linear-gradient(135deg, #F6D77A, #D9A93A 55%, #B8862A); color: #3B2A06; box-shadow: 0 1px 6px rgba(217, 169, 58, .45); }
.bcond svg { width: 15px; height: 15px; flex: none; }
.bcline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.bcline .bcond { font-size: 13px; padding: 5px 12px 5px 8px; }
.bcline .bcond svg { width: 18px; height: 18px; }
table.loops td.bctd { background: rgba(217, 169, 58, .16); font-weight: 800; white-space: nowrap; }
.lgrid > div.bcbox { grid-column: span 2; background: rgba(217, 169, 58, .16); border-radius: 10px; padding: 4px 8px; }
.lgrid > div.bcbox > b { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.bccard h3 { display: flex; align-items: center; gap: 8px; }
.bccard h3 svg { width: 22px; height: 22px; color: var(--gold); }
.bclist { display: flex; flex-direction: column; gap: 6px; }
.bcrow { display: flex; align-items: center; gap: 10px; width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 10px; background: var(--card); color: var(--ink); text-align: start; cursor: pointer; }
.bcrow .nm { flex: 1; min-width: 0; } .bcrow .nm b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcrow .nm span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bclbl { flex: none; width: 74px; display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.bclbl .lc { width: 6px; height: 20px; border-radius: 3px; flex: none; }
.bcall { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); } .bcall svg { width: 16px; height: 16px; }
.bctime { font-size: 18px; color: var(--gold); flex: none; }
.rmain .nm > span.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; white-space: normal; overflow: visible; color: inherit; -webkit-line-clamp: unset; }
.rmain .nm > span.chips .chip { margin-top: 0; }
/* finish prediction */
.etaline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--soft); font-size: 13.5px; }
.etaline svg { width: 18px; height: 18px; color: var(--gold); flex: none; }
.etaline b { font-size: 20px; } .etaline small { font-size: 12.5px; }
.pwin { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, var(--brand, #2A0B16), var(--brand-2, #5A1C33)); color: #fff; border: 1.5px solid var(--gold); }
.pwin > svg { width: 44px; height: 44px; color: var(--gold); flex: none; }
.pwin .nm { flex: 1; min-width: 0; } .pwin .nm b { display: block; font-size: 17px; overflow-wrap: anywhere; } .pwin .nm span { display: block; font-size: 13px; opacity: .8; }
.pwin .nm .muted { color: #E5B850 !important; font-weight: 700; text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; }
.pwt { text-align: end; flex: none; } .pwt b { display: block; font-size: 30px; line-height: 1; color: var(--gold); } .pwt small { color: rgba(255,255,255,.75) !important; font-size: 12.5px; text-transform: none; letter-spacing: 0; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 10px; width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 10px; background: var(--card); color: var(--ink); text-align: start; cursor: pointer; }
.prow.lead { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.prow.fin { opacity: .85; }
.prank { width: 24px; text-align: center; font: 800 18px/1 var(--num); color: var(--gold); flex: none; }
.prow .nm { flex: 1; min-width: 0; } .prow .nm b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .nm span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .nm .psub { color: var(--ink); opacity: .75; font-size: 11.5px; margin-top: 1px; }
.pt { flex: none; text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; } .pt b { font-size: 18px; } .pt small { font-size: 11.5px; }
/* vet gate timers */
.card h3 > svg { width: 18px; height: 18px; vertical-align: -3px; margin-inline-end: 4px; color: var(--gold); }
.glist { display: flex; flex-direction: column; gap: 8px; }
.gtile { display: flex; align-items: center; gap: 10px; width: 100%; border: 1.5px solid var(--line); border-inline-start: 6px solid var(--good); border-radius: 14px; padding: 10px; background: var(--card); color: var(--ink); text-align: start; cursor: pointer; }
.gtile.present { border-inline-start-color: var(--warn); }
.gtile.soon, .gtile.over { border-color: var(--bad); border-inline-start-color: var(--bad); background: var(--bad-bg); }
.gtile .nm { flex: 1; min-width: 0; } .gtile .nm b { display: block; font-size: 15px; overflow-wrap: anywhere; } .gtile .nm span { display: block; font-size: 12.5px; color: var(--muted); }
.gt { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.gt .tmr { font-size: 26px; line-height: 1; }
.gtile.soon .tmr, .gtile.over .tmr { color: var(--bad); }
.gtile.soon { animation: gpulse 1s ease-in-out infinite; }
@keyframes gpulse { 50% { box-shadow: 0 0 0 4px rgba(224, 49, 49, .25); } }
.gchip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 800; background: var(--good-bg); color: var(--good); }
.gchip.present { background: var(--warn-bg); color: var(--warn); }
.gchip.soon, .gchip.over { background: var(--bad-bg); color: var(--bad); }
.gchip svg { width: 13px; height: 13px; }
.gbanner { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--good-bg); color: var(--good); font-size: 13.5px; font-weight: 600; }
.gbanner.present { background: var(--warn-bg); color: var(--warn); }
.gbanner.soon, .gbanner.over { background: var(--bad-bg); color: var(--bad); }
.gbanner > svg { width: 22px; height: 22px; flex: none; }
.gbanner > span { flex: 1; } .gbanner .tmr { font-size: 24px; }
@media (max-width: 380px) { .bclbl { width: 60px; } .pwt b { font-size: 24px; } .gt .tmr { font-size: 22px; } }
.hmedal { display: inline-flex; vertical-align: -3px; margin-inline-start: 5px; color: var(--gold); filter: drop-shadow(0 1px 3px rgba(217, 169, 58, .5)); }
.hmedal svg { width: 17px; height: 17px; }
/* loop cards: coloured header band per loop and a divider between loops */
.lcards { gap: 0; }
.lcard { position: relative; overflow: visible; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); padding: 0 14px 12px; }
.lcard + .lcard { margin-top: 30px; }
.lcard + .lcard::before { content: ""; position: absolute; left: 10%; right: 10%; top: -16px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent); }
.lcard + .lcard::after { content: ""; position: absolute; left: 50%; top: -21px; width: 12px; height: 12px; border-radius: 3px; transform: translateX(-50%) rotate(45deg);
  background: var(--lc, #999); box-shadow: 0 0 0 4px var(--card); }
.lch { margin: 0 -14px 12px; padding: 10px 14px; border-radius: 0 13px 0 0; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--lc, #999) 22%, transparent), color-mix(in srgb, var(--lc, #999) 6%, transparent)); }
html[dir="rtl"] .lch { border-radius: 13px 0 0 0; background: linear-gradient(270deg, color-mix(in srgb, var(--lc, #999) 22%, transparent), color-mix(in srgb, var(--lc, #999) 6%, transparent)); }
.lch .lnum { display: inline-flex; align-items: center; gap: 8px; }
.lch .lnum::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--lc, #999); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lc, #999) 30%, transparent); }
.lgrid { row-gap: 10px; }
.lgrid > div.bcbox { grid-column: auto; padding: 4px 8px; margin: -4px -8px; }
/* weather at the venue */
.wx { background: linear-gradient(135deg, color-mix(in srgb, #2F6FA3 16%, var(--card)), var(--card) 70%); }
.wx.warm { background: linear-gradient(135deg, color-mix(in srgb, #F08A00 16%, var(--card)), var(--card) 70%); }
.wx.hot { background: linear-gradient(135deg, color-mix(in srgb, #D0021B 18%, var(--card)), var(--card) 70%); }
.wxtop { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.wxsky { font-size: 40px; line-height: 1; }
.wxnow { flex: 1; min-width: 0; } .wxnow > b { display: block; font-size: 40px; line-height: 1; }
.wxnow > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.wxwarn { flex: none; }
.wxgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wxt { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; position: relative; }
.wxt > span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.wxt > b { display: block; font-size: 22px; line-height: 1.15; } .wxt > b small { font-size: 11px; color: var(--muted); margin-inline-start: 2px; font-weight: 600; }
.wxt .wxdir { position: absolute; top: 6px; inset-inline-end: 6px; }
.wxdir { width: 14px; height: 14px; color: var(--gold); flex: none; vertical-align: -2px; }
.wxnext { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
.wxlbl { font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: .04em; font-size: 12px; }
.wxv { display: inline-flex; align-items: center; gap: 4px; } .wxv b { font-size: 15px; } .wxv small { color: var(--muted); }
@media (max-width: 380px) { .wxt > b { font-size: 18px; } .wxt > span { font-size: 10.5px; } .wxgrid { gap: 6px; } }
/* Race tab and the compare button on a rider */
.sq.cmpb { background: var(--brand-2); color: #fff; }
.sq.cmpb.off { background: var(--soft); color: var(--muted); box-shadow: none; cursor: default; opacity: .75; }
.rfacts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rfacts > div { background: var(--soft); border-radius: 12px; padding: 8px 10px; }
.rfacts span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.rfacts b { display: block; font-size: 20px; line-height: 1.2; }
.rloops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.rloop { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 12.5px; font-weight: 700;
  background: color-mix(in srgb, var(--lc, #999) 16%, transparent); border: 1px solid color-mix(in srgb, var(--lc, #999) 45%, transparent); }
.rloop i { width: 10px; height: 10px; border-radius: 50%; background: var(--lc, #999); }
.rloop small { color: var(--muted); font-weight: 600; margin-inline-start: 4px; }
.menu { padding: 4px 0; }
.menu > button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; color: var(--ink); text-align: start; cursor: pointer; padding: 12px 16px; }
.menu > button + button { border-top: 1px solid var(--line); }
.menu > button > svg { width: 26px; height: 26px; color: var(--gold); flex: none; }
.menu > button > span { flex: 1; min-width: 0; } .menu b { display: block; font-size: 15.5px; } .menu small { color: var(--muted); font-size: 12.5px; }
.menu > button > i { font-style: normal; font-size: 22px; color: var(--muted); }
html[dir="rtl"] .menu > button > i { transform: scaleX(-1); display: inline-block; }
/* map labels: name and speed */
.leaflet-tooltip.rtip { background: rgba(28, 10, 18, .92); color: #fff; border: 0; border-radius: 10px; padding: 5px 9px; font: 600 12.5px/1.35 Inter, Tajawal, system-ui, sans-serif; box-shadow: 0 3px 12px rgba(0,0,0,.35); }
.leaflet-tooltip.rtip b.num { font-size: 15px; color: #E5B850; }
.leaflet-tooltip.rtip::before { border-top-color: rgba(28, 10, 18, .92); }
.leaflet-tooltip.rtip.on.me { background: #D9A93A; color: #2A1E03; } .leaflet-tooltip.rtip.on.me b.num { color: #2A1E03; } .leaflet-tooltip.rtip.on.me::before { border-top-color: #D9A93A; }
.leaflet-tooltip.rtip.on.behind { background: #2F6FA3; } .leaflet-tooltip.rtip.on.behind b.num { color: #fff; } .leaflet-tooltip.rtip.on.behind::before { border-top-color: #2F6FA3; }
.cmlegend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; }
.cmlegend span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.cmlegend .pin { width: 14px; height: 14px; border-width: 1px; flex: none; }

/* rider page: rank at each gate and the averages bar */
.lch .lrank { display: inline-flex; align-items: baseline; gap: 5px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 12px; font-weight: 600; color: var(--muted); }
.lch .lrank b { font-size: 17px; color: var(--ink); }
.avgbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.avgbar > div { background: var(--soft); border-radius: 12px; padding: 8px 4px; text-align: center; }
.avgbar > div > span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; line-height: 1.25; }
.avgbar > div > b { display: block; font-size: 22px; line-height: 1.2; color: var(--ink); }
.avgbar .hrv svg { width: 15px; height: 15px; color: var(--bad); margin-inline-end: 3px; vertical-align: -1px; }
@media (max-width: 380px) { .avgbar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* race status card: on loop / arrived (blue) / in vet (orange) / eliminated, loop by loop; rider rows take the same colour line */
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.orange { background: var(--orange-bg); color: var(--orange); }
.rrow.st-arr { border-inline-start: 6px solid var(--blue); background: linear-gradient(90deg, var(--blue-bg), var(--card) 45%); }
.rrow.st-vet { border-inline-start: 6px solid var(--orange); background: linear-gradient(90deg, var(--orange-bg), var(--card) 45%); }
.rrow.st-loop { border-inline-start: 6px solid var(--gold); }
.rrow.st-out { border-inline-start: 6px solid var(--bad); opacity: .82; }
html[dir="rtl"] .rrow.st-arr { background: linear-gradient(270deg, var(--blue-bg), var(--card) 45%); }
html[dir="rtl"] .rrow.st-vet { background: linear-gradient(270deg, var(--orange-bg), var(--card) 45%); }
.stcard { --c-loop: var(--gold); --c-arr: var(--blue); --c-vet: var(--orange); --c-out: var(--bad); --c-pass: var(--good); }
.stgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.sttile { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px 14px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
.sttile b { font-size: 34px; line-height: 1; color: var(--tc); }
.sttile span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.sttile i { position: absolute; inset-inline-start: 0; bottom: 0; height: 4px; width: var(--p); background: var(--tc); border-radius: 0 4px 4px 0; transition: width .4s; }
.sttile::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tc); opacity: .9; }
.sttile.loop { --tc: var(--c-loop); } .sttile.arr { --tc: var(--c-arr); } .sttile.vet { --tc: var(--c-vet); } .sttile.out { --tc: var(--c-out); }
.sttile.on { border-color: var(--tc); box-shadow: 0 0 0 2px var(--tc) inset; }
.sttile:active { transform: scale(.98); }
.stpills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.stpill { display: inline-flex; align-items: baseline; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 12px; background: var(--soft); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.stpill b { font-size: 16px; color: var(--ink); }
.stpill.on { border-color: var(--ink); color: var(--ink); }
.sttbl { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.sttbl th { font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 2px 6px; border-bottom: 1px solid var(--line); }
.sttbl td { text-align: center; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 700; }
.sttbl tr:last-child td { border-bottom: 0; }
.sttbl td.z { color: var(--line); font-weight: 500; }
.sttbl td.loop { color: var(--c-loop); } .sttbl td.arr { color: var(--c-arr); } .sttbl td.vet { color: var(--c-vet); } .sttbl td.pass { color: var(--c-pass); } .sttbl td.out { color: var(--c-out); }
.sttbl .lnum { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 14px; }
.stfbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 8px 10px; border-radius: 12px; background: var(--soft); font-size: 13.5px; }
.stfbar .btn { margin-inline-start: auto; }
@media (max-width: 380px) { .sttile b { font-size: 28px; } .sttile span { font-size: 11.5px; } }

/* leader: trophy tag, gold line on the row */
.ldr { display: inline-flex; align-items: center; gap: 4px; width: max-content; padding: 2px 9px 2px 7px; margin-bottom: 3px; border-radius: 999px; background: linear-gradient(135deg, #F4D27A, var(--gold)); color: var(--gold-ink); font-size: 11.5px; font-weight: 800; letter-spacing: .02em; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ldr svg { width: 14px; height: 14px; }
.nm .ldr { display: flex; }
.rrow.leader { border-color: var(--gold); border-inline-start: 6px solid var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow); }
tr.ldrrow td { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.tv .nm .ldr { font-size: 14px; }
/* winner prediction */
.pred h3 svg { width: 18px; height: 18px; color: var(--gold); vertical-align: -3px; margin-inline-end: 4px; }
.wplist { display: grid; gap: 8px; }
.wprow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.wprow.first { border-color: var(--gold); background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card) 60%); }
html[dir="rtl"] .wprow.first { background: linear-gradient(270deg, color-mix(in srgb, var(--gold) 16%, var(--card)), var(--card) 60%); }
.wprk { width: 26px; display: grid; place-items: center; flex: none; color: var(--muted); font-size: 18px; }
.wprk svg { width: 22px; height: 22px; color: var(--gold); }
.wpnm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wpnm b { font-size: 15px; } .wpnm > span { font-size: 12.5px; color: var(--muted); }
.wpnm small { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.wppct { flex: none; width: 64px; text-align: end; }
.wppct b { font-size: 22px; }
.wppct i { display: block; height: 4px; border-radius: 4px; background: var(--soft); margin-top: 4px; position: relative; overflow: hidden; }
.wppct i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--gold); border-radius: 4px; }
.hrec { display: grid; gap: 6px; margin-top: 10px; }
.hrec > div { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.hrec > div:last-child { border-bottom: 0; }
.hrec b.win { color: var(--gold); } .hrec b.fin { color: var(--good); } .hrec b.out { color: var(--bad); }
.ldr > span, .nm .ldr > span, .nm > .ldr span { color: var(--gold-ink); font-size: 11.5px; font-weight: 800; line-height: 1.3; }

/* rider country flag (flagcdn picture of the FEI country code) */
img.flag { display: inline-block; width: 22px; height: 15px; object-fit: cover; border-radius: 3px; margin-inline-end: 6px; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(0,0,0,.18); }
.tv img.flag { width: 30px; height: 20px; vertical-align: -3px; }
.wpnm > span img.flag { width: 18px; height: 12px; vertical-align: -1px; }

/* loop number on the rider status ("On loop 2") */
.chip.lp { background: var(--soft); color: var(--ink); }
.chip.lp b, .chip.onl b { font-size: 14px; margin-inline-start: 2px; }
/* Races screen (Al-Ramk Timing) */
.rkbadge { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.rkbadge .logo { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); padding: 6px; box-shadow: 0 0 0 2px var(--gold); }
.rkbadge > span { display: flex; flex-direction: column; line-height: 1.1; }
.rkbadge b { font-family: "Tajawal", system-ui, sans-serif; font-size: 18px; font-weight: 800; color: var(--gold); }
.rkbadge small { font-size: 8.5px; font-weight: 800; letter-spacing: .12em; color: var(--muted); }
.rkhero { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.rkhero .rkbadge .logo { width: 54px; height: 54px; }
.rkhero .rkbadge b { font-size: 26px; } .rkhero .rkbadge small { color: rgba(255,255,255,.75); font-size: 10px; }
.rkhero p { margin: 0; font-size: 13px; color: rgba(255,255,255,.85); }
.rkcount { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 10px; font-size: 18px; }
.rkcount span { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 17px; font-weight: 700; padding: 0 8px; }
.rkcards { display: grid; gap: 10px; }
.rkcard { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px; border: 1.5px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); font: inherit; text-align: start; cursor: pointer; box-shadow: var(--shadow); }
.rkcard.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow); }
.rkcard .rkbadge > span { display: none; }
.rkcard .car { font-style: normal; font-size: 26px; color: var(--muted); }
html[dir="rtl"] .rkcard .car { transform: scaleX(-1); }
.rkmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rktop { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.rklive { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: #D7261E; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.rklive i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: rkpulse 1.4s infinite; }
@keyframes rkpulse { 50% { opacity: .25; } }
.rkname { font-size: 16.5px; line-height: 1.25; }
.rksub { font-size: 12.5px; color: var(--muted); }
.rkchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.rkc { display: inline-flex; align-items: baseline; gap: 4px; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; }
.rkc b { font-size: 15px; }
.rkc.b { background: var(--blue-bg); color: var(--blue); } .rkc.g { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.rkc.ok { background: var(--good-bg); color: var(--good); } .rkc.bad { background: var(--bad-bg); color: var(--bad); }
.rkc.gps { background: var(--soft); color: var(--ink); align-items: center; } .rkc.gps svg { width: 14px; height: 14px; }
.viewnote { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border-radius: 14px; background: var(--blue-bg); color: var(--blue); font-size: 13.5px; }

/* Horse results page */
.hsorts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.hsort { border: 1.5px solid var(--line); background: var(--soft); color: var(--muted); border-radius: 999px; padding: 5px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.hsort.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.hlist { display: grid; gap: 8px; }
.hcard { border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); overflow: hidden; }
.hcard.open { border-color: var(--gold); }
.hcard.out { opacity: .7; }
.hhead { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; background: none; color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.hnm { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hnm b { font-size: 15px; } .hnm > span { font-size: 12.5px; color: var(--muted); }
.hnums { display: grid; grid-template-columns: repeat(4, auto); gap: 10px; flex: none; text-align: center; }
.hnums b { display: block; font-size: 17px; line-height: 1.1; } .hnums small { font-size: 10px; color: var(--muted); font-weight: 600; }
.hcard .hrec { margin: 0; padding: 0 12px 10px; }
@media (max-width: 400px) { .hnums { gap: 6px; } .hnums b { font-size: 15px; } }
@media (max-width: 520px) { .hhead { flex-wrap: wrap; } .hnums { width: 100%; grid-template-columns: repeat(4, 1fr); padding-top: 6px; border-top: 1px solid var(--line); } .hnm { flex-basis: 60%; } }

/* Al-Ramk logo (picture): white round badge so the white background of the logo looks intentional */
img.logo { display: block; flex: none; object-fit: contain; background: #fff; border-radius: 50%; padding: 3px; box-shadow: 0 0 0 2px var(--gold); }
.top img.logo { width: 40px; height: 40px; }
@media (max-width: 380px) { .top img.logo { width: 32px; height: 32px; } }
.tvh img.logo { width: 54px; height: 54px; }
.rkbadge img.logo { width: 42px; height: 42px; background: #fff; padding: 3px; }
.rkhero { flex-direction: column; text-align: center; background: #fff; color: var(--brand); border: 1.5px solid var(--line); }
.rkhero .rkfull { width: min(100%, 300px); height: auto; display: block; margin: 0 auto; }
.rkhero p { color: #5a3a44; font-size: 13.5px; }
.top img.logo { width: 48px; height: 48px; } .top .ttl b { letter-spacing: .01em; } @media (max-width: 380px) { .top img.logo { width: 42px; height: 42px; } }

/* departure time of the loop (like Mindari's Depart column) */
.chip.dep { display: inline-flex; align-items: center; gap: 4px; background: var(--soft); color: var(--ink); }
.chip.dep svg { width: 13px; height: 13px; color: var(--gold); }
.chip.dep b { font-size: 13.5px; }
/* Results of past races: supervisor tools */
.rsup { border: 1.5px dashed var(--gold); }
.rtools { display: inline-flex; align-items: center; gap: 6px; flex: none; margin-inline-start: 6px; }
.rtools .sq { width: 34px; height: 34px; min-width: 34px; font-size: 15px; padding: 0; display: grid; place-items: center; border: 1.5px solid var(--line); background: var(--soft); color: var(--ink); border-radius: 10px; cursor: pointer; }
.rtools .sq.del { color: var(--bad); }
.erow.edited { box-shadow: inset 3px 0 0 var(--gold); }
html[dir="rtl"] .erow.edited { box-shadow: inset -3px 0 0 var(--gold); }
.erow.gone { opacity: .6; }
.rform { border: 1.5px solid var(--gold); }
.rgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.rgrid input, .rgrid select { font: inherit; font-size: 15px; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.rgrid input[readonly] { background: var(--soft); }
@media (max-width: 420px) { .rgrid { grid-template-columns: 1fr; } }

/* Race status chart: horizontal bars, name + number + share always written (colour is not the only cue) */
.stcard { --c-rdy: #1F8F86; --c-hold: #8E7C83; --c-fin: var(--good); }
:root[data-theme="dark"] .stcard { --c-rdy: #4FD1C2; --c-hold: #A8979D; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stcard { --c-rdy: #4FD1C2; --c-hold: #A8979D; } }
.sbars { display: grid; gap: 4px; margin-top: 12px; }
.sbar { display: grid; grid-template-columns: minmax(84px, 30%) 1fr 70px; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; text-align: start; cursor: pointer; }
.sbar:hover, .sbar.on { background: var(--soft); }
.sbar.on { box-shadow: inset 0 0 0 1.5px var(--line); }
.sbar .sl { font-size: 13.5px; font-weight: 700; }
.sbar .st { height: 14px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.sbar .st i { display: block; height: 100%; border-radius: 4px; background: var(--bc); transition: width .45s ease; }
.sbar .sv { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.sbar .sv b { font-size: 20px; line-height: 1; }
.sbar .sv small { font-size: 11.5px; color: var(--muted); min-width: 30px; text-align: end; }
.sbar.zero .sl, .sbar.zero .sv b { color: var(--muted); font-weight: 600; }
.sbar.rdy { --bc: var(--c-rdy); } .sbar.loop { --bc: var(--gold); } .sbar.arr { --bc: var(--blue); } .sbar.vet { --bc: var(--orange); }
.sbar.hold { --bc: var(--c-hold); } .sbar.fin { --bc: var(--c-fin); }
.sbar.out { --bc: var(--bad); } .sbar.out .st i, .lst i.out, .slegend i.out { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 3px, transparent 3px 7px); }
/* by loop: one stacked bar per loop */
.slegend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.slegend > span { display: inline-flex; align-items: center; gap: 5px; }
.slegend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.slegend i.loop, .lst i.loop { background-color: var(--gold); } .slegend i.arr, .lst i.arr { background-color: var(--blue); }
.slegend i.vet, .lst i.vet { background-color: var(--orange); } .slegend i.fin, .lst i.fin { background-color: var(--c-fin); }
.slegend i.out, .lst i.out { background-color: var(--bad); }
.lrow { display: grid; grid-template-columns: 26px 1fr 34px; align-items: center; gap: 8px; margin-bottom: 6px; }
.lrow .lnum { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; }
.lrow .lst { display: flex; gap: 2px; height: 24px; min-width: 4px; }
.lrow .lst i { display: grid; place-items: center; min-width: 4px; border-radius: 4px; overflow: hidden; }
.lrow .lst i b { font-size: 12px; color: #1b0f13; font-weight: 800; }
.lrow .lst i.out b, .lrow .lst i.fin b { color: #fff; }
.lrow .lsum { font-size: 15px; text-align: end; }
@media (max-width: 380px) { .sbar { grid-template-columns: 78px 1fr 62px; gap: 6px; } .sbar .sl { font-size: 12.5px; } }

/* Race status (user's chosen layout): Total, six icon tiles with coloured count boxes, two pie charts */
.stcard { --t-out: #d03b3b; --t-fin: #0ca30c; --t-rdy: #0e8fa6; --t-loop: #eda100; --t-arr: #546e7a; --t-vet: #2a78d6; --t-hold: #7d6b72;
  --pfin: #0ca30c; --pout: #d03b3b; --pc1: #2a78d6; --pc2: #eb6834; --pc3: #1baf7a; --pc4: #eda100; --pc5: #e87ba4; }
:root[data-theme="dark"] .stcard { --pc1: #3987e5; --pc2: #d95926; --pc3: #199e70; --pc4: #c98500; --pc5: #d55181; --t-arr: #6b8796; --t-hold: #8e7c83; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stcard { --pc1: #3987e5; --pc2: #d95926; --pc3: #199e70; --pc4: #c98500; --pc5: #d55181; --t-arr: #6b8796; --t-hold: #8e7c83; } }
.sttotal { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 1.5px solid var(--brand-2); border-radius: 14px; font-size: 17px; }
.sttotal b { font-size: 22px; }
.stls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; margin-top: 16px; }
.stl { display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 10px; padding: 4px; border: 0; border-radius: 16px; background: none; font: inherit; color: var(--ink); cursor: pointer; --tc: var(--t-out); }
.stl.on { background: var(--soft); box-shadow: inset 0 0 0 1.5px var(--tc); }
.stl .sti { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--tc); text-align: center; }
.stl .sti svg { width: 32px; height: 32px; }
.stl .sti span { font-size: 13px; font-weight: 700; line-height: 1.2; }
.stl .stb { position: relative; display: grid; place-items: center; height: 64px; border-radius: 12px; background: var(--tc); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.stl .stb::before { content: ""; position: absolute; inset-inline-start: -7px; top: 50%; margin-top: -7px; border: 7px solid transparent; border-inline-start: 0; border-inline-end-color: var(--tc); }
.stl .stb b { font-size: 28px; font-weight: 700; }
.stl.out { --tc: var(--t-out); } .stl.fin { --tc: var(--t-fin); } .stl.rdy { --tc: var(--t-rdy); } .stl.loop { --tc: var(--t-loop); }
.stl.arr { --tc: var(--t-arr); } .stl.vet { --tc: var(--t-vet); } .stl.hold { --tc: var(--t-hold); }
.stl.loop .stb { color: #2a1e00; }
.spies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.spie { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.spie figcaption { font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: center; }
.spie .pc { position: relative; width: min(100%, 150px); aspect-ratio: 1; border-radius: 50%; box-shadow: 0 0 0 2px var(--card), 0 2px 8px rgba(0,0,0,.18); }
.spie .pc span { position: absolute; transform: translate(-50%, -50%); color: #fff; font-size: 13px; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.55); white-space: nowrap; }
.spie ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; width: 100%; }
.spie li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.spie li i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.spie li b { margin-inline-start: auto; font-size: 14px; }
.spie li small { color: var(--muted); font-size: 11px; min-width: 40px; text-align: end; }
@media (max-width: 380px) { .stl { grid-template-columns: 1fr 60px; } .stl .stb { height: 56px; } .stl .stb b { font-size: 24px; } .spies { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .spies { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .spie li { font-size: 11.5px; gap: 4px; } .spie li small { display: none; } } @media (max-width: 330px) { .spies { grid-template-columns: 1fr; } }
