/* Planspiel Verkehrsführung – Gelände Patersdorf */
:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #1f1f1f; --muted: #5d6470; --line: #d9dce1;
  --accent: #1f4fb4; --accent-ink: #fff; --ok: #1e8e3e; --warn: #c0392b; --chip: #eef1f5;
  --radius: 10px; --tap: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: "Segoe UI", Arial, Helvetica, sans-serif; font-size: 15px; }
button, input, textarea, select { font: inherit; color: inherit; }
.hint { color: var(--muted); font-weight: normal; font-size: 0.85em; }
.screen { display: none; height: 100%; }
.screen.active { display: block; }

/* ---------- Buttons ---------- */
.btn { min-height: var(--tap); padding: 0 16px; border: 1px solid #c5cad3; background: #fff; border-radius: 8px; cursor: pointer; touch-action: manipulation; }
.btn:hover { background: #f4f6fa; }
.btn:focus-visible, .tool:focus-visible, .chip:focus-visible, .pal:focus-visible, .hv:focus-visible { outline: 3px solid #f2a900; outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #193f91; }
.btn.danger { color: var(--warn); border-color: #e6b3ad; }
.btn.big { min-height: 52px; font-size: 17px; padding: 0 26px; }
.btn.small { min-height: 40px; padding: 0 12px; }
.btn.icon { width: var(--tap); padding: 0; font-size: 20px; }
.btn[disabled] { opacity: 0.45; cursor: default; }

/* ---------- Start ---------- */
#screen-start.active { display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 24px 16px; }
.start-card { background: #fff; max-width: 720px; width: 100%; padding: 28px 32px; border-radius: 14px; box-shadow: 0 2px 16px rgba(0,0,0,.08); }
.kicker { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.start-card h1 { margin: 4px 0 10px; font-size: 28px; }
.lead { line-height: 1.5; margin: 0 0 12px; }
.start-tasks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.start-tasks b { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; background: var(--chip); margin-right: 6px; font-size: 13px; }
.deadline { background: #fff7e0; border: 1px solid #f2d27a; padding: 8px 12px; border-radius: 8px; }
.field { margin: 10px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input { width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid #c5cad3; border-radius: 8px; font-size: 16px; }
.form-error { color: var(--warn); min-height: 1.2em; margin: 6px 0; }
.start-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.privacy { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- Spiel-Layout ---------- */
#screen-game.active { display: grid; grid-template-columns: 270px 1fr 290px; grid-template-rows: 60px 1fr; grid-template-areas: "top top top" "left stage right"; height: 100%; overflow: hidden; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); }
.tb-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tb-user { font-weight: normal; color: var(--muted); margin-left: 6px; }
.progress { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 140px; }
.progress-bar { flex: 1; height: 12px; background: #e5e8ec; border-radius: 6px; overflow: hidden; max-width: 320px; }
#progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2ca02c, #5cc45c); transition: width .4s; }
#progress-text { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-actions { display: flex; gap: 6px; }

.panel { background: #fff; overflow-y: auto; padding: 10px 12px 24px; -webkit-overflow-scrolling: touch; }
.panel.left { grid-area: left; border-right: 1px solid var(--line); }
.panel.right { grid-area: right; border-left: 1px solid var(--line); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 8px; }
.panel h2:first-child { margin-top: 4px; }
.tools { display: grid; gap: 6px; }
.tool { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 6px 10px; border: 1px solid #d3d7de; border-radius: 8px; background: #fff; cursor: pointer; text-align: left; touch-action: manipulation; }
.tool .ti { width: 24px; text-align: center; font-size: 18px; }
.tool.active { background: #e8eefb; border-color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.subopts { display: none; margin: 8px 0 4px; padding: 8px; background: #f7f8fa; border-radius: 8px; }
.subopts.show { display: block; }
.optlabel { font-size: 13px; font-weight: 600; margin: 10px 0 6px; }
.subopts .optlabel { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 10px; border: 1px solid #d3d7de; border-radius: 22px; background: #fff; cursor: pointer; touch-action: manipulation; font-size: 14px; }
.chip.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; font-weight: 600; }
.sw { display: inline-block; width: 18px; height: 14px; border: 1px solid #333; border-radius: 3px; flex: none; }
.sw.line { height: 5px; border: none; }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 14px; }
.check input { width: 22px; height: 22px; }

.palette { display: grid; gap: 6px; }
.pal { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border: 1px dashed #9aa3af; border-radius: 8px; background: #fff; cursor: grab; text-align: left; touch-action: none; user-select: none; }
.pal small { display: block; color: var(--muted); font-size: 12px; }
.pal-sw { width: 28px; height: 28px; border: 1.5px solid #1f1f1f; border-radius: 3px; flex: none; }
.pal.used { opacity: 0.55; }
.hallgrid { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 4px; align-items: center; font-size: 12px; }
.hallgrid .hh { font-weight: 600; text-align: center; color: var(--muted); }
.hallgrid .hr { font-weight: 600; white-space: nowrap; padding-right: 2px; }
.hv { min-height: var(--tap); border: 1px dashed #9aa3af; border-radius: 6px; background: #fbf4e4; cursor: grab; touch-action: none; user-select: none; font-size: 11px; line-height: 1.15; padding: 2px; }
.hv.current { border: 2px solid var(--ink); font-weight: 700; }
.beladegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.beladegrid .hv { background: repeating-linear-gradient(45deg, #fbefe4 0 4px, #e9c9ae 4px 5px); font-size: 12px; }

/* ---------- Plan ---------- */
.stage { grid-area: stage; position: relative; overflow: hidden; background: #e9ecef; touch-action: none; }
#plan { width: 100%; height: 100%; display: block; background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#plan.drawing { cursor: crosshair; }
#plan.panning { cursor: grabbing; }
.vf-piece, .vf-area, .vf-gala, .vf-bel, .vf-route, .vf-note { cursor: pointer; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoom .btn { box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.scalebar { position: absolute; left: 12px; bottom: 12px; background: rgba(255,255,255,.9); padding: 4px 8px; border-radius: 6px; font-size: 12px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
#scalebar-bar { height: 6px; border: 1px solid #1f1f1f; background: linear-gradient(90deg, #1f1f1f 50%, #fff 50%); }
.north { position: absolute; right: 16px; top: 12px; background: rgba(255,255,255,.9); border-radius: 6px; padding: 4px 8px; font-weight: 700; text-align: center; line-height: 1; pointer-events: none; }
.draw-hint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: #1f1f1f; color: #fff; padding: 6px 8px 6px 14px; border-radius: 10px; display: flex; align-items: center; gap: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25); max-width: calc(100% - 120px); }
.draw-hint[hidden] { display: none; }
.draw-hint .btn { color: var(--ink); }
.draw-hint .btn.primary { color: #fff; }
.toast { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); background: rgba(31,31,31,.92); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80%; text-align: center; }
.toast.show { opacity: 1; }

/* ---------- Aufgaben ---------- */
.tasks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.tasks li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; background: #f7f8fa; }
.tasks .tick { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #b8bec8; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; transition: all .3s; }
.tasks li.done { background: #e9f6ec; }
.tasks li.done .tick { background: var(--ok); border-color: var(--ok); }
.tasks li.optional .tick { border-style: dashed; }
.tasks .tl { font-size: 14px; line-height: 1.3; }
.tasks .tl small { display: block; color: var(--muted); font-size: 12px; }
.tasks .tl b { margin-right: 4px; }

/* ---------- Auswahl ---------- */
.sel-panel { background: #f3f6fd; border: 1px solid #c9d6f3; border-radius: 10px; padding: 4px 10px 10px; margin-top: 12px; }
.sel-panel h2 { margin-top: 8px; }
.sel-name { font-weight: 700; }
.sel-dims { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.sel-warn { color: var(--warn); font-size: 13px; margin: 4px 0 6px; font-weight: 600; }
.sel-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.sel-row .btn { flex: 1 1 auto; }
.sel-panel textarea { width: 100%; }

.ta-label { display: block; font-size: 14px; margin: 6px 0 4px; }
textarea { width: 100%; border: 1px solid #c5cad3; border-radius: 8px; padding: 8px; font-size: 15px; resize: vertical; }
.legend { display: grid; gap: 4px; font-size: 13px; }
.legend .lg { display: flex; align-items: center; gap: 8px; }
.legend .lg i { width: 26px; height: 12px; flex: none; display: inline-block; }
.legend .sep { margin-top: 6px; font-weight: 600; color: var(--muted); font-size: 12px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,24,30,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-card h2 { margin: 0 0 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.sum-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.sum-list li { padding: 6px 10px; border-radius: 6px; background: #f7f8fa; }
.sum-list li.ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.sum-list li.miss::before { content: "! "; color: var(--warn); font-weight: 700; }
.warnbox { background: #fff4f2; border: 1px solid #f1c2bb; border-radius: 8px; padding: 8px 12px; margin-top: 10px; }
.thumb-prev { width: 100%; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }

/* ---------- kleinere Bildschirme (Tablet hoch / kleine Laptops) ---------- */
@media (max-width: 1180px) {
  #screen-game.active { grid-template-columns: 240px 1fr 250px; }
  .tb-title { display: none; }
}
@media (max-width: 900px) {
  #screen-game.active { grid-template-columns: 1fr; grid-template-rows: 60px 55vh auto auto; grid-template-areas: "top" "stage" "left" "right"; overflow: auto; height: auto; min-height: 100%; }
  .panel { overflow: visible; }
  .start-tasks { grid-template-columns: 1fr; }
  .tb-actions #btn-help, .tb-actions #btn-new { display: none; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
