@font-face {
    font-family: "Grundschrift";
    src: url("fonts/Grundschrift-Regular.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: rgb(232, 238, 243);
    --panel: #ffffff;
    --ink: #1f252b;
    --muted: #6f7880;
    --hairline: rgba(21, 31, 40, 0.14);
    --nav: rgb(86, 110, 141);
    --shadow: 0 10px 28px rgba(31, 37, 43, 0.08);
    --radius: 10px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --band-rot: #b9494a;
    --band-blau: #1a4766;
    --band-gruen: #3f8b81;
    --band-orange: #f2805b;
    --band-gelb: #d9a915;
    --band-lila: #7e5a9b;
    --nagel: #7d868e;
    --nagel-rand: #5d666e;
    --spiegel: #e0218a;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.settings-dialog,
.settings-dialog * {
    -webkit-user-select: auto;
    user-select: auto;
}

button,
select,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.app-shell {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ------------------------------------------------------------- Topbar */

.topbar {
    height: 54px;
    flex: 0 0 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px max(14px, env(safe-area-inset-right)) 6px max(14px, env(safe-area-inset-left));
    background: var(--panel);
    border-bottom: 1px solid var(--hairline);
}

.topbar h1 {
    margin: 0;
    font-size: clamp(18px, 2.2vw, 23px);
    font-weight: 650;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--nav);
    border-radius: 8px;
    cursor: pointer;
}

.icon-button svg,
.board-menu svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.1;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-button:hover {
    background: rgba(86, 110, 141, 0.09);
}

.icon-button:disabled {
    opacity: 0.35;
    cursor: default;
    background: transparent;
}

.board-menu {
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px 0 10px;
    color: var(--ink);
    background: rgba(86, 110, 141, 0.08);
    border-radius: 8px;
    cursor: pointer;
}

.board-menu select {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    outline: 0;
    cursor: pointer;
    font-weight: 600;
}

.board-menu svg {
    width: 17px;
    height: 17px;
    color: var(--nav);
}

/* ------------------------------------------------------------- Workspace */

.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: clamp(8px, 1.4vw, 14px);
    padding: clamp(10px, 2vw, 20px);
    padding-bottom: calc(clamp(10px, 2vw, 20px) + var(--safe-bottom));
}

/* ------------------------------------------------------------- Band-Vorrat */

.band-tray {
    flex: 0 0 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 8px;
}

.tray-band {
    width: 52px;
    height: 52px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
    border-radius: 50%;
}

.tray-band svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tray-band:active {
    cursor: grabbing;
}

/* ------------------------------------------------------------- Bühne */

.stage-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.2vw, 12px);
}

/* ------------------------------------------------------------- Forscherkarte */

.forscher-karte {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 14px 12px;
    border-left: 5px solid var(--nav);
}

.forscher-karte-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.forscher-karte-titel {
    font-weight: 700;
    font-size: 16px;
}

.forscher-karte-titel .klasse-chip {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    font-weight: 650;
    color: var(--nav);
    background: rgba(86, 110, 141, 0.12);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: 1px;
}

.forscher-karte-text {
    font-size: 15px;
    line-height: 1.4;
    margin-top: 2px;
}

.forscher-karte-sammlung {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.merken-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 0;
    background: var(--nav);
    color: #fff;
    font-weight: 650;
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
    flex: 0 0 auto;
}

.merken-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linejoin: round;
}

.merken-button:hover {
    filter: brightness(1.08);
}

.sammlung-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}

.sammlung-strip svg {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    background: var(--bg);
    border-radius: 8px;
}

.sammlung-zaehler {
    font-size: 14px;
    font-weight: 650;
    color: var(--muted);
    white-space: nowrap;
}

.forscher-dialog {
    width: min(520px, calc(100vw - 40px));
}

.forscher-liste {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.forscher-liste button {
    text-align: left;
    border: 1px solid var(--hairline);
    background: var(--panel);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
}

.forscher-liste button:hover {
    background: rgba(86, 110, 141, 0.06);
}

.forscher-liste .karten-titel {
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.forscher-liste .klasse-chip {
    font-size: 12px;
    font-weight: 650;
    color: var(--nav);
    background: rgba(86, 110, 141, 0.12);
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

.forscher-liste .karten-text {
    font-size: 13.5px;
    color: var(--muted);
    margin-top: 3px;
    line-height: 1.35;
}

/* ------------------------------------------------------------- Klapp-Knopf */

.klapp-button {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: var(--spiegel);
    color: #fff;
    font-weight: 650;
    font-size: 15px;
    border-radius: 999px;
    padding: 10px 18px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(224, 33, 138, 0.3);
}

.klapp-button svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.klapp-button:hover {
    filter: brightness(1.07);
}

/* ------------------------------------------------------------- Vorhang */

.vorhang-button {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--hairline);
    background: var(--panel);
    color: var(--nav);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(31, 37, 43, 0.12);
    cursor: pointer;
}

.vorhang-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.vorhang {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.05) 0 26px,
            rgba(0, 0, 0, 0.07) 26px 52px
        ),
        var(--nav);
    border-radius: var(--radius);
}

