:root {
  --bg: #07142a;
  --panel: #0e2347;
  --panel2: #13305e;
  --line: #24467f;
  --text: #f2f5fa;
  --muted: #9fb0cc;
  --yellow: #ffd23f;
  --red: #ff5a5f;
  --green: #5fd068;
  --blue: #3fb6ff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--panel2); font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--yellow); color: #1a1400; }
button.danger { background: var(--red); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
input, select { background: #061026; border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--yellow); outline-offset: 0; }
h1, h2, h3 { margin: 0 0 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Start & Lobby ---------- */
.start { max-width: 460px; margin: 0 auto; padding: 24px 16px 40px; }
.logo { text-align: center; margin: 12px 0 24px; }
.logo .big { font-size: 40px; font-weight: 900; letter-spacing: 2px; }
.logo .big span { color: var(--yellow); }
.logo .sub { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }
.code-big { font: 800 46px/1 var(--mono); letter-spacing: 10px; color: var(--yellow); text-align: center; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plist li:last-child { border: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 14px; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.rules { font-size: 14px; color: var(--muted); }
.rules b { color: var(--text); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 9px 6px; font-size: 13px; background: #061026; border: 1px solid var(--line); }
.seg button.on { background: var(--yellow); color: #1a1400; border-color: var(--yellow); }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- Spiel ---------- */
.game { max-width: 1280px; margin: 0 auto; padding: 8px; display: grid; gap: 8px; grid-template-columns: 1fr; }
.game .col-left, .game .col-right { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; min-width: 0; }
@media (min-width: 980px) {
  .game { grid-template-columns: minmax(380px, 1fr) minmax(0, 1.25fr); align-items: start; padding: 12px; }
}
.topbar { position: sticky; top: 0; z-index: 10; box-shadow: 0 6px 14px rgba(0,0,0,.45); display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.clock { font: 800 26px/1 var(--mono); color: var(--yellow); }
.topbar .goal { flex: 1; min-width: 0; font-size: 13px; line-height: 1.25; }
.topbar .goal b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { width: 46px; height: 46px; position: relative; flex: 0 0 46px; }
.timer svg { transform: rotate(-90deg); }
.timer .num { position: absolute; inset: 0; display: grid; place-items: center; font: 700 15px var(--mono); }
.iconbtn { background: transparent; padding: 6px; font-size: 20px; }

.durchsage { background: linear-gradient(135deg, #102b57, #0b2049); border: 1px solid var(--line); border-left: 5px solid var(--yellow); border-radius: var(--radius); padding: 10px 12px; min-height: 64px; }
.durchsage .head { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--yellow); margin-bottom: 2px; }
.durchsage .txt { font-size: 15px; }
.durchsage.flash { animation: flash .9s ease-out; }
@keyframes flash { from { background: #3d4f12; } }

.mapwrap { background: #050f22; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; }
.mapwrap svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 6px 10px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.legend span i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel > h3 { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); padding: 10px 12px 0; margin: 0; }
.panel .inner { padding: 10px 12px 12px; }

/* Abfahrtstafel */
.board { background: #0a2f6b; border-radius: 10px; overflow: hidden; font-family: var(--mono); }
.board .bh { display: grid; grid-template-columns: 52px 1fr 44px; gap: 6px; padding: 6px 10px; background: #072556; color: #bcd0f5; font-size: 11px; text-transform: uppercase; }
.dep { display: grid; grid-template-columns: 52px 1fr 44px; gap: 6px; padding: 9px 10px; border-top: 1px solid #1c4a92; cursor: pointer; align-items: start; }
.dep:hover { background: #0e3a80; }
.dep.sel { background: #33450a; outline: 2px solid var(--yellow); outline-offset: -2px; }
.dep.later { cursor: default; opacity: .7; }
.dep.later:hover { background: transparent; }
.dep .t { font-weight: 700; }
.dep .d { color: var(--red); font-weight: 700; font-size: 13px; }
.dep .d.ok { color: var(--green); }
.dep .dest { font-family: system-ui, sans-serif; font-weight: 700; font-size: 15px; }
.dep .via { font-family: system-ui, sans-serif; font-size: 12px; color: #bcd0f5; }
.dep .via b { color: var(--yellow); }
.dep .pl { text-align: right; font-weight: 800; font-size: 18px; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 5px; font: 700 12px var(--mono); margin-right: 6px; vertical-align: 1px; color: #000; }
.tag.ICE { background: #fff; }
.tag.BUS { background: #ffd23f; }
.empty { padding: 14px 10px; color: #bcd0f5; font-family: system-ui; font-size: 14px; }

/* Im Zug */
.ride .train { font-size: 18px; font-weight: 800; }
.stops { list-style: none; padding: 0; margin: 10px 0 0; }
.stops li { display: flex; gap: 10px; padding: 5px 0 5px 18px; position: relative; font-size: 14px; }
.stops li::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 3px; background: var(--line); }
.stops li::after { content: ""; position: absolute; left: 0; top: 10px; width: 11px; height: 11px; border-radius: 50%; background: var(--panel); border: 2px solid var(--muted); }
.stops li.goal::after { background: var(--yellow); border-color: var(--yellow); }
.stops li.skip { color: var(--red); text-decoration: line-through; }
.stops .eta { font-family: var(--mono); color: var(--muted); width: 44px; }

/* Karten */
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.gc { background: linear-gradient(160deg, #1b3c73, #112a54); border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; min-height: 110px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.gc.sabotage { background: linear-gradient(160deg, #5a1d2a, #2f1022); border-color: #7d2b3d; }
.gc.taxi { background: linear-gradient(160deg, #5a4a10, #2e260a); border-color: #7d6a1b; }
.gc.sel { outline: 3px solid var(--yellow); }
.gc .ic { font-size: 24px; }
.gc .nm { font-weight: 800; font-size: 13px; line-height: 1.15; }
.gc .ds { font-size: 11px; color: #d2dbea; line-height: 1.25; }
.composer { margin-top: 10px; padding: 10px; background: #061026; border-radius: 10px; border: 1px dashed var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--panel2); font-size: 13px; font-weight: 600; cursor: pointer; border: 2px solid transparent; }
.chip.on { border-color: var(--yellow); }
.reasonwrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.reasonwrap span { white-space: nowrap; font-size: 13px; color: var(--muted); }

/* Aktionsleiste */
.actionbar { position: sticky; bottom: 0; z-index: 5; background: rgba(7, 20, 42, .96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); margin: 0 -8px; }
@media (min-width: 980px) { .actionbar { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); } }
.actionbar .summary { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.actionbar .summary b { color: var(--text); }
.actionbar .btns { display: flex; gap: 8px; }
.actionbar .btns button { flex: 1; }
.sent { text-align: center; color: var(--green); font-weight: 700; }

/* Mitspieler */
.players { display: grid; gap: 4px; }
.pl-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.pl-row .nm { font-weight: 700; }
.pl-row .st { color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-row .rd { font-size: 12px; }

/* Log */
.log { max-height: 320px; overflow-y: auto; font-size: 13px; }
.log div { padding: 5px 0; border-bottom: 1px solid #142c55; }
.log .c { font-family: var(--mono); color: var(--yellow); margin-right: 6px; }
.log .k-sab { color: #ffb3b5; }
.log .k-good { color: #b7f5bd; }
.log .k-me { color: var(--blue); font-weight: 600; }
.log .k-block { color: #ffd9a0; }

/* Ende */
.result { max-width: 760px; margin: 0 auto; padding: 16px; }
.rank { width: 100%; border-collapse: collapse; font-size: 14px; }
.rank th, .rank td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.rank td.n { text-align: right; font-family: var(--mono); }
.rank tr.first td { color: var(--yellow); font-weight: 800; }
.hist div { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #2a1220; border: 1px solid var(--red); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; font-size: 14px; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; font-size: 12px; padding: 3px; z-index: 60; }

@keyframes pulse { 0% { r: 9; opacity: .9; } 100% { r: 22; opacity: 0; } }
.pulse { animation: pulse 1.6s infinite; }

.ptok { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 2px solid #fff; font-weight: 900; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.ptok.me { border-color: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }
.tok .pulse { transform-origin: center; transform-box: fill-box; }
@keyframes tokpulse { 0% { stroke-opacity: .9; stroke-width: 4; } 100% { stroke-opacity: 0; stroke-width: 18; } }
.tok .pulse { animation: tokpulse 1.6s infinite; }

/* Aktionen oben */
.panel > h3 .h-note { float: right; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--muted); }
.acts { display: grid; gap: 8px; }
.act { display: block; width: 100%; text-align: left; padding: 12px 14px; background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 16px; line-height: 1.3; }
.act:hover { border-color: var(--yellow); }
.act small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); margin-top: 3px; }
.act.home { background: #2b3a0e; border-color: var(--yellow); }
.act.home small { color: #e6eab8; }
.act.pending { opacity: .6; pointer-events: none; }
.act.chosen { background: #12391f; border-color: var(--green); cursor: default; }
.act.chosen .lbl { color: var(--green); }
.linkbtn { background: none; padding: 8px 2px 0; color: var(--muted); text-decoration: underline; font-weight: 500; font-size: 13px; }
.red { color: var(--red); font-weight: 700; }
.alert { background: #3d2a05; border: 1px solid var(--yellow); color: #ffe9a8; border-radius: 10px; padding: 9px 12px; font-size: 14px; font-weight: 600; }
.alert + .alert { margin-top: 6px; }
#alerts:empty { display: none; }
.queued { background: #12391f; border: 1px solid var(--green); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 14px; }
.queued .linkbtn { padding-top: 4px; }
.gc.played { outline: 3px solid var(--green); }
.targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 6px; }
.target { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; padding: 8px 10px; background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; }
.target:hover { border-color: var(--red); }
.target .ptok { grid-row: span 2; }
.target small { color: var(--muted); font-weight: 500; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Heimweg-Rennen */
.race { display: grid; gap: 10px; }
.race-row { display: flex; align-items: center; gap: 10px; }
.race-row.me .nm { color: var(--yellow); }
.race-main { flex: 1; min-width: 0; }
.race-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.race-top .nm { font-weight: 800; }
.race-right { color: var(--muted); font-size: 12px; font-family: var(--mono); white-space: nowrap; }
.race-bar { height: 10px; background: #061026; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin: 4px 0 3px; }
.race-bar i { display: block; height: 100%; border-radius: 6px; transition: width 1.2s cubic-bezier(.2,.8,.2,1); }
.race-st { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remain { font-weight: 700; color: var(--yellow); }

/* Mini-Karte */
.minimap { position: relative; background: #050f22; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.minimap > svg { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; }
.minimap.all > svg { aspect-ratio: 1500 / 1020; }
.minimap .legend { display: none; }
.minimap.all .legend { display: flex; }
.mapmode { position: absolute; top: 8px; right: 8px; padding: 6px 10px; font-size: 12px; border-radius: 8px; background: rgba(14, 35, 71, .9); border: 1px solid var(--line); }

/* Rundenbericht */
.rep { display: grid; gap: 5px; }
.rep-ev { border-left: 4px solid var(--line); background: #0a1d3d; padding: 6px 10px; border-radius: 0 8px 8px 0; font-size: 14px; line-height: 1.35; }
.rep-ev.k-delay, .rep-ev.k-block { border-left-color: var(--yellow); }
.rep-ev.k-sab { border-left-color: var(--red); background: #2c1020; }
.rep-ev.k-good { border-left-color: var(--green); background: #10301c; }
.rep-ev.mine { border-left-color: var(--blue); background: #0d2f52; font-weight: 700; }
.rep-more { font-size: 12px; color: var(--muted); }
.report.fresh { animation: repFresh 1.6s ease-out; }
@keyframes repFresh { from { box-shadow: 0 0 0 3px var(--yellow); } to { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .report.fresh { animation: none; } }

/* ===================== Bahnhofs-Optik ===================== */
:root {
  /* Schmale Schilderschrift aus Systemschriften – kein Nachladen, kein externer Dienst */
  --cond: "Avenir Next Condensed", "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", "Helvetica Neue", system-ui, sans-serif;
}
.ic { display: inline-block; vertical-align: -0.2em; flex: 0 0 auto; }
.ic.gold { color: var(--yellow); }
.ic.green { color: var(--green); }
.ic.red { color: var(--red); }
.ic.muted { color: var(--muted); }

/* Panel-Überschriften als Schild */
.panel > h3 { font-family: var(--cond); font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #fff; background: #0a2f6b; margin: 0; padding: 7px 12px; border-bottom: 2px solid var(--yellow); }
.panel > h3 .h-note { color: #bcd0f5; font-family: system-ui, sans-serif; font-size: 12px; font-weight: 600; }
.act .lbl, .race-top .nm, .target span, .gc .nm, .tabbar span { font-family: var(--cond); }
.act .lbl { display: flex; align-items: center; gap: 8px; font-size: 18px; letter-spacing: .2px; }
.act .lbl .tag { margin-right: 2px; }

/* Fallblatt-Uhr */
.clock { display: flex; align-items: center; gap: 2px; perspective: 200px; }
.clock .flap { display: inline-block; min-width: .72em; text-align: center; background: #10151f; color: var(--yellow); border-radius: 4px; padding: 2px 1px; position: relative; box-shadow: inset 0 -1px 0 rgba(255,255,255,.06); font: 800 24px/1.1 var(--mono); }
.clock .flap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,.65); }
.clock .colon { color: var(--yellow); font: 800 22px var(--mono); margin: 0 1px; }
.clock .flap.flip { animation: flapDown .45s ease-out; transform-origin: 50% 50%; }
@keyframes flapDown { 0% { transform: rotateX(-90deg); } 60% { transform: rotateX(12deg); } 100% { transform: rotateX(0); } }
@media (prefers-reduced-motion: reduce) { .clock .flap.flip { animation: none; } }

/* Kompakte Kartenhand */
.hand { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; grid-template-columns: none; }
.gc { flex: 0 0 92px; min-height: 0; height: 96px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; border-radius: 10px; color: #fff; }
.gc .nm { font-size: 14px; font-weight: 700; line-height: 1.1; }
.gc.sel { outline: 3px solid var(--yellow); transform: translateY(-3px); }
.gc.played { outline: 3px solid var(--green); }
.cdesc { font-size: 14px; margin-bottom: 8px; }
.playbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Kartenmodus-Knopf */
.mapmode { display: flex; align-items: center; gap: 6px; }

/* Reiter: nur auf dem Handy */
.tabbar { display: none; }
@media (max-width: 979px) {
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(7, 20, 42, .97); border-top: 2px solid var(--yellow); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar button { flex: 1; background: none; border-radius: 10px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); position: relative; font-size: 13px; }
  .tabbar button.on { color: var(--yellow); background: #0e2347; }
  .tabbar .dot { display: none; position: absolute; top: 4px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }
  .tabbar button.news .dot { display: block; }
  .game { padding-bottom: 84px; }
  .game[data-tab="play"] [data-tab]:not([data-tab="play"]),
  .game[data-tab="lage"] [data-tab]:not([data-tab="lage"]),
  .game[data-tab="log"] [data-tab]:not([data-tab="log"]) { display: none !important; }
  .game[data-tab="log"] .log { max-height: none; }
}
.tag { white-space: nowrap; }

/* Endbildschirm */
.result { display: grid; gap: 12px; }
.end-hero { text-align: center; padding: 18px 12px 8px; }
.end-hero .ic { color: var(--yellow); }
.end-hero.home .ic { color: var(--green); }
.end-hero.hotel .ic { color: var(--muted); }
.end-title { font-family: var(--cond); font-size: 46px; font-weight: 800; letter-spacing: 2px; line-height: 1.05; margin-top: 6px; color: var(--yellow); }
.end-hero.home .end-title { color: var(--green); }
.end-hero.hotel .end-title { color: #fff; }
.end-sub { font-size: 17px; margin-top: 6px; }
.end-note { color: var(--muted); font-size: 13px; margin-top: 4px; }
.rank tr.mine td { background: rgba(255, 210, 63, .07); }
.rank .name-cell { display: inline-flex; align-items: center; gap: 8px; }
.rank .pts { font-size: 11px; white-space: nowrap; }

/* Störungsprognose */
.warnline { display: block; color: #ffb35c; font-weight: 700; margin-top: 3px; }
.rep-ev.k-plan, .reso-ev.k-plan { border-left-color: #ff9f1c; background: #2a1d08; }
.log .k-plan { color: #ffcf8f; }
.rep-sub { font-family: var(--cond); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: #ff9f1c; margin-top: 6px; }
