:root {
  --bg: #eef1f4;
  --card: #ffffff;
  --ink: #1b2733;
  --muted: #5b6b7a;
  --primary: #16425b;
  --primary-d: #0f2e41;
  --ein: #1f8a4c;
  --ein-d: #176c3b;
  --aus: #c2410c;
  --aus-d: #9a330a;
  --line: #d9dfe5;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden-Attribut zuverlaessig durchsetzen — sonst ueberschreibt .sheet/.done
   (display:flex) den UA-Default [hidden]{display:none}. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-user-select: none; user-select: none;
}

body { display: flex; flex-direction: column; min-height: 100dvh; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--primary); color: #fff;
  padding: max(env(safe-area-inset-top), 14px) 18px 14px;
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-size: 1.15rem; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: .85rem; opacity: .8; font-variant-numeric: tabular-nums; }
.back {
  background: rgba(255,255,255,.15); color: #fff; border: 0;
  width: 40px; height: 40px; border-radius: 10px;
  font-size: 1.8rem; line-height: 1; cursor: pointer;
}

main { flex: 1; display: flex; flex-direction: column; padding: 20px 18px 28px; }

/* Screens */
.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.prompt { font-size: 1.5rem; font-weight: 700; margin: 4px 2px 18px; }
.hint { font-size: .95rem; color: var(--muted); text-align: center; margin: 8px 0 0; }
.error { color: var(--aus); font-weight: 600; }

/* Namensauswahl */
.namegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.namegrid button {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-size: 1.35rem; font-weight: 600;
  min-height: 92px; padding: 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16,30,45,.05);
  transition: transform .08s ease, background .12s ease;
}
.namegrid button:active { transform: scale(.97); background: #f3f6f9; }

/* PIN */
.dots { display: flex; justify-content: center; gap: 18px; margin: 8px 0 4px; }
.dots span {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--primary); background: transparent;
  transition: background .12s ease, transform .12s ease;
}
.dots span.on { background: var(--primary); transform: scale(1.05); }
.dots.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-9px); }
  40%,80% { transform: translateX(9px); }
}

.keypad {
  margin-top: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.keypad button {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.9rem; font-weight: 600; color: var(--ink);
  height: 72px; cursor: pointer;
  transition: transform .07s ease, background .12s ease;
}
.keypad button:active { transform: scale(.96); background: #eef2f6; }
.keypad button.ghost { background: transparent; border-color: transparent; color: var(--muted); }

/* Stempel-Button */
.status-line { font-size: 1.05rem; color: var(--muted); margin: 0 2px 18px; }
.stampbtn {
  margin-top: auto; border: 0; border-radius: 20px; color: #fff;
  font-size: 1.7rem; font-weight: 700; min-height: 140px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 6px 16px rgba(16,30,45,.18);
  transition: transform .08s ease, filter .12s ease;
}
.stampbtn:active { transform: scale(.98); filter: brightness(.95); }
.stampbtn.ein { background: linear-gradient(180deg, var(--ein), var(--ein-d)); }
.stampbtn.aus { background: linear-gradient(180deg, var(--aus), var(--aus-d)); }
.stampbtn[disabled] { opacity: .6; }

.geo-note {
  margin: 16px 4px 0; font-size: .82rem; line-height: 1.4;
  color: var(--muted); text-align: center;
}

/* Installieren-Hinweis */
.install-btn {
  margin: 22px auto 4px; display: block;
  background: transparent; border: 1px solid var(--line); border-radius: 12px;
  color: var(--muted); font-size: .95rem; font-weight: 600;
  padding: 11px 18px; cursor: pointer;
}
.install-btn:active { background: #e7ecf1; }

.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(20,30,40,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.sheet-card {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 24px 22px max(env(safe-area-inset-bottom), 22px);
}
.sheet-card h2 { margin: 2px 0 14px; font-size: 1.25rem; }
.sheet-card p { color: var(--muted); margin: 0 0 12px; }
.sheet-card ol { margin: 0; padding-left: 20px; line-height: 1.7; }
.sheet-card li { margin-bottom: 6px; }
.sheet-card .ic { font-size: 1.1em; }
.ins-block { margin-bottom: 14px; }
.ins-head { color: var(--ink); font-weight: 700; margin: 0 0 4px; }
.sheet-close {
  margin-top: 20px; width: 100%; border: 0; border-radius: 14px;
  background: var(--primary); color: #fff; font-size: 1.1rem; font-weight: 700;
  padding: 15px; cursor: pointer;
}

/* Rückmeldung */
.done {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center; padding: 24px;
  animation: fade .2s ease;
}
.done.ein { background: var(--ein); }
.done.aus { background: var(--aus); }
.done-icon {
  width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem; margin-bottom: 22px;
}
.done-title { font-size: 1.8rem; font-weight: 700; }
.done-time { font-size: 1.3rem; margin-top: 8px; opacity: .92; font-variant-numeric: tabular-nums; }
.done-hint { margin-top: 34px; font-size: .9rem; opacity: .75; }
