/* Mindreader – Gestaltung wie die Steuer-App von MagicWeb */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --bg: #111214;
    --box: #1d1f23;
    --line: #2e3138;
    --text: #e9eaec;
    --muted: #8c9099;
    --accent: #ff9f0a;
    --red: #ff5a5f;
    --ok: #30d158;
    --warn: #ffd60a;
}

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

a { color: var(--accent); }
h1, h2 { margin: 0 0 .6em; }
h2 { font-size: 1.1em; margin-top: 1.2em; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 .8em; }
code { background: #000; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .85em; }
.label { color: var(--muted); font-size: .8em; text-transform: uppercase; letter-spacing: .06em; margin: 4px 0 8px; }

/* Navigation */
.top {
    position: sticky; top: 0; z-index: 5;
    background: rgba(17, 18, 20, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top);
}
nav { display: flex; max-width: 760px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { display: none; }
nav a {
    flex: 1; text-align: center; padding: 14px 4px;
    color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95em;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
nav a.active { color: var(--text); border-bottom-color: var(--accent); }
@media (max-width: 560px) {
    nav a { flex: 1 0 auto; padding: 14px 11px; font-size: .9em; }
}

/* Ansichten umschalten */
.panel { display: none; max-width: 760px; margin: 0 auto; padding: 12px; }
body.view-trick #panel-trick,
body.view-lage #panel-lage,
body.view-spick #panel-spick,
body.view-settings #panel-settings,
body.view-users #panel-users { display: block; }

.box { background: var(--box); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }

.flash { max-width: 736px; margin: 12px auto 0; padding: 10px 14px; border-radius: 10px; }
.flash.ok { background: #183a24; color: #8ee6a8; }
.error { background: #3a1818; color: #ffaaaa; padding: 10px 14px; border-radius: 10px; margin: 12px 0 0; }

/* Formulare */
input[type=text], input[type=password], input[type=number], input[type=email], textarea, select {
    width: 100%; margin-top: 4px;
    background: #0c0d0f; color: var(--text);
    border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; font: inherit;
}
input[type=color] { width: 100%; height: 42px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: #0c0d0f; padding: 3px; }
.form label { display: block; margin-bottom: 12px; font-size: .92em; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

button, .button {
    display: inline-block; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--accent); color: #000; font: inherit; font-weight: 600;
    padding: 10px 16px; text-decoration: none; text-align: center;
}
button.ghost, .button.ghost { background: #2a2d33; color: var(--text); }
button.danger { color: var(--red); }
.btn-big { display: block; width: 100%; padding: 15px 16px; font-size: 1.1em; border-radius: 12px; }

/* Login */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth .box { width: 100%; max-width: 360px; }
.auth input { margin-bottom: 10px; }
.auth button { width: 100%; }
.auth-logo { text-align: center; margin-bottom: 8px; }
.auth-logo img { border-radius: 14px; }
.auth h1 { text-align: center; }

/* Badges / Benutzerverwaltung */
details.user { border-top: 1px solid var(--line); padding: 10px 0; }
details.user:first-of-type { border-top: 0; }
details.user summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; list-style: none; }
details.user summary::-webkit-details-marker { display: none; }
details.user summary small { flex-basis: 100%; }
details.user form { margin-top: 12px; }
.badge { font-size: .72em; padding: 2px 8px; border-radius: 999px; background: #2a2d33; color: var(--muted); }
.badge.admin { background: rgba(255, 159, 10, .18); color: var(--accent); }

/* Theme-Auswahl (wie MagicWeb) */
.themes { display: grid; gap: 8px; margin-bottom: 14px; }
.theme-opt { display: flex; align-items: center; gap: 10px; background: #0c0d0f; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 8px 8px; }
.theme-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.form .theme-opt label { flex: 1; display: flex; align-items: center; gap: 12px; margin: 0; cursor: pointer; min-width: 0; }
.theme-opt input { position: absolute; opacity: 0; pointer-events: none; }
.theme-opt .swatch { flex: none; width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15); }
.theme-opt .theme-text { display: flex; flex-direction: column; min-width: 0; }
.theme-opt small { color: var(--muted); font-size: .82em; line-height: 1.3; }

/* Trick-Reiter */
.preview-buttons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.preview-buttons button { padding: 10px 0; font-size: 1.05em; }
#panel-trick.is-locked { pointer-events: none; }

/* Einstellungen: Positionen */
.positions { display: grid; gap: 6px; margin-bottom: 10px; }
.pos-row { display: grid; grid-template-columns: 1.6em 56px 1fr; gap: 8px; align-items: center; }
.pos-row input { margin-top: 0; }
.pos-row .num, .mapping .num { font-weight: 700; color: var(--accent); text-align: center; }
.zodiac-cols { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

/* Spickzettel */
.table-wrap { overflow-x: auto; margin: 0 -4px 10px; }
.mapping { border-collapse: collapse; font-size: .88em; white-space: nowrap; }
.mapping th, .mapping td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.mapping th { color: var(--muted); font-weight: 600; font-size: .9em; }
.swatch-inline, .mapping .swatch {
    display: inline-block; vertical-align: middle; width: 1.6em; height: .95em; margin-right: 6px;
    border-radius: 4px; background: var(--c); box-shadow: 0 0 8px var(--c);
}

/* ===== Lagetest ===== */
.readings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.reading { display: flex; flex-direction: column; align-items: center; padding: 12px 4px; background: #0c0d0f; border: 1px solid var(--line); border-radius: 12px; }
.reading-label { color: var(--muted); font-size: .8em; text-align: center; }
.reading-label small { display: block; font-size: .8em; }
.reading-value { margin-top: 4px; font-size: 1.45em; font-weight: 700; font-variant-numeric: tabular-nums; }
.zbar { display: flex; align-items: center; gap: 8px; font-size: .8em; color: var(--muted); }
.zbar-track { position: relative; flex: 1; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--red), #3a3d44 50%, var(--ok)); }
.zbar-marker {
    position: absolute; top: 50%; left: 50%; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transform: translate(-50%, -50%); transition: left .08s linear;
}
.message { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 12px; text-align: center; transition: border-color .2s, background .2s; }
.message-icon { font-size: 2.6em; }
.message-text { font-size: 1.25em; font-weight: 700; }
.message-sub { min-height: 1.2em; }
.message[data-state="up"]       { border-color: var(--ok);   background: rgba(48, 209, 88, .1); }
.message[data-state="vertical"] { border-color: var(--warn); background: rgba(255, 214, 10, .08); }

/* Vollflächig weiß leuchtend, wenn das Display nach unten zeigt */
.facedown-overlay {
    position: fixed; inset: 0; z-index: 40;
    display: flex; align-items: center; justify-content: center;
    background: #fff; color: #c8c8c8; font-size: 1.2em; font-weight: 600;
}

/* ===== Bühne des Tricks (Vollbild) ===== */
body.stage-on { overflow: hidden; overscroll-behavior: none; background: #000; }
body.stage-on .top, body.stage-on .flash { display: none; }
.stage {
    position: fixed; inset: 0; z-index: 20;
    background: #000;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    touch-action: manipulation;
}
.waiting {
    display: flex; align-items: center; justify-content: center;
    height: 100%; padding: 2rem; text-align: center; color: #555; font-size: 1.1em;
}

/* Spur am rechten Rand mit N gleich großen Positionen */
.beacon-track {
    --n: 6;
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 24vw; max-width: 9rem;
}
.beacon {
    --slot: 0;
    --c: #fff;
    position: absolute; right: 0; left: 0;
    top: calc(100% / var(--n) * var(--slot));
    height: calc(100% / var(--n));
    background-color: var(--c);
    transform: scaleY(.86); /* kleiner Abstand zwischen den Positionen */
    box-shadow: 0 0 40px 10px var(--c);
    border-radius: 6px 0 0 6px;
}

.debug {
    position: absolute; left: .5rem; bottom: max(.5rem, env(safe-area-inset-bottom)); z-index: 60;
    padding: .3rem .5rem; font: 12px/1.3 ui-monospace, monospace; color: #8f8;
    background: rgba(0, 0, 0, .7); border-radius: .3rem;
}

/* ===== Simulator (?sim=1) ===== */
.simulator {
    position: fixed; right: .5rem; bottom: .5rem; z-index: 100;
    display: flex; flex-direction: column; gap: .3rem;
    padding: .6rem .8rem; font-size: .8rem; color: #fff;
    background: rgba(30, 30, 40, .92); border: 1px solid #444; border-radius: .5rem;
}
.simulator label { display: flex; align-items: center; gap: .4rem; }
.simulator output { width: 2.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.sim-presets { display: flex; gap: .3rem; }
.sim-presets button { font-size: .75rem; padding: .2rem .4rem; }
