:root{
  --line:rgba(255,255,255,.24);
  --line-strong:rgba(255,255,255,.34);
  --text:#f7f4f5;
  --muted:rgba(255,255,255,.66);
  --accent:#f0d99b;
  --status-pre:#f0c74f;
  --status-live:#7bdc72;
  --status-final:#ef6a65;
}
*{box-sizing:border-box}
html,body,#screenApp{width:100%;height:100%;margin:0}
html,body{
  overflow:hidden;
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at 22% 12%,rgba(255,255,255,.12),transparent 22%),
    radial-gradient(circle at 86% 18%,rgba(255,224,67,.13),transparent 24%),
    linear-gradient(135deg,#57248d 0%,#77238d 43%,#b11087 100%);
}
.boot,.disabled-screen{height:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:18px;color:rgba(255,255,255,.72)}
.disabled-screen h1{margin:0;color:var(--accent);font-size:clamp(30px,4vw,64px);font-weight:500}
.disabled-screen p{margin:0;font-size:clamp(17px,1.7vw,28px)}
.screen-shell{width:100%;height:100vh;padding:.75vh .7vw;display:flex;flex-direction:column;min-height:0}
.topbar{height:7vh;flex:0 0 7vh;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;border-bottom:1px solid rgba(255,255,255,.28);padding:0 .25vw}
.headline{grid-column:2;display:flex;align-items:center;justify-content:center;gap:.75vw;font-size:clamp(16px,1.18vw,23px);font-weight:500;letter-spacing:.025em;white-space:nowrap}
.headline-dot{width:.46em;height:.46em;border-radius:50%;background:var(--accent);flex:none}
.screen-status{grid-column:3;justify-self:end;display:flex;align-items:center;gap:.55vw;font-size:clamp(13px,.95vw,18px);font-weight:850;letter-spacing:.06em}
.status-dot{width:.7em;height:.7em;border-radius:50%;flex:none}
.screen-status.pre .status-dot{background:var(--status-pre);box-shadow:0 0 0 .2em rgba(240,199,79,.10)}
.screen-status.live .status-dot{background:var(--status-live);box-shadow:0 0 0 .2em rgba(123,220,114,.10)}
.screen-status.final .status-dot{background:var(--status-final);box-shadow:0 0 0 .2em rgba(239,106,101,.10)}
.table-wrap{flex:1;min-height:0;padding-top:.6vh;position:relative}
.score-table{width:100%;border-collapse:collapse;table-layout:fixed;background:transparent;font-variant-numeric:tabular-nums}
.score-table th,.score-table td{border:1px solid var(--line);text-align:center;padding:0 .16vw;overflow:hidden}
.score-table th{background:rgba(255,255,255,.06);color:#f3eef1;font-size:clamp(8px,.67vw,13px);font-weight:500;line-height:1.03;vertical-align:middle}
.score-table td{white-space:nowrap;text-overflow:ellipsis;font-size:clamp(11px,.82vw,16px);line-height:1.08}
.score-table .place{font-weight:900;color:var(--accent);font-size:clamp(12px,.95vw,18px)}
.score-table th.place,.score-table th.code,.score-table th.team,.score-table th.extra,.score-table th.total{font-weight:500;font-size:clamp(8px,.67vw,13px);color:#f3eef1}
.score-table .code{font-weight:900}
.score-table .team{text-align:left;padding-left:.55vw;font-weight:900;letter-spacing:.02em}
.score-table tbody tr:nth-child(even) td{background:rgba(255,255,255,.035)}
.score-table tbody tr.podium td{background:rgba(240,217,155,.07)}
.score-table tbody tr.podium td.block-gap{background:transparent!important}

/* KOPVĒRTĒJUMS */
.overall-table{height:100%}
.overall-table thead{height:8.7vh}
.overall-table tbody tr{height:5.15vh}
.score-table th.station span{display:block;white-space:normal;word-break:normal;line-height:1.08}
.score-table .station-score{font-weight:400;color:#f0eaed}
.score-table .extra{font-weight:900;color:var(--accent)}
.score-table .total{font-weight:950;color:var(--accent);font-size:clamp(12px,1vw,19px)}
.col-place{width:3.7%}.col-code{width:4.1%}.col-team{width:11.2%}.col-extra{width:3.7%}.col-total{width:5.6%}
.col-station{width:calc(71.7% / var(--station-count))}

/* DETALIZĒTA STACIJAS TABULA */
.detailed-station-wrap{padding-top:.45vh}
.station-detail-table{height:100%}
.station-detail-table thead{height:11.1vh}
.station-detail-table thead .group-row{height:4.15vh}
.station-detail-table thead .sub-row{height:6.95vh}
.station-detail-table tbody tr{height:5.02vh}
.station-detail-table th{font-size:clamp(7.5px,.60vw,12px);padding:0 .10vw}
.station-detail-table tbody td{font-size:clamp(11px,.84vw,17px);padding:0 .10vw}
.station-detail-table td.place{font-size:clamp(12px,.92vw,18px)}
.station-detail-table td.code{font-size:clamp(11px,.82vw,16px)}
.station-detail-table td.team{font-size:clamp(10.5px,.78vw,15.5px);padding-left:.35vw}
.component-group,.summary-group{font-weight:700!important;letter-spacing:.025em;color:#fff!important;border-bottom:1px solid var(--line-strong)!important}
.summary-group{color:var(--accent)!important}
.station-detail-table .sub-row th{font-size:clamp(6.8px,.52vw,10.5px);line-height:1.05;white-space:normal}
.station-detail-table .summary-component span{display:block;font-size:.92em;line-height:1.02;max-height:2.08em;overflow:hidden}
.station-detail-table .summary-component b{display:block;margin-top:.2vh;color:var(--accent);font-size:.88em;font-weight:700}
.component-value{font-weight:650;color:#fff;font-size:clamp(12px,.90vw,18px)!important}
.component-place{font-weight:600;color:rgba(255,255,255,.92);font-size:clamp(11.5px,.86vw,17px)!important}
.component-points,.summary-points{font-weight:700;color:#f8f1e5;font-size:clamp(11.5px,.86vw,17px)!important}
.summary-points{background:rgba(255,255,255,.025)}
.component-total{font-weight:850;color:var(--accent);background:rgba(240,217,155,.06)!important;font-size:clamp(12px,.90vw,18px)!important}
.station-place{font-weight:850;color:#fff;font-size:clamp(12px,.90vw,18px)!important}
.station-points{font-weight:950!important;color:var(--accent)!important;background:rgba(240,217,155,.075)!important;font-size:clamp(13px,1vw,20px)!important}
th.block-gap,td.block-gap{border:0!important;background:transparent!important;padding:0!important}

/* KVSK */
.kvsk-table{height:100%}
.kvsk-table thead{height:10.7vh}
.kvsk-table thead .group-row{height:4.1vh}
.kvsk-table thead .sub-row{height:6.6vh}
.kvsk-table tbody tr{height:5.05vh}
.kvsk-table .sub-row th{font-size:clamp(7.5px,.61vw,12px);white-space:normal;line-height:1.05}
.kvsk-table tbody td{font-size:clamp(12px,.90vw,18px);font-weight:600}
.kvsk-table .sub-row small{display:block;margin-top:.25vh;color:rgba(255,255,255,.62);font-size:.82em;font-weight:500}

/* SIMPLE / TESTA STACIJAS */
.station-table{height:100%}
.station-table thead{height:8.7vh}
.station-table tbody tr{height:5.15vh}
.station-table tbody td{font-size:clamp(13px,1vw,20px)}
.st-col-place{width:5%}.st-col-code{width:7%}.st-col-team{width:31%}.st-col-result{width:43%}.st-col-points{width:14%}
.station-table .station-team{font-weight:900}
.station-result{text-align:center!important;padding-left:.16vw!important;font-weight:650;color:#f8f4f5;font-size:clamp(13px,1vw,20px)!important}
.station-result b{display:block;font-size:1em;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* PUNKTU SKAITĪŠANAS NOTEIKUMI */
.rules-wrap{flex:1;min-height:0;padding:.9vh .3vw .45vh;display:grid;grid-template-rows:minmax(0,1fr) auto;gap:1vh}
.rules-grid{min-height:0;display:grid;grid-template-columns:1.15fr .85fr;gap:1vw}
.rule-card{min-height:0;border:1px solid var(--line);background:rgba(255,255,255,.045);padding:1.25vh 1.05vw;display:flex;flex-direction:column;overflow:hidden}
.rule-kicker{font-size:clamp(9px,.69vw,13px);font-weight:700;color:var(--accent);letter-spacing:.09em}
.rule-card h2{margin:.45vh 0 .9vh;font-size:clamp(16px,1.35vw,27px);font-weight:650;line-height:1.05}
.rule-team{display:flex;align-items:baseline;gap:.65vw;margin-bottom:.8vh}
.rule-team b{color:var(--accent);font-size:clamp(15px,1.15vw,23px)}
.rule-team span{font-size:clamp(13px,1.02vw,20px);font-weight:850}
.rule-components{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.55vw;min-height:0}
.rule-component{border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.035);padding:.75vh .6vw;min-width:0}
.rule-label{display:block;height:2.1em;overflow:hidden;color:rgba(255,255,255,.78);font-size:clamp(8px,.59vw,11px);font-weight:650;line-height:1.05}
.rule-component strong{display:block;margin:.55vh 0 .25vh;font-size:clamp(19px,1.65vw,32px);font-weight:800;color:#fff}
.rule-arrow{font-size:clamp(9px,.67vw,13px);white-space:nowrap;color:rgba(255,255,255,.72)}
.rule-arrow b{color:var(--accent)}
.rule-equation{margin-top:auto;padding-top:1vh;display:flex;align-items:center;justify-content:center;gap:.55vw;flex-wrap:wrap;font-size:clamp(10px,.78vw,15px)}
.rule-equation b{color:var(--accent)}
.eq-arrow{color:rgba(255,255,255,.55)}
.rule-copy{font-size:clamp(11px,.88vw,17px);line-height:1.35;color:rgba(255,255,255,.82);margin:.5vh 0}
.overall-formula{display:grid;gap:.8vh;margin-top:1vh}
.formula-line{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:.65vw;border-bottom:1px solid rgba(255,255,255,.13);padding:.65vh .1vw;font-size:clamp(11px,.86vw,17px)}
.formula-line .formula-parts{white-space:normal;line-height:1.25;color:rgba(255,255,255,.82)}
.formula-line b{color:var(--accent);white-space:nowrap}
.formula-line.final-line{grid-template-columns:1fr auto auto auto auto;border-bottom:0;font-size:clamp(13px,1.02vw,20px);font-weight:700}
.tie-rule{border:1px solid rgba(240,217,155,.42);background:rgba(240,217,155,.08);padding:.9vh 1vw;display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:1vw;align-items:center}
.tie-title{color:var(--accent);font-size:clamp(10px,.72vw,14px);font-weight:800;letter-spacing:.05em;white-space:nowrap}
.tie-copy{font-size:clamp(9px,.67vw,13px);line-height:1.25;color:rgba(255,255,255,.86)}
.tie-example{display:flex;flex-direction:column;gap:.25vh;font-size:clamp(9px,.68vw,13px);font-variant-numeric:tabular-nums;white-space:nowrap}
.tie-example b,.tie-example strong{color:var(--accent)}

.footer{height:2vh;flex:0 0 2vh;display:grid;grid-template-columns:1fr auto;align-items:end;color:rgba(255,255,255,.62);font-size:clamp(8px,.62vw,11px);padding:0 .2vw}
.footer span:last-child{text-align:right}.footer strong{color:var(--accent);font-weight:700}

@media(max-width:1400px){
  .headline{font-size:16px}
  .overall-table th{font-size:8.5px}.overall-table td{font-size:10.5px}
  .station-detail-table th{font-size:7.5px}
  .station-detail-table tbody td{font-size:11px}
  .station-detail-table td.team{font-size:10.5px}
}

/* ============================================================
   RC v4 — staciju tabulu MIN/MAX platumi + centrēta KOMANDA
   ============================================================ */

/* KOMANDA headeris un saturs visās rezultātu tabulās ir centrā. */
.score-table .team,
.score-table th.team,
.score-table td.team{
  text-align:center!important;
  padding-left:.16vw!important;
  padding-right:.16vw!important;
}

/* Staciju tabulas netiek mākslīgi izstieptas. Ja saturs ir šaurāks,
   tabula sākas no kreisās malas; ja kolonnu ir daudz, izmanto līdz 100%. */
.detailed-station-wrap,
.kvsk-wrap,
.station-wrap{
  display:flex;
  align-items:stretch;
  justify-content:flex-start;
}
.station-detail-table{
  max-width:100%;
  margin:0!important;
  flex:none;
}
.kvsk-table{
  width:min(100%,1450px)!important;
  max-width:100%;
  margin:0!important;
  flex:none;
}
.station-table{
  width:min(100%,1080px)!important;
  max-width:100%;
  margin:0!important;
  flex:none;
}

/* Skaitļiem jābūt salasāmiem arī no distances. */
.station-detail-table tbody td.component-value{
  font-size:clamp(14px,1.04vw,21px)!important;
  font-weight:700;
}
.station-detail-table tbody td.component-place,
.station-detail-table tbody td.component-points,
.station-detail-table tbody td.summary-points,
.station-detail-table tbody td.component-total,
.station-detail-table tbody td.station-place{
  font-size:clamp(13px,.96vw,19px)!important;
}
.station-detail-table tbody td.station-points{
  font-size:clamp(14px,1.08vw,22px)!important;
}

/* Ja rezultāts ir teksts, piem. "3 no 6", neļaujam to saspiest līdz nesalasāmam. */
.station-detail-table .component-value{
  white-space:nowrap;
  text-overflow:clip;
}

/* ============================================================
   SCREEN CONTROL v5 — optional LOGO / CLOCK / PAZIŅOJUMS slides
   ============================================================ */
.aux-slide{
  width:100vw;height:100vh;padding:0;
  display:flex;position:relative;overflow:hidden;
  align-items:center;justify-content:center;
}
.logo-slide .hero-logo{
  width:min(72vw,1180px);max-height:72vh;object-fit:contain;
  filter:drop-shadow(0 10px 28px rgba(0,0,0,.24));
}
.clock-slide{flex-direction:column;gap:1.2vh;text-align:center}
.clock-logo{width:min(34vw,540px);max-height:24vh;object-fit:contain;margin-bottom:2vh;filter:drop-shadow(0 8px 22px rgba(0,0,0,.22))}
.clock-time{font-size:clamp(88px,11vw,220px);line-height:.9;font-weight:300;letter-spacing:.015em;font-variant-numeric:tabular-nums;color:#fff}
.clock-date{font-size:clamp(22px,2.1vw,42px);font-weight:500;color:var(--accent);letter-spacing:.05em}
.clock-event{font-size:clamp(16px,1.3vw,26px);font-weight:600;letter-spacing:.08em;color:rgba(255,255,255,.83);margin-top:1.2vh}
.announcement-slide{padding:7vh 7vw}
.announcement-slide.valign-top{align-items:flex-start}
.announcement-slide.valign-center{align-items:center}
.announcement-slide.valign-bottom{align-items:flex-end}
.announcement-slide.align-left{justify-content:flex-start;text-align:left}
.announcement-slide.align-center{justify-content:center;text-align:center}
.announcement-slide.align-right{justify-content:flex-end;text-align:right}
.announcement-text{width:100%;line-height:1.08;white-space:pre-wrap;overflow-wrap:anywhere;text-shadow:0 3px 12px rgba(0,0,0,.2)}


/* ============================================================
   SCREEN v6 — compact station tables (no giant empty cells)
   ============================================================ */

/* Simple station/INDI tables must use content-sized geometry, not fill the screen. */
.station-wrap:not(.detailed-station-wrap){
  align-items:flex-start!important;
}
.station-table{
  width:min(100%, 764px)!important;
  height:auto!important;
  align-self:flex-start;
}
.station-table thead{
  height:52px!important;
}
.station-table tbody tr{
  height:52px!important;
}
.station-table th,
.station-table td{
  height:52px!important;
}
.station-table .st-col-place{width:56px!important}
.station-table .st-col-code{width:88px!important}
.station-table .st-col-team{width:300px!important}
.station-table .st-col-result{width:190px!important}
.station-table .st-col-points{width:130px!important}

/* KVSK can also contain only a few rows; keep rows compact instead of stretching vertically. */
.kvsk-wrap{
  align-items:flex-start!important;
}
.kvsk-table{
  width:min(100%, 1180px)!important;
  height:auto!important;
  align-self:flex-start;
}
.kvsk-table thead{
  height:72px!important;
}
.kvsk-table thead .group-row{height:30px!important}
.kvsk-table thead .sub-row{height:42px!important}
.kvsk-table tbody tr,
.kvsk-table tbody td{
  height:52px!important;
}

/* On a smaller viewport preserve the same proportions without horizontal scrolling. */
@media (max-width:820px){
  .station-table{width:100%!important}
  .station-table .st-col-place{width:7%!important}
  .station-table .st-col-code{width:11%!important}
  .station-table .st-col-team{width:39%!important}
  .station-table .st-col-result{width:26%!important}
  .station-table .st-col-points{width:17%!important}
}


/* ============================================================
   SCREEN v7 — hard viewport fit + single-GAME simplification
   + highlighted multi-GAME scoring sum
   ============================================================ */

/* Neviena stacijas tabula nedrīkst pārsniegt reālo viewport platumu. */
.station-wrap{
  width:100%;
  max-width:100%;
  overflow:hidden;
}
.station-wrap > .score-table{
  max-width:100%!important;
  box-sizing:border-box;
}

/* Vienas GAME stacijās nav dublēta STACIJAS KOPSAVILKUMA bloka:
   RAW rezultāts → vieta → kopvērtējuma punkti. */
.detailed-station-wrap.single-component{
  align-items:flex-start!important;
}
.detailed-station-wrap.single-component .station-detail-table{
  height:auto!important;
}
.detailed-station-wrap.single-component .station-detail-table thead{
  height:72px!important;
}
.detailed-station-wrap.single-component .station-detail-table thead .group-row{
  height:30px!important;
}
.detailed-station-wrap.single-component .station-detail-table thead .sub-row{
  height:42px!important;
}
.detailed-station-wrap.single-component .station-detail-table tbody tr,
.detailed-station-wrap.single-component .station-detail-table tbody td{
  height:52px!important;
}

/* Vairāku GAME stacijās vizuāli izceļam vietu, kur GAME ieskaites
   punkti tiek savākti vienā summā un no tās rodas vieta stacijā. */
.detailed-station-wrap.multi-component .summary-zone{
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.085) 0%,
      rgba(255,255,255,.045) 58%,
      rgba(255,255,255,.022) 100%
    )!important;
}
.detailed-station-wrap.multi-component .summary-start{
  border-left:2px solid rgba(255,255,255,.48)!important;
  box-shadow:inset 10px 0 16px -15px rgba(255,255,255,.95);
}
.detailed-station-wrap.multi-component .summary-group{
  color:#fff;
  font-weight:650;
  letter-spacing:.035em;
}
.detailed-station-wrap.multi-component .summary-total{
  color:#fff;
  font-weight:850;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.13),
      rgba(255,255,255,.055)
    )!important;
}
.detailed-station-wrap.multi-component .station-points.summary-zone{
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.08),
      rgba(240,217,155,.16)
    )!important;
}

/* Ļoti platām stacijām fonti drīkst nedaudz sarauties, bet tabula neiziet ārpus SCREEN. */
@media (max-width:1500px){
  .detailed-station-wrap.multi-component .station-detail-table th{
    font-size:clamp(6.5px,.55vw,10px);
  }
  .detailed-station-wrap.multi-component .station-detail-table tbody td{
    font-size:clamp(10px,.78vw,15px);
  }
}
