:root {
  --bg: #282828;
  --panel: #1f1f1f;
  --panel-2: #343434;
  --text: #ffffff;
  --muted: #c9c9c9;
  --line: rgba(255, 255, 255, 0.14);
  --yellow: #ffff04;
  --green: #23d18b;
  --red: #ff5a67;
  --orange: #ff9f43;
  --blue: #f0f0f0;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  font-family: Arial, Helvetica, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 4, 0.09) 0 12%, transparent 12% 100%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 26px),
    linear-gradient(180deg, #3a3a3a 0%, #282828 38%, #1d1d1d 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
body.has-modal { overflow: hidden; }

.app-shell { width: min(1200px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 80px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; padding: 18px 20px; border-radius: 8px; background: var(--yellow); color: #111; box-shadow: var(--shadow); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 4vw, 3rem); letter-spacing: 0; font-weight: 1000; text-transform: uppercase; }
h2 { margin-bottom: 8px; }
.eyebrow { margin-bottom: 6px; color: var(--yellow); font-size: 0.78rem; font-weight: 1000; letter-spacing: 0; text-transform: uppercase; }
.topbar .eyebrow { color: #282828; }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.tab { border: 1px solid var(--line); border-radius: 6px; padding: 13px; background: rgba(31, 31, 31, 0.9); color: var(--muted); font-weight: 900; text-transform: uppercase; }
.tab.is-active { color: #111; background: var(--yellow); border-color: var(--yellow); box-shadow: 0 8px 24px rgba(255, 255, 4, 0.18); }
.view { display: none; }
.view.is-active { display: block; }
.panel { background: linear-gradient(180deg, rgba(52, 52, 52, 0.98), rgba(31, 31, 31, 0.98)); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 20px; }
.hero-panel, .results-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero-panel p { color: var(--muted); max-width: 720px; margin-bottom: 0; line-height: 1.55; }
.hero-stat { width: 105px; height: 105px; flex: 0 0 105px; display: grid; place-content: center; text-align: center; border-radius: 8px; background: var(--yellow); color: #101010; transform: skew(-7deg); }
.hero-stat span { font-size: 2rem; font-weight: 1000; line-height: 1; }
.hero-stat small { font-weight: 900; text-transform: uppercase; }

.intro-layout { display: grid; gap: 18px; }
.intro-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 28px;
  align-items: end;
  border: 1px solid rgba(255, 255, 4, 0.28);
  border-radius: 8px;
  padding: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 4, 0.16), transparent 32%),
    linear-gradient(180deg, rgba(52, 52, 52, 0.98), rgba(20, 20, 20, 0.98));
  box-shadow: var(--shadow);
}
.intro-copy h2 { max-width: 620px; margin-bottom: 14px; font-size: 2.45rem; line-height: 1.06; text-transform: uppercase; }
.intro-copy p:not(.eyebrow) { max-width: 580px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; line-height: 1.55; }
.intro-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; min-height: 310px; }
.intro-podium-place { display: grid; align-content: end; min-width: 0; text-align: center; }
.intro-podium-place--winner { min-height: 292px; }
.intro-podium-place--second { min-height: 248px; }
.intro-podium-place--third { min-height: 220px; }
.intro-podium-jersey { width: min(132px, 86%); height: 132px; display: block; margin: 0 auto 12px; object-fit: contain; filter: drop-shadow(0 15px 18px rgba(0, 0, 0, 0.34)); }
.intro-podium-step {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 88px;
  border-radius: 6px 6px 0 0;
  padding: 14px 8px;
  background: #f0f0f0;
  color: #101010;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.55), 0 12px 22px rgba(0, 0, 0, 0.28);
}
.intro-podium-place--winner .intro-podium-step { min-height: 132px; background: var(--yellow); }
.intro-podium-place--second .intro-podium-step { min-height: 106px; background: var(--green); }
.intro-podium-place--third .intro-podium-step { background: #ffffff; }
.intro-podium-step strong { font-size: 1rem; line-height: 1.2; text-transform: uppercase; overflow-wrap: anywhere; }
.intro-podium-step span { font-size: 0.82rem; font-weight: 900; opacity: 0.72; text-transform: uppercase; }
.intro-route {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  color: #111;
  box-shadow: var(--shadow);
}
.intro-route .eyebrow { color: #d1a900; }
.intro-route-header { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 14px; }
.intro-route-header h3 { margin-bottom: 0; font-size: 1.35rem; line-height: 1.2; text-transform: uppercase; }
.intro-route-header span { flex: 0 0 auto; border-radius: 6px; padding: 8px 10px; background: #111; color: var(--yellow); font-weight: 1000; text-transform: uppercase; }
.intro-route-map { display: block; width: 100%; max-height: 720px; object-fit: contain; border-radius: 6px; background: #ffffff; }
.intro-actions { display: flex; justify-content: center; }
.intro-start-button { min-width: 240px; padding: 15px 22px; font-size: 1.04rem; }

.form-panel { margin-top: 16px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
label { color: var(--muted); font-size: 0.9rem; font-weight: 700; }
input, select { width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 6px; background: #161616; color: var(--text); padding: 12px 13px; outline: none; }
input:focus, select:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 255, 4, 0.12); }

.btn { border: 0; border-radius: 6px; padding: 12px 15px; font-weight: 1000; text-transform: uppercase; transition: transform 0.12s ease, filter 0.12s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary { background: var(--yellow); color: #17140a; }
.btn-secondary { background: #111; color: var(--text); border: 1px solid var(--line); }
.btn-success { background: var(--green); color: #06291b; }
.btn-danger { background: var(--red); color: white; }
.btn-blue { background: #ffffff; color: #171717; }
.btn-small { padding: 9px 11px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.suggestions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.suggestions > span { color: var(--muted); font-size: 0.88rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; background: #161616; color: var(--text); padding: 8px 12px; }
.chip:disabled { opacity: 0.45; }
.card-grid, .timer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-top: 16px; }
.team-card, .timer-card { border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(180deg, #343434, #202020); padding: 18px; box-shadow: var(--shadow); }
.team-card { border-left: 5px solid var(--yellow); }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-title-row h3 { margin-bottom: 0; }
.rider-list { display: grid; gap: 8px; margin: 14px 0; }
.rider-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 6px; background: rgba(255,255,255,0.05); }
.rider-row span { overflow: hidden; text-overflow: ellipsis; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.help-text { color: var(--muted); font-size: 0.8rem; line-height: 1.4; }

.stage-overview { border-top: 6px solid var(--stage-color, var(--yellow)); }
.stage-overview-content { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: stretch; }
.stage-kicker { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 14px; color: var(--muted); font-weight: 800; }
.stage-number { color: #111; background: var(--yellow); border-radius: 4px; padding: 5px 8px; }
.stage-state { color: var(--text); }
.stage-description { color: var(--text); line-height: 1.55; white-space: pre-line; font-size: 1.04rem; }
.stage-note, .stage-intermission { color: var(--muted); line-height: 1.5; margin: 12px 0 0; }
.stage-note strong { color: var(--yellow); }
.stage-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 13px; }
.meta-pill { border: 1px solid var(--line); background: #161616; border-radius: 999px; padding: 7px 10px; font-size: 0.8rem; color: var(--muted); }
.stage-image { width: 100%; aspect-ratio: 16 / 9; max-height: 640px; object-fit: cover; border-radius: 8px; border: 3px solid var(--yellow); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28); }
.stage-timing-preview { margin-top: 0; min-height: 280px; align-content: start; border: 3px solid var(--yellow); border-radius: 8px; padding: 14px; background: linear-gradient(180deg, rgba(52, 52, 52, 0.94), rgba(23, 23, 23, 0.94)); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28); }
.stage-timing-preview.timer-grid { margin-top: 0; }
.stage-timing-preview .countdown-panel { margin-top: 0; box-shadow: none; }
.stage-timing-preview .timer-card { box-shadow: none; }
.stage-result-board { position: relative; overflow: hidden; border: 3px solid var(--yellow); border-radius: 8px; padding: 18px; background: linear-gradient(180deg, rgba(52, 52, 52, 0.96), rgba(17, 17, 17, 0.96)); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28); }
.stage-result-board::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 0 36%, rgba(255,255,4,0.22) 43%, transparent 50% 100%); transform: translateX(-70%); animation: podiumGlow 2.7s ease-out 1; }
.stage-result-header { position: relative; z-index: 1; margin-bottom: 16px; }
.stage-result-header h3 { margin-bottom: 6px; font-size: clamp(1.6rem, 4vw, 2.8rem); text-transform: uppercase; }
.stage-result-header p { margin-bottom: 0; color: var(--muted); font-weight: 900; }
.stage-result-header strong { color: var(--yellow); }
.stage-podium { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: center; gap: 12px; min-height: 230px; margin: 10px 0 16px; }
.podium-place { flex: 1; min-width: 0; display: grid; align-content: end; justify-items: center; border: 1px solid var(--line); border-bottom: 7px solid var(--yellow); border-radius: 8px 8px 4px 4px; padding: 14px 10px; background: linear-gradient(180deg, #3a3a3a, #191919); text-align: center; }
.podium-place.rank-1 { order: 2; min-height: 220px; border-color: rgba(255,255,4,0.72); box-shadow: 0 0 34px rgba(255, 255, 4, 0.18); animation: winnerPulse 1.9s ease-in-out infinite; }
.podium-place.rank-2 { order: 1; min-height: 178px; }
.podium-place.rank-3 { order: 3; min-height: 148px; }
.podium-rank { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 12px; border-radius: 50%; background: var(--yellow); color: #111; font-weight: 1000; font-size: 1.45rem; }
.podium-rank--jersey { width: 70px; height: 70px; border-radius: 0; background: transparent; padding: 0; overflow: visible; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.34)); }
.podium-jersey { width: 100%; height: 100%; display: block; object-fit: contain; }
.podium-name { width: 100%; color: var(--text); font-size: 1.05rem; font-weight: 1000; overflow-wrap: anywhere; }
.podium-sub { width: 100%; margin-top: 4px; color: var(--muted); font-size: 0.8rem; font-weight: 800; overflow-wrap: anywhere; }
.podium-time { margin-top: 10px; color: var(--yellow); font-variant-numeric: tabular-nums; font-weight: 1000; }
.stage-result-list { position: relative; z-index: 1; display: grid; gap: 8px; }
.stage-result-row { display: grid; grid-template-columns: 44px minmax(0, 1.1fr) minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.stage-result-row span, .stage-result-row strong { min-width: 0; overflow-wrap: anywhere; }
.stage-result-row .rank { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,4,0.16); color: var(--yellow); }
.stage-result-row .rank--jersey { border-radius: 0; background: transparent; overflow: visible; }
@keyframes podiumGlow {
  from { transform: translateX(-75%); }
  to { transform: translateX(75%); }
}
@keyframes winnerPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.stage-controls { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; align-items: center; }
.stage-start-button { min-width: 170px; }
.stage-list { display: grid; gap: 18px; margin-top: 16px; }
.route-intermission-card { border: 1px solid rgba(255, 255, 4, 0.36); border-left: 6px solid var(--yellow); border-radius: 8px; background: linear-gradient(180deg, rgba(255, 255, 4, 0.1), rgba(32, 32, 32, 0.98)); box-shadow: var(--shadow); padding: 16px 18px; }
.route-intermission-card h3 { margin: 10px 0 8px; color: var(--yellow); font-size: 1.18rem; }
.route-intermission-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.stage-list-card { display: grid; grid-template-columns: minmax(240px, 42%) minmax(0, 1fr); gap: 18px; overflow: hidden; border: 1px solid var(--line); border-top: 6px solid var(--stage-color, var(--yellow)); border-radius: 8px; background: linear-gradient(180deg, #343434, #202020); box-shadow: var(--shadow); }
.stage-list-card img { width: 100%; height: 100%; min-height: 280px; object-fit: cover; }
.stage-list-card__body { padding: 18px; }
.stage-list-card h3 { margin-bottom: 10px; font-size: 1.45rem; }
.stage-list-card p { color: var(--muted); line-height: 1.55; }

.timer-card.is-finished { border-color: rgba(35, 209, 139, 0.45); }
.relay-order-card { border-left: 5px solid var(--yellow); }
.relay-order-list { display: grid; gap: 8px; margin-top: 14px; perspective: 900px; }
.relay-order-row { position: relative; display: grid; grid-template-columns: 36px 42px minmax(0, 1fr) 34px; gap: 9px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); transition: transform 0.16s ease, opacity 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease; }
.relay-order-row.is-drop-before::before, .relay-order-row.is-drop-after::after { content: ""; position: absolute; left: 2px; right: 2px; height: 5px; border-radius: 999px; background: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 255, 4, 0.16), 0 0 22px rgba(255, 255, 4, 0.52); animation: relayDropLine 0.42s ease-in-out infinite alternate; }
.relay-order-row.is-drop-before::before { top: -4px; }
.relay-order-row.is-drop-after::after { bottom: -4px; }
.relay-order-row.is-dragging { opacity: 0.24; transform: scale(0.98); border-radius: 8px; background: rgba(255, 255, 4, 0.08); }
.relay-order-row.is-skipped { color: var(--muted); opacity: 0.72; }
.relay-order-row.is-just-placed { animation: relayPlaced 0.34s cubic-bezier(0.2, 0.9, 0.2, 1); border-radius: 8px; background: rgba(255, 255, 4, 0.2); }
.relay-order-position { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 4, 0.16); color: var(--yellow); font-size: 0.82rem; font-weight: 1000; }
.relay-order-position--inline { margin-right: 8px; vertical-align: middle; }
.relay-drag-handle { width: 38px; height: 38px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 1.45rem; font-weight: 1000; line-height: 1; cursor: grab; touch-action: none; }
.relay-drag-handle:hover { color: var(--yellow); transform: translateY(-1px); }
.relay-drag-handle:active, body.is-relay-dragging .relay-drag-handle { cursor: grabbing; }
.relay-participation-toggle { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; font-size: 1.28rem; font-weight: 1000; line-height: 1; transition: transform 0.12s ease, filter 0.12s ease; }
.relay-participation-toggle:hover:not(:disabled) { transform: scale(1.12); filter: brightness(1.12); }
.relay-participation-toggle.is-active { color: var(--green); }
.relay-participation-toggle.is-skipped { color: var(--red); }
body.is-relay-dragging { user-select: none; cursor: grabbing; }
body.is-relay-dragging .relay-order-row:not(.is-dragging) { transform: translateZ(-4px); }
.relay-drag-ghost { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; border: 1px solid rgba(255, 255, 4, 0.52); border-top: 1px solid rgba(255, 255, 255, 0.34); border-radius: 8px; padding: 9px 12px; background: linear-gradient(180deg, rgba(68, 68, 68, 0.98), rgba(24, 24, 24, 0.98)); box-shadow: 0 28px 55px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 4, 0.16), 0 12px 30px rgba(255, 255, 4, 0.16); transform-style: preserve-3d; will-change: transform; }
.relay-drag-ghost .relay-drag-handle { color: var(--yellow); }
.relay-drag-ghost .relay-participation-toggle { opacity: 0.78; }
@keyframes relayDropLine {
  from { transform: scaleX(0.96); opacity: 0.72; }
  to { transform: scaleX(1); opacity: 1; }
}
@keyframes relayPlaced {
  0% { transform: translateZ(34px) scale(1.06); box-shadow: 0 0 0 3px rgba(255, 255, 4, 0.62), 0 18px 36px rgba(255, 255, 4, 0.2); }
  58% { transform: translateZ(0) scale(0.985); box-shadow: 0 0 0 2px rgba(35, 209, 139, 0.35), 0 8px 20px rgba(35, 209, 139, 0.14); }
  100% { transform: translateZ(0) scale(1); box-shadow: none; }
}
.countdown-panel { margin-top: 16px; text-align: center; border-color: var(--yellow); }
.countdown-clock { margin: 8px auto 10px; width: min(260px, 75vw); aspect-ratio: 1; display: grid; place-items: center; border: 8px solid var(--yellow); border-radius: 50%; background: #111; color: var(--yellow); font-size: clamp(5rem, 18vw, 9rem); font-weight: 1000; font-variant-numeric: tabular-nums; box-shadow: inset 0 0 35px rgba(255, 255, 4, 0.12), 0 18px 45px rgba(0, 0, 0, 0.35); }
.team-timer { margin: 12px 0 14px; font-variant-numeric: tabular-nums; font-weight: 1000; font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: 0; color: var(--yellow); }
.timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timer-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.timer-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.timer-status.stopped::before { background: var(--muted); box-shadow: none; }
.rider-timer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.rider-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rider-time { font-variant-numeric: tabular-nums; font-weight: 900; }
.rider-timer-row > div { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.rider-timer-row .btn-small { min-width: 82px; }
.selection-badge { display: inline-flex; align-items: center; min-height: 35px; border: 1px solid rgba(255, 255, 4, 0.35); border-radius: 6px; padding: 8px 11px; color: var(--yellow); font-size: 0.82rem; font-weight: 1000; text-transform: uppercase; }

.penalty-panel { margin-top: 16px; }
.penalty-grid { display: grid; grid-template-columns: 1.1fr 1.1fr 1fr auto; gap: 10px; align-items: end; }
.penalty-list { margin-top: 14px; display: grid; gap: 8px; }
.penalty-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 6px; background: rgba(255, 90, 103, 0.08); border: 1px solid rgba(255, 90, 103, 0.18); }
.penalty-item span:last-child { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

.intermission-panel { margin-top: 16px; border-color: rgba(255, 255, 4, 0.35); }
.intermission-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.intermission-heading > span { flex: 0 0 auto; border-radius: 999px; background: var(--yellow); color: #111; padding: 7px 10px; font-size: 0.78rem; font-weight: 1000; text-transform: uppercase; }
.intermission-list { margin: 16px 0 0; padding-left: 24px; display: grid; gap: 10px; }
.intermission-list li { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.intermission-list strong { display: inline-block; margin-right: 8px; color: var(--yellow); }
.intermission-list span { color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.intermission-list p { margin: 6px 0 0; color: var(--text); line-height: 1.45; }
.intermission-answer { margin-top: 8px; color: var(--muted); }
.intermission-answer summary { cursor: pointer; color: var(--yellow); font-size: 0.78rem; font-weight: 1000; text-transform: uppercase; }
.intermission-answer p { color: var(--muted); }
.intermission-list.compact { padding-left: 20px; }
.intermission-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.history-intermission { margin-top: 18px; }

.tour-final-summary { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 16px; border-color: rgba(255,255,4,0.42); background: linear-gradient(135deg, rgba(255,255,4,0.18), rgba(52,52,52,0.98) 42%, rgba(31,31,31,0.98)); }
.tour-final-trophy { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 50%; background: var(--yellow); color: #111; font-size: 3rem; box-shadow: 0 0 34px rgba(255, 255, 4, 0.22); }
.tour-final-summary h2 { margin-bottom: 6px; font-size: clamp(1.8rem, 4vw, 3rem); text-transform: uppercase; }
.tour-final-summary p:last-child { margin-bottom: 0; color: var(--text); font-size: 1.05rem; line-height: 1.45; }
.tour-final-summary strong { color: var(--yellow); }

.jersey-legend { display: flex; flex-wrap: wrap; gap: 13px; color: var(--muted); font-size: 0.82rem; }
.jersey-legend span { display: flex; align-items: center; gap: 6px; }
.jersey-icon { width: 24px; height: 24px; flex: 0 0 24px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.jersey-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.jersey-card { position: relative; border-radius: 8px; padding: 18px 104px 28px 18px; min-height: 156px; color: #121212; box-shadow: var(--shadow); overflow: hidden; }
.jersey-card.yellow-card { background: var(--yellow); }
.jersey-card.green-card { background: linear-gradient(145deg, #6af2b9, #1fc684); }
.jersey-card.polka-card { background: white; }
.jersey-card.polka-card::before { content: ""; position: absolute; inset: 0; z-index: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Ccircle cx='28' cy='28' r='8' fill='%23e53935'/%3E%3C/svg%3E"); background-size: 56px 56px; background-position: -6px -6px; opacity: 1; }
.jersey-card__image { position: absolute; top: 12px; right: 12px; z-index: 2; width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.28)); }
.jersey-card small, .jersey-card h3, .jersey-card p { position: relative; z-index: 3; }
.jersey-card.polka-card small, .jersey-card.polka-card h3, .jersey-card.polka-card p { display: table; width: fit-content; max-width: 100%; background: white; box-shadow: 0 0 0 8px white; border-radius: 2px; }
.jersey-card small { font-weight: 1000; text-transform: uppercase; opacity: 0.7; }
.jersey-card h3 { margin: 18px 0 8px; font-size: 1.35rem; line-height: 1.32; }
.jersey-card p { margin: 0; font-weight: 800; line-height: 1.3; }

.table-wrap { overflow-x: auto; }
.table-wrap h3 { margin: 18px 0 8px; }
.table-wrap h3:first-child { margin-top: 0; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 13px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0; }
td strong { font-size: 1.02rem; }
.rank { width: 40px; font-weight: 1000; }
.rank-jersey { width: 30px; height: 30px; display: block; margin: 0 auto; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.time-cell { font-variant-numeric: tabular-nums; font-weight: 900; }
.history-list { display: grid; gap: 13px; margin-top: 16px; }
.history-card { background: linear-gradient(180deg, #343434, #202020); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.history-card summary { cursor: pointer; font-weight: 900; }
.history-body { margin-top: 13px; color: var(--muted); }
.history-body h3 { margin: 18px 0 8px; color: var(--text); }
.history-body h3:first-child { margin-top: 0; }

.empty-state { text-align: center; padding: 35px 20px; color: var(--muted); }
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; margin-top: 34px; border-top: 1px solid var(--line); padding-top: 18px; color: var(--muted); font-size: 0.86rem; font-weight: 800; text-align: center; }
.site-footer a { color: var(--text); text-decoration: none; }
.site-footer a:hover { color: var(--yellow); text-decoration: underline; text-underline-offset: 3px; }
.toast { position: fixed; right: 20px; bottom: 20px; transform: translateY(30px); opacity: 0; pointer-events: none; background: var(--yellow); color: #111; border-radius: 6px; padding: 12px 15px; font-weight: 1000; box-shadow: var(--shadow); transition: 0.2s ease; z-index: 20; }
.toast.show { transform: translateY(0); opacity: 1; }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.modal__panel { position: relative; width: min(880px, 100%); max-height: min(820px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--line); border-top: 6px solid var(--yellow); border-radius: 8px; background: linear-gradient(180deg, #343434, #202020); box-shadow: var(--shadow); padding: 20px; }
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.modal__header h2 { margin-bottom: 0; }
.rules-content { display: grid; gap: 14px; }
.rules-content section { border-top: 1px solid var(--line); padding-top: 14px; }
.rules-content section:first-child { border-top: 0; padding-top: 0; }
.rules-content h3 { margin-bottom: 8px; color: var(--yellow); }
.rules-content ul { margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.55; }
.rules-content li + li { margin-top: 5px; }
.rules-content p { margin-bottom: 0; color: var(--text); line-height: 1.55; }
.rule-callout { border: 1px solid rgba(255, 255, 4, 0.28); border-radius: 8px; background: rgba(255, 255, 4, 0.08); padding: 14px; }

@media (max-width: 980px) {
  .intro-hero { grid-template-columns: 1fr; }
  .intro-copy h2 { font-size: 2.1rem; }
  .intro-podium { width: min(680px, 100%); justify-self: center; }
}

@media (max-width: 760px) {
  .topbar, .hero-panel, .results-header { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .header-actions .btn { flex: 1 1 auto; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .intro-hero, .intro-route { padding: 16px; }
  .intro-copy h2 { font-size: 1.9rem; line-height: 1.1; }
  .intro-podium { gap: 6px; min-height: 0; }
  .intro-podium-place--winner, .intro-podium-place--second, .intro-podium-place--third { min-height: 0; }
  .intro-podium-jersey { width: min(96px, 88%); height: 96px; margin-bottom: 8px; }
  .intro-podium-step, .intro-podium-place--winner .intro-podium-step, .intro-podium-place--second .intro-podium-step { min-height: 78px; padding: 11px 5px; }
  .intro-podium-step strong { font-size: 0.84rem; }
  .intro-podium-step span { font-size: 0.72rem; }
  .intro-route-header { align-items: flex-start; flex-direction: column; }
  .intro-route-header span { align-self: flex-start; }
  .intro-start-button { width: 100%; min-width: 0; }
  .stage-controls { display: grid; grid-template-columns: 1fr; }
  .stage-controls .btn { width: 100%; }
  .stage-start-button { min-width: 0; }
  .form-panel, .penalty-grid { grid-template-columns: 1fr; }
  .stage-image { aspect-ratio: 4 / 3; max-height: none; }
  .stage-podium { flex-direction: column; align-items: stretch; min-height: 0; }
  .podium-place, .podium-place.rank-1, .podium-place.rank-2, .podium-place.rank-3 { order: initial; min-height: 0; }
  .stage-result-row { grid-template-columns: 36px minmax(0, 1fr); }
  .stage-result-row .time-cell { grid-column: 2; }
  .stage-list-card { grid-template-columns: 1fr; }
  .stage-list-card img { aspect-ratio: 4 / 3; min-height: 0; }
  .rider-timer-row { grid-template-columns: 1fr; }
  .relay-order-row { grid-template-columns: 32px 42px minmax(0, 1fr) 34px; }
  .timer-actions { grid-template-columns: 1fr; }
  .rider-name { white-space: normal; }
  .rider-timer-row > div { justify-content: stretch; }
  .rider-timer-row > div .btn { flex: 1; }
  .penalty-item { align-items: flex-start; flex-direction: column; }
  .intermission-heading { flex-direction: column; }
  .intermission-heading > span { align-self: flex-start; }
  .tour-final-summary { grid-template-columns: 1fr; }
  .tour-final-trophy { width: 70px; height: 70px; font-size: 2.5rem; }
  .jersey-cards { grid-template-columns: 1fr; }
  .tabs { position: sticky; top: 0; z-index: 10; padding: 8px 0; background: rgba(40, 40, 40, 0.94); backdrop-filter: blur(10px); }
  .tab { font-size: 0.82rem; }
  .modal { padding: 12px; align-items: stretch; }
  .modal__panel { max-height: calc(100vh - 24px); padding: 16px; }
  .modal__header { flex-direction: column; }
  .modal__header .btn { width: 100%; }
}
