:root {
  --bg-1: #0b1f1a;
  --bg-2: #15382e;
  --paper: #fffaf0;
  --paper-2: #f4ead6;
  --ink: #1d2b26;
  --ink-soft: #5b6b64;
  --red: #c8322f;
  --red-dark: #9e2522;
  --gold: #e7bb52;
  --green: #2f7d5b;
  --white-soft: rgba(255, 255, 255, 0.78);
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--paper);
  background: radial-gradient(1200px 700px at 50% -10%, #1f4a3c 0%, var(--bg-2) 35%, var(--bg-1) 100%) fixed;
  background-color: var(--bg-1);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#snow, #confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#snow { z-index: 0; opacity: 0.7; }
#confetti { z-index: 5; }

.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

.view[hidden] { display: none !important; }
.view { animation: fade-in 0.35s ease both; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Start ---------- */
.hero { text-align: center; margin: 8px 0 22px; }
.hero-badge {
  font-size: 44px;
  width: 76px; height: 76px;
  display: grid; place-items: center;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
h1 {
  font-size: clamp(2.2rem, 9vw, 3rem);
  margin: 0;
  letter-spacing: -0.02em;
}
.lead { margin: 8px auto 0; max-width: 32ch; color: var(--white-soft); line-height: 1.45; }

.progress { margin: 0 4px 16px; }
.progress-text { font-size: 0.92rem; color: var(--white-soft); margin-bottom: 6px; text-align: center; }
.progress-bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #f6dc8f);
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}

.all-done {
  text-align: center;
  background: rgba(231, 187, 82, 0.16);
  border: 1px solid rgba(231, 187, 82, 0.45);
  color: #ffe9b3;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
  font-weight: 600;
}

.names {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.loading { grid-column: 1 / -1; text-align: center; color: var(--white-soft); padding: 24px; }

.name-card {
  appearance: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 76px;
}
.name-card:active { transform: scale(0.97); }
@media (hover: hover) {
  .name-card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,0.34); }
}
.name-card:focus-visible, .btn:focus-visible, .card:focus-visible, .back:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.name-card .who { display: flex; flex-direction: column; min-width: 0; }
.name-card .name { font-weight: 700; font-size: 1.08rem; }
.name-card .state { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.name-card.done { background: var(--paper-2); }
.name-card.done .state { color: var(--green); font-weight: 600; }

.avatar {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  background: var(--red);
  position: relative;
}
.name-card.done .avatar::after {
  content: "✓";
  position: absolute;
  right: -3px; bottom: -3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.72rem;
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 2px var(--paper-2);
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.8rem; margin: 0 auto 12px; }

.howto {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 4px 16px;
  color: var(--white-soft);
  line-height: 1.5;
  font-size: 0.95rem;
}
.howto summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--paper); }
.howto ol { padding-left: 20px; margin: 4px 0 8px; }
.howto p { margin: 0 0 12px; }

/* ---------- PIN ---------- */
.back {
  appearance: none;
  border: 0;
  background: none;
  color: var(--white-soft);
  font: inherit;
  padding: 8px 4px;
  margin-bottom: 8px;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}
.panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 24px;
  padding: 28px 20px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 1.6rem; }
.muted { color: var(--ink-soft); line-height: 1.45; }
.view > .muted, .reveal-actions .muted { color: var(--white-soft); }
.panel .muted { margin: 0 auto 18px; max-width: 34ch; }
.tiny { font-size: 0.82rem; }
.center { text-align: center; }

#pin-form { position: relative; }
.pin-boxes {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 6px 0 4px;
}
.pin-boxes span {
  width: 54px; height: 62px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #ddd2bc;
  display: grid; place-items: center;
  font-size: 1.6rem;
  transition: border-color 0.15s, transform 0.15s;
}
.pin-boxes span.filled::before { content: "●"; color: var(--ink); font-size: 1.1rem; }
.pin-boxes span.active { border-color: var(--red); }
.pin-boxes.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
/* Unsichtbares echtes Eingabefeld über den Kästchen (für Tastatur & Autofill) */
.pin-input {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 252px; height: 62px;
  opacity: 0;
  font-size: 16px; /* verhindert Zoom auf iOS */
  border: 0;
  caret-color: transparent;
}
.error { min-height: 1.4em; color: var(--red); font-weight: 600; margin: 10px 0 8px; font-size: 0.92rem; }

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  width: 100%;
  padding: 15px 18px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(200, 50, 47, 0.35); }
.btn-primary:not([disabled]):hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px #ddd2bc; }

#pin-footnote { margin: 14px 0 0; }

/* ---------- Aufdecken ---------- */
.reveal-title { text-align: center; margin: 12px 0 4px; font-size: 1.7rem; }
#reveal-hint { margin: 0 0 22px; }

.card {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  display: block;
  width: min(100%, 320px, 42vh);
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  perspective: 1200px;
  cursor: pointer;
  font: inherit;
}
.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.9s cubic-bezier(.3,1.3,.5,1);
  transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card.flipped { cursor: default; }
.card-face {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.card-front {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 45%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0 12px, transparent 12px 24px),
    linear-gradient(160deg, #d63b37, #a3221f);
  color: #fff;
}
.ribbon-v, .ribbon-h { position: absolute; background: linear-gradient(90deg, #d9a63a, var(--gold), #d9a63a); }
.ribbon-v { top: 0; bottom: 0; left: 50%; width: 34px; transform: translateX(-50%); }
.ribbon-h { left: 0; right: 0; top: 38%; height: 34px; transform: translateY(-50%); background: linear-gradient(180deg, #d9a63a, var(--gold), #d9a63a); }
.bow {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -62%);
  font-size: 74px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.tap {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.28);
  padding: 9px 16px;
  border-radius: 99px;
  font-weight: 700;
  letter-spacing: 0.01em;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}
.card:not(.flipped) .card-inner { animation: wiggle 3.5s ease-in-out 1.2s infinite; }
@keyframes wiggle {
  0%, 86%, 100% { transform: rotate(0); }
  89% { transform: rotate(-3deg); }
  92% { transform: rotate(3deg); }
  95% { transform: rotate(-2deg); }
}
.card-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 0%, #fff 0%, var(--paper) 55%, var(--paper-2) 100%);
  color: var(--ink);
  padding: 24px;
  text-align: center;
}
.card-label { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.card-name {
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  font-weight: 800;
  color: var(--red);
  margin: 10px 0 14px;
  line-height: 1.05;
  word-break: break-word;
}
.card-psst { color: var(--ink-soft); font-size: 0.95rem; }

.reveal-actions { margin-top: 26px; animation: fade-in 0.4s ease both; }
.reveal-actions .tiny { margin-top: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; margin: 8px 0 18px; text-align: left; }
.admin-table td { padding: 10px 6px; border-bottom: 1px solid #eadfc8; vertical-align: middle; }
.admin-table td:last-child { text-align: right; }
.pill { display: inline-block; font-size: 0.78rem; padding: 3px 9px; border-radius: 99px; font-weight: 700; white-space: nowrap; }
.pill-done { background: #dff1e8; color: var(--green); }
.pill-open { background: #f1ebde; color: var(--ink-soft); }
.pill-lock { background: #fbe3e2; color: var(--red); margin-left: 4px; }
.btn-small { width: auto; padding: 7px 12px; font-size: 0.85rem; border-radius: 10px; }
.text-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 2px solid #ddd2bc;
  margin-bottom: 12px;
  background: #fff;
  color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--red); }
.stack { display: grid; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #snow { display: none; }
}
