/* ============ Carpet Racer 1:10 ============ */

* { box-sizing: border-box; }

/* Design-Token: eine Stelle für Farben, Linien und Radien von Menü und Editor. */
:root {
  --bg: #05060a;
  --surface: rgba(11, 14, 22, 0.7);
  --surface-2: rgba(9, 11, 17, 0.62);
  --line: rgba(150, 170, 210, 0.18);
  --line-strong: rgba(180, 200, 240, 0.44);
  --text: #e8ecf6;
  --muted: #98a3ba;
  --dim: #6f7c95;
  --accent: #4ea8ff;
  --ok: #7ee787;
  --warn: #ffd166;
  --danger: #ff6b6b;
  --r-lg: 16px;
  --r-md: 12px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

html, body {
  margin: 0;
  height: 100%;
  background: #05060a;
  color: #e8ecf6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#stage { position: fixed; inset: 0; }
canvas { width: 100%; height: 100%; display: block; }

/* Enhanced 3D: eigener Canvas über dem 2D-Canvas. Der 2D-Canvas bleibt im Layout
   (visibility statt display), damit View.resize() weiter die echte Größe misst. */
#game3d { position: absolute; inset: 0; display: none; touch-action: none; }
body.r3d #game3d { display: block; }
body.r3d #game { visibility: hidden; }
body:not(.r3d) .r3d-only { display: none !important; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud { position: absolute; inset: 0; pointer-events: none; }

.panel {
  position: absolute;
  background: linear-gradient(180deg, rgba(16, 20, 31, 0.78), rgba(9, 11, 17, 0.72));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
}

.hud-left { top: 14px; left: 14px; min-width: 196px; }
.hud-right { top: 14px; right: 14px; text-align: right; min-width: 150px; }

.hud-lap {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.hud-lap .k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.hud-lap .v { font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

.row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; line-height: 1.7; }
.row .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.row .v { font-size: 14px; font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.dim { color: var(--muted); }
.best { color: var(--ok); }

.meter { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; margin: 10px 0 5px; overflow: hidden; }
.meter-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--warn), var(--danger));
  transition: width .08s linear;
}
.meter-label { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }

.speed { display: flex; align-items: baseline; gap: 6px; justify-content: flex-end; }
.speed-v { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.speed-u { font-size: 11px; color: var(--dim); letter-spacing: .1em; font-weight: 600; }

.hud-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; margin-top: 9px; }
.chip {
  display: inline-block; padding: 3px 9px;
  border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  background: rgba(78, 168, 255, 0.14); border: 1px solid rgba(78, 168, 255, 0.38); color: #a8d8ff;
}
.chip.air { background: rgba(255, 209, 102, 0.16); border-color: rgba(255, 209, 102, 0.5); color: var(--warn); display: none; }
.chip.air.on { display: inline-block; }
.chip.track {
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(126, 231, 135, 0.12);
  border-color: rgba(126, 231, 135, 0.38); color: #b6f0c0; letter-spacing: .04em;
}

/* Startrampen-Licht */
#countlight {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%);
  min-width: 150px; height: 150px; padding: 0 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; font-size: 92px; font-weight: 800; letter-spacing: .02em;
  color: #fff; text-shadow: 0 4px 22px rgba(0, 0, 0, .6);
  background: radial-gradient(circle, rgba(29, 111, 208, 0.42), rgba(9, 11, 17, 0.55) 70%);
  border: 1px solid rgba(124, 194, 255, 0.45);
  box-shadow: 0 0 60px rgba(78, 168, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Toast */
#toast {
  position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%) translateY(10px);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: rgba(12, 16, 24, 0.88); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .18s ease, transform .18s ease;
  pointer-events: none; z-index: 5;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Tastenhilfe: dezente Leiste unten, Tasten als kleine Kappen */
.keys {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 28px);
  display: flex; gap: 6px 14px; flex-wrap: wrap; justify-content: center;
  padding: 7px 14px; border-radius: var(--r-md);
  background: rgba(9, 11, 17, 0.5); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 11px; color: var(--muted); opacity: .82;
}
.keys b {
  display: inline-block; padding: 0 5px; margin-right: 2px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #dfe6f3; font-weight: 600; font-size: 10.5px; line-height: 1.6;
}
.keys .padnote { color: var(--dim); }

/* Werkzeugleiste oben mittig, zwischen den beiden HUD-Panels */
.hud-tools {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 4px; pointer-events: auto;
  border-radius: 14px; background: rgba(9, 11, 17, 0.62); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.hud-tools .tool { background: transparent; border-color: transparent; border-radius: 10px; padding: 6px 11px; white-space: nowrap; }
.hud-tools .tool:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line); }

