:root {
    --bg: #101318;
    --panel: rgba(21, 25, 32, 0.96);
    --panel-2: #202633;
    --text: #f5f7fb;
    --muted: #aab2c3;
    --accent: #6ea8fe;
    --danger: #ff5c5c;
    --ok: #41d17d;
    --border: #333b4d;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { border: 0; border-radius: 12px; padding: 0.78rem 1rem; color: #071018; background: var(--accent); font-weight: 700; cursor: pointer; }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); color: #160000; }
button.green { background: var(--ok); color: #001407; }
button.red { background: var(--danger); color: #160000; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.active-choice { outline: 3px solid white; }

.topbar { position: relative; z-index: 30; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.45rem 1rem; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar button { padding-block: 0.6rem; }
main { position: relative; z-index: 1; isolation: isolate; height: calc(100% - 56px); display: grid; grid-template-columns: 1fr 390px; min-height: 0; }
#map { width: 100%; height: 100%; min-height: 320px; position: relative; z-index: 0; overflow: hidden; }
.panel { overflow: auto; background: var(--panel); border-left: 1px solid var(--border); padding: 1rem; position: relative; z-index: 20; }
.sheet-handle { display: none; }
.tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.tab { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.tab.active { color: var(--text); border-color: var(--accent); }
.tab-page { display: none; }
.tab-page.active { display: block; }
label { display: grid; gap: 0.35rem; margin: 0 0 0.9rem; color: var(--muted); font-size: 0.9rem; }
input, select { width: 100%; border: 1px solid var(--border); background: #0d1118; color: var(--text); border-radius: 12px; padding: 0.75rem; }
.actions { display: grid; gap: 0.55rem; margin-top: 0.9rem; }
.hint { margin-top: 0.9rem; color: var(--muted); line-height: 1.4; font-size: 0.88rem; }
.point-list, .question-list { display: grid; gap: 0.7rem; }
.point-card, .question-card { border: 1px solid var(--border); background: rgba(255,255,255,0.03); border-radius: 16px; padding: 0.85rem; }
.point-card { cursor: pointer; }
.point-card.active-point { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110,168,254,0.22) inset; }
.point-card header, .question-card header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.7rem; }
.point-card h3, .question-card h3 { font-size: 0.98rem; margin: 0; }
.meta { color: var(--muted); font-size: 0.82rem; word-break: break-word; }
.point-actions, .answer-actions, .card-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem; margin-top: 0.6rem; }
.point-actions button, .answer-actions button, .card-actions button { min-width: 0; }
.card-actions.three { grid-template-columns: 1fr 1fr 1fr; }
/* Lokaler Leaflet-CSS-Fallback: wichtig, falls das externe leaflet.css nicht
   oder zu spät geladen wird. Ohne diese Regeln werden Kartenkacheln im normalen
   Dokumentfluss angezeigt; dann entstehen versetzte, fehlende Tile-Blöcke. */
.leaflet-container {
    overflow: hidden;
    position: relative;
    outline-offset: 1px;
    background: #1c2530;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
    position: absolute;
    left: 0;
    top: 0;
}
.leaflet-tile {
    width: 256px;
    height: 256px;
    max-width: none !important;
    max-height: none !important;
    border: 0;
    user-select: none;
    -webkit-user-drag: none;
}
.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }
.leaflet-marker-icon,
.leaflet-marker-shadow { display: block; }
.leaflet-container .leaflet-overlay-pane svg { max-width: none !important; max-height: none !important; }
.leaflet-map-pane { z-index: 0; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-interactive { cursor: pointer; }
.distance-label { background: rgba(0,0,0,0.75); color: white; border: 0; border-radius: 999px; padding: 0.25rem 0.5rem; }
.start-zone-label { color: white; background: rgba(0,0,0,0.55); border: 0; border-radius: 999px; padding: 0.25rem 0.5rem; }


@media (max-width: 850px) {
    .topbar { height: 56px; min-height: 56px; align-items: center; }
    main { height: calc(100% - 56px); display: block; overflow: hidden; }
    #map { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
    .panel {
        --sheet-height: 54px;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 25;
        height: var(--sheet-height);
        max-height: calc(100% - 8px);
        overflow-y: hidden;
        overscroll-behavior: contain;
        border-left: 0;
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
        padding-top: 3.25rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        box-shadow: 0 -12px 28px rgba(0,0,0,0.32);
        touch-action: pan-y;
        transition: height 180ms ease-out;
    }
    .sheet-handle {
        position: sticky;
        top: -3.25rem;
        display: flex;
        align-items: center;
        justify-content: center;
        width: calc(100% + 2rem);
        height: 52px;
        margin: -3.25rem -1rem 0;
        cursor: ns-resize;
        touch-action: none;
        z-index: 2;
    }
    .sheet-handle span {
        width: 54px;
        height: 5px;
        border-radius: 999px;
        background: rgba(255,255,255,0.35);
    }
    .panel.expanded { overflow-y: auto; }
    .panel.dragging { user-select: none; overflow: hidden; touch-action: none; transition: none; }
    button { padding: 0.78rem 0.75rem; }
}
.question-card.active-question {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(110,168,254,0.22) inset;
}
.card-actions.two { grid-template-columns: 1fr 1fr; }
.point-actions .danger { grid-column: 1 / -1; }
.full-width { width: 100%; }

.reset-game-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
