/* TV-Dashboard: dunkel, grosse Schrift, fuer 1920x1080 aus mehreren Metern Abstand. */

:root {
  --tv-bg:    #14140f;
  --tv-card:  #1e1e18;
  --tv-line:  #32322a;
  --tv-text:  #f4f4ef;
  --tv-muted: #8d8d82;
  --tv-accent:#3ad29f;
  --tv-brand: #FF5100;
}

/* Heller Modus: derselbe Aufbau, zweiter Variablensatz. Umgeschaltet per
   Knopf/Taste H (gemerkt im Geraet) oder ?hell=1 fuer den Kioskstart. */
body.tv.hell {
  --tv-bg:    #f2f1ea;
  --tv-card:  #ffffff;
  --tv-line:  #dddcd0;
  --tv-text:  #1a1a18;
  --tv-muted: #6e6e62;
  --tv-accent:#0c8a66;
}

html, body.tv { height: 100%; margin: 0; overflow: hidden; }

body.tv {
  background: var(--tv-bg);
  color: var(--tv-text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.tv-wrap {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(12px, 1.4vh, 24px) clamp(16px, 1.6vw, 34px);
  gap: clamp(10px, 1.2vh, 20px);
  box-sizing: border-box;
}

/* -------------------------------------------------------------- Kopf */
.tv-head { display: flex; align-items: baseline; gap: clamp(14px, 1.6vw, 30px); }
.tv-title { font-size: clamp(22px, 2.5vw, 46px); font-weight: 600; letter-spacing: -0.01em; }
.tv-sub   { font-size: clamp(12px, 1vw, 19px); color: var(--tv-muted); }
.tv-clock {
  margin-left: auto; font-size: clamp(26px, 3vw, 58px); font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  font-family: 'SF Mono','Consolas',ui-monospace,monospace;
}
.tv-live { display: inline-flex; align-items: center; gap: 8px; font-size: clamp(11px,.9vw,17px); color: var(--tv-accent); }
.tv-live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tv-accent); animation: tvpulse 2s infinite; }
.tv-live.off { color: #e06a6a; } .tv-live.off .dot { background: #e06a6a; }
@keyframes tvpulse { 50% { opacity: .3; } }

/* -------------------------------------------------------------- Hauptteil */
.tv-main { display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(12px, 1.4vw, 26px); min-height: 0; }

.tv-card {
  background: var(--tv-card); border: 1px solid var(--tv-line);
  border-radius: clamp(10px, 1vw, 18px);
  padding: clamp(12px, 1.2vw, 24px);
  display: flex; flex-direction: column; min-height: 0;
}
.tv-card h2 {
  margin: 0 0 clamp(8px,.9vh,16px); font-size: clamp(13px, 1.15vw, 22px);
  font-weight: 500; color: var(--tv-muted); text-transform: uppercase; letter-spacing: .06em;
}
.tv-list { flex: 1 1 auto; overflow: hidden; display: flex; flex-direction: column; }

/* Zieleinlauf */
.tv-tick {
  display: grid; grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: clamp(8px, 1vw, 20px);
  padding: clamp(4px, .45vh, 9px) 0;
  border-bottom: 1px solid var(--tv-line);
  font-size: clamp(15px, 1.5vw, 30px);
  line-height: 1.15;
}
.tv-tick:last-child { border-bottom: none; }
.tv-tick.new { animation: tvin 1.2s ease-out; }
@keyframes tvin { 0% { background: rgba(58,210,159,.22); } 100% { background: transparent; } }
.tv-plate {
  font-family: 'SF Mono','Consolas',ui-monospace,monospace; font-weight: 700;
  font-variant-numeric: tabular-nums; min-width: 2.6em;
  padding: .12em .35em; border-radius: .22em; text-align: center;
}
.tv-tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Die Wertungsklasse steht NEBEN dem Namen, nicht darunter: die zweite Zeile
   hat die Zeilenhoehe verdoppelt und damit die Haelfte der Zieleinlaeufe
   gekostet. So bleibt die Schriftgroesse fuer den Blick aus fuenf Metern. */
.tv-tcat  { font-size: .62em; color: var(--tv-muted); margin-left: .6em; }
.tv-trank { color: var(--tv-accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.tv-ttime { font-family: 'SF Mono','Consolas',ui-monospace,monospace; font-weight: 600;
            font-variant-numeric: tabular-nums; }

/* Rotierende Klassenwertung */
.tv-catname { font-size: clamp(16px, 1.7vw, 34px); font-weight: 600; margin-bottom: .15em; }
.tv-catmeta { font-size: clamp(11px, .95vw, 18px); color: var(--tv-muted); margin-bottom: clamp(6px,.7vh,12px); }
.tv-rank {
  display: grid; grid-template-columns: 1.6em auto 1fr auto;
  align-items: center; gap: clamp(7px,.8vw,16px);
  padding: clamp(5px,.65vh,12px) 0; border-bottom: 1px solid var(--tv-line);
  font-size: clamp(14px, 1.35vw, 27px);
}
.tv-rank:last-child { border-bottom: none; }
.tv-rank .pl { color: var(--tv-muted); font-variant-numeric: tabular-nums; text-align: right; }
.tv-rank.p1 .pl { color: #ffd166; font-weight: 700; }
/* Das Gold des ersten Platzes braucht auf hellem Grund eine dunklere Stufe. */
body.tv.hell .tv-rank.p1 .pl { color: #a87900; }
.tv-dots { display: flex; gap: 6px; margin-top: auto; padding-top: clamp(6px,.8vh,12px); }
.tv-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tv-line); display: block; }
.tv-dots i.on { background: var(--tv-accent); }

/* -------------------------------------------------------------- Fuss */
.tv-foot { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: clamp(14px,1.6vw,32px); }
.tv-stats { display: flex; gap: clamp(14px, 1.8vw, 40px); }
.tv-stat  { text-align: left; }
.tv-stat b { display: block; font-size: clamp(20px, 2.1vw, 42px); font-weight: 600; line-height: 1.05;
             font-variant-numeric: tabular-nums; }
.tv-stat span { font-size: clamp(10px, .85vw, 16px); color: var(--tv-muted); text-transform: uppercase; letter-spacing: .05em; }

.tv-qr { display: flex; align-items: center; gap: clamp(10px,1vw,20px); }
.tv-qr svg { width: clamp(74px, 8.2vh, 128px); height: auto; display: block; border-radius: 5px; }
.tv-qr .cap { font-size: clamp(11px, .95vw, 18px); color: var(--tv-muted); max-width: 12em; line-height: 1.3; }
.tv-qr .cap strong { color: var(--tv-text); display: block; font-size: 1.12em; font-weight: 500; }

.tv-sponsor { display: flex; align-items: center; gap: clamp(8px,.8vw,16px); }
.tv-sponsor svg { height: clamp(18px, 2vh, 32px); width: auto; color: var(--tv-text); display: block; }
.tv-sponsor span { font-size: clamp(10px,.85vw,16px); color: var(--tv-muted); }

.tv-msg { font-size: clamp(15px,1.4vw,28px); color: var(--tv-muted); text-align: center; padding: 2em 0; }

/* ------------------------------------------------------------------ Vollbild */
.tv-full {
  position: fixed; top: 14px; right: 16px; z-index: 20;
  width: 42px; height: 42px; border-radius: 9px;
  background: rgba(255,255,255,.10); color: rgba(255,255,255,.75);
  border: 1px solid rgba(255,255,255,.22);
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: opacity .35s;
}
.tv-full:hover { background: rgba(255,255,255,.20); color: #fff; }

/* Ruht die Maus, verschwinden Knopf und Zeiger - auf einem Beamer soll nur
   das Rennen zu sehen sein. Jede Regung holt beide zurueck. */
body.tv.ruht .tv-full { opacity: 0; pointer-events: none; }
body.tv.ruht { cursor: none; }

/* Heller Modus: die halbtransparenten Knoepfe kippen von Weiss- auf Schwarzanteile. */
body.tv.hell .tv-full {
  background: rgba(0,0,0,.07); color: rgba(0,0,0,.62);
  border-color: rgba(0,0,0,.18);
}
body.tv.hell .tv-full:hover { background: rgba(0,0,0,.14); color: #000; }

/* Zweiter Knopf links neben dem Vollbild, gleiche Machart. */
.tv-full.tv-hell-knopf { right: 68px; }
/* Dritter Knopf (Ton, nur Startuhr). */
.tv-full.tv-ton-knopf { right: 122px; }
.tv-full.tv-ton-knopf.aus { opacity: .55; }
