:root {
  --night: #0d1b3d;
  --night2: #1a2f63;
  --card: rgba(255, 255, 255, .07);
  --card-line: rgba(255, 255, 255, .14);
  --fg: #f6f1e7;
  --dim: #a9b4d0;
  --red: #ff4d5e;
  --green: #35d07f;
  --gold: #ffc93c;
  --blue: #4cc9f0;
  --purple: #b388ff;
  --pink: #ff7aa2;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--night) 0%, var(--night2) 70%, #24407f 100%) fixed;
  color: var(--fg);
  font: 17px/1.55 var(--round);
  overflow-x: hidden;
}

a { color: var(--gold); }

/* ---------------------------------------------------------------- Schnee */
.snow, .snow::after {
  position: fixed; inset: -10vh 0 0 0; pointer-events: none; z-index: 1;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 90px 120px, rgba(255,255,255,.9) 50%, transparent 51%),
    radial-gradient(2px 2px at 160px 60px, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(3px 3px at 230px 180px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 300px 90px, rgba(255,255,255,.8) 50%, transparent 51%);
  background-size: 320px 220px;
  animation: snow 14s linear infinite;
  opacity: .7;
}
.snow::after { content: ""; background-size: 260px 300px; animation-duration: 22s; opacity: .5; }
@keyframes snow { to { transform: translateY(220px); } }

/* ---------------------------------------------------------------- Kopf + Lichterkette */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .25rem .6rem;
  padding: 1.6rem 1rem .6rem;
  text-align: center;
}
.brand {
  font-weight: 900; font-size: 1.35rem; letter-spacing: .06em; text-decoration: none;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green), var(--blue), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.agent { color: var(--dim); font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }

