/* ==========================================================================
   Big screen / projector view.
   Loads after theme.css and reuses its tokens, so the screen follows whichever
   theme is selected. Everything is sized in vw/clamp to fill a TV.
   ========================================================================== */

body.screen-body {
  display: block;
  min-height: 100vh;
  color: var(--screen-text);
  background: var(--screen-bg);
  overflow: hidden;
}
body.screen-body::before,
body.screen-body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: 0;
}
body.screen-body::before {
  width: 55vw; height: 55vw;
  top: -22vw; left: -10vw;
  background: var(--screen-glow-1);
}
body.screen-body::after {
  width: 45vw; height: 45vw;
  bottom: -22vw; right: -6vw;
  background: var(--screen-glow-2);
}

.screen-main,
.screen-footer { position: relative; z-index: 1; }
/* Above the panels, so the settings menu is not covered by the standings. */
.screen-header { position: relative; z-index: 20; }

/* ==========================================================================
   Header
   ========================================================================== */

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: clamp(18px, 2.2vw, 32px) clamp(20px, 3vw, 48px);
}

.title-block { display: flex; align-items: center; gap: clamp(14px, 1.6vw, 24px); min-width: 0; }

.screen-logo {
  width: clamp(56px, 6vw, 104px);
  height: clamp(56px, 6vw, 104px);
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow-lg);
  flex: none;
}

.race-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 54px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--screen-text);
}
.race-sub {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  color: var(--screen-muted);
  font-size: clamp(14px, 1.2vw, 20px);
}

.pill {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: clamp(11px, 0.8vw, 14px);
  font-weight: 800;
  letter-spacing: 0.1em;
  border: 1px solid var(--screen-line);
  background: rgba(255, 255, 255, 0.12);
  color: var(--screen-text);
}
.pill.draft { background: rgba(255, 255, 255, 0.07); color: var(--screen-muted); }
.pill.finished { background: rgba(255, 255, 255, 0.18); }
.dot { color: var(--screen-muted); }

.stats-block { display: flex; align-items: center; gap: clamp(10px, 1.2vw, 20px); flex-wrap: wrap; }

