:root {
  --night: #1A2246;
  --night-deep: #111733;
  --paper: #F5EDE0;
  --paper-shade: #E3D5BF;
  --ink: #2A2440;
  --ink-soft: #6A6177;
  --cord: #D2343F;
  --gold: #F2C14E;
  --frost: #AFC2E6;

  --row: 168px;          /* Höhe einer Girlanden-Reihe */
  --cord-y: 10px;        /* Lage der Schnur innerhalb der Reihe */

  --sans: "Bricolage Grotesque", system-ui, sans-serif;
  --hand: "Caveat", "Segoe Print", cursive;

  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--night);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-variation-settings: "opsz" 14;
  overflow-x: hidden;
}

/* Sternenhimmel: feste Punkte, kein Gefunkel */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1.5px 1.5px at 8% 12%, var(--frost) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 30%, var(--paper) 50%, transparent 51%),
    radial-gradient(2px 2px at 37% 8%, var(--gold) 50%, transparent 51%),
    radial-gradient(1px 1px at 51% 22%, var(--frost) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 66% 6%, var(--paper) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 28%, var(--paper) 50%, transparent 51%),
    radial-gradient(2px 2px at 91% 14%, var(--frost) 50%, transparent 51%),
    radial-gradient(1px 1px at 14% 58%, var(--frost) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 52%, var(--paper) 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 72%, var(--frost) 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 86%, var(--paper) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 5% 90%, var(--gold) 50%, transparent 51%);
  opacity: .7;
}

header, main { position: relative; z-index: 1; }

/* ---------- Kopf ---------- */
.top {
  max-width: 64rem;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 4.5rem) 1rem 0;
}

h1 {
  margin: 0;
  font-size: clamp(3.25rem, 13vw, 8rem);
  line-height: .86;
  font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 75;
  letter-spacing: -.02em;
  color: var(--paper);
  text-wrap: balance;
}

.status {
  margin: 1rem 0 0;
  max-width: 38rem;
  color: var(--frost);
  font-size: clamp(1.05rem, 2.6vw, 1.25rem);
}
.status strong { color: var(--gold); font-weight: 650; }

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

.loading { color: var(--frost); }

/* ---------- Anhänger (gemeinsame Form) ---------- */
.tag {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), transparent 30%),
    var(--paper);
  color: var(--ink);
  clip-path: polygon(22% 0, 78% 0, 100% 16%, 100% 100%, 0 100%, 0 16%);
  border-radius: 0 0 6px 6px;
}
.hole {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--night-deep);
  box-shadow: 0 0 0 3px var(--paper-shade);
}

/* ---------- Eintragen ---------- */
.view-join { padding-top: 1rem; }

.hang {
  position: relative;
  width: min(100%, 24rem);
  transform-origin: 50% 0;
}
.cord-drop {
  display: block;
  width: 3px;
  height: 46px;
  margin-left: calc(50% - 1.5px);
  background: var(--cord);
  border-radius: 2px;
}
.tag--form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 3rem 1.5rem 1.5rem;
  margin-top: -14px; /* Schnur läuft ins Loch */
}
.tag--form label {
  font-weight: 700;
  font-size: 1.5rem;
  font-variation-settings: "opsz" 40, "wdth" 85;
  line-height: 1.1;
}
.tag--form input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--hand);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1.1;
  padding: .1rem 0 .15rem;
  border-radius: 0;
}
.tag--form input::placeholder { color: #B1A48F; }
.tag--form input:focus { outline: none; border-bottom-color: var(--cord); }
.tag--form input:focus-visible { box-shadow: 0 3px 0 0 var(--cord); }
.tag--form .btn { margin-top: .9rem; }
.hint { margin: 0 0 .5rem; color: var(--ink-soft); font-size: .95rem; line-height: 1.4; }
.form-error { margin: 0; min-height: 0; color: #A3202B; font-weight: 600; font-size: .95rem; }
.form-error:empty { display: none; }

.aside { color: var(--frost); max-width: 34rem; margin-top: 2rem; }

/* Formular-Anhänger schaukelt einmal sanft beim Laden */
.view-join:not([hidden]) .hang { animation: settle 2.4s cubic-bezier(.3,.7,.3,1) both; }
@keyframes settle {
  0% { transform: rotate(-7deg); }
  30% { transform: rotate(4deg); }
  55% { transform: rotate(-2deg); }
  78% { transform: rotate(.8deg); }
  100% { transform: rotate(0); }
}
/* Beim Abschicken fliegt er nach oben an die Girlande */
.hang.lift { animation: lift .7s cubic-bezier(.6,-0.2,.7,.5) forwards; }
@keyframes lift {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(12px) rotate(-3deg); }
  100% { transform: translateY(-110vh) rotate(8deg); }
}

/* ---------- Buttons & Links ---------- */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-variation-settings: "opsz" 24, "wdth" 90;
  font-size: 1.125rem;
  padding: .8rem 1.25rem;
  border-radius: 999px;
  background: var(--cord);
  color: #fff;
  transition: transform .15s ease, background-color .15s ease;
}
.btn:hover { background: #B92733; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--small { font-size: 1rem; padding: .55rem 1rem; white-space: nowrap; }

.link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.link:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn:focus-visible { outline-color: var(--gold); }

/* ---------- Eigener Bereich oben in der Liste ---------- */
.my-slot:empty { display: none; }
.my-slot { margin: 1.5rem 0 3rem; }

.linkbox {
  max-width: 36rem;
  border-left: 3px solid var(--gold);
  padding: .25rem 0 .25rem 1.25rem;
  color: var(--frost);
}
.linkbox p { margin: 0 0 .75rem; }
.linkbox-hello {
  color: var(--paper) !important;
  font-size: 1.5rem;
  font-weight: 700;
  font-variation-settings: "opsz" 40, "wdth" 85;
  line-height: 1.2;
}
.linkbox-hello [data-name] { font-family: var(--hand); font-size: 2rem; color: var(--gold); font-weight: 700; }
.linkbox-row { display: flex; gap: .5rem; align-items: center; }
.linkbox-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: .95rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  border: 1px solid rgba(175,194,230,.35);
  background: var(--night-deep);
  color: var(--paper);
}
.linkbox.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { border-left-color: var(--paper); } 100% { border-left-color: var(--gold); } }