.garland {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between;
  height: 26px; margin: 0 -6px;
  background: radial-gradient(ellipse 60% 18px at 50% -6px, transparent 96%, #1f5130 97%, #1f5130 100%, transparent 101%) 0 0 / 60px 26px repeat-x;
}
.garland i {
  width: 11px; height: 17px; margin-top: 6px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--c);
  box-shadow: 0 0 10px 2px var(--c);
  animation: bulb 1.6s ease-in-out infinite;
}
.garland i::before { content: ""; display: block; width: 7px; height: 4px; margin: -4px auto 0; background: #2d3b2f; border-radius: 2px; }
.garland i:nth-child(5n+1) { --c: var(--red); }
.garland i:nth-child(5n+2) { --c: var(--gold); animation-delay: .4s; }
.garland i:nth-child(5n+3) { --c: var(--green); animation-delay: .8s; }
.garland i:nth-child(5n+4) { --c: var(--blue); animation-delay: 1.2s; }
.garland i:nth-child(5n+5) { --c: var(--purple); animation-delay: .6s; }
@keyframes bulb { 50% { opacity: .35; box-shadow: none; } }

/* ---------------------------------------------------------------- Inhalt */
.wrap { position: relative; z-index: 2; max-width: 720px; margin: 0 auto; padding: 1rem 1rem 140px; }

.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 18px;
  padding: 1.25rem 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.card.festive { border-top: 6px solid transparent; border-image: repeating-linear-gradient(45deg, var(--red) 0 12px, #fff 12px 24px) 6 0 0 0 / 6px 0 0 0; }
.center { text-align: center; }

h1, h2 { line-height: 1.2; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; color: var(--gold); }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

.meta { font: 600 .75rem/1.4 var(--mono); letter-spacing: .14em; color: var(--pink); margin: 0; text-transform: uppercase; }
.dim { color: var(--dim); font-size: .9rem; }
.err { color: var(--red); }
.type { font-family: var(--mono); font-size: .95rem; white-space: pre-line; }

.text p { margin: 0 0 .8rem; }
.text blockquote {
  margin: 0 0 1rem; padding: .8rem 1rem;
  border-left: 4px solid var(--green);
  border-radius: 0 12px 12px 0;
  background: rgba(53, 208, 127, .1);
}
.text ul, .text ol { padding-left: 1.3rem; }
.text li { margin-bottom: .3rem; }
code { font-family: var(--mono); color: var(--gold); }

.media { margin: 1rem 0; }
.media img, .media video { width: 100%; height: auto; display: block; border-radius: 12px; border: 3px solid #fff; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.media audio { width: 100%; }
.media figcaption { color: var(--dim); font-size: .85rem; margin-top: .35rem; }
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.media-grid .media { margin: 0; }
.media-grid .media:nth-child(odd) img { transform: rotate(-1.5deg); }
.media-grid .media:nth-child(even) img { transform: rotate(1.5deg); }

/* ---------------------------------------------------------------- Formulare */
.stack { display: grid; gap: .75rem; max-width: 420px; margin: 1rem auto; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }

input, button { font: inherit; border-radius: 12px; padding: .85rem 1rem; }
input {
  background: rgba(0, 0, 0, .3);
  color: var(--fg);
  border: 2px solid var(--card-line);
  min-width: 0; flex: 1;
}
input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 60, .3); }
input[type="checkbox"] { flex: none; }
.inline { display: flex; gap: .4rem; align-items: center; }

button {
  background: linear-gradient(180deg, #ff6b78, var(--red));
  color: #fff;
  border: 0;
  font-weight: 800;
  letter-spacing: .03em;
  cursor: pointer;
  box-shadow: 0 4px 0 #b3202f;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3202f; }
button.ghost { background: transparent; color: var(--gold); border: 2px solid var(--gold); box-shadow: none; }
button.danger { background: #8b1d2a; box-shadow: none; }
button.mini { padding: .3rem .6rem; font-size: .75rem; border-radius: 8px; box-shadow: none; }
button[disabled] { opacity: .5; cursor: default; }

.step { border-top: 2px dashed var(--card-line); margin-top: 1.2rem; padding-top: 1.2rem; }
.answer { margin: 1rem 0 0; max-width: none; grid-template-columns: 1fr auto; }
.answer input { font-family: var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.feedback { min-height: 1.5em; color: var(--pink); margin: .6rem 0 0; font-weight: 700; }
.feedback.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.multi { display: grid; gap: .5rem; margin-top: 1rem; }
.check { display: flex; gap: .7rem; align-items: center; padding: .65rem .8rem; border-radius: 12px;
         background: rgba(255, 255, 255, .06); border: 2px solid var(--card-line); cursor: pointer; }
.check input { width: 1.3rem; height: 1.3rem; accent-color: var(--green); flex: none; padding: 0; }
.check:has(input:checked) { border-color: var(--green); background: rgba(53, 208, 127, .12); }
.multi button { margin-top: .4rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }
.choices .choice:last-child { background: linear-gradient(180deg, #4fe39a, #22a862); box-shadow: 0 4px 0 #157a45; }

.ok-block { border-left: 4px solid var(--green); padding-left: 1rem; margin: 1rem 0; }

.bigdigit {
  margin: 1.25rem 0; padding: 1rem;
  text-align: center; letter-spacing: .15em; font-weight: 800;
  border-radius: 16px; color: #3b2800;
  background: linear-gradient(135deg, #ffe08a, var(--gold));
  box-shadow: 0 0 30px rgba(255, 201, 60, .45);
}
.bigdigit strong { font-size: 3rem; display: block; letter-spacing: 0; line-height: 1.1; }

.hints { margin-top: 1.5rem; border-top: 2px dashed var(--card-line); padding-top: 1rem; }
.hint { background: rgba(255, 201, 60, .1); border-radius: 12px; padding: .7rem .9rem; }
.hint span { font-weight: 800; color: var(--gold); }

.back { margin-top: 2rem; }

/* ---------------------------------------------------------------- Wand-Chat (Tag 21) */
.wallchat { margin-top: 1rem; border-radius: 16px; overflow: hidden; background: #070b16; border: 1px solid rgba(255, 255, 255, .12); }
.chatlog { max-height: 55vh; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem;
           background: repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 2px, transparent 2px 40px); }
.bubble-w, .bubble-n { max-width: 85%; padding: .65rem .9rem; border-radius: 16px; line-height: 1.4; font-size: .95rem; }
.bubble-w { align-self: flex-start; background: #1b2238; color: #ffe9b0; border-bottom-left-radius: 4px; font-family: var(--mono); font-size: .88rem;
            box-shadow: 0 0 14px rgba(255, 201, 60, .12); }
.bubble-w small { display: block; margin-top: .35rem; font-size: .7rem; letter-spacing: .12em; color: var(--pink); }
.bubble-w.typing { opacity: .6; animation: blink 1s steps(1) infinite; }
.bubble-n { align-self: flex-end; background: var(--green); color: #052414; border-bottom-right-radius: 4px; font-weight: 600; }
.wallchat .chat-note { align-self: center; text-align: center; font-size: .82rem; opacity: .7; padding: .4rem 1rem; }
.wallchat .replay { margin-left: .35rem; padding: .15rem .55rem; font-size: .72rem; font-weight: 700; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--fg); box-shadow: none; border: 1px solid rgba(255,255,255,.18); }
.chatform { display: flex; gap: .5rem; padding: .8rem 1rem 1rem; }
.chatform input { border-radius: 999px; }
.chatform input:disabled { opacity: .4; }
.chatform button { border-radius: 999px; padding: .7rem 1rem; }

/* ---------------------------------------------------------------- Bestellung (Tag 15) */
.order { margin-top: 1rem; background: #fffaf2; color: #2b2b2b; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.shop { display: flex; align-items: center; gap: .8rem; padding: 1rem; background: #1b1b1b; color: #fff; border-radius: 16px 16px 0 0; }
.shop-logo { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: #c0392b; font-size: 1.3rem; flex: none; }
.shop-name strong { display: block; font-size: 1.3rem; letter-spacing: .25em; }
.shop-name small { color: #bbb; font-size: .78rem; }
.shop-to { margin-left: auto; text-align: right; font-size: .75rem; color: #bbb; line-height: 1.3; }
.shop-to b { color: #fff; font-size: .95rem; }
.order-meta { margin: 0; padding: .6rem 1rem; font: .78rem var(--mono); color: #8a7f6a; background: #f6eedf; }
.order .cat { margin: 0; padding: 1rem 1rem .35rem; font: 800 .75rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #c0392b; border-top: 1px dashed #e3d9c6; }
.item { display: grid; grid-template-columns: 2.4rem 1fr auto 2.3rem; gap: .6rem; align-items: center; padding: .5rem 1rem; transition: background .15s; }
.item .no { font: 700 .72rem var(--mono); color: #8a7f6a; background: #f1e8d8; border-radius: 8px; text-align: center; padding: .3rem 0; }
.item b { display: block; font-weight: 700; line-height: 1.25; }
.item small { display: block; color: #8a7f6a; font-size: .78rem; line-height: 1.3; }
.item .price { font: 600 .85rem var(--mono); white-space: nowrap; }
.order .add { width: 2.2rem; height: 2.2rem; padding: 0; border-radius: 50%; font-size: 1.2rem; line-height: 1;
              background: #fff; color: #c0392b; border: 2px solid #c0392b; box-shadow: none; }
.item.in { background: #fff0dc; }
.item.in .add { background: #2a9d5c; border-color: #2a9d5c; color: #fff; }
.pick { margin-top: .4rem; width: 100%; font: inherit; font-size: .9rem; padding: .45rem; border-radius: 8px; border: 2px solid #e0b36a; background: #fff; color: #2b2b2b; }
.cart { position: sticky; bottom: 92px; z-index: 5; border-radius: 0 0 16px 16px; box-shadow: 0 -6px 16px rgba(0, 0, 0, .25); display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; background: #1b1b1b; color: #fff; font-size: .9rem; line-height: 1.25; }
.cart-icon { font-size: 1.4rem; }
.cart > span:nth-child(2) { white-space: nowrap; }
.cart-sum { font-family: var(--mono); color: #ffc93c; }
.order .send { margin-left: auto; padding: .65rem 1.1rem; font-size: .95rem; white-space: nowrap; }

/* ---------------------------------------------------------------- Zentrale */
.digits { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1.1rem; flex-wrap: wrap; }
.digits .label { width: 100%; text-align: center; color: var(--dim); letter-spacing: .15em; font: 700 .75rem var(--mono); }
.digit {
  width: 3rem; height: 3.6rem; display: grid; place-items: center;
  border: 2px dashed var(--card-line); border-radius: 12px;
  font: 800 1.8rem var(--mono); color: var(--dim);
}
.digit.got { color: #3b2800; border: 0; background: linear-gradient(135deg, #ffe08a, var(--gold)); box-shadow: 0 0 16px rgba(255, 201, 60, .5); }

.chapter { margin-bottom: 1.6rem; }
.chapter h2 { display: flex; align-items: center; gap: .5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: .7rem; }

.tile {
  --c: var(--red);
  position: relative;
  aspect-ratio: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  border-radius: 14px; text-decoration: none; color: #fff;
  background: var(--c);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18), 0 6px 14px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.grid > :nth-child(6n+1) { --c: #e63946; }
.grid > :nth-child(6n+2) { --c: #2a9d5c; }
.grid > :nth-child(6n+3) { --c: #e9a400; }
.grid > :nth-child(6n+4) { --c: #2f7fd6; }
.grid > :nth-child(6n+5) { --c: #8e5cd9; }
.grid > :nth-child(6n+6) { --c: #e05597; }
.tile .num { position: relative; z-index: 1; font: 900 1.6rem var(--round); text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.tile .st { position: relative; z-index: 1; font: 700 .65rem var(--mono); letter-spacing: .1em; }

/* Geschenk: Schleifenband */
.tile.locked::before, .tile.locked::after { content: ""; position: absolute; background: rgba(255, 255, 255, .55); }
.tile.locked::before { left: 44%; width: 12%; top: 0; bottom: 0; }
.tile.locked::after { top: 44%; height: 12%; left: 0; right: 0; }
.tile.locked { filter: saturate(.75) brightness(.85); }
.tile.locked .num { background: rgba(0, 0, 0, .38); border-radius: 10px; padding: 0 .4rem; line-height: 1.3; }

.tile.new { animation: wiggle 2.4s ease-in-out infinite; box-shadow: 0 0 0 3px #fff, 0 0 22px 4px var(--c); }
.tile.opened { box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.tile.solved { background: rgba(255, 255, 255, .1); border: 2px solid var(--c); }
.tile.solved .num { color: var(--c); text-shadow: none; }
.tile.solved .st { font-size: 1.1rem; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-6deg); } 85% { transform: rotate(5deg); } 95% { transform: rotate(-2deg); } }

.countdown { font: 800 1.7rem var(--mono); color: var(--gold); letter-spacing: .06em; }

/* ---------------------------------------------------------------- Erfolg + Konfetti */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(13, 27, 61, .9);
}
.overlay[hidden] { display: none; }
.overlay-text {
  font: 900 clamp(1.8rem, 8vw, 3.2rem)/1.2 var(--round); text-align: center; color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 201, 60, .8);
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.overlay-text small { display: block; font-size: .45em; color: var(--fg); margin-top: .4rem; text-shadow: none; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 101; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------------------------------------------------------------- Freddy läuft */
.ground {
  position: fixed; left: 0; right: 0; bottom: 0; height: 34px; z-index: 3; pointer-events: none;
  background:
    radial-gradient(28px 14px at 30px 2px, #fff 98%, transparent) 0 0 / 90px 34px repeat-x,
    linear-gradient(#eef4ff, #d9e4f7);
  padding-bottom: env(safe-area-inset-bottom);
}
.runner {
  position: fixed; bottom: 26px; left: 0; z-index: 4;
  width: 78px; height: 60px;
  animation: run 16s linear infinite;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dog {
  width: 78px; height: 60px;
  background: url("dog.svg") 0 0 / 312px 60px no-repeat;
  image-rendering: pixelated;
  animation: trot .48s steps(4) infinite;
}
@keyframes trot { to { background-position: -312px 0; } }
@keyframes run { from { transform: translateX(-90px); } to { transform: translateX(calc(100vw + 10px)); } }
.runner.paused, .runner.paused .dog { animation-play-state: paused; }
.bubble {
  position: absolute; bottom: 64px; left: 0;
  white-space: nowrap; background: #fff; color: #222;
  font: 700 .8rem var(--round); padding: .4rem .7rem; border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}
.bubble::after { content: ""; position: absolute; left: var(--arrow, 22px); bottom: -6px; border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .snow, .snow::after, .garland i, .tile.new { animation: none; }
  .runner { animation-duration: 40s; }
}

/* ---------------------------------------------------------------- Admin */
.table-wrap { overflow-x: auto; }
table.admin { width: 100%; border-collapse: collapse; font: .8rem var(--mono); }
table.admin th, table.admin td { border-bottom: 1px solid var(--card-line); padding: .4rem; text-align: left; vertical-align: top; }
table.admin tr.solved td { color: var(--green); }
td.actions { display: flex; gap: .3rem; }
td.actions form { margin: 0; }