.vorhang-inhalt {
    text-align: center;
    color: #fff;
}

.vorhang-text {
    font-family: "Grundschrift", sans-serif;
    font-size: clamp(20px, 3vw, 28px);
    margin-bottom: 22px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

#vorhangAufdecken {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 0;
    background: #fff;
    color: var(--nav);
    font-weight: 700;
    font-size: 17px;
    border-radius: 999px;
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

#vorhangAufdecken svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.settings-select-row {
    justify-content: space-between;
}

.settings-select-row select {
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 4px 8px;
    background: var(--panel);
    color: var(--ink);
}

.board-stage {
    position: relative;
    flex: 1;
    min-width: 0;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

#boardSvg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.stage-hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    background: rgba(31, 37, 43, 0.78);
    color: #fff;
    font-size: 15px;
    line-height: 1.35;
    text-align: center;
    padding: 9px 16px;
    border-radius: 10px;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s ease;
    max-width: min(86%, 420px);
}

.stage-hint.hidden {
    opacity: 0;
}

/* ------------------------------------------------------------- Band-Werkzeuge */

.band-toolbar {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(31, 37, 43, 0.16);
    padding: 5px;
}

.band-toolbar button {
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--nav);
    border-radius: 9px;
    cursor: pointer;
}

.band-toolbar button:hover {
    background: rgba(86, 110, 141, 0.09);
}

.band-toolbar svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.figur-info {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--hairline);
    box-shadow: 0 6px 22px rgba(31, 37, 43, 0.16);
    border-radius: 12px;
    padding: 10px 18px;
    font-family: "Grundschrift", sans-serif;
    font-size: 22px;
    text-align: center;
    pointer-events: none;
    max-width: 86%;
}

.figur-info .attribute {
    font-size: 16px;
    color: var(--muted);
}

.zoom-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zoom-controls button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--hairline);
    background: var(--panel);
    color: var(--nav);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(31, 37, 43, 0.12);
    cursor: pointer;
}

.zoom-controls svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* ------------------------------------------------------------- SVG-Inhalte */

.nagel {
    fill: var(--nagel);
    stroke: var(--nagel-rand);
}

.gitterlinie {
    stroke: rgba(21, 31, 40, 0.06);
    fill: none;
}

.kreislinie {
    stroke: rgba(21, 31, 40, 0.14);
    fill: none;
}

.koordinaten-label {
    font-family: "Grundschrift", sans-serif;
    fill: var(--muted);
    text-anchor: middle;
    user-select: none;
    pointer-events: none;
}

.band-flaeche {
    stroke: none;
}

.band-linie {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.band-treffer {
    fill: none;
    stroke: transparent;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.spiegel-band {
    opacity: 0.45;
    pointer-events: none;
}

.spiegel-achse {
    stroke: var(--spiegel);
    stroke-dasharray: 0.16 0.14;
    fill: none;
    pointer-events: none;
}

.spiegel-griff {
    fill: #fff;
    stroke: var(--spiegel);
    cursor: grab;
}

.mass-label {
    font-family: "Grundschrift", sans-serif;
    fill: var(--ink);
    text-anchor: middle;
    user-select: none;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.85);
    stroke-linejoin: round;
}

.winkel-marke {
    fill: none;
    stroke: var(--ink);
    opacity: 0.55;
    pointer-events: none;
}

.zell-label {
    font-family: "Grundschrift", sans-serif;
    text-anchor: middle;
    user-select: none;
    pointer-events: none;
}

/* ------------------------------------------------------------- Settings-Dialog */

.settings-dialog {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(31, 37, 43, 0.28);
    padding: 20px 24px 24px;
    width: min(440px, calc(100vw - 40px));
    max-height: min(80dvh, 640px);
    overflow-y: auto;
    color: var(--ink);
}

.settings-dialog::backdrop {
    background: rgba(31, 37, 43, 0.35);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.dialog-header h2 {
    margin: 0;
    font-size: 19px;
}

.settings-group {
    margin-top: 22px;
}

.settings-group-label {
    font-size: 13px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 8px;
}

.settings-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
}

.settings-group input[type="checkbox"] {
    width: 19px;
    height: 19px;
    accent-color: var(--nav);
}

.text-button {
    border: 1px solid var(--hairline);
    background: transparent;
    color: var(--nav);
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
}

.text-button:hover {
    background: rgba(86, 110, 141, 0.09);
}

/* ------------------------------------------------------------- Archiv-Sheet */

.archiv-sheet {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: rgba(31, 37, 43, 0.35);
    padding: 14px;
}

/* ------------------------------------------------------------- Hochformat */

@media (orientation: portrait) {
    .workspace {
        flex-direction: column;
    }

    .band-tray {
        flex: 0 0 76px;
        flex-direction: row;
        order: 2;
        padding: 8px 12px;
    }
}

/* Schmale Screens (iPhone): Topbar kompakt, damit alle Knöpfe Platz haben. */
@media (max-width: 560px) {
    .topbar h1 {
        display: none;
    }

    .topbar {
        justify-content: center;
    }

    .topbar-actions {
        gap: 3px;
    }

    .board-menu {
        padding: 0 6px 0 8px;
    }
}
