/* Sportival results screen, design v2. Stage is a fixed 1920x1080 canvas scaled to the window. */

@font-face { font-family: "Inter Display"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/InterDisplay-Medium.otf") format("opentype"); }
@font-face { font-family: "Inter Display"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/InterDisplay-SemiBold.otf") format("opentype"); }
@font-face { font-family: "Inter Display"; font-weight: 900; font-style: normal; font-display: swap; src: url("fonts/InterDisplay-Black.otf") format("opentype"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/Poppins-Bold.ttf") format("truetype"); }

:root, :root[data-theme="dark"] {
  --bg: #01113f;
  --surface: #072263;
  --ink: #f3f7ff;
  --muted: #9fb4de;
  --line: #1b3d86;
  --run: #2fe0c8;
  --ride: #4fb4ff;
  --multi: #ff9272;
  --hl: #c2f51a;
  --podium-ink: #010039;
}
:root[data-theme="light"] {
  --bg: #f3f6fc;
  --surface: #ffffff;
  --ink: #010039;
  --muted: #475a88;
  --line: #d0daf0;
  --run: #0a8a7c;
  --ride: #0353a0;
  --multi: #d4472a;
  --hl: #021f5a;
  --podium-ink: #c2f51a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body { font-family: "Inter Display", Inter, "Helvetica Neue", Arial, sans-serif; font-weight: 500; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
.display, .wordmark, .search-title, .p-name, .total-num, .total-unit, .bib-rank, .stat b, .goal-head b { font-family: "Poppins", "Inter Display", Inter, sans-serif; font-weight: 700; }

#viewport { position: fixed; inset: 0; background: var(--bg); }
#stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; background: var(--bg); overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s linear .35s; }
.screen.is-active { opacity: 1; visibility: visible; transition: opacity .35s ease; }

/* ---------- shared top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 80px; }
.brand { display: flex; align-items: baseline; gap: 28px; }
.wordmark { font-size: 40px; letter-spacing: -0.02em; }
.event-sub { font-size: 28px; color: var(--muted); }
.tools { display: flex; align-items: center; gap: 20px; }
.tool { font: inherit; font-weight: 600; font-size: 26px; color: var(--ink); background: transparent; border: 2px solid var(--line); border-radius: 999px; padding: 12px 28px; cursor: pointer; display: inline-flex; align-items: center; gap: 12px; }
.tool:hover { border-color: var(--muted); }
.tool:focus-visible, .row:focus-visible { outline: 4px solid var(--hl); outline-offset: 3px; }
.tool-dot { width: 18px; height: 18px; border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 2px solid var(--ink); }
.demo-badge { font-weight: 600; font-size: 24px; color: var(--podium-ink); background: var(--hl); border-radius: 8px; padding: 8px 16px; }

/* ---------- search screen: one centred column ---------- */
#search { --glow: #ff6b4a; --glow-o: .22; --d1: #ff6b4a; --d1-o: .14; --d2: #0a78b8; --d2-o: .38; }
:root[data-theme="light"] #search { --glow: #ff9272; --glow-o: .38; --d1: #ff9272; --d1-o: .22; --d2: #4fa7d9; --d2-o: .16; }
.dunes { position: absolute; inset: 0; width: 100%; height: 100%; }
.stack { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding-top: 190px; transition: padding-top .5s cubic-bezier(.2,.8,.2,1); }
.logo-xl { height: 200px; width: auto; display: block; transition: height .5s cubic-bezier(.2,.8,.2,1); animation: bob 7s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
#search .event-sub { font-size: 46px; font-weight: 600; color: var(--muted); margin: 26px 0 36px; max-width: 1500px; letter-spacing: .01em; text-align: center; }

.search-field { position: relative; display: block; width: 1180px; height: 118px; border-radius: 59px; background: var(--surface); border: 3px solid var(--line);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 40, .55); transition: border-color .2s, box-shadow .2s; }
.search-field:focus-within { border-color: var(--hl); box-shadow: 0 0 0 6px color-mix(in srgb, var(--hl) 30%, transparent), 0 24px 60px -20px rgba(0, 0, 40, .55); }
.sf-icon { position: absolute; left: 44px; top: 50%; width: 50px; height: 50px; margin-top: -25px; color: var(--muted); }
.search-field input { width: 100%; height: 100%; font: inherit; font-weight: 600; font-size: 54px; text-align: center; color: var(--ink); background: transparent; border: 0; border-radius: 59px; padding: 0 110px; caret-color: var(--hl); }
#q:focus-visible { outline: none; }
.ph { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-weight: 600; font-size: 54px; color: var(--muted); }
.ph span { grid-area: 1 / 1; opacity: 0; animation: phswap 7s ease-in-out infinite; }
.ph span:nth-child(2) { animation-delay: 3.5s; }
@keyframes phswap { 0%, 4% { opacity: 0; transform: translateY(10px); } 12%, 42% { opacity: 1; transform: none; } 50%, 100% { opacity: 0; transform: translateY(-10px); } }
.search-field.filled .ph { display: none; }

.results { list-style: none; width: 1180px; margin-top: 22px; }
.row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; column-gap: 26px; height: 72px; padding: 0 44px; border-radius: 39px; cursor: pointer; }
.row .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.row .nm { font-weight: 600; font-size: 40px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 28px; color: var(--muted); }
.row[aria-selected="true"] { background: var(--surface); box-shadow: inset 0 0 0 3px var(--c); }
.row[aria-selected="true"] .meta { color: var(--ink); }
.search-hint { margin-top: 20px; text-align: center; font-size: 26px; color: var(--muted); }
.empty { font-size: 38px; color: var(--muted); text-align: center; padding: 34px 0; }
.corner { position: absolute; top: 40px; display: flex; gap: 16px; align-items: center; opacity: .75; }
.corner:hover, .corner:focus-within { opacity: 1; }
.corner-tl { left: 56px; } .corner-tr { right: 56px; }
.copyright { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; font-size: 24px; color: var(--muted); letter-spacing: .02em; }
.corner .tool { font-size: 24px; padding: 10px 24px; }
#stage:has(#search.is-active) .dune-a { animation: drift 26s ease-in-out infinite alternate; }
#stage:has(#search.is-active) .dune-b { animation: drift 34s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translateX(-90px); } to { transform: translateX(90px); } }
@media (prefers-reduced-motion: reduce) { .logo-xl, .dune { animation: none !important; } .ph span:first-child { animation: none; opacity: 1; } .ph span:nth-child(2) { display: none; } }

/* ---------- result screen ---------- */
#result { padding: 56px 96px 48px; display: grid; grid-template-rows: 80px 1fr 320px 104px; row-gap: 28px; }
#result[data-cls="running"]    { --accent: var(--run); }
#result[data-cls="cycling"]    { --accent: var(--ride); }
#result[data-cls="multisport"] { --accent: var(--multi); }

.class-pill { display: inline-flex; align-items: center; gap: 14px; font-weight: 600; font-size: 30px; border: 2px solid var(--accent, var(--line)); border-radius: 999px; padding: 10px 28px; }
.pill-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }

.hero { display: grid; grid-template-columns: 1fr 470px; column-gap: 64px; align-items: stretch; min-height: 0; }
.hero-main { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.p-name { font-size: 96px; line-height: 1.05; letter-spacing: -0.02em; white-space: nowrap; }
.total { display: flex; align-items: baseline; gap: 22px; margin-top: 2px; padding-bottom: 20px; color: var(--accent); white-space: nowrap; }
.total-num { font-size: 220px; line-height: .9; letter-spacing: -0.04em; }
.total-unit { font-size: 72px; letter-spacing: -0.01em; }
.total-caption { font-size: 36px; color: var(--muted); }

/* The rank block is shaped like a race bib. */
.bib { position: relative; border: 6px solid var(--ink); border-radius: 18px; padding: 52px 36px 28px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: var(--surface); }
.bib.podium { background: var(--hl); border-color: var(--hl); color: var(--podium-ink); }
.bib.podium .bib-of, .bib.podium .bib-top { color: var(--podium-ink); }
.pin { position: absolute; top: 16px; width: 18px; height: 18px; border-radius: 50%; border: 4px solid currentColor; opacity: .55; }
.pin-l { left: 20px; } .pin-r { right: 20px; }
.bib-rank { font-size: 170px; line-height: 1; letter-spacing: -0.04em; }
.bib-of { font-weight: 600; font-size: 36px; margin-top: 4px; }
.bib-top { font-weight: 600; font-size: 34px; color: var(--muted); margin-top: 8px; }

.hero-main.long .p-name { line-height: 1.06; }
.hero-main.long .total-num { font-size: 170px; }
.hero-main.long .total-unit { font-size: 60px; }

/* ---------- lower band: training calendar + goal ---------- */
.lower { display: grid; grid-template-columns: 1100px 1fr; column-gap: 64px; min-height: 0; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart text { font-family: inherit; fill: var(--muted); font-size: 24px; font-weight: 500; }
.chart .dl { font-size: 22px; }
.chart .wk-lbl { font-size: 24px; }
.chart .wk-lbl.empty { opacity: .6; }

/* weekly bars (used only when a participant has no daily data) */
.chart .val { font-size: 26px; font-weight: 600; fill: var(--ink); }
.chart .val.zero { fill: var(--muted); font-weight: 500; }
.chart .val.best { fill: var(--hl); font-weight: 900; font-size: 32px; }
.chart .wk.best { fill: var(--hl); font-weight: 900; }
.chart .base { stroke: var(--line); stroke-width: 3; }
.seg-main { fill: var(--accent); } .seg-run { fill: var(--run); } .seg-ride { fill: var(--ride); }
.cap { fill: var(--hl); } .zero-tick { fill: var(--line); }
.legend text { fill: var(--ink); font-weight: 600; }

/* calendar cells */
.cell { fill: var(--accent); }
.cell.off { fill: var(--surface); stroke: var(--line); stroke-width: 2; fill-opacity: 1; }
.cell.gap { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 5 6; }
.cell.best { stroke: var(--hl); stroke-width: 5; }
.pop { transform-box: fill-box; transform-origin: 50% 50%; animation: pop .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--w) * 40ms + 150ms); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* goal */
.goal { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.goal-head { display: flex; align-items: baseline; gap: 18px; white-space: nowrap; }
.goal-head b { font-size: 84px; line-height: 1; letter-spacing: -0.03em; }
.goal-head span { font-size: 32px; color: var(--muted); white-space: normal; }
.track { position: relative; height: 30px; margin: 30px 0 52px; border-radius: 15px; background: var(--surface); border: 2px solid var(--line); }
.track i { font-style: normal; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 15px; background: var(--accent); transform-origin: 0 50%; animation: growx 1s cubic-bezier(.2,.8,.2,1) .4s both; }
.track .tick { position: absolute; top: -14px; bottom: -14px; width: 6px; margin-left: -3px; border-radius: 3px; background: var(--hl); }
.track .tick::after { content: attr(data-label); position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font-size: 24px; font-weight: 600; color: var(--hl); white-space: nowrap; }
.track .tick.end::after { left: auto; right: 0; transform: none; }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.goal-when { font-size: 32px; font-weight: 600; }
.cal-note { font-size: 24px; color: var(--muted); margin-top: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); align-items: stretch; }
.stat { padding: 0 40px; border-left: 2px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.stat:first-child { padding-left: 0; border-left: 0; }
.stat b { font-size: 56px; line-height: 1.05; letter-spacing: -0.03em; }
.stat b i { font-family: "Inter Display", Inter, sans-serif; font-style: normal; font-weight: 600; font-size: 32px; letter-spacing: 0; color: var(--muted); margin-left: 10px; }
.stat span { font-size: 28px; color: var(--muted); margin-top: 6px; }

.hold { position: absolute; left: 0; bottom: 0; height: 8px; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.hold.run { animation: drain linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* weekly-bar fallback animation */
.rise { transform-box: fill-box; transform-origin: 50% 100%; animation: rise .7s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 60ms + 150ms); }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.fade-in { animation: fade .5s ease both; animation-delay: calc(var(--i) * 60ms + 500ms); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .rise, .fade-in, .pop, .track .fill { animation: none; }
  .screen, .screen.is-active { transition: none; }
}

.logo { height: 132px; width: auto; display: block; margin: -26px 0; }
.brand { align-items: center; gap: 36px; }
.logo { height: 104px; margin: -12px 0; }

.logo-l { display: none; }
:root[data-theme="light"] .logo-d { display: none; }
:root[data-theme="light"] .logo-l { display: block; }

/* ---------- detail page revision ---------- */
#result { padding: 48px 96px 36px; grid-template-rows: 90px 1fr 252px 92px; row-gap: 14px; }
#result .event-sub { font-size: 28px; }
.logo { height: 92px; margin: -4px 0; }
.tool.icon { width: 56px; height: 56px; padding: 0; justify-content: center; }
.tool.icon svg { width: 28px; height: 28px; }
#result .tools { gap: 16px; }
.congrats { font-size: 40px; font-weight: 600; color: var(--hl); letter-spacing: .01em; line-height: 1.1; }
.name-row { display: flex; align-items: center; gap: 32px; }
.name-row .p-name { font-size: 104px; line-height: 1.04; }
.name-row .class-pill { flex-shrink: 0; font-size: 34px; padding: 10px 30px; }
.hero-main { justify-content: center; }
.total { margin-top: 0; padding-bottom: 10px; }
.total-num { font-size: 168px; }
.total-unit { font-size: 64px; }
.total-caption { font-size: 34px; }
.hero-main.long .total-num { font-size: 140px; }
.goal { margin-top: 12px; }
.goal-head { display: flex; align-items: baseline; gap: 16px; }
.goal-head b { font-size: 54px; line-height: 1; }
.goal-head span { font-size: 30px; color: var(--muted); }
.goal-head em { margin-left: auto; font-style: normal; font-size: 30px; font-weight: 600; }
.track { margin: 18px 0 8px; height: 26px; border-radius: 13px; }
.track .fill { border-radius: 13px; }
.track .tick { top: -12px; bottom: -12px; }
.track .tick::after { content: none; }
.lower { display: flex; justify-content: center; align-items: center; grid-template-columns: none; }
.chart { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.chart svg { width: 800px; height: 227px; }
.chart text { font-size: 31px; }
.chart .dl { font-size: 29px; }
.chart .wk-lbl { font-size: 31px; }
.cal-note { font-size: 22px; color: var(--muted); margin-top: 8px; text-align: center; }
.stat b { font-size: 52px; }
.stat span { font-size: 26px; }

/* ---------- detail page revision 2 ---------- */
#result { grid-template-rows: 90px 1fr 300px; }
.congrats { font-family: "Poppins", "Inter Display", Inter, sans-serif; font-weight: 700; font-size: 64px; line-height: 1.05; text-transform: uppercase; letter-spacing: -0.01em; }
.co2 { display: flex; align-items: center; gap: 12px; font-size: 30px; font-weight: 600; margin-top: 6px; }
.co2:empty { display: none; }
.co2 svg { width: 34px; height: 34px; flex-shrink: 0; color: var(--hl); }
.lower { display: grid; grid-template-columns: 1fr 470px; column-gap: 64px; align-items: center; justify-content: stretch; }
.chart { align-items: stretch; }
.chart svg { width: 100%; height: auto; }
.chart text { font-size: 24px; }
.chart .dl { font-size: 22px; }
.chart .wk-lbl { font-size: 24px; }
.stats { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; height: 100%; }
.stat { padding: 0 18px; border-left: 0; align-items: center; text-align: center; }
.stat:nth-child(even) { border-left: 2px solid var(--line); }
.stat:nth-child(n+3) { border-top: 2px solid var(--line); }
.stat b { font-size: 46px; }
.stat b i { font-size: 26px; }
.stat span { font-size: 22px; }
.corner .tool.icon { padding: 0; font-size: inherit; }
.tool.icon svg { width: 28px; height: 28px; }

/* bib lines up with the Congratulations line (top) and the goal bar (bottom) */
.hero { align-self: center; align-items: stretch; }
.hero-main { justify-content: flex-start; }
.goal .track { margin-bottom: 0; }
.hero .bib { margin-top: 10px; }

/* ---------- detail page: content scaled to 90% so every edge has more breathing room ---------- */
#result { padding: 0; display: block; }
.r-inner { position: absolute; left: 182px; top: 80px; width: 1728px; height: 996px; transform: scale(.9); transform-origin: 0 0;
  display: grid; grid-template-rows: 90px 1fr 300px; row-gap: 14px; }

/* ---------- detail page revision 3 ---------- */
.r-inner { left: 165px; top: 70px; transform: scale(.92); grid-template-rows: 90px 1fr; }
.main { display: grid; grid-template-columns: 1fr 470px; column-gap: 64px; align-self: center; }
.mainleft { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.main .bib { margin-top: 10px; }
.lowerleft { display: grid; grid-template-columns: 380px 786px; column-gap: 28px; align-items: stretch; }
.lowerleft .stats { height: auto; }
.lowerleft .chart { display: block; }
.lowerleft .chart svg { width: 786px; height: 264px; display: block; }
.stat b { font-size: 42px; } .stat b i { font-size: 24px; } .stat span { font-size: 22px; }
.total-caption { font-size: 40px; line-height: 1.15; }
.co2 { font-size: 40px; margin-top: 4px; }
.co2 svg { width: 42px; height: 42px; }
.lowerleft .stat { padding: 0 6px; }
.lowerleft .stat span { font-size: 21px; }
.lowerleft .chart text { font-size: 21px; }
.lowerleft .chart .dl { font-size: 21px; }
.lowerleft .chart .wk-lbl { font-size: 21px; }

/* ---------- detail page revision 4 ---------- */
.r-inner { left: 126px; width: 1812px; }
.lowerleft { grid-template-columns: 440px 810px; column-gap: 28px; }
.lowerleft .chart svg { width: 810px; }
.lowerleft .stat { align-items: flex-start; text-align: left; padding: 0 0 0 30px; }
.lowerleft .stat:nth-child(odd) { padding-left: 0; }
.lowerleft .stat:nth-child(even) { border-left: 2px solid var(--line); }
.lowerleft .stat b { font-size: 54px; }
.lowerleft .stat b i { font-size: 28px; }
.lowerleft .stat span { font-size: 24px; margin-top: 6px; }
.main .bib { justify-content: flex-start; padding-top: 80px; }

/* rev5: one-line facts row + bib badge */
.facts { display: flex; align-items: center; gap: 28px; margin-top: 4px; }
.facts .co2, .facts .total-caption { margin: 0; font-size: 40px; font-weight: 600; line-height: 1.15; color: var(--ink); white-space: nowrap; }
.facts .total-caption { color: var(--muted); }
.facts-sep { width: 3px; height: 44px; background: var(--line); border-radius: 2px; flex-shrink: 0; }
.facts.solo .facts-sep { display: none; }
.facts .co2:empty { display: none; }
.main .bib { position: relative; }
.bib-badge { position: absolute; left: 36px; right: 36px; bottom: 36px; padding: 16px 12px; border-radius: 14px; font-family: "Poppins","Inter Display",Inter,sans-serif; font-weight: 700; font-size: 38px; letter-spacing: .02em; text-transform: uppercase; text-align: center; border: 3px solid var(--hl); color: var(--hl); }
.bib-badge[hidden] { display: none; }
.bib-badge[data-kind="winner"] { background: var(--hl); color: var(--podium-ink); }
.bib-badge[data-kind="finisher"] { background: transparent; }
.bib-badge[data-kind="participant"] { border-color: var(--line); color: var(--muted); }
.bib.podium .bib-badge { border-color: var(--podium-ink); color: var(--podium-ink); }
.bib.podium .bib-badge[data-kind="winner"] { background: var(--podium-ink); color: var(--hl); }
.facts .total-caption { color: var(--ink); }
/* rev6: badge on top of rank, one line, gold / silver / transparent */
.main .bib { padding-top: 56px; }
.bib-badge { position: static; left: auto; right: auto; bottom: auto; align-self: center; margin: 0 0 22px; padding: 12px 30px; font-size: 34px; white-space: nowrap; border-width: 3px; border-style: solid; }
.bib-badge[hidden] { display: none; }
.bib-badge[data-kind="winner"] { background: linear-gradient(135deg,#ffe27a,#f2b705 55%,#c98f00); color: #3a2600; border-color: #fff2b0; }
.bib-badge[data-kind="finisher"] { background: linear-gradient(135deg,#f4f7fb,#b9c2cf 55%,#8d97a6); color: #1b2430; border-color: #ffffff; }
.bib-badge[data-kind="participant"] { background: transparent; color: var(--ink); border-color: var(--line); }
.bib.podium .bib-badge[data-kind="winner"] { background: linear-gradient(135deg,#ffe27a,#f2b705 55%,#c98f00); color: #3a2600; border-color: var(--podium-ink); }
.bib.podium .bib-badge[data-kind="finisher"] { border-color: var(--podium-ink); }
.bib.podium .bib-badge[data-kind="participant"] { background: transparent; color: var(--podium-ink); border-color: var(--podium-ink); }
.bib .bib-badge[data-kind="finisher"], .bib.podium .bib-badge[data-kind="finisher"] { color: #1b2430; }
.bib.podium .bib-badge[data-kind="winner"] { color: #3a2600; }

/* rev7: detail page, light theme -> warm orange scheme from the logo */
:root[data-theme="light"] #result {
  --bg: #fff3ea; --surface: #ffe3d2; --line: #f4bfa3; --muted: #8a4a33; --ink: #2a0f08;
  --hl: #e8501f; --podium-ink: #2a0f08;
  --run: #0a7d70; --ride: #0b55a8; --multi: #d4401c;
  background: var(--bg);
}
:root[data-theme="light"] #result .bib { border-color: var(--hl); }
:root[data-theme="light"] #result .bib.podium { background: #f28f6f; border-color: #f28f6f; color: var(--podium-ink); }
:root[data-theme="light"] #result .tool, :root[data-theme="light"] #result .icon-btn { border-color: var(--line); color: var(--ink); }
:root[data-theme="light"] #result .goal .track { background: #ffd2b8; }
:root[data-theme="light"] #result .bib-badge[data-kind="participant"] { color: var(--ink); border-color: var(--hl); }
:root[data-theme="light"] #result { color: var(--ink); } :root[data-theme="light"] #result .p-name, :root[data-theme="light"] #result .goal-head em { color: var(--ink); }
/* rev8: one bib template per theme (no rank-based variant); ?bib=filled previews the alternative */
.bib.filled { background: var(--hl); border-color: var(--hl); color: var(--podium-ink); }
.bib.filled .bib-of, .bib.filled .bib-top { color: var(--podium-ink); }
.bib.filled .bib-badge[data-kind="participant"] { color: var(--podium-ink); border-color: var(--podium-ink); }
:root[data-theme="light"] #result .bib.filled { background: #f28f6f; border-color: #f28f6f; }

/* rev9: locked — dark = filled bib, light = outlined bib */
:root:not([data-theme="light"]) .bib { background: var(--hl); border-color: var(--hl); color: var(--podium-ink); }
:root:not([data-theme="light"]) .bib .bib-of, :root:not([data-theme="light"]) .bib .bib-top { color: var(--podium-ink); }
:root:not([data-theme="light"]) .bib .bib-badge[data-kind="participant"] { color: var(--podium-ink); border-color: var(--podium-ink); }
:root:not([data-theme="light"]) .bib .bib-badge[data-kind="winner"], :root:not([data-theme="light"]) .bib .bib-badge[data-kind="finisher"] { border-color: var(--podium-ink); }


/* rev11: modern badges — flat metal, soft sheen, icon, no heavy outline */
.bib .bib-badge { display: inline-flex; align-items: center; justify-content: center; gap: 14px; border: 0; border-radius: 999px; padding: 14px 34px 14px 26px; font-size: 32px; letter-spacing: .06em; box-shadow: inset 0 1.5px 0 rgba(255,255,255,.55), inset 0 -2px 0 rgba(0,0,0,.12), 0 8px 18px -8px rgba(0,0,0,.45); }
.bib .bib-badge svg { width: 38px; height: 38px; flex-shrink: 0; }
.bib .bib-badge[data-kind="winner"], :root:not([data-theme="light"]) .bib .bib-badge[data-kind="winner"], .bib.podium .bib-badge[data-kind="winner"] { background: linear-gradient(160deg, #f7df8e 0%, #e3b441 60%, #d9a52e 100%); color: #4a3000; border: 0; }
.bib .bib-badge[data-kind="finisher"], :root:not([data-theme="light"]) .bib .bib-badge[data-kind="finisher"], .bib.podium .bib-badge[data-kind="finisher"] { background: linear-gradient(160deg, #f1f4f8 0%, #c9d0da 60%, #b4bcc8 100%); color: #263142; border: 0; }
.bib .bib-badge[data-kind="participant"] { box-shadow: none; padding-left: 34px; border: 3px solid currentColor; background: transparent; }
:root[data-theme="light"] #result .bib .bib-badge[data-kind="participant"] { color: var(--ink); border-color: var(--hl); }
:root:not([data-theme="light"]) .bib .bib-badge[data-kind="participant"] { color: var(--podium-ink); border-color: var(--podium-ink); }
.bib .bib-badge { font-size: 28px; letter-spacing: .05em; padding: 13px 28px 13px 22px; gap: 11px; }
.bib .bib-badge svg { width: 34px; height: 34px; }
#result .logo { height: 129px; margin: -22px 0; }
.bib .bib-badge[hidden] { display: none; }

/* rev12/13: stage fills the window; result page stretches across it (height stays 16:9-based) */
#result.screen { inset: auto; left: 0; width: var(--sw, 1920px); height: 1080px; top: calc((var(--sh, 1080px) - 1080px) / 2); }
#result .r-inner { left: 126px; width: calc((var(--sw, 1920px) - 252px) / 0.92); }
#result .lowerleft { grid-template-columns: 440px 1fr; }
#result .lowerleft .chart svg { width: 100%; }
.exporting *, .exporting { animation: none !important; transition: none !important; }
.name-row .p-name { min-width: 0; }

/* rev14: calendar + goal block use one orange for every sport */
#result .goal, #result .chart { --accent: var(--multi); }

/* rev15: total number unified: blue in dark mode, orange in light mode */
#result .total { --accent: var(--ride); }
:root[data-theme="light"] #result .total { --accent: var(--multi); }

/* v2: participant photo circle on the bib + capture dialog */
.bib .photo { --pc: var(--podium-ink); position: relative; flex: none; width: 250px; height: 250px; margin: 34px auto 0; padding: 0; border-radius: 50%; border: 6px solid var(--pc); background: transparent; color: var(--pc); cursor: pointer; overflow: visible; font: inherit; display: flex; align-items: center; justify-content: center; }
:root[data-theme="light"] #result .bib .photo { --pc: var(--hl); }
.bib .photo.empty { border-style: dashed; }
.bib .photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.bib .photo img[hidden], .bib .photo .photo-hint[hidden], .bib .photo .photo-edit[hidden] { display: none; }
.photo-hint { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 28px; font-weight: 600; }
.photo-hint svg { width: 64px; height: 64px; }
.photo-edit { position: absolute; right: -6px; bottom: -6px; width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--pc); color: var(--hl); border: 4px solid var(--hl); }
:root[data-theme="light"] #result .photo-edit { color: #fff; border-color: var(--surface); }
.photo-edit svg { width: 32px; height: 32px; }

.pm { position: absolute; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; }
.pm[hidden] { display: none; }
.pm-card { width: 760px; background: #14181d; color: #fff; border-radius: 28px; padding: 40px 48px; display: flex; flex-direction: column; gap: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.6); font-family: inherit; }
:root[data-theme="light"] .pm-card { background: #fff3ea; color: #2a0f08; }
.pm-title { font-size: 44px; font-weight: 700; text-align: center; }
.pm-body { display: flex; flex-direction: column; align-items: center; gap: 22px; min-height: 360px; justify-content: center; }
.pm-choose { display: flex; flex-direction: column; gap: 22px; width: 100%; align-items: center; }
.pm-big { width: 100%; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 34px; font-size: 40px; font-weight: 600; border-radius: 22px; border: 3px solid currentColor; background: transparent; color: inherit; cursor: pointer; font-family: inherit; }
.pm-big svg { width: 56px; height: 56px; }
.pm-big:hover { background: rgba(255,255,255,.08); }
:root[data-theme="light"] .pm-big:hover { background: rgba(232,80,31,.1); }
.pm-link { background: none; border: 0; color: inherit; opacity: .75; font-size: 26px; text-decoration: underline; cursor: pointer; font-family: inherit; }
.pm-link[hidden], .pm-btn[hidden], .pm-choose[hidden], .pm-stage[hidden], .pm-msg[hidden], .pm-count[hidden], #pmZoom[hidden] { display: none; }
.pm-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.pm-view { position: relative; width: 400px; height: 400px; border-radius: 50%; overflow: hidden; background: #000; border: 6px solid #e8501f; }
.pm-view video, .pm-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; touch-action: none; }
.pm-view video { transform: scaleX(-1); }
.pm-view canvas { cursor: grab; }
.pm-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 180px; font-weight: 700; color: #fff; text-shadow: 0 4px 24px rgba(0,0,0,.7); }
#pmZoom { width: 400px; accent-color: #e8501f; height: 28px; }
.pm-hint, .pm-msg { font-size: 28px; text-align: center; opacity: .85; }
.pm-actions { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.pm-btn { font-size: 32px; font-weight: 600; padding: 18px 42px; border-radius: 999px; border: 3px solid currentColor; background: transparent; color: inherit; cursor: pointer; font-family: inherit; }
.pm-btn.pm-main { background: #e8501f; border-color: #e8501f; color: #fff; }
.photo-hint { padding: 0 44px; text-align: center; line-height: 1.15; font-size: 28px; }
.photo-hint b { font-weight: 600; max-width: 130px; }
/* photo sits between the badge and the rank number */
/* the photo circle is off by default; it appears after a photo is added when downloading */
.bib .photo { display: none; }
html.photo-on .bib .photo { display: flex; width: 250px; height: 250px; margin: 0 auto 20px; }
html.photo-on .bib .photo-hint { padding: 0 40px; font-size: 28px; }
html.photo-on .bib .photo-hint svg { width: 60px; height: 60px; }
html.photo-on .bib .bib-rank { font-size: 160px; }
.bib .photo { pointer-events: none; cursor: default; }
