:root {
  --bg: #15181d;
  --panel: #1f242b;
  --line: #333a44;
  --text: #e8eaed;
  --muted: #9aa3ad;
  --accent: #ffc107;
  --human: #4fc3f7;
  --bot: #b0bec5;
  --ok: #66bb6a;
  --bad: #ef5350;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Raum mit Passwort: bis zur Freigabe nur die Passwortkarte */
body.locked .access { display: none !important; }
.error { color: var(--bad); font-size: 13px; }
/* kein "Ziehen zum Aktualisieren": ein Wisch nach unten würde die Seite neu laden (Fahrt, Auswertung weg) */
html, body { overscroll-behavior: none; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.35 system-ui, "Segoe UI", Roboto, sans-serif; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
header strong { font-size: 18px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.chip { padding: 2px 10px; border-radius: 12px; background: #2b323b; font-size: 13px; }
.chip.on { background: #1e4d2b; }
.chip.off { background: #5a2323; }

/* rechte Spalte auf schmalen Bildschirmen (Fernseher: 960 px) etwas schmaler, damit die Kacheln Platz haben */
main { display: grid; grid-template-columns: 1fr clamp(280px, 30vw, 340px); gap: 12px; padding: 12px 16px; height: calc(100% - 46px); overflow: hidden; }
/* min-height 0: sonst streckt eine lange Rangliste das Raster und die ganze Seite rutscht */
.ride { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
aside { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overflow-x: hidden; min-width: 0; min-height: 0; }

.hud { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--panel); border-radius: 10px; padding: 6px 8px; text-align: center; min-width: 0; overflow: hidden; }
/* Schrift wächst mit der Breite, damit z. B. "41,1" auch in schmalen Kacheln (Fernseher: 960 px) passt */
.tile span { display: block; font-size: clamp(16px, 2vw, 24px); font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.big span { font-size: clamp(20px, 2.5vw, 34px); color: var(--accent); }
.tile small { color: var(--muted); }

.view { position: relative; flex: 1; min-height: 180px; }
canvas { display: block; width: 100%; background: var(--panel); border-radius: 10px; }
#near, #world { height: 100%; }
#world { touch-action: none; outline: none; }
.viewBtn { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, .45); border-color: transparent; }
#overview { height: 110px; flex: none; }
.badge { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--ok); color: #000; font-weight: 700; padding: 3px 10px; border-radius: 8px; }
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: 96px; font-weight: 800; color: var(--accent); background: rgba(0, 0, 0, .35); border-radius: 10px; text-align: center; }
#overlay small { font-size: 22px; color: var(--text); font-weight: 400; }

/* Trainingsanzeige links über der Straße, wie bei Zwift */
.workout { position: absolute; top: 10px; left: 10px; width: 250px; max-height: calc(100% - 20px); overflow: hidden;
  display: flex; flex-direction: column; gap: 4px; background: rgba(20, 24, 29, .82); border-radius: 10px; padding: 8px 10px; }
.woHead { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
.woHead b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.woNow { display: flex; justify-content: space-between; align-items: baseline; }
#woTarget { font-size: 28px; font-weight: 800; color: var(--accent); }
#woLeft { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.woHint { font-size: 13px; font-weight: 700; min-height: 17px; }
.woHint.ok { color: var(--ok); }
.woHint.low, .woHint.high { color: #ffa726; }
#woChart { height: 46px; background: none; border-radius: 4px; }
.woTotal { font-size: 12px; color: var(--muted); text-align: right; }
#woSteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
#woSteps li { padding: 3px 8px; border-radius: 5px; font-weight: 700; font-size: 13px; color: #111; display: flex; justify-content: space-between; }
#woSteps li.now { font-size: 17px; padding: 6px 8px; outline: 2px solid #fff; }
#woSteps li.past { opacity: .45; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }

/* Meine Fahrten */
.rides { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.rides li { padding: 6px 8px; border-radius: 6px; background: #2b323b; cursor: pointer; font-size: 13px; }
.rides li b { display: block; font-size: 14px; }

/* Auswertung nach der Fahrt */
.dialog { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.dialogBox { background: var(--panel); border-radius: 12px; padding: 14px 16px; width: min(1100px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; }
.dialogBox h2 { margin: 0; font-size: 20px; }
.dialogBox h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.anTiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.anTile { background: #2b323b; border-radius: 8px; padding: 6px 8px; }
.anTile b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.anTile small { color: var(--muted); }
#anChart { height: 220px; background: #191d22; }
.anLegend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.anLegend span::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; }
.anLegend .lp::before { background: #ffc107; }
.anLegend .lh::before { background: #ef5350; }
.anLegend .lt::before { border-top: 2px dashed #fff; height: 0; }
.anLegend .le::before { background: rgba(255, 255, 255, .25); height: 8px; }
.anRow { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 16px; }
.anBar { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #262c34; }
.anZone { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.anZone b { text-align: right; font-variant-numeric: tabular-nums; }
.anZoneBar { height: 10px; background: #2b323b; border-radius: 5px; overflow: hidden; }
.anZoneBar div { height: 100%; }
.anStars { font-size: 22px; color: var(--accent); letter-spacing: 2px; }

.card { background: var(--panel); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.card.grow { flex: 1; }
.card h2 { margin: 0; font-size: 15px; color: var(--muted); font-weight: 600; }
label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
input, select, button { font: inherit; color: var(--text); background: #2b323b; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input[type=number] { width: 80px; }
input[type=range] { flex: 1; padding: 0; }
select { width: 100%; }
button { cursor: pointer; }
button.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
button:disabled { opacity: .45; cursor: default; }
button.x { padding: 0 8px; background: none; border: none; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--line); padding: 3px 4px; }
td { padding: 5px 4px; border-bottom: 1px solid #262c34; white-space: nowrap; }
td.name { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; } /* nimmt nur den Rest – die Tabelle passt immer in die Spalte */
tr.me td { color: var(--accent); font-weight: 700; }
tr.offline td { opacity: .5; }
.tag { font-size: 11px; color: var(--bot); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; margin-left: 4px; }

@media (max-width: 900px) {
  .anTiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .anRow { grid-template-columns: 1fr; }
  .workout { width: 200px; }
  main { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .view { height: 260px; flex: none; }
}

a { color: var(--accent); }

/* Fernbedienung (App "ErgoRace TV"): deutlich sichtbar, wo man gerade ist */
body.tv :focus { outline: 3px solid var(--accent); outline-offset: 2px; }
body.tv .rides li:focus { background: #3a4350; }
