/* Dunkles, zurückhaltendes Thema: Graphit statt Blau, eine Akzentfarbe, Symbole statt
   Emojis. Die App läuft draußen in der Sonne – Kontraste bleiben deshalb kräftig.
   Alle Tippziele mindestens 40 px, Abstände respektieren die iOS-Safe-Areas. */

:root {
  --bg: #0e0f11;
  --bg-raised: #17181b;
  --bg-elev: #1b1c20;
  --bg-input: #24252a;
  --bg-press: #2c2d33;
  --line: #2c2e33;
  --line-soft: #24252a;
  --text: #ededef;
  --muted: #8f929a;
  --faint: #5f626a;
  --accent: #4d8df5;
  --accent-ink: #ffffff;
  --danger: #f2555a;
  --ok: #3ecf8e;
  --warn: #f5b84d;
  --orange: #fc5a1c;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden muss gegen display-Regeln der Bausteine gewinnen */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body { -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- Symbole ---------- */
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Panels ---------- */
.panel { position: absolute; inset: 0 0 calc(var(--tabbar-h) + var(--safe-b)) 0; display: flex; flex-direction: column; }
.panel[hidden] { display: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 16px) 8px calc(var(--safe-l) + 16px);
}
.panel-head h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -.4px; flex: 1; }
.panel-head .icon-btn { margin-right: -8px; }
.panel-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px calc(var(--safe-r) + 14px) 28px calc(var(--safe-l) + 14px);
  display: flex; flex-direction: column; gap: 12px;
}
.back { display: flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--accent); padding: 6px 0; font-size: 15px; margin-left: -6px; }

/* ---------- Karte ---------- */
#map { position: absolute; inset: 0; background: #121315; }
.leaflet-container { background: #121315; font: inherit; }
.leaflet-control-attribution { background: rgba(14,15,17,.72) !important; color: var(--muted); font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted); }
.jl-mask, .jl-edges { position: absolute; top: 0; left: 0; pointer-events: none; }
.jl-edges { mix-blend-mode: screen; }

.map-top {
  position: absolute; z-index: 500; display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start;
  top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 64px);
}
.map-side {
  position: absolute; z-index: 500; display: flex; flex-direction: column; gap: 6px;
  right: calc(var(--safe-r) + 10px); top: calc(var(--safe-t) + 10px);
}
.map-bottom {
  position: absolute; z-index: 500; bottom: 14px;
  left: calc(var(--safe-l) + 14px); right: calc(var(--safe-r) + 14px);
}

