:root.tc-open, :root.tc-open body { overflow:hidden; overscroll-behavior:none; }
.tr-cockpit {
  --tc-ice:#f8f3df;
  --tc-ink:#111f23;
  --tc-mint:#a9eddd;
  --tc-accent:#ffb05d;
  --tc-gutter:clamp(16px,2.4vw,46px);
  position:fixed; inset:0; z-index:2147483000;
  width:100%; height:100%; height:100dvh;
  background:#164b5b; color:var(--tc-ice);
  font:500 16px/1.45 Inter,system-ui,sans-serif;
  isolation:isolate; overflow:hidden;
}
.tr-cockpit:fullscreen { width:100vw; height:100vh; }
.tr-cockpit *, .tr-cockpit *::before, .tr-cockpit *::after { box-sizing:border-box; }
.tr-cockpit[hidden], .tr-cockpit [hidden] { display:none!important; }
.tr-cockpit:focus { outline:none; }
.tr-cockpit button {
  border:1px solid #d3ede75e; border-radius:6px; padding:9px 13px;
  background:#13282ad9; color:#f9f6e8; font:650 .83rem/1.3 Inter,system-ui,sans-serif;
  min-height:40px; touch-action:manipulation; cursor:pointer;
}
.tr-cockpit button:focus-visible { outline:3px solid #f7c063; outline-offset:3px; }
.tr-cockpit button:disabled { opacity:.48; cursor:default; }
.tc-stage { position:absolute; inset:0; overflow:hidden; }
.tr-cockpit:is([data-mode="levels"],[data-mode="loading"],[data-mode="error"]) .tc-stage::after {
  content:''; position:absolute; inset:0;
  background:linear-gradient(90deg,#11180f9c,transparent 74%),url('./assets/port-gellhorn-cover.webp') 68% center / cover no-repeat;
}
.tc-stage canvas { display:block; max-width:none; width:100%; height:100%; }
.tc-rail,.tc-hud { position:absolute; inset:0; pointer-events:none; }
.tc-rail {
  inset:0 0 auto 0; z-index:4; display:flex; align-items:center; justify-content:space-between;
  padding:max(12px,env(safe-area-inset-top)) max(var(--tc-gutter),env(safe-area-inset-right)) 25px max(var(--tc-gutter),env(safe-area-inset-left));
  background:linear-gradient(#071618bb,transparent);
}
.tc-brand {
  color:#fff3db; font:900 clamp(15px,1.55vw,26px)/.83 'Port Inter',Inter,system-ui,sans-serif; letter-spacing:-.075em;
  text-shadow:0 1px 3px #101c22;
}
.tc-brand em { display:block; color:var(--tc-accent); font-style:normal; }
.tc-toolbar { display:flex; align-items:center; gap:6px; pointer-events:auto; }
.tr-cockpit .tc-toolbar button { background:#091d22b8; backdrop-filter:blur(8px); white-space:nowrap; }
.tc-stage:empty { background:linear-gradient(0deg,#17180faa,transparent 55%),url('./assets/port-gellhorn-cover.webp') 58% center/cover; }
.tc-panel {
  position:absolute; z-index:3; left:max(var(--tc-gutter),env(safe-area-inset-left)); bottom:max(var(--tc-gutter),env(safe-area-inset-bottom));
  width:min(390px,calc(100% - 2 * var(--tc-gutter))); max-height:calc(100% - 85px); overflow:auto; overscroll-behavior:contain;
  padding:clamp(16px,1.7vw,27px); color:var(--tc-ice); background:linear-gradient(130deg,#122a2af5,#101f25f2);
  border:1px solid #b0c1b058; border-top:3px solid #f3be6e; border-radius:9px;
  box-shadow:0 13px 45px #00171d4d; scrollbar-color:#667f7b transparent; backdrop-filter:blur(12px);
}
.tc-panel:focus { outline:none; }
.tc-caption,.tr-cockpit small {
  color:#a9cebe; font:700 10px/1.4 ui-monospace,monospace; letter-spacing:.11em; text-transform:uppercase;
}
.tc-panel > h2 { font:800 clamp(26px,3.5vw,45px)/1 Inter,system-ui,sans-serif; letter-spacing:-.055em; margin:8px 0; overflow-wrap:anywhere; }
.tc-blurb { margin:0 0 12px; color:#d1ded2; font-size:.9rem; }
.tr-cockpit[data-mode=levels] .tc-panel { width:min(590px,calc(100% - 2 * var(--tc-gutter))); max-height:calc(100% - 85px); }
.tc-chapters { display:grid; grid-auto-flow:column; grid-auto-columns:minmax(0,1fr); gap:3px; }
.tr-cockpit .tc-chapter { border:0; border-bottom:2px solid #61716a; border-radius:0; background:#1a3130; padding:6px 3px; min-height:35px; font-size:.75rem; }
.tr-cockpit .tc-chapter[aria-pressed=true] { border-bottom-color:var(--tc-accent); color:var(--tc-accent); }
.tc-chapter-name { margin:14px 0 6px; font:750 1.03rem/1.2 'Port Inter',system-ui,sans-serif; letter-spacing:-.03em; }
.tc-courses { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
.tr-cockpit .tc-course { display:grid; align-content:center; gap:3px; min-height:66px; padding:7px 10px; text-align:left; background:#1b3437; }
.tr-cockpit .tc-course[aria-pressed=true] { background:#dfe9d8; border-color:#dfe9d8; color:#193234; }
.tr-cockpit .tc-course:disabled { opacity:1; background:#1a2b2d; border-color:#536663; color:#b7c3ba; }
.tc-course small { color:inherit; font-size:.55rem; letter-spacing:.055em; }
.tc-course strong { font-size:.93rem; line-height:1.12; }
.tc-course span { font:600 .64rem/1.3 ui-monospace,monospace; }
.tc-course-brief { margin:10px 0 0; color:#d8dbcb; font-size:.82rem; }
.tc-course-brief:empty { display:none; }
.tc-actions,.tc-stats { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.tc-actions:not(:empty),.tc-stats:not(:empty) { margin-top:13px; }
.tc-rank-status { margin:12px 0 0; color:#a9d9c8; font-size:.83rem; }
.tc-rank-status:empty { display:none; }
.tr-cockpit .tc-primary { background:var(--tc-accent); color:#1d2924; border-color:#ffdf9c; font-weight:800; flex:1; min-height:48px; }
.tc-stats>div { padding:5px 13px 5px 0; }
.tc-stats strong { display:block; font-size:1.2rem; }
.tc-hud { z-index:2; text-shadow:0 2px 5px #08232bbb; }
.tc-telemetry,.tc-waypoint {
  position:absolute; display:flex; gap:16px; align-items:center;
  background:#112831d9; backdrop-filter:blur(8px); border:1px solid #d2e6d551;
  border-radius:6px; padding:8px 13px;
}
.tc-telemetry { top:max(75px,calc(48px + env(safe-area-inset-top))); left:max(var(--tc-gutter),env(safe-area-inset-left)); }
.tc-map {
  position:absolute; left:max(var(--tc-gutter),env(safe-area-inset-left)); bottom:calc(max(var(--tc-gutter),env(safe-area-inset-bottom)) + 67px);
  width:clamp(140px,13vw,172px); height:auto; aspect-ratio:7/5;
  border:1px solid #d2e6d587; border-radius:6px; box-shadow:0 4px 14px #091c2c48;
}
.tc-touch-on .tc-map { top:max(147px,calc(123px + env(safe-area-inset-top))); bottom:auto; }
.tc-waypoint { top:max(75px,calc(48px + env(safe-area-inset-top))); right:max(var(--tc-gutter),env(safe-area-inset-right)); gap:8px; }
.tc-telemetry strong,.tc-waypoint strong { display:block; font:800 clamp(17px,1.9vw,27px)/1.1 Inter,system-ui,sans-serif; font-variant-numeric:tabular-nums; }
.tc-waypoint i { display:grid; place-items:center; font:800 25px/1 Inter,system-ui,sans-serif; color:var(--tc-accent); width:26px; }
.tc-time.is-low { color:#ffb29c; }
.tc-instruments {
  position:absolute; right:max(var(--tc-gutter),env(safe-area-inset-right)); bottom:max(var(--tc-gutter),env(safe-area-inset-bottom));
  display:flex; align-items:baseline; gap:7px; background:#10232cba; padding:7px 12px; border-radius:5px;
}
.tc-speed { font:italic 850 clamp(34px,5vw,76px)/1 Inter,system-ui,sans-serif; letter-spacing:-.085em; font-variant-numeric:tabular-nums; }
.tc-instruments span { font:700 .65rem ui-monospace,monospace; text-transform:uppercase; letter-spacing:.09em; color:#d6f0e1; }
.tc-guidance { position:absolute; bottom:max(var(--tc-gutter),env(safe-area-inset-bottom)); left:max(var(--tc-gutter),env(safe-area-inset-left)); max-width:min(65%,550px); }
.tc-hint,.tc-key-help { display:block; width:fit-content; padding:5px 9px; background:#0c202bd9; border-radius:4px; }
.tc-hint { color:#f8dfaa; font-size:.9rem; font-weight:650; }
.tc-hint:empty { display:none; }
.tr-cockpit .tc-key-help { margin-top:3px; font-size:.62rem; color:#ebeedd; letter-spacing:.04em; }
.tc-touch { display:none; }
.tc-touch-on .tc-touch {
  position:absolute; left:max(var(--tc-gutter),env(safe-area-inset-left)); right:max(var(--tc-gutter),env(safe-area-inset-right));
  bottom:max(15px,env(safe-area-inset-bottom)); display:flex; align-items:end; justify-content:space-between; gap:10px;
}
.tc-steer,.tc-throttle { display:flex; gap:5px; align-items:end; }
.tr-cockpit .tc-control {
  min-width:clamp(42px,6vw,72px); height:clamp(48px,8vh,78px); padding:6px;
  pointer-events:auto; user-select:none; -webkit-user-select:none; touch-action:none;
  border:1px solid #e3f4df9c; background:#0e242ec4; backdrop-filter:blur(5px);
}
.tr-cockpit .tc-left,.tr-cockpit .tc-right { font-size:22px; }
.tr-cockpit .tc-gas { color:var(--tc-ink); background:#a9edddd9; }
.tr-cockpit .tc-boost { color:var(--tc-ink); background:#ffcf71df; }
.tr-cockpit .tc-control.is-held { transform:translateY(2px); color:#12282e; background:#fff3d5; }
.tc-touch-on .tc-guidance,.tc-touch-on .tc-instruments { bottom:calc(max(15px,env(safe-area-inset-bottom)) + clamp(48px,8vh,78px) + 8px); }
.tc-touch-on .tc-key-help { display:none; }
@media(max-width:600px) {
  .tr-cockpit { --tc-gutter:12px; }
  .tc-toolbar { gap:3px; }
  .tr-cockpit .tc-toolbar button { min-height:36px; font-size:.7rem; padding:6px 7px; }
  .tc-telemetry,.tc-waypoint { top:max(58px,calc(43px + env(safe-area-inset-top))); padding:6px 9px; }
  .tc-map,.tc-touch-on .tc-map { top:max(115px,calc(101px + env(safe-area-inset-top))); bottom:auto; width:125px; }
  .tc-guidance { max-width:62%; }
  .tc-panel { width:calc(100% - 2 * var(--tc-gutter)); max-height:68%; }
  .tc-brand { font-size:16px; }
  .tc-hint { font-size:.76rem; }
}
@media(max-height:520px) and (orientation:landscape) {
  .tr-cockpit { --tc-gutter:10px; }
  .tc-rail { padding-top:max(5px,env(safe-area-inset-top)); }
  .tc-panel { padding:14px; max-height:calc(100% - 54px); }
  .tc-telemetry,.tc-waypoint { top:54px; }
  .tc-map,.tc-touch-on .tc-map { top:115px; bottom:auto; width:107px; }
  .tc-panel>h2 { font-size:25px; }
  .tr-cockpit[data-mode=levels] .tc-panel { max-height:calc(100% - 56px); }
  .tc-courses { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media(max-width:400px) {
  .tr-cockpit .tc-toolbar button { font-size:0; min-width:36px; padding-inline:8px; }
  .tr-cockpit .tc-toolbar button::before { font:700 11px/1.2 Inter,system-ui,sans-serif; }
  .tc-sound::before { content:'Sound'; }
  .tc-touch-toggle::before { content:'Touch'; }
  .tc-pause::before { content:'Pause'; }
  .tc-close::before { content:'Exit ↗'; }
  .tr-cockpit .tc-toolbar button[aria-pressed=true] { color:var(--tc-mint); border-color:var(--tc-mint); }
  .tc-telemetry { gap:9px; }
  .tc-telemetry small,.tc-waypoint small { font-size:9px; letter-spacing:.055em; }
  .tc-waypoint { gap:4px; }
}
.tc-instruments { display:grid; gap:3px; }
.tc-charge { display:flex; align-items:center; gap:4px; color:#d7efe2; font:650 .58rem/1 ui-monospace,monospace; text-transform:uppercase; letter-spacing:.08em; }
.tc-charge meter { width:clamp(34px,3.7vw,60px); height:7px; background:#465553; border:0; border-radius:3px; }
.tc-charge meter::-webkit-meter-bar { border:0; background:#465553; border-radius:3px; }
.tc-charge meter::-webkit-meter-optimum-value { background:#ffcf71; }
.tc-charge meter::-moz-meter-bar { background:#ffcf71; }

.tc-race-id { display:flex; align-items:center; gap:13px; min-width:0; }
.tc-race-name { display:none; padding-left:12px; border-left:1px solid #ffefd083; color:#fff1db; text-shadow:0 2px 6px #141115; font:700 clamp(12px,1.15vw,18px)/1.1 'Port Inter',Inter,system-ui,sans-serif; }
.tr-cockpit[data-mode=drive] .tc-race-name:not(:empty) { display:block; }
.tc-telemetry,.tc-waypoint,.tc-instruments { color:#fff6ea; background:linear-gradient(115deg,#191922ed,#202128bf); border:1px solid #f0d6b34d; border-radius:3px; }
.tc-telemetry { border-left:3px solid #ffad66; }
.tc-telemetry small,.tc-waypoint small { color:#e6c7a9; }
.tc-telemetry strong,.tc-waypoint strong { letter-spacing:-.045em; }
.tc-instruments { padding:8px 13px; border-right:3px solid #ffad66; }
.tc-map { border-color:#ecd9bd73; border-radius:3px; }
.tc-skills {
  position:absolute; right:max(var(--tc-gutter),env(safe-area-inset-right)); top:max(150px,calc(122px + env(safe-area-inset-top)));
  width:min(169px,44vw); border:1px solid #bacac34d; border-left:3px solid #96e6d3; border-radius:3px;
  background:linear-gradient(115deg,#13272bef,#192329d9); color:#f9f6e8; text-shadow:none;
}
.tc-line,.tc-arcade { padding:6px 9px; }
.tc-skills .tc-line>div,.tc-skills .tc-arcade>div { display:flex; align-items:baseline; justify-content:space-between; gap:3px; }
.tc-skills small { color:#b3e6d7; font-size:9px; letter-spacing:.075em; }
.tc-line-score { display:block; font:800 clamp(17px,1.55vw,24px)/1.12 Inter,system-ui,sans-serif; font-variant-numeric:tabular-nums; letter-spacing:-.045em; }
.tc-line-streak,.tc-arcade-score { font:650 10px/1.2 ui-monospace,monospace; color:#f5e1b9; white-space:nowrap; }
.tc-line-feedback,.tc-arcade-feedback { display:block; font:650 11px/1.35 Inter,system-ui,sans-serif; color:#d4e5de; }
.tc-line-feedback[data-grade=perfect],.tc-line-feedback[data-grade=clean] { color:#a2ffdf; }
.tc-line-feedback[data-grade=wide],.tc-line-feedback[data-grade=miss] { color:#ffd194; }
.tc-arcade { border-top:1px solid #becdca42; }
.tc-arcade small { color:#ffca8d; }
.tc-arcade-hits { display:block; font:600 10px/1.35 ui-monospace,monospace; color:#ebd7bf; }
.tc-skill-result { margin:10px 0 0; color:#c1e8db; font-size:.8rem; line-height:1.5; }
.tc-skill-result:empty { display:none; }
.tr-cockpit .tc-fire { color:#ffe2c3; background:#733b2beb; border-color:#f6af81; }
@media(max-width:600px), (max-height:520px) and (orientation:landscape) {
  .tc-skills { top:max(114px,calc(100px + env(safe-area-inset-top))); width:min(139px,44vw); }
  .tc-line,.tc-arcade { padding:4px 6px; }
  .tc-line-score { font-size:17px; }
  .tc-line-feedback,.tc-arcade-feedback { font-size:10px; }
  .tc-arcade:has(.tc-arcade-feedback:not(:empty)) .tc-arcade-hits { display:none; }
}
@media(max-width:360px) {
  .tr-cockpit .tc-control { min-width:40px; padding:3px; }
  .tc-touch-on .tc-touch,.tc-throttle,.tc-steer { gap:3px; }
}
@media(max-width:650px) {
  .tc-race-id { display:block; }
  .tr-cockpit[data-mode=drive] .tc-race-name:not(:empty) { margin-top:4px; max-width:33vw; border:0; padding:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
  .tr-cockpit[data-mode=drive] .tc-brand em { display:inline; }
}
