/* Pitlane – UI nach dem Pitlane-Design-System (HUD-Tokens, Barlow Condensed / Barlow / JetBrains Mono) */
:root {
  --ui-bg: #0e1013; --ui-panel: #171a1f; --ui-raised: #22262d; --ui-line: #2c3139;
  --ink: #f3f4f6; --ink-muted: #9aa3ad; --ink-inv: #0e1013; --focus: #ffd200;
  --purple: #b07cff; --green: #36d474; --yellow: #ffd23d;
  --flag-green: #1fa84f; --flag-yellow: #ffd200; --flag-red: #c81e26; --flag-blue: #1a62bd; --flag-sc: #ff9a1f;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif; --body: 'Barlow', 'Helvetica Neue', Arial, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow-hud: 0 2px 0 rgba(0,0,0,0.35);
  --gut: max(10px, env(safe-area-inset-left));
}
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ui-bg); color: var(--ink); font-family: var(--body); font-size: 15px; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lbl { font-family: var(--cond); font-weight: 600; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-muted); text-transform: uppercase; }
.panel { background: rgba(23,26,31,0.92); box-shadow: var(--shadow-hud); border-radius: 0; }

/* ---------- Touch ---------- */
#touch { position: fixed; inset: 0; display: none; pointer-events: none; }
#touch.on { display: block; }
.tz { position: absolute; bottom: 0; width: 50%; height: 62%; pointer-events: auto; }
.tz-l { left: 0; } .tz-r { right: 0; }
.tz.act { background: linear-gradient(to top, rgba(255,210,0,0.10), transparent 70%); }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--cond); }
.hud button, .hud .radio, .hud .tower { pointer-events: auto; }
.hud-tl { position: absolute; top: max(10px, env(safe-area-inset-top)); left: var(--gut); display: flex; flex-direction: column; gap: 6px; width: 200px; }
.hud-tc { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(460px, 52vw); display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.hud-tr { position: absolute; top: max(10px, env(safe-area-inset-top)); right: var(--gut); width: 210px; display: flex; flex-direction: column; gap: 6px; }
.hud-bl { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: var(--gut); }
.hud-br { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); right: var(--gut); display: grid; grid-template-columns: repeat(3, 84px); gap: 6px; }
.posbox { padding: 6px 12px; display: flex; align-items: baseline; justify-content: space-between; }
.pos { font-size: 38px; font-weight: 800; line-height: 1; }
.pos small { font-size: 16px; color: var(--ink-muted); font-weight: 600; margin-left: 2px; }
.lap { font-size: 16px; font-weight: 700; letter-spacing: 0.04em; }
.tower { list-style: none; margin: 0; padding: 4px 0; font-size: 14px; }
.tower li { display: grid; grid-template-columns: 22px 6px 38px 1fr 22px; gap: 6px; align-items: center; padding: 1px 8px; height: 22px; }
.tower li.me { background: var(--ui-raised); }
.tower li .p { text-align: right; font-weight: 700; }
.tower li .bar { width: 4px; height: 14px; }
.tower li .c { font-weight: 700; letter-spacing: 0.04em; }
.tower li .g { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--ink-muted); }
.tower li .t { justify-self: end; }
.tower li.pit .g { color: var(--flag-sc); }
.tyre { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-family: var(--cond); font-weight: 800; font-size: 12px; border: 2px solid currentColor; background: #0e1013; line-height: 1; }
.times { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.trow { display: flex; justify-content: space-between; align-items: baseline; }
.trow .mono { font-size: 14px; }
.trow .big { font-size: 20px; font-weight: 600; }
.sectors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 3px 0 4px; }
.sec { font-size: 12px; font-weight: 700; text-align: center; padding: 1px 0; background: var(--ui-raised); color: var(--ink-muted); }
.sec.purple { background: var(--purple); color: var(--ink-inv); } .sec.green { background: var(--green); color: var(--ink-inv); } .sec.yellow { background: var(--yellow); color: var(--ink-inv); }
.wx { padding: 8px 10px; }
.wx .now, .eng-wx .now { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }
.fc { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-top: 6px; }
.fc div { text-align: center; font-family: var(--mono); font-size: 10px; padding: 2px 0; background: var(--ui-raised); color: var(--ink-muted); }
.fc div b { display: block; font-family: var(--cond); font-size: 10px; color: var(--ink-muted); font-weight: 600; }
.fc div.r1 { background: #24405f; color: var(--ink); } .fc div.r2 { background: #1f5d9e; color: var(--ink); } .fc div.r3 { background: #1a62bd; color: var(--ink); }
.mini { width: 210px; height: 170px; display: block; }
.carbox { padding: 10px 12px; width: 236px; display: flex; flex-direction: column; gap: 6px; }
.carbox .row2 { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; letter-spacing: 0.03em; }
.meter { height: 6px; background: var(--ui-raised); position: relative; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); }
.meter i.warn { background: var(--yellow); } .meter i.bad { background: var(--flag-red); } .meter i.ers { background: var(--purple); }
.hbtn { pointer-events: auto; height: 54px; border: 0; background: rgba(23,26,31,0.92); box-shadow: var(--shadow-hud); font-family: var(--cond); font-weight: 700; font-size: 15px; letter-spacing: 0.06em; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; touch-action: manipulation; }
.hbtn small { font-size: 11px; color: var(--ink-muted); font-weight: 600; letter-spacing: 0.04em; }
.hbtn:active { background: var(--ui-raised); }
.hbtn.box { background: var(--flag-sc); color: var(--ink-inv); }
.hbtn.box.req { background: var(--focus); }
.hbtn.boost.on { background: var(--purple); color: var(--ink-inv); }
.hbtn.boost.on small { color: var(--ink-inv); }
.flag { padding: 6px 12px; text-align: center; font-weight: 800; font-size: 18px; letter-spacing: 0.08em; }
.flag.sc { background: var(--flag-sc); color: var(--ink-inv); } .flag.yellow { background: var(--flag-yellow); color: var(--ink-inv); }
.flag.green { background: var(--flag-green); color: var(--ink-inv); } .flag.blue { background: var(--flag-blue); color: var(--ink); }
.flag.chq { background: repeating-conic-gradient(#f4f4f2 0 25%, #141517 0 50%) 0 0/16px 16px; color: var(--ink-inv); text-shadow: 0 0 6px #fff, 0 0 3px #fff; }
.radio { display: flex; flex-direction: column; gap: 6px; }
.rmsg { background: rgba(23,26,31,0.95); box-shadow: var(--shadow-hud); padding: 8px 12px; font-family: var(--body); font-size: 14px; line-height: 19px; display: flex; flex-direction: column; gap: 6px; }
.rmsg .who { font-family: var(--cond); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; color: var(--focus); }
.rmsg.warn .who { color: var(--flag-sc); }
.rmsg .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.rmsg .acts button { border: 0; padding: 6px 10px; background: var(--ui-raised); font-family: var(--cond); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; cursor: pointer; min-height: 34px; }
.rmsg .acts button:first-child { background: var(--focus); color: var(--ink-inv); }
.lights { position: fixed; z-index: 6; pointer-events: none; top: 30%; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; background: #0b0b0c; padding: 12px 16px; box-shadow: var(--shadow-hud); }
.lights i { width: 34px; height: 34px; border-radius: 50%; background: #2a1012; }
.lights i.on { background: #ff2a2a; box-shadow: 0 0 16px #ff2a2a; }
.center-msg { position: fixed; z-index: 6; pointer-events: none; font-family: var(--cond); top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 40px; font-weight: 800; letter-spacing: 0.06em; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,0.5); }
.center-msg small { display: block; font-size: 18px; color: var(--ink-muted); }

/* ---------- Renningenieur ---------- */
.eng { display: grid; grid-template-columns: 330px minmax(0, 1fr) 440px; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) var(--gut) max(10px, env(safe-area-inset-bottom)); }
.eng.hud { display: grid; }
.eng[hidden] { display: none !important; }
.eng .panel, .eng button { pointer-events: auto; }
.eng-top { grid-column: 1 / -1; display: flex; gap: 8px 14px; align-items: center; padding: 6px 10px; flex-wrap: wrap; }
.eng-race { display: flex; gap: 10px; align-items: center; font-size: 16px; font-weight: 700; }
.chip { padding: 2px 8px; font-weight: 800; font-size: 13px; letter-spacing: 0.06em; background: var(--flag-green); color: var(--ink-inv); }
.chip.sc { background: var(--flag-sc); } .chip.chq { background: #f4f4f2; }
.eng-wx { flex: 1 1 260px; min-width: 0; }
.eng-wx .fc { grid-template-columns: repeat(10, 1fr); margin-top: 2px; }
.seg { border: 0; background: var(--ui-raised); padding: 6px 10px; font-family: var(--cond); font-weight: 700; font-size: 14px; cursor: pointer; min-height: 32px; color: var(--ink); }
.seg.on { background: var(--focus); color: var(--ink-inv); }
.eng-speed, .eng-cam { display: flex; gap: 2px; }
.eng-left { grid-column: 1; grid-row: 2 / 4; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; pointer-events: auto; }
.drv { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.drv .hd { display: flex; justify-content: space-between; align-items: baseline; }
.drv .hd b { font-size: 24px; font-weight: 800; }
.drv .hd span { font-size: 22px; font-weight: 800; }
.drv .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; font-size: 13px; }
.drv .grid .mono { font-size: 13px; }
.drv .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.drv .acts .seg { flex: 1; }
.drv .acts .box { background: var(--flag-sc); color: var(--ink-inv); }
.drv .acts .box.req { background: var(--focus); }
.chartbox { padding: 8px 10px; flex-shrink: 0; }
#e-chart { width: 100%; height: 150px; display: block; }
.eng-right { grid-column: 3; grid-row: 2; align-self: start; max-height: 100%; overflow-y: auto; padding: 4px 0; }
.ttable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ttable th { font-weight: 600; font-size: 11px; letter-spacing: 0.08em; color: var(--ink-muted); text-align: left; padding: 4px 6px; text-transform: uppercase; }
.ttable td { padding: 2px 6px; height: 24px; white-space: nowrap; }
.ttable td.mono { font-size: 12px; }
.ttable tr.me { background: var(--ui-raised); }
.ttable tr.pit td { color: var(--flag-sc); }
.ttable .bar { display: inline-block; width: 4px; height: 13px; margin-right: 6px; vertical-align: -2px; }
.eng-view { grid-column: 2; grid-row: 2 / 4; pointer-events: none; min-height: 0; }
.eng-radio { grid-column: 2; grid-row: 3; align-self: end; z-index: 1; }
.eng-mini { grid-column: 3; grid-row: 3; width: 100%; height: 190px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(14,16,19,0.72); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-in { width: min(560px, 100%); padding: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--ui-panel); max-height: 100%; overflow-y: auto; }
.modal h2 { margin: 0; font-family: var(--cond); font-size: 30px; font-weight: 700; }
.compounds { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.comp { border: 2px solid var(--ui-line); background: var(--ui-raised); padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-family: var(--cond); }
.comp .tyre { width: 30px; height: 30px; font-size: 16px; border-width: 3px; }
.comp b { font-size: 14px; font-weight: 700; }
.comp small { font-size: 11px; color: var(--ink-muted); text-align: center; }
.comp.sel { border-color: var(--focus); }
.comp.rec::after { content: 'EMPFOHLEN'; font-size: 10px; font-weight: 700; color: var(--focus); letter-spacing: 0.06em; }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--focus); }
.proj { font-size: 15px; line-height: 21px; background: var(--ui-raised); padding: 8px 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Menüs ---------- */
.menu { position: fixed; inset: 0; overflow-y: auto; background: var(--ui-bg); z-index: 10; -webkit-user-select: none; touch-action: pan-y; }
.menu[hidden] { display: none; }
.menu.pause { background: rgba(14,16,19,0.86); }
.screen { max-width: 1100px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 22px; }
.screen h1 { margin: 0; font-family: var(--cond); font-size: clamp(40px, 7vw, 72px); font-weight: 800; letter-spacing: 0.02em; line-height: 0.95; }
.screen h2 { margin: 0; font-family: var(--cond); font-size: 28px; font-weight: 700; }
.screen h3 { margin: 0 0 8px; font-family: var(--cond); font-size: 13px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-muted); text-transform: uppercase; }
.screen p { margin: 0; line-height: 22px; color: var(--ink); max-width: 68ch; }
.muted { color: var(--ink-muted) !important; }
.title { min-height: 100vh; justify-content: center; }
.title .kicker { font-family: var(--cond); font-weight: 600; letter-spacing: 0.12em; color: var(--focus); font-size: 14px; }
.title-hero { position: relative; padding-bottom: 8px; }
.title-hero h1 { font-size: clamp(64px, 13vw, 140px); }
.stripe { height: 10px; background: repeating-linear-gradient(90deg, #d7262e 0 30px, #f4f1ea 30px 60px); width: min(420px, 80%); margin-top: 10px; }
.btn { border: 0; background: var(--ui-raised); padding: 12px 18px; font-family: var(--cond); font-weight: 700; font-size: 18px; letter-spacing: 0.04em; cursor: pointer; min-height: 48px; text-align: left; }
.btn.primary { background: var(--focus); color: var(--ink-inv); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.big { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; }
.btn.big small { font-family: var(--body); font-weight: 400; font-size: 14px; letter-spacing: 0; color: var(--ink-muted); }
.btn.primary.big small { color: #3a3200; }
.mainbtns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; max-width: 820px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.card { border: 2px solid transparent; background: var(--ui-panel); padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; text-align: left; font-family: var(--body); }
.card.sel { border-color: var(--focus); background: var(--ui-raised); }
.card .nm { font-family: var(--cond); font-weight: 700; font-size: 20px; line-height: 1.1; }
.card .sub { font-size: 13px; color: var(--ink-muted); line-height: 18px; }
.livery { display: flex; height: 8px; } .livery i { flex: 1; } .livery i:first-child { flex: 3; }
.stat { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 6px; font-family: var(--cond); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-muted); }
.stat .meter i { background: var(--ink-muted); }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px 18px; }
.opt { display: flex; flex-direction: column; gap: 6px; }
.segs { display: flex; flex-wrap: wrap; gap: 2px; }
.segs .seg { flex: 1; min-height: 40px; font-size: 15px; }
.foot { display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--ui-bg) 30%); padding-top: 18px; }
.trackmap { width: 100%; aspect-ratio: 960 / 900; background: #0e1013; display: block; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { font-family: var(--cond); font-weight: 600; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-muted); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ui-line); text-transform: uppercase; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--ui-line); }
.table tr.me td { background: var(--ui-raised); }
.table .mono { font-size: 13px; }
.tablewrap { overflow-x: auto; background: var(--ui-panel); }
.stints { display: flex; gap: 2px; align-items: center; min-width: 140px; }
.stints i { height: 14px; display: block; font-style: normal; font-family: var(--cond); font-size: 10px; font-weight: 800; text-align: center; line-height: 14px; }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.plan { background: var(--ui-panel); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plan .nm { font-family: var(--cond); font-weight: 700; font-size: 18px; }
.lifes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.life { background: var(--ui-panel); padding: 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 13px; }
.life b { font-family: var(--cond); font-size: 16px; }
.help { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.help div { background: var(--ui-panel); padding: 14px; line-height: 21px; font-size: 14px; }
.help kbd { font-family: var(--mono); font-size: 12px; background: var(--ui-raised); padding: 1px 5px; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }

@media (max-width: 1280px) {
  .eng { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .eng-view { grid-column: 2; grid-row: 2; }
  .eng-radio { grid-column: 2; grid-row: 2; align-self: end; }
  .eng-right { grid-column: 2; grid-row: 3; max-height: 32vh; align-self: stretch; }
  .eng-left { grid-column: 1; grid-row: 2 / 4; }
  .eng-mini { display: none; }
}
@media (max-width: 900px) {
  .hud-tl { width: 160px; }
  .hud-tl .tower li { grid-template-columns: 18px 4px 34px 1fr; } .tower li .t { display: none; }
  .hud-tr { width: 170px; }
  .mini { width: 170px; height: 130px; }
  .hud-tc { width: min(360px, 46vw); }
  .carbox { width: 200px; }
  .hud-br { grid-template-columns: repeat(3, 66px); }
  .hbtn { height: 48px; font-size: 13px; }
  .ttable th:nth-child(7), .ttable td:nth-child(7) { display: none; }
  .split { grid-template-columns: 1fr; }
  .lifes { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .hud-tl { width: 112px; } .tower { display: none; } .pos { font-size: 30px; }
  .posbox { flex-direction: column; align-items: flex-start; gap: 2px; } .lap { font-size: 13px; }
  .trow .big { font-size: 15px; } .trow .mono { font-size: 12px; } .times { padding: 6px 8px; } .wx { padding: 6px 8px; }
  .hud-tr .times .trow:nth-child(n+5) { display: none; }
  .hud-tr { width: 136px; } .mini { width: 136px; height: 104px; }
  .wx .fc { grid-template-columns: repeat(4, 1fr); } .wx .fc div:nth-child(n+5) { display: none; }
  .hud-tc { top: 64px; width: calc(100vw - 2 * var(--gut)); }
  .carbox { width: 160px; padding: 8px; font-size: 13px; }
  .hud-bl { bottom: 128px; }
  .hud-br { grid-template-columns: repeat(3, 1fr); left: var(--gut); }
  .eng { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(34vh, 1fr) auto auto auto; gap: 4px; }
  .eng-view { grid-column: 1; grid-row: 2; }
  .eng-right { grid-column: 1; grid-row: 3; max-height: 22vh; }
  .eng-radio { grid-column: 1; grid-row: 2; align-self: end; }
  .eng-left { grid-column: 1; grid-row: 4 / 6; flex-direction: row; overflow: auto; max-height: 38vh; }
  .eng-left .drv { min-width: 270px; gap: 4px; padding: 8px 10px; } .chartbox, .eng-mini { display: none; }
  .eng-left .drv .grid { gap: 2px 6px; } .eng-left .drv .hd b, .eng-left .drv .hd span { font-size: 20px; }
  .eng-top { padding: 4px 8px; gap: 4px 8px; } .eng-wx .lbl { display: none; }
  .eng { grid-template-rows: auto minmax(26vh, 1fr) auto auto auto; }
  .ttable th:nth-child(4), .ttable td:nth-child(4), .ttable th:nth-child(6), .ttable td:nth-child(6) { display: none; }
  .compounds { grid-template-columns: repeat(3, 1fr); }
  .lifes { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 520px) {
  .tower { display: none; } .mini { height: 110px; }
  .hud-tr .times .trow:nth-child(n+5) { display: none; }
  .eng-mini, .chartbox { display: none; }
}