.screen-header .stat {
  background: var(--screen-panel);
  border: 1px solid var(--screen-line);
  border-radius: 16px;
  padding: clamp(9px, 1vw, 15px) clamp(13px, 1.4vw, 22px);
  min-width: clamp(84px, 8vw, 128px);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.screen-header .stat .value {
  display: block;
  font-size: clamp(24px, 2.4vw, 40px);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--screen-text);
}
.screen-header .stat .label {
  display: block;
  margin-top: 2px;
  color: var(--screen-muted);
  font-size: clamp(10px, 0.75vw, 13px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* The next-lap countdown is the single most useful number on the screen */
.screen-header .stat.countdown .value {
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  color: var(--screen-accent);
}
.screen-header .stat.countdown.urgent {
  background: rgba(232, 57, 59, 0.42);
  border-color: rgba(255, 255, 255, 0.4);
}

.clock {
  font-family: var(--font-mono);
  font-size: clamp(16px, 1.5vw, 26px);
  color: var(--screen-text);
  opacity: .85;
}

/* ==========================================================================
   Panels
   ========================================================================== */

.screen-main { padding: 0 clamp(20px, 3vw, 48px) clamp(14px, 2vw, 28px); }

.panel {
  display: none;
  background: var(--screen-panel);
  border: 1px solid var(--screen-line);
  border-radius: 22px;
  padding: clamp(16px, 1.8vw, 28px);
  box-shadow: 0 18px 44px rgba(10, 18, 30, 0.30);
  animation: fadeIn 600ms ease;
}
.panel.active { display: block; }
@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 {
  margin: 0;
  color: var(--screen-text);
  font-size: clamp(20px, 2vw, 34px);
  letter-spacing: -0.01em;
}
.panel-note { color: var(--screen-muted); font-size: clamp(12px, 1vw, 17px); }

.leader-hero-screen {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.6vw, 26px);
  flex-wrap: wrap;
  padding: clamp(12px, 1.4vw, 20px) clamp(16px, 1.8vw, 26px);
  margin-bottom: 18px;
  border-radius: 18px;
  background: linear-gradient(100deg,
    rgba(3, 196, 235, 0.26), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(3, 196, 235, 0.45);
}
.leader-hero-screen .leader-title {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: clamp(10px, 0.8vw, 14px);
  font-weight: 800;
  color: var(--screen-text);
  opacity: .8;
}
.leader-hero-screen .leader-name {
  font-size: clamp(22px, 2.4vw, 40px);
  font-weight: 800;
  color: var(--screen-text);
  letter-spacing: -0.02em;
}
.leader-hero-screen .leader-meta {
  margin-left: auto;
  font-size: clamp(18px, 2vw, 34px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--screen-text);
}

/* ==========================================================================
   Screen tables
   ========================================================================== */

.screen-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(14px, 1.25vw, 24px);
}
.screen-body th,
.screen-body td {
  padding: clamp(7px, 0.8vw, 14px) clamp(6px, 0.7vw, 12px);
  border-bottom: 1px solid var(--screen-line);
}
.screen-body thead th {
  text-align: left;
  color: var(--screen-muted);
  font-size: clamp(10px, 0.8vw, 14px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.screen-body tbody tr:nth-child(odd) { background: var(--screen-row); }
.screen-body tbody tr:last-child td { border-bottom: 0; }
.screen-body .laps {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(16px, 1.5vw, 28px);
  color: var(--screen-accent);
}
.screen-body .bib { color: var(--screen-muted); }

.screen-body .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: clamp(10px, 0.8vw, 14px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.screen-body .tag.ok  { background: rgba(255, 255, 255, 0.20); color: var(--screen-text); }
.screen-body .tag.dnf { background: rgba(200, 30, 32, 0.55); color: #fff; }

/* ==========================================================================
   Footer ticker
   ========================================================================== */

.screen-footer { padding: 0 clamp(20px, 3vw, 48px) clamp(16px, 2vw, 28px); color: var(--screen-muted); }
.ticker {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: clamp(12px, 1vw, 17px);
}
.ticker-label { color: var(--screen-accent); font-weight: 800; letter-spacing: 0.06em; }
.ticker-sep { opacity: .5; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  body.screen-body { overflow: auto; }
  .screen-header { flex-direction: column; align-items: flex-start; }
}

/* Page counter shown when the field is too big to fit on one screen. */
.page-indicator {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--screen-line);
  background: rgba(255, 255, 255, 0.10);
  color: var(--screen-text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.page-indicator[hidden] { display: none; }

/* A provisional lap number on the big screen. */
.screen-body .credit-mark {
  background: rgba(255, 255, 255, 0.16);
  color: var(--screen-text);
  border-color: var(--screen-line);
  font-size: clamp(9px, 0.65vw, 12px);
}

/* Same grouping on the big screen: still in on top, stopped below. */
.screen-body tbody tr.is-dnf td { color: var(--screen-muted); }
.screen-body tbody tr:not(.is-dnf) + tr.is-dnf td {
  border-top: 2px solid var(--screen-line);
}

/* Teams panel: how much of each team is still on the course, and the
   combined figures for every team at the foot of the table. */
.screen-body .still-out {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--screen-text);
}
.screen-body .still-out .of {
  font-weight: 600;
  color: var(--screen-muted);
  font-size: 0.75em;
}

.screen-body tfoot .totals td {
  border-top: 2px solid var(--screen-line);
  border-bottom: 0;
  padding-top: clamp(9px, 1vw, 16px);
  font-weight: 800;
  color: var(--screen-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.9em;
}
.screen-body tfoot .totals .laps { font-size: clamp(16px, 1.5vw, 28px); }

/* Sized to match the height of the DNF tag beside it, so rows stay even. */
.screen-body .tag.is-icon { padding: 3px 10px; }
.screen-body .run-icon {
  width: clamp(13px, 1.05vw, 19px);
  height: clamp(13px, 1.05vw, 19px);
}

/* How far a runner who stopped actually got. Beside the lap count, not
   under it: a second line would make every DNF row taller than the rest. */
.screen-body .laps-km {
  display: inline;
  margin-left: 0.5em;
  font-size: clamp(10px, 0.75vw, 13px);
  font-weight: 600;
  color: var(--screen-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
   Wide screen: two columns, and the on-screen settings menu
   ========================================================================== */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(14px, 1.8vw, 34px);
  align-items: start;
}
.two-col .col-table[hidden] { display: none; }
.two-col + .panel-empty { margin-top: 12px; }

.panel-empty {
  margin: 0;
  padding: clamp(12px, 1.5vw, 24px) 0;
  color: var(--screen-muted);
  font-size: clamp(13px, 1.1vw, 19px);
}

/* Tighter than the single-column screen throughout: every pixel reclaimed
   here is another runner on the page, which is the whole point of this
   layout. Still sized to read from across a hall. */
.screen-body.is-wide table { font-size: clamp(12px, 0.85vw, 17px); }
.screen-body.is-wide th,
.screen-body.is-wide td { padding: clamp(3px, 0.32vw, 6px) clamp(4px, 0.45vw, 9px); }
.screen-body.is-wide .laps { font-size: clamp(13px, 0.95vw, 19px); }
.screen-body.is-wide .laps-km { font-size: clamp(9px, 0.6vw, 12px); }
.screen-body.is-wide .tag { font-size: clamp(9px, 0.6vw, 12px); padding: 2px 7px; }
.screen-body.is-wide .tag.is-icon { padding: 2px 7px; }
.screen-body.is-wide .run-icon { width: clamp(11px, 0.8vw, 15px); height: clamp(11px, 0.8vw, 15px); }

.screen-body.is-wide .screen-header { padding: clamp(10px, 1.1vw, 18px) clamp(16px, 2vw, 34px); }
.screen-body.is-wide .race-title { font-size: clamp(22px, 2.2vw, 38px); }
.screen-body.is-wide .screen-header .stat { padding: clamp(6px, 0.7vw, 11px) clamp(10px, 1.1vw, 17px); }
.screen-body.is-wide .screen-header .stat .value { font-size: clamp(19px, 1.7vw, 30px); }

.screen-body.is-wide .distance-strip {
  margin: 0 clamp(16px, 2vw, 34px) clamp(8px, 0.9vw, 13px);
  padding: clamp(6px, 0.7vw, 11px) clamp(12px, 1.4vw, 20px);
}
.screen-body.is-wide .distance-total .value { font-size: clamp(20px, 1.9vw, 32px); }
.screen-body.is-wide .milestones .m-count { font-size: clamp(13px, 1.1vw, 19px); }

.screen-body.is-wide .screen-main { padding: 0 clamp(16px, 2vw, 34px) clamp(8px, 1vw, 14px); }
.screen-body.is-wide .panel { padding: clamp(10px, 1.1vw, 18px) clamp(12px, 1.3vw, 20px); }
.screen-body.is-wide .panel-head { margin-bottom: clamp(6px, 0.7vw, 11px); }
.screen-body.is-wide .panel-head h2 { font-size: clamp(17px, 1.5vw, 26px); }
.screen-body.is-wide .screen-footer { padding: 0 clamp(16px, 2vw, 34px) clamp(8px, 1vw, 14px); }

/* The settings menu, top right of the header. */
.screen-settings { position: relative; flex: none; }
.screen-settings > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: clamp(38px, 3vw, 52px);
  height: clamp(38px, 3vw, 52px);
  border-radius: 14px;
  border: 1px solid var(--screen-line);
  background: var(--screen-panel);
}
.screen-settings > summary::-webkit-details-marker { display: none; }
.screen-settings > summary:hover { background: rgba(255, 255, 255, 0.16); }
.screen-settings[open] > summary { border-color: var(--screen-accent); }

/* A gear drawn from a ring and spokes: no icon font to depend on. */
.screen-settings .gear {
  position: relative;
  width: 46%;
  height: 46%;
  border-radius: 50%;
  border: 2.5px solid var(--screen-text);
  box-shadow: 0 0 0 2.5px transparent;
}
.screen-settings .gear::before,
.screen-settings .gear::after {
  content: "";
  position: absolute;
  inset: -5px 45%;
  background: var(--screen-text);
  border-radius: 2px;
}
.screen-settings .gear::after { transform: rotate(90deg); }

.settings-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  width: 270px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--screen-line);
  background: #10161f;
  box-shadow: var(--shadow-lg);
  color: var(--screen-text);
}
.settings-menu .settings-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--screen-muted);
  margin-bottom: 8px;
}
.settings-menu label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  cursor: pointer;
}
.settings-menu label:hover { background: rgba(255, 255, 255, 0.08); }
.settings-menu input { width: auto; accent-color: var(--screen-accent); }
.settings-menu hr { border: 0; border-top: 1px solid var(--screen-line); margin: 8px 0; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}


/* ==========================================================================
   Distance slide: where the field has got to
   ========================================================================== */

.milestone-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: clamp(10px, 1.2vw, 22px);
}
.milestone-cards li {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: clamp(14px, 1.8vw, 32px) clamp(8px, 1vw, 16px);
  border-radius: 18px;
  border: 1px solid var(--screen-line);
  background: rgba(255, 255, 255, 0.07);
}
.milestone-cards .mc-count {
  font-size: clamp(34px, 4.4vw, 82px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--screen-accent);
}
.milestone-cards .mc-label {
  font-size: clamp(12px, 1.1vw, 20px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--screen-text);
  text-align: center;
}
.milestone-cards .mc-km {
  font-size: clamp(10px, 0.8vw, 14px);
  color: var(--screen-muted);
  font-variant-numeric: tabular-nums;
}
.milestone-cards li.is-empty { opacity: .4; }
.milestone-cards li.is-empty .mc-count { color: var(--screen-muted); }
