:root {
    --bg: #0d1117;
    --card: #161b22;
    --text: #f0f6fc;
    --muted: #8b949e;
    --line: #30363d;
    --green: #2ea043;
    --red: #f85149;
    --yellow: #d29922;
    --blue: #388bfd;
    --purple: #8957e5;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1f2937, var(--bg));
    color: var(--text);
}
.app { max-width: 1500px; margin: 0 auto; padding: 24px; }
.hero, .timer-card, .panel {
    background: rgba(22, 27, 34, 0.95);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.hero { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 20px; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.progress-text { color: var(--muted); font-weight: 800; }
.eyebrow { color: var(--blue); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(32px, 4vw, 56px); }
h2 { font-size: clamp(26px, 4vw, 52px); margin-bottom: 0; }
.label { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 14px; font-weight: 800; }
.timer-topline { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.best-time { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; color: #7ee787; text-align: right; }
.live-timer { font-size: clamp(72px, 14vw, 190px); line-height: .95; font-weight: 950; font-variant-numeric: tabular-nums; text-align: center; margin: 28px 0; letter-spacing: -.06em; }
.controls { display: grid; grid-template-columns: 2fr 2fr 1fr 1fr 1fr; gap: 14px; }
button { border: 0; border-radius: 18px; padding: 18px 22px; color: white; font-size: 22px; font-weight: 900; cursor: pointer; transition: transform .08s ease, filter .08s ease; }
button:hover { filter: brightness(1.1); }
button:active { transform: scale(.98); }
button.start { background: var(--green); }
button.finish { background: var(--red); }
button.dnf { background: var(--yellow); }
button.dns { background: var(--blue); }
button.dsq { background: var(--purple); }
button.ghost { background: transparent; border: 1px solid var(--line); font-size: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; align-items: start; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.big-info { font-size: clamp(24px, 3vw, 40px); font-weight: 900; }
.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 12px; text-align: left; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
tr.active-row td { color: #ffd166; font-weight: 900; background: rgba(210,153,34,.08); }
tr.ok td { color: #7ee787; }
tr.dnf td, tr.dsq td, tr.dns td, tr.dnq td { color: #ffb4b4; }
.badge { display: inline-block; min-width: 76px; text-align: center; border-radius: 999px; padding: 4px 10px; color: var(--text); background: #30363d; font-size: 12px; font-weight: 900; }
.badge.ok { background: rgba(46,160,67,.25); color: #7ee787; }
.badge.running { background: rgba(210,153,34,.25); color: #ffd166; }
.badge.pending { background: rgba(139,148,158,.18); color: #c9d1d9; }
.badge.dnf, .badge.dns, .badge.dsq, .badge.dnq { background: rgba(248,81,73,.18); color: #ffb4b4; }
.message { min-height: 24px; color: #ffb4b4; text-align: center; font-weight: 800; }
@media (max-width: 1000px) {
    .hero, .timer-topline { display: block; }
    .header-actions { margin-top: 16px; justify-content: space-between; }
    .grid, .grid.three { grid-template-columns: 1fr; }
    .controls { grid-template-columns: 1fr; }
    .best-time { text-align: left; }
}

/* v0.3 parallel runners / scheduled starts */
.live-timers { display: grid; gap: 14px; margin: 16px 0; }
.runner-timer { border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 14px 18px; background: rgba(255,255,255,.04); }
.timer-rider { color: #9fb0c7; font-weight: 700; letter-spacing: .03em; margin-bottom: 4px; }
.countdown { font-size: clamp(2rem, 5vw, 4.5rem); font-weight: 900; margin-top: 10px; letter-spacing: -0.04em; }
.countdown.in-window { text-shadow: 0 0 24px rgba(59, 255, 154, .55); }
.countdown.late { opacity: .8; }
.window-row { outline: 2px solid rgba(59, 255, 154, .7); outline-offset: -2px; }
.subtle { color: #718096; font-size: .82rem; margin-top: 2px; }
button.danger { border-color: rgba(255,255,255,.15); }

/* v0.5 Ampel + On The Fly */
.signal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin: 18px 0;
}

.lamp-card {
    border-radius: 20px;
    padding: 22px;
    background: rgba(255,255,255,0.07);
    border: 2px solid rgba(255,255,255,0.12);
    box-shadow: 0 18px 50px rgba(0,0,0,0.25);
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.lamp-card.open {
    border-color: rgba(46, 213, 115, .85);
    background: rgba(46, 213, 115, .12);
}

.lamp-card.closed {
    border-color: rgba(255, 193, 7, .55);
    background: rgba(255, 193, 7, .08);
}

.lamp-card.blocked {
    border-color: rgba(255, 71, 87, .85);
    background: rgba(255, 71, 87, .12);
}

.lamp-head {
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
    opacity: .9;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    display: inline-block;
    background: #ffc107;
    box-shadow: 0 0 18px rgba(255,193,7,.75);
}

.lamp-card.open .dot {
    background: #2ed573;
    box-shadow: 0 0 22px rgba(46,213,115,.85);
}

.lamp-card.blocked .dot {
    background: #ff4757;
    box-shadow: 0 0 22px rgba(255,71,87,.85);
}

.lamp-rider {
    font-size: clamp(24px, 4vw, 44px);
    font-weight: 900;
    line-height: 1.05;
    margin-top: 12px;
}

.on-the-fly {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.otf-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
    color: inherit;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
}

.otf-item:hover,
.otf-item.selected {
    border-color: rgba(46,213,115,.85);
    background: rgba(46,213,115,.14);
}

.otf-item span {
    font-weight: 800;
}

.otf-item small {
    opacity: .75;
    white-space: nowrap;
}

.empty {
    opacity: .65;
    padding: 12px 0;
}

.expected-row td,
.runner-timer.expected {
    outline: 2px solid rgba(46,213,115,.75);
    outline-offset: -2px;
}

@media (max-width: 850px) {
    .signal-grid {
        grid-template-columns: 1fr;
    }
}