.chip {
  background: rgba(23,24,27,.9); border: 1px solid rgba(255,255,255,.06); color: var(--text);
  border-radius: 12px; padding: 6px 10px; font-size: 12px; line-height: 1.25;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-height: 36px;
}
.chip-stat { display: flex; flex-direction: column; justify-content: center; text-align: left; }
.chip-stat b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-stat span { color: var(--muted); font-size: 11px; }
button.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; }
.chip-endgame { flex-direction: row; align-items: center; gap: 8px; }
.chip-endgame > div { display: flex; flex-direction: column; }
.chip-endgame .ic { color: var(--orange); width: 18px; height: 18px; }
.chip-endgame.rec .rec-dot { display: block; }
.rec-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.fab {
  width: 44px; height: 44px; border-radius: 12px; padding: 0;
  background: rgba(23,24,27,.92); color: var(--text); border: 1px solid rgba(255,255,255,.06);
  display: grid; place-items: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.fab.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.fab-gap { height: 6px; }

.measure-readout {
  position: absolute; z-index: 500; left: 50%; transform: translateX(-50%);
  bottom: 76px; background: rgba(23,24,27,.95); border: 1px solid rgba(255,255,255,.06);
  padding: 8px 12px; border-radius: 12px; font-size: 14px; text-align: center;
  display: flex; align-items: center; gap: 6px; max-width: calc(100% - 28px);
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 600;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(14,15,17,.94); border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabbar button {
  background: none; border: 0; color: var(--faint); font-size: 10.5px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  position: relative;
}
.tabbar .ic { width: 22px; height: 22px; }
.tabbar button.active { color: var(--text); }
.badge {
  position: absolute; top: 5px; left: calc(50% + 6px); background: var(--accent); color: var(--accent-ink);
  border-radius: 9px; font-size: 10px; font-style: normal; font-weight: 600; padding: 0 5px; min-width: 17px; text-align: center; line-height: 16px;
}

/* ---------- Knöpfe ---------- */
.btn {
  background: var(--bg-input); color: var(--text); border: 0;
  border-radius: 12px; padding: 11px 16px; font-size: 15px; font-weight: 550; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn .ic { width: 18px; height: 18px; }
.btn:active, .icon-btn:active, .row-item:is(button):active, .pill:active { background: var(--bg-press); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: #3f7ce0; }
.btn-small { padding: 7px 12px; min-height: 36px; font-size: 13.5px; border-radius: 10px; gap: 6px; }
.btn-small .ic { width: 16px; height: 16px; }
.btn-wide { width: 100%; }
.btn-danger { color: var(--danger); }
.btn-ghost { background: none; }
.btn[disabled] { opacity: .4; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; padding: 0; flex: none;
  background: none; color: var(--text); display: inline-grid; place-items: center;
}
.icon-btn.danger { color: var(--danger); }
.icon-btn-solid { background: var(--accent); color: var(--accent-ink); }
.icon-btn-solid:active { background: #3f7ce0 !important; }
.icon-btn .ic { width: 20px; height: 20px; }

.row { display: flex; gap: 8px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* ---------- Karten und Listen ---------- */
.card {
  background: var(--bg-raised); border: 0; border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 8px; color: var(--text);
}
button.card { text-align: left; width: 100%; font: inherit; }
button.card:active { background: var(--bg-press); }
button.card[disabled] { opacity: .45; }
.card.off { opacity: .45; }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.card-title .ic { color: var(--muted); }
.card-title .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.card-sub { color: var(--muted); font-size: 13px; }

.group { display: flex; flex-direction: column; gap: 6px; }
.group-title {
  color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 4px 0;
}
.list { background: var(--bg-raised); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.sheet .list { background: var(--bg-input); }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 52px;
  background: none; border: 0; text-align: left; width: 100%; color: var(--text);
}
.row-item + .row-item { box-shadow: inset 0 1px 0 var(--line-soft); }
.sheet .row-item + .row-item { box-shadow: inset 0 1px 0 var(--line); }
.row-icon { color: var(--muted); }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 15px; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.row-value { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.row-chevron { color: var(--faint); width: 18px; height: 18px; }
.row-item.danger, .row-item.danger .row-icon { color: var(--danger); }
.row-item.stacked { align-items: flex-start; }
.row-item.stacked .row-icon { margin-top: 1px; }
.row-below { margin-top: 10px; }
.row-below input[type=range] { width: 100%; }

.switch {
  width: 48px; height: 30px; border-radius: 15px; border: 0; padding: 0; flex: none; position: relative;
  background: var(--bg-press); transition: background .18s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #f4f4f5; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .18s;
}
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(18px); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--bg-input); border: 1px solid transparent; color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 16px; width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=range] { padding: 0; background: none; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
details summary { cursor: pointer; }

.seg { display: flex; background: var(--bg-input); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 8px; font-size: 14px; font-weight: 550; min-height: 38px; border-radius: 9px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills-center { justify-content: center; }
.pill {
  background: var(--bg-input); border: 0; color: var(--text);
  border-radius: 999px; padding: 8px 13px; font-size: 13.5px; min-height: 36px;
}
.pill.on { background: var(--accent); color: var(--accent-ink); }
.pill.tag-yes { box-shadow: inset 0 0 0 1px #1f5140; }
.pill.tag-no { box-shadow: inset 0 0 0 1px #5b2b34; }

.empty { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 14px; }
.empty .ic { width: 32px; height: 32px; color: var(--faint); margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.warn { color: var(--warn); }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  background: var(--bg-elev); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0;
  max-height: 90vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b); animation: slideup .22s cubic-bezier(.2,.8,.3,1);
}
.sheet::before { content: ''; width: 36px; height: 4px; border-radius: 2px; background: var(--bg-press); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px 18px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-foot { padding: 10px 16px 14px; display: flex; gap: 8px; }
.sheet .card { background: var(--bg-input); }
.sheet .btn, .sheet .pill, .sheet .seg, .sheet input, .sheet select, .sheet textarea { background: var(--bg-press); }
.sheet .btn-primary, .sheet .pill.on { background: var(--accent); }
.sheet .seg button.on { background: var(--accent); }
@keyframes slideup { from { transform: translateY(24px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toasts ---------- */
#toast-root {
  position: fixed; z-index: 1200; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  background: #2a2b30; border-radius: 12px; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13.5px; max-width: 90%; pointer-events: auto;
  animation: fade .15s ease; box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
.toast.error { color: #ffc9cb; box-shadow: inset 3px 0 0 var(--danger), 0 8px 28px rgba(0,0,0,.45); }
.toast.ok { color: #c8f5df; box-shadow: inset 3px 0 0 var(--ok), 0 8px 28px rgba(0,0,0,.45); }
.verdict { background: rgba(242,85,90,.12); color: #ffc9cb; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }

/* ---------- Timer ---------- */
.timer-face { font-size: 40px; font-weight: 600; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer-face.done { color: var(--warn); }
.timer-face.over { color: var(--danger); }
.timer-controls { gap: 4px; }
.stepper { display: inline-flex; align-items: center; background: var(--bg-input); border-radius: 12px; }
.stepper button { width: 40px; height: 40px; border: 0; background: none; display: grid; place-items: center; border-radius: 12px; }
.stepper button:active { background: var(--bg-press); }
.stepper-label { color: var(--muted); font-size: 12.5px; padding: 0 2px; font-variant-numeric: tabular-nums; }

/* ---------- Karten-Marker ---------- */
.jl-pin {
  width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5);
}
.jl-label {
  background: rgba(14,15,17,.88) !important; border: 0 !important; color: var(--text) !important;
  border-radius: 6px !important; padding: 2px 6px !important; font-size: 11px !important; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.35) !important;
}
.jl-label::before { display: none; }
.jl-me {
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 1px 6px rgba(0,0,0,.4);
}
.jl-me.manual { background: var(--warn); }

table.scores { width: 100%; border-collapse: collapse; font-size: 14px; }
table.scores th, table.scores td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line-soft); }
table.scores tr:last-child td { border-bottom: 0; }
table.scores th { color: var(--muted); font-size: 12px; font-weight: 500; }
table.scores td.num { text-align: right; font-variant-numeric: tabular-nums; }

.log-entry { display: flex; gap: 10px; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.log-entry:last-child { border-bottom: 0; }
.log-entry time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

.qr-wrap { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; }
.qr-wrap img, .qr-wrap canvas { width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; }

.progress { height: 6px; background: var(--bg-input); border-radius: 99px; overflow: hidden; display: flex; }
.sheet .progress { background: var(--bg-press); }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.progress > i.guess { background: repeating-linear-gradient(90deg, var(--orange) 0 4px, transparent 4px 7px); opacity: .7; }

/* ---------- Punktmenü ---------- */
.coords { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- Endgame ---------- */
.endgame-stop { display: flex; align-items: center; gap: 12px; background: var(--bg-input); border-radius: 12px; padding: 12px 14px; }
.endgame-stop > .ic { color: var(--orange); width: 24px; height: 24px; }
.endgame-hero { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 6px; }
.endgame-pct { font-size: 40px; font-weight: 650; letter-spacing: -1px; color: var(--orange); font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Taschenmodus: so wenig Licht wie möglich */
.pocket {
  position: fixed; inset: 0; z-index: 3000; background: #000; color: #4a4a4a;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-t) + 40vh) 24px calc(var(--safe-b) + 48px); touch-action: none;
}
.pocket-body { text-align: center; }
.pocket-text { font-size: 17px; font-weight: 600; color: #555; }
.pocket-sub { font-size: 12.5px; color: #3c3c3c; margin-top: 6px; text-align: center; }
.pocket-unlock { display: flex; flex-direction: column; align-items: center; }
.pocket-ring {
  width: 72px; height: 72px; border-radius: 50%; border: 2px solid #2a2a2a;
  transition: border-color .9s linear, transform .9s linear;
}
.pocket-ring.holding { border-color: var(--orange); transform: scale(1.12); }
