:root {
  --wand: #e9d9bd;
  --wand-dunkel: #d9c4a0;
  --holz: #8a5a33;
  --holz-hell: #b98150;
  --karton: #e2c28f;
  --karton-rand: #a9763b;
  --papier: #fbf4e3;
  --tinte: #2d2118;
  --blau: #3f6f9f;
  --rot: #b3433d;
  --gruen: #3f7d4e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--tinte);
  background-color: var(--wand);
  background-image: radial-gradient(circle at 12px 12px, rgba(120, 85, 45, .22) 2.5px, transparent 3px);
  background-size: 28px 28px;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.noscript { padding: 2rem; text-align: center; }

#buehne { min-height: 100%; padding: max(16px, env(safe-area-inset-top)) 16px 32px; display: flex; flex-direction: column; align-items: center; }
.seite { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 18px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
.klein { font-size: .85rem; opacity: .75; margin: 0; }
.zentriert { text-align: center; }

.karte {
  background: var(--papier);
  border: 3px dashed var(--karton-rand);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 4px 0 rgba(90, 55, 25, .25);
}
.kachel {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 28px 18px; border: 3px solid var(--karton-rand); background: var(--karton);
  border-radius: var(--radius); box-shadow: 0 5px 0 var(--karton-rand); font-size: 1.35rem; font-weight: 700; width: 100%;
}
.kachel:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--karton-rand); }
.knopf {
  border: 3px solid var(--karton-rand); background: var(--karton); padding: 12px 18px; border-radius: 12px;
  font-weight: 700; box-shadow: 0 3px 0 var(--karton-rand); min-height: 48px;
}
.knopf:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--karton-rand); }
.knopf.gross { width: 100%; font-size: 1.1rem; background: var(--gruen); color: #fff; border-color: #2c5a37; box-shadow: 0 4px 0 #2c5a37; }
.knopf[disabled] { opacity: .45; cursor: not-allowed; }
.knopf.gefahr { background: var(--rot); color: #fff; border-color: #7e2a26; box-shadow: 0 3px 0 #7e2a26; }
.link { background: none; border: none; text-decoration: underline; padding: 8px; font-size: .9rem; opacity: .8; }

/* Tor mit Zahlenschloss */
.tor {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(180deg, #c5ccd2 0 34px, #98a1a9 34px 40px);
  transition: transform 1.3s cubic-bezier(.6, .05, .3, 1);
}
.tor.offen { transform: translateY(-105%); }
.tor::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 18px; background: #6e767d; }
.schloss {
  position: relative; z-index: 2; width: min(88vw, 360px); background: #3a3f45; color: #f1ece0; border-radius: 18px;
  padding: 22px 20px; box-shadow: 0 8px 0 #1f2328, 0 18px 30px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.schloss h1 { font-size: 1.5rem; }
.schloss input {
  width: 100%; font-size: 1.8rem; letter-spacing: .25em; text-align: center; padding: 12px 8px; border-radius: 10px;
  border: 3px solid #1f2328; background: #101214; color: #ffd86b; font-family: ui-monospace, Consolas, monospace;
}
.schloss input:focus { outline: 3px solid #ffd86b; outline-offset: 2px; }
.schloss .meldung { min-height: 1.4em; margin: 0; color: #ffb3a8; font-weight: 700; }
.schloss .knopf { background: #ffd86b; border-color: #a98b2a; color: #2d2118; box-shadow: 0 3px 0 #a98b2a; }
.schuettel { animation: schuettel .4s; }
@keyframes schuettel { 20%,60% { transform: translateX(-9px); } 40%,80% { transform: translateX(9px); } }

/* Profil anlegen */
.vorschau { display: flex; justify-content: center; }
.auswahlzeile { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.auswahlzeile > span { min-width: 6.2em; font-weight: 700; }
.chip { border: 3px solid var(--karton-rand); background: #fff; border-radius: 12px; padding: 8px 12px; min-height: 44px; min-width: 44px; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--karton); box-shadow: inset 0 0 0 2px var(--tinte); }
.farbe { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--karton-rand); padding: 0; }
.farbe[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--papier), 0 0 0 6px var(--tinte); }
.namenraster { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 380px) { .namenraster { grid-template-columns: 1fr; } }
.name { border: 3px solid var(--karton-rand); background: #fff; border-radius: 12px; padding: 12px 8px; font-weight: 700; min-height: 52px; }
.name[aria-pressed="true"] { background: #fff1b8; box-shadow: inset 0 0 0 3px var(--tinte); }
.fehlertext { color: var(--rot); font-weight: 700; margin: 0; min-height: 1.3em; }

.nummer {
  font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; letter-spacing: .08em; text-align: center;
  background: #fff; border: 3px solid var(--tinte); border-radius: 12px; padding: 14px 8px; word-break: break-all; user-select: all;
}

/* Werkstatt */
.werkstatt { gap: 22px; }
.kopfleiste { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.zahnrad { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(60,40,20,.35); background: rgba(255,255,255,.55); font-size: 1.15rem; line-height: 1; padding: 0; }
.rahmen {
  display: flex; align-items: center; gap: 14px; width: fit-content; background: #fffaf0; border: 8px solid var(--holz); border-radius: 6px; padding: 8px 18px 8px 8px;
  box-shadow: 0 5px 0 rgba(70,40,15,.35);
}
.rahmen strong { font-size: 1.1rem; }
.schrank { background: var(--holz); border-radius: 10px; padding: 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; box-shadow: 0 6px 0 #5a3a1e; }
.schublade {
  background: var(--holz-hell); border: 3px solid #5a3a1e; border-radius: 6px; min-height: 76px; position: relative; font-weight: 800; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center; color: #3a2312;
}
.schublade::before { content: ""; position: absolute; top: 9px; width: 34px; height: 8px; background: #5a3a1e; border-radius: 4px; }
.schublade span { margin-top: 18px; background: var(--papier); border: 2px solid #5a3a1e; padding: 1px 12px; border-radius: 4px; }
.hinweis { text-align: center; min-height: 1.4em; font-weight: 700; margin: 0; }

.einstellungen { position: fixed; inset: 0; z-index: 40; background: rgba(30,20,10,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.einstellungen .karte { width: min(92vw, 420px); display: flex; flex-direction: column; gap: 12px; }

[hidden] { display: none !important; }
