* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* sonst gewinnt .overlay{display:flex} gegen das hidden-Attribut */
html, body { margin: 0; height: 100%; background: #07090c; color: #e8eef5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; }

/* Rahmen: Anzeigetafel links neben der Strecke (breites Fenster) oder als Leiste darüber (schmales Fenster).
   Welche Variante mehr Platz für die Strecke lässt, entscheidet game.js (Klasse „seite“ / „oben“ am <body>). */
#rahmen { display: flex; align-items: stretch; }
body.oben #rahmen { flex-direction: column; }
#buehne { position: relative; flex: 0 0 auto; overflow: hidden; background: #1c2a1a; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- Anzeigetafel (schwarzer Kasten wie beim Vorbild) ---------- */
#tafel { background: #0a0d11; border: 1px solid #232b35; font-family: "DejaVu Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  display: flex; flex-direction: column; gap: 6px; padding: 14px 14px 12px; width: 250px; flex: 0 0 auto; overflow: hidden; }
.logo { font-family: system-ui, sans-serif; font-weight: 900; font-style: italic; font-size: 19px; letter-spacing: .5px; color: #fff;
  border-bottom: 3px solid #d42a2a; padding-bottom: 7px; white-space: nowrap; }
.logo b { color: #ffd23c; }
.strecke { color: #9fb0c3; font-size: 12.5px; white-space: nowrap; }
.hname { color: #5ab0ff; font-weight: 800; font-size: 17px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gross { display: flex; gap: 8px; margin: 2px 0 6px; }
.gross > div { flex: 1; background: #141a22; border: 1px solid #232b35; border-radius: 8px; padding: 6px 8px; text-align: center; }
.gross span { display: block; font-size: 10.5px; color: #8796a8; text-transform: uppercase; letter-spacing: .8px; }
.gross b { font-size: 25px; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hrow { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: #9fb0c3; line-height: 1.55; white-space: nowrap; }
.hrow b { color: #fff; font-variant-numeric: tabular-nums; }
.rang { list-style: none; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid #232b35; font-family: system-ui, sans-serif; font-size: 13px; flex: 1 1 auto; overflow: hidden; }
.rang li { display: flex; align-items: center; gap: 7px; padding: 2.5px 4px; border-radius: 5px; color: #c7d0da; white-space: nowrap; }
.rang li.ich { background: #1b2735; color: #fff; font-weight: 700; }
.rang .p { width: 18px; text-align: right; color: #8796a8; font-variant-numeric: tabular-nums; }
.rang .f { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.3); }
.rang .z { margin-left: auto; color: #8796a8; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.hilfe { font-family: system-ui, sans-serif; font-size: 11.5px; color: #6f7e90; line-height: 1.6; border-top: 1px solid #232b35; padding-top: 8px; }
.hilfe b { color: #aebccc; }

body.oben #tafel { flex-direction: row; align-items: center; gap: 18px; width: auto; height: 64px; padding: 6px 14px; }
body.oben .logo { border-bottom: 0; border-right: 3px solid #d42a2a; padding: 0 14px 0 0; font-size: 16px; }
body.oben .strecke, body.oben .rang, body.oben .hilfe { display: none; }
body.oben .hname { margin: 0; max-width: 130px; font-size: 15px; }
body.oben .gross { margin: 0; }
body.oben .gross > div { padding: 2px 10px; }
body.oben .gross b { font-size: 19px; }
body.oben .hrow { flex-direction: column; gap: 0; font-size: 11px; line-height: 1.3; }
body.oben .hrow b { font-size: 14px; }

/* ---------- Dialoge über der Strecke ---------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 10, 14, .46); }
.box { background: rgba(16, 22, 30, .96); border: 1px solid #2b3747; border-radius: 16px; padding: 22px 26px;
  width: min(440px, 94%); max-height: 96%; overflow: auto; text-align: center; box-shadow: 0 18px 60px rgba(0, 0, 0, .6); }
.box.breit { width: min(700px, 96%); }
h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: .5px; }
h2 { margin: 0 0 12px; font-size: 21px; }
.sub { color: #93a1b3; font-size: 14px; margin: 6px 0 14px; line-height: 1.5; }
label { display: block; text-align: left; font-size: 13px; color: #93a1b3; margin: 14px 0; }
input { display: block; width: 100%; margin-top: 6px; padding: 11px 13px; font-size: 16px;
  background: #0e141c; border: 1px solid #2b3747; border-radius: 10px; color: #e8eef5; }
.btn { cursor: pointer; border: 0; border-radius: 11px; background: #d42a2a; color: #fff; font-size: 15px; font-weight: 700; padding: 10px 18px; }
.btn:hover { background: #ea3a3a; }
.btn.gross { width: 100%; padding: 13px; font-size: 17px; margin-top: 8px; }

.liste { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; max-height: 190px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 8px; }
.liste.ergebnis { grid-template-columns: 1fr; }
.liste li { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 9px; background: #0e141c; font-size: 14px; white-space: nowrap; overflow: hidden; }
.liste li.ich { outline: 1px solid #5ab0ff; }
.liste .punkt { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.3); }
.liste .pl { width: 22px; color: #ffd23c; font-weight: 800; font-variant-numeric: tabular-nums; }
.liste .zt { margin-left: auto; color: #93a1b3; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.liste .wirt { font-size: 11px; color: #f0b429; }

.trackctl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 12px; }
.trackbtn { padding: 0 0 6px; border-radius: 10px; border: 2px solid #2b3747; background: #0e141c; color: #c7d0da; font-size: 12.5px; cursor: pointer; overflow: hidden; }
.trackbtn canvas { width: 100%; height: auto; display: block; margin-bottom: 5px; }
.trackbtn .wuerfel { display: flex; align-items: center; justify-content: center; aspect-ratio: 1024 / 720; font-size: 34px; margin-bottom: 5px; background: #18212c; }
.trackbtn:hover { border-color: #51627a; }
.trackbtn.an { border-color: #ffd23c; color: #fff; font-weight: 700; }
.trackctl.gast .trackbtn { cursor: default; opacity: .75; }
.trackctl.gast .trackbtn.an { opacity: 1; }
.botctl { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 4px 0 10px; font-size: 14px; color: #c7d0da; }
.botctl b { min-width: 20px; text-align: center; font-size: 17px; color: #fff; }
.botbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid #2b3747; background: #0e141c; color: #fff; font-size: 20px; cursor: pointer; line-height: 1; }
.botbtn:hover { background: #1b2430; }

#boosthint { position: absolute; top: 3%; left: 50%; transform: translateX(-50%); pointer-events: none;
  color: #ffd54a; font-weight: 900; font-size: 28px; font-style: italic; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
#toast { position: absolute; top: 12%; left: 50%; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  background: rgba(10, 13, 17, .88); border: 1px solid #3a4756; border-radius: 10px; padding: 9px 18px; font-size: 17px; font-weight: 700; }
.cd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-size: 170px; font-weight: 900; font-style: italic; color: #fff; text-shadow: 0 6px 0 #d42a2a, 0 10px 34px rgba(0,0,0,.8); }