.notice { max-width: 36rem; color: var(--frost); }
.notice strong { color: var(--paper); }

/* ---------- Girlande ---------- */
.list-title {
  margin: 0 0 .5rem;
  font-size: 1.5rem;
  font-weight: 700;
  font-variation-settings: "opsz" 40, "wdth" 85;
}
#list-count { color: var(--gold); }

.garland {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  grid-auto-rows: var(--row);
  /* Eine rote Schnur pro Reihe */
  background-image:
    linear-gradient(to bottom,
      transparent var(--cord-y),
      var(--cord) var(--cord-y), var(--cord) calc(var(--cord-y) + 3px),
      rgba(0,0,0,.25) calc(var(--cord-y) + 3px), rgba(0,0,0,.25) calc(var(--cord-y) + 5px),
      transparent calc(var(--cord-y) + 5px));
  background-size: 100% var(--row);
  background-repeat: repeat-y;
}
.garland-empty { color: var(--frost); }

.garland li {
  display: flex;
  justify-content: center;
  padding-top: var(--cord-y);
}
.swing {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: 50% 0;
  animation: sway var(--sway-dur, 5s) ease-in-out var(--sway-delay, 0s) infinite alternate;
}
.swing::before { /* Bändchen von der Schnur zum Loch */
  content: "";
  width: 2px;
  height: 30px;
  margin-bottom: -16px;
  background: var(--paper-shade);
  position: relative;
  z-index: 1;
}
.mine .swing::before { background: var(--gold); width: 3px; }

.garland .tag {
  width: 96px;
  min-height: 112px;
  padding: 32px 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transform: rotate(var(--tilt, 0deg));
}
.tag-name {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: .95;
  overflow-wrap: break-word;
  hyphens: manual;
  max-width: 100%;
}
.tag-name.is-long { font-size: 1.35rem; }
.tag-name.is-very-long { font-size: 1.1rem; }
.mine .tag { background: var(--gold); }
.mine .tag .hole { box-shadow: 0 0 0 3px #D9A635; }
.tag-you {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--ink);
  opacity: .7;
}

@keyframes sway {
  from { transform: rotate(-2.2deg); }
  to   { transform: rotate(2.2deg); }
}

/* Neue Anhänger fallen an die Schnur und pendeln aus */
.garland li.drop .swing {
  animation:
    drop .9s cubic-bezier(.25,.9,.35,1.15) var(--drop-delay, 0s) both,
    sway var(--sway-dur, 5s) ease-in-out calc(var(--drop-delay, 0s) + .9s) infinite alternate;
}
@keyframes drop {
  0% { transform: translateY(-140px) rotate(-18deg); opacity: 0; }
  35% { opacity: 1; }
  60% { transform: translateY(6px) rotate(9deg); }
  80% { transform: translateY(-2px) rotate(-4deg); }
  100% { transform: translateY(0) rotate(-2.2deg); }
}

.invite { margin-top: 2.5rem; color: var(--frost); }

/* ---------- Das Los ---------- */
.reveal-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.reveal {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  perspective: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 22rem);
  transform-origin: 50% 0;
}
.reveal:not(.is-open) { animation: nudge 4s ease-in-out 1.2s infinite; }
@keyframes nudge {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-3deg); }
  90% { transform: rotate(2.4deg); }
  94% { transform: rotate(-1.2deg); }
}
.reveal-cord {
  width: 3px;
  height: 44px;
  margin-bottom: -14px;
  background: var(--gold);
  border-radius: 2px;
  position: relative;
  z-index: 2;
}
.flip {
  position: relative;
  display: grid;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(.3,1.4,.45,1);
}
.reveal.is-open .flip { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  min-height: 15rem;
  padding: 3.25rem 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face--back { transform: rotateY(180deg); background: var(--gold); }
.face--back .hole { box-shadow: 0 0 0 3px #D9A635; }
.face-small { font-size: 1.05rem; color: var(--ink-soft); font-weight: 500; }
.face--back .face-small { color: var(--ink); }
.face-small [data-name] { font-family: var(--hand); font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.face-big {
  margin-top: .5rem;
  font-size: 1.6rem;
  font-weight: 800;
  font-variation-settings: "opsz" 48, "wdth" 80;
  line-height: 1.05;
}
.face-recipient {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(3rem, 14vw, 4.5rem);
  line-height: .95;
  margin-top: .35rem;
  overflow-wrap: anywhere;
}
.reveal:focus-visible { outline: none; }
.reveal:focus-visible .face { outline: 3px solid var(--gold); outline-offset: 4px; }
.reveal-note { color: var(--frost); max-width: 26rem; margin-top: 1.25rem; }

/* Papiersterne beim Umdrehen */
.burst {
  position: fixed;
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 10;
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
  animation: burst 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
@keyframes burst {
  0% { transform: translate(0,0) rotate(0) scale(.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

.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;
}

@media (max-width: 480px) {
  :root { --row: 156px; }
  .garland { grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); }
  .garland .tag { width: 86px; min-height: 104px; }
  .tag-name { font-size: 1.5rem; }
  .linkbox-row { flex-direction: column; align-items: stretch; }
}

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