button {
  font: inherit; color: inherit; cursor: pointer;
  background: rgba(20, 25, 37, 0.85); border: 1px solid rgba(150, 170, 210, 0.26);
  border-radius: 10px; padding: 7px 12px;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
button:hover { background: rgba(38, 49, 70, 0.92); border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.42; cursor: default; }
button.primary {
  background: linear-gradient(180deg, #2f86e6, #1a62c0); border-color: #5cb0ff;
  color: #f2f8ff; font-weight: 700; box-shadow: 0 6px 18px rgba(29, 111, 208, 0.35);
}
button.primary:hover { background: linear-gradient(180deg, #3a92f2, #2069cc); border-color: #7cc2ff; }
.tool { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.tool b { color: var(--warn); }
.tool kbd { font-size: 10px; padding: 0 5px; line-height: 1.5; opacity: .85; }
.tool.accent { background: rgba(29, 111, 208, 0.26); border-color: rgba(78, 168, 255, 0.55); color: #e3f1ff; }
.tool.accent:hover { background: rgba(29, 111, 208, 0.42); border-color: #7cc2ff; }

/* ---------- Darstellung (Menü-Segmente + 3D-Kamera-Panel) ---------- */

.seg { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: rgba(9, 11, 17, 0.55); }
.seg button { border: 1px solid transparent; border-radius: 9px; background: transparent; padding: 7px 13px; font-size: 13px; color: var(--muted); }
.seg button:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.seg button.sel { background: rgba(29, 111, 208, 0.4); border-color: rgba(78, 168, 255, 0.6); color: #fff; }
body.want3d .seg-cam2d { display: none; }
body:not(.want3d) .seg-cam3d { display: none; }

.cam3d {
  top: 118px; right: 14px; width: 320px; pointer-events: auto; font-size: 12px;
  max-height: calc(100% - 200px); overflow: auto; padding: 14px;
}
.c3head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 13px; }
.c3head em { color: var(--accent); font-style: normal; font-weight: 600; }
.c3seg { display: flex; margin-bottom: 10px; }
.c3seg button { flex: 1; padding: 6px 4px; font-size: 11px; }
.c3row { display: grid; grid-template-columns: 84px 1fr 62px; align-items: center; gap: 8px; margin: 6px 0; }
.c3k { color: var(--muted); }
.c3v { text-align: right; font-variant-numeric: tabular-nums; color: #dfe6f3; }
.c3row input[type=range] { width: 100%; accent-color: var(--accent); }
.c3row select {
  font: inherit; color: inherit; background: rgba(18, 22, 32, 0.9);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 6px;
}
.c3foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.c3hint { margin: 8px 0 0; color: var(--dim); font-size: 11px; }

/* ---------- Touch ---------- */

.touch-pad { position: absolute; inset: auto 0 0 0; display: none; }
body.touch .touch-pad { display: block; }
body.touch .keys { display: none; }

.tbtn {
  position: absolute; bottom: 18px; width: 84px; height: 74px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  background: rgba(14, 18, 26, 0.72); border: 1px solid rgba(150, 170, 210, 0.3);
  color: #b9c5da; user-select: none; pointer-events: auto; touch-action: none;
}
.tbtn.down { background: rgba(78, 168, 255, 0.32); border-color: #4ea8ff; color: #fff; }
.tbtn.left { left: 16px; }
.tbtn.right { left: 110px; }
.tbtn.gas { right: 16px; height: 96px; background: rgba(30, 70, 45, 0.7); border-color: rgba(120, 230, 160, 0.4); }
.tbtn.brake { right: 110px; }
.tbtn.hb { right: 204px; width: 66px; }

/* ---------- Menü ---------- */

kbd {
  font: 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cfd8ea; font-variant-numeric: tabular-nums;
}

.overlay {
  position: absolute; inset: 0; display: flex;
  background: radial-gradient(120% 90% at 50% 0%, rgba(20, 30, 50, 0.86), rgba(4, 5, 9, 0.95));
  padding: 24px; overflow: auto; overscroll-behavior: contain;
}
/* Auto-Raender statt align-items:center: bei hoeherem Inhalt bleibt der obere Rand
   erreichbar (zentriertes Flex-Overflow ist sonst nicht scrollbar). */
.menu-inner, .padmap-inner, .pause-inner { margin: auto; }
.padmap-inner { width: min(720px, 100%); }
h1 { margin: 0; font-size: clamp(26px, 4.4vw, 42px); letter-spacing: -0.015em; }
h1 span { color: var(--accent); font-weight: 500; }
.sub { margin: 6px 0 18px; color: #97a3ba; font-size: 14px; }

/* ---------- Startbild ---------- */

.menu { padding: 0; }
.menu-inner {
  margin: 0 auto; width: min(1240px, 100%); min-height: 100%;
  display: flex; flex-direction: column; gap: 18px;
}

/* Kopfzeile: Titel links, aktuelle Auswahl und Startaktion rechts – bleibt beim Scrollen stehen. */
.menu-head {
  position: sticky; top: 0; z-index: 6;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 28px;
  padding: 20px 26px 14px;
  background: linear-gradient(180deg, rgba(6, 8, 13, 0.97) 58%, rgba(6, 8, 13, 0.76));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-brand .sub { margin: 8px 0 0; max-width: 62ch; font-size: 13px; }
.menu-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.qchip {
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.qchip span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.qchip b { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cta-primary {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 999px;
  background: linear-gradient(180deg, #2b83e8, #1a5fbf);
  border: 1px solid rgba(78, 168, 255, 0.55);
  color: #f2f8ff; font-size: 15px; font-weight: 700;
  box-shadow: 0 12px 28px rgba(20, 70, 140, 0.45);
}
.cta-primary:hover { background: linear-gradient(180deg, #3a92f2, #2069cc); border-color: #7cc2ff; transform: translateY(-1px); }
.cta-primary kbd { background: rgba(4, 12, 22, 0.35); border-color: rgba(200, 228, 255, 0.35); color: #eaf4ff; }

/* Zweispaltig: links die grossen Streckenkarten, rechts die Auswahl- und Infosaeule. */
.menu-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px;
  align-items: start; flex: 1; padding: 0 26px;
}
.mcol-side { display: flex; flex-direction: column; gap: 14px; }
.mpanel {
  padding: 13px 14px 15px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--line);
}

.sec-title {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 10px;
  margin: 0 0 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.sec-title em { color: var(--accent); font-style: normal; font-size: 12px; letter-spacing: .04em; text-transform: none; }
.sec-keys { font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--dim); }
.sec-keys b { color: #cfd8ea; }
.mpanel .tip { display: block; margin: 10px 0 0; font-size: 11.5px; }

/* ---------- Streckenauswahl (Vorschau = gerendertes Streckenbild) ---------- */

.tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 13px; }
.tcard {
  position: relative; display: block; text-align: left; padding: 0; overflow: hidden;
  border-radius: var(--r-lg); cursor: pointer; color: inherit; font: inherit;
  background: var(--surface); border: 1px solid var(--line);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.tcard:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.tcard.sel { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(78, 168, 255, .55), 0 16px 40px rgba(20, 70, 140, .4); }
.tcard.sel::after {
  content: '✓'; position: absolute; top: 9px; right: 9px; z-index: 2;
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 999px; background: var(--accent); color: #04121f;
  font-size: 13px; font-weight: 800; box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.thumb {
  display: block; width: 100%; height: auto; background: #0b0b0f;
  border-bottom: 1px solid rgba(150, 170, 210, 0.14);
}
.tinfo { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; }
.tmeta { display: flex; flex-direction: column; gap: 7px; }
.tmeta h3 { margin: 0; font-size: 14.5px; line-height: 1.3; }
.tbadges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Technik-Stufe als fünf Punkte – macht die Kurse untereinander sofort vergleichbar. */
.tdots { display: inline-flex; gap: 3px; margin-right: 2px; }
.tdots i { width: 6px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .16); }
.tdots i.on { background: var(--accent); box-shadow: 0 0 6px rgba(78, 168, 255, .55); }
.tb {
  font-size: 10px; letter-spacing: .04em; padding: 3px 6px; border-radius: 6px; white-space: nowrap;
  background: rgba(255, 255, 255, .07); color: #9fb0cc;
}
.tb.jump { background: rgba(255, 209, 102, .14); color: var(--warn); }
.tb.nojump { background: rgba(126, 231, 135, .12); color: var(--ok); }
.tstats { display: flex; flex-wrap: wrap; gap: 4px 5px; }
.tstat {
  font-size: 11px; color: var(--muted); padding: 2px 7px; border-radius: 6px;
  background: rgba(255, 255, 255, .05); font-variant-numeric: tabular-nums;
}
.tstat.len { color: #cfd8ea; background: rgba(255, 255, 255, .09); font-weight: 600; }
.tstat.best { color: var(--dim); }
.tstat.best:empty { display: none; }
.tstat.best.has { color: var(--ok); background: rgba(126, 231, 135, .1); }

.cards { display: grid; grid-template-columns: 1fr; gap: 11px; }
.card {
  position: relative; text-align: left; padding: 13px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); color: inherit; font: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(78, 168, 255, .5), 0 14px 34px rgba(20, 70, 140, .35); }
.card-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 17px; }
.card-sub { font-size: 11.5px; color: var(--muted); }
.card p { margin: 9px 0 0; color: #99a5bc; font-size: 12px; line-height: 1.5; }
.swatch { width: 13px; height: 13px; border-radius: 4px; background: var(--c); box-shadow: 0 0 12px var(--c); }
.stats { display: grid; gap: 6px; margin-top: 11px; }
.stat { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: #93a0b8; }
.stat span { width: 68px; flex: none; }
.bar { flex: 1; height: 6px; border-radius: 4px; background: rgba(255,255,255,.09); display: block; overflow: hidden; }
.bar b { display: block; height: 100%; width: calc(var(--v, .5) * 100%); background: linear-gradient(90deg, #4ea8ff, #7ee787); }
.cta {
  margin-top: 11px; display: inline-block; padding: 6px 13px; border-radius: 999px;
  background: rgba(78, 168, 255, .16); border: 1px solid rgba(78, 168, 255, .45);
  color: #bfe3ff; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}

/* Seitenbereiche des Startbilds: Segmente, Bestzeiten, Fusszeile */
.viewsel { display: flex; flex-direction: column; gap: 8px; }
.viewsel .seg { display: flex; }
.viewsel .seg button { flex: 1; }

.board ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.board li {
  padding: 6px 9px; border-radius: 8px; background: rgba(255, 255, 255, .04);
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; color: #cfd8ea;
}
.board li.best { color: var(--ok); background: rgba(126, 231, 135, .1); }

.menu-foot {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: space-between;
  padding: 13px 26px; margin-top: 4px;
  background: linear-gradient(0deg, rgba(6, 8, 13, 0.97) 45%, rgba(6, 8, 13, 0.72));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.menu-keys { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: 11.5px; color: #78839a; }
.menu-keys b { color: #cfd8ea; }
.menu-keys .padnote { color: var(--dim); }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tool.danger:hover { border-color: rgba(255, 107, 107, .55); background: rgba(255, 107, 107, .16); color: #ffb3b3; }
.tip { color: var(--dim); }

/* ---------- Dialoge (Pad-Zuordnung, Pause) ---------- */

.dialog {
  background: linear-gradient(180deg, rgba(20, 26, 40, 0.92), rgba(10, 13, 20, 0.94));
  border: 1px solid var(--line); border-radius: 20px;
  padding: 26px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.dialog h2 { margin: 0 0 4px; font-size: clamp(22px, 3.4vw, 28px); letter-spacing: -0.01em; }
.dialog .sub { margin: 6px 0 0; font-size: 13.5px; line-height: 1.55; }
.dialog .sub b { color: var(--text); }

/* ---------- Gamepad- / RC-Sender-Zuordnung ---------- */

.padmap-inner { width: min(740px, 100%); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 18px 0 12px; }
.prow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; padding: 12px 14px; border-radius: var(--r-md);
  background: rgba(14, 18, 28, 0.75); border: 1px solid var(--line);
}
.prow:hover { border-color: var(--line-strong); }
.prow.listen { border-color: var(--accent); background: rgba(29, 111, 208, 0.22); box-shadow: 0 0 0 1px rgba(78, 168, 255, .35); }
.pk { font-size: 13px; color: #dfe6f3; letter-spacing: .03em; font-weight: 600; }
.pv { font: 12px ui-monospace, Menlo, monospace; color: var(--ok); }
.prow.listen .pv { color: var(--warn); }
.plive {
  display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); min-height: 44px;
  padding: 10px 12px; border-radius: var(--r-md); background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line);
}
.plive #padAsk { color: #dfe6f3; }
.praw { font: 12px ui-monospace, Menlo, monospace; color: var(--dim); }
.ptest { font: 12px ui-monospace, Menlo, monospace; color: var(--ok); }
.pid { margin-top: 10px; font-size: 12px; color: var(--muted); }
.padmap-inner .tip { font-size: 12px; line-height: 1.6; margin: 12px 0 0; }
.pfoot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Pause ---------- */

#pause { background: rgba(4, 6, 10, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.pause-inner { text-align: center; width: min(380px, 100%); }
.pause-inner h2 { font-size: 34px; }
.pause-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.pause-actions button { flex: 1; padding: 10px 14px; font-size: 14px; justify-content: center; }

@media (max-width: 1020px) {
  .menu-grid { grid-template-columns: 1fr; }
  .mcol-side { flex-direction: row; flex-wrap: wrap; }
  .mcol-side .mpanel { flex: 1 1 260px; }
}

/* Mittige Werkzeugleiste kollidiert sonst mit den beiden Panels */
@media (max-width: 980px) {
  .hud-tools { top: auto; bottom: 58px; }
}

@media (max-width: 640px) {
  .hud-tools { left: auto; right: 14px; transform: none; bottom: 108px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 28px); }
  .hud-left { min-width: 150px; padding: 8px 10px; }
  .hud-lap .v { font-size: 20px; }
  .speed-v { font-size: 30px; }
  .keys { display: none; }
  .chip.track { max-width: 120px; }
  .dialog { padding: 20px 18px; }
  .menu-head, .menu-foot { padding-left: 14px; padding-right: 14px; }
  .menu-grid { padding: 0 14px; }
  .menu-quick { width: 100%; }
  .cta-primary { flex: 1; justify-content: center; }
  .qchip { flex: 1; }
  .tracks { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .menu-keys { display: none; }
}

/* ---------- Streckeneditor ---------- */

#editor { padding: 12px; background: radial-gradient(120% 90% at 50% 0%, rgba(18, 26, 44, 0.97), rgba(4, 5, 9, 0.98)); z-index: 20; }
.ed-inner { width: 100%; height: 100%; display: flex; flex-direction: column; gap: 12px; }

/* Kopfleiste */
.ed-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.ed-title { display: flex; align-items: center; gap: 10px; }
.ed-logo {
  width: 36px; height: 36px; display: grid; place-items: center; font-size: 18px;
  border-radius: 11px; background: linear-gradient(160deg, rgba(78, 168, 255, 0.35), rgba(29, 111, 208, 0.12));
  border: 1px solid rgba(78, 168, 255, 0.45);
}
.ed-title-txt { display: flex; flex-direction: column; line-height: 1.2; }
.ed-title-txt b { font-size: 16px; letter-spacing: -0.01em; }
.ed-title-txt span { font-size: 11px; color: var(--dim); letter-spacing: .04em; }
.ed-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: 8px; }
.ed-chip {
  display: flex; align-items: baseline; gap: 7px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.ed-chip span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.ed-bar-spacer { flex: 1; }
.ed-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ed-drivegroup {
  display: flex; align-items: center; gap: 4px; padding: 3px;
  border-radius: 12px; background: rgba(9, 11, 17, 0.55); border: 1px solid var(--line);
}
.ed-drivegroup .ed-input { border-color: transparent; background: transparent; width: auto; }
.ed-stat { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--warn); font-size: 12.5px; font-weight: 600; }
.ed-badge {
  font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  border: 1px solid rgba(150, 170, 210, 0.35); background: rgba(14, 18, 28, 0.7); color: #aeb8cc;
}
.ed-badge.ok { color: var(--ok); border-color: rgba(126, 231, 135, 0.5); background: rgba(46, 160, 67, 0.15); }
.ed-badge.warn { color: var(--warn); border-color: rgba(255, 209, 102, 0.45); background: rgba(255, 209, 102, 0.12); }

/* Arbeitsflaeche: Werkzeuge | Zeichenflaeche | Eigenschaften */
.ed-main { flex: 1; display: flex; gap: 12px; min-height: 0; }
.ed-tools, .ed-props { flex: none; display: flex; flex-direction: column; gap: 10px; overflow: auto; padding-right: 2px; }
.ed-tools { width: 224px; }
.ed-tools, .ed-props, .cam3d, .overlay { scrollbar-width: thin; scrollbar-color: rgba(150, 170, 210, 0.28) transparent; }
.ed-tools::-webkit-scrollbar, .ed-props::-webkit-scrollbar { width: 6px; }
.ed-tools::-webkit-scrollbar-thumb, .ed-props::-webkit-scrollbar-thumb { background: rgba(150, 170, 210, 0.28); border-radius: 999px; }
.ed-props { width: 276px; }
.ed-sec {
  display: flex; flex-direction: column; gap: 7px;
  padding: 12px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.ed-sec-title {
  margin: 0 0 2px; font-size: 10.5px; font-weight: 700; color: var(--dim);
  text-transform: uppercase; letter-spacing: .12em;
}
.ed-tools .ed-sec > button, .ed-tools .ed-sec > .tool { width: 100%; justify-content: flex-start; text-align: left; }
.ed-btnrow { display: flex; gap: 6px; }
.ed-btnrow > * { flex: 1; justify-content: center; text-align: center; min-width: 0; }
.ed-sec .tool kbd { margin-left: auto; }

.ed-seg {
  display: flex; flex-direction: column; gap: 3px; padding: 3px;
  border: 1px solid var(--line); border-radius: 11px; background: rgba(9, 11, 17, 0.55);
}
.ed-seg button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  padding: 7px 9px; font-size: 12.5px; color: #cfd8ea;
}
.ed-seg button:hover { background: rgba(255, 255, 255, 0.06); }
.ed-seg button.sel { background: rgba(29, 111, 208, 0.4); border-color: rgba(78, 168, 255, 0.6); color: #fff; }
.ed-seg button kbd { margin-left: auto; font-size: 10px; padding: 0 5px; line-height: 1.5; }

.ed-canvaswrap {
  flex: 1; position: relative; min-width: 0; background: #3e8f3c;
  border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.ed-canvaswrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.ed-canvasfoot {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.ed-canvasfoot > div {
  padding: 6px 11px; border-radius: 10px; font-size: 12px;
  background: rgba(9, 11, 17, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ed-status { color: #dfe6f3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-pos { flex: none; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px !important; }

.ed-colors { display: flex; align-items: center; gap: 6px; }
.ed-swatch {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.4); padding: 0;
  cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.ed-swatch:hover { transform: translateY(-1px); }
.ed-swatch.sel { outline: 2px solid #fff; outline-offset: 2px; }
.ed-color { width: 38px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; margin-left: auto; }

.ed-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ed-row-col { flex-direction: column; align-items: stretch; gap: 5px; }
.ed-row label { color: #cfd8ea; font-size: 12.5px; }
.ed-input {
  background: rgba(6, 8, 13, 0.7); border: 1px solid rgba(150, 170, 210, 0.24); border-radius: 9px;
  color: var(--text); padding: 6px 9px; font: inherit; font-size: 13px; width: 104px;
  transition: border-color .15s, box-shadow .15s;
}
.ed-input:hover { border-color: var(--line-strong); }
.ed-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78, 168, 255, 0.2); }
.ed-input.wide { width: 100%; }
.ed-hint { font-size: 11.5px; color: var(--dim); line-height: 1.55; }
.ed-jump {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid rgba(255, 209, 102, 0.35); background: rgba(255, 209, 102, 0.06);
  border-radius: 10px; padding: 10px;
}
.ed-jump button { margin-top: 4px; }
.ed-warn {
  border: 1px solid rgba(255, 107, 107, 0.55); background: rgba(255, 107, 107, 0.1);
  color: #ffb3b3; border-radius: 10px; padding: 8px 10px;
  font-size: 11.5px; line-height: 1.5; white-space: pre-line;
}
.ed-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--muted); }
.ed-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ed-keys { display: grid; gap: 5px; font-size: 11.5px; color: var(--muted); }
.ed-keys > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ed-keys kbd { font-size: 10px; padding: 1px 6px; }
.ed-file {
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: rgba(20, 25, 37, 0.85); border: 1px solid rgba(150, 170, 210, 0.26);
  border-radius: 10px; color: var(--text); padding: 7px 10px; font-size: 12px;
  transition: background .15s, border-color .15s;
}
.ed-file:hover { background: rgba(38, 49, 70, 0.92); border-color: var(--line-strong); }

@media (max-width: 1100px) {
  .ed-tools { width: 196px; }
  .ed-props { width: 240px; }
  .ed-chips { margin-left: 0; }
}

/* ---------- 3D-Vorschau im Editor ----------
   Das Enhanced-3D-Bild liegt als #game3d im #stage unter dem Editor-Overlay.
   Damit es wahrend der Vorschau sichtbar bleibt, werden Overlay und Zeichenflaeche
   transparent; das 2D-Canvas des Editors wird ausgeblendet. Alles ist an body.r3d
   gekoppelt: ohne WebGL bleibt der normale 2D-Editor einfach erhalten. */
.ed-previewcap { display: none; color: #aeb8cc; font-size: 12px; }
body.edpreview.r3d #editor { background: transparent; }
body.edpreview.r3d .ed-canvaswrap { background: transparent; border-color: transparent; }
body.edpreview.r3d .ed-canvaswrap canvas { display: none; }
body.edpreview.r3d .ed-previewcap {
  display: block; position: absolute; left: 12px; top: 12px; z-index: 5;
  padding: 7px 12px; border-radius: 10px; color: #dfe6f3;
  background: rgba(9, 11, 17, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
body.edpreview #menu { display: none; }
body.edpreview #editor { pointer-events: none; }
body.edpreview .ed-bar, body.edpreview .ed-tools, body.edpreview .ed-props { pointer-events: auto; }

/* ---------- Ausstieg aus der Testfahrt ---------- */
.ed-exittest { display: none; }
body.testdrive .ed-exittest {
  display: inline-flex; position: fixed; right: 18px; bottom: 18px; z-index: 60;
  padding: 10px 16px; border-radius: 12px; font-weight: 600;
  background: linear-gradient(180deg, #2f86e6, #1a62c0); border: 1px solid #5cb0ff;
  color: #f2f8ff; font: inherit; font-size: 13px; cursor: pointer;
  box-shadow: 0 10px 28px rgba(29, 111, 208, 0.4);
}
body.testdrive .ed-exittest:hover { background: linear-gradient(180deg, #3a92f2, #2069cc); }

/* ---------- eigene Strecken in der Streckenauswahl ---------- */
.tcard.custom { border-color: rgba(126, 231, 135, 0.3); }
.tcard.custom:hover { border-color: rgba(126, 231, 135, 0.6); }
.tb.own { background: rgba(126, 231, 135, 0.16); color: var(--ok); }
