:root {
  --bg1: #17493c;
  --bg2: #0b2a24;
  --bg3: #061a16;
  --red: #c0272d;
  --red-d: #8f171d;
  --gold: #e8c066;
  --gold-d: #b8913a;
  --paper: #fff8e7;
  --paper-2: #f6ead0;
  --ink: #3a2a1f;
  --script: "Snell Roundhand", "Apple Chancery", "Segoe Script", "Brush Script MT", "Lucida Handwriting", cursive;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html { background: #061a16; }
body {
  margin: 0;
  min-height: 100vh;
  color: #f7efd9;
  font: 16px/1.5 var(--sans);
  padding-bottom: env(safe-area-inset-bottom);
}
/* Hintergrund als feste Ebene – funktioniert auch auf iPhone/iPad zuverlässig */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg1), transparent 70%),
    linear-gradient(180deg, var(--bg2), var(--bg3));
}
body.lock { overflow: hidden; }
[hidden] { display: none !important; }

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.hero, .toolbar, main, .foot { position: relative; z-index: 1; }

/* ---------- Kopfbereich ---------- */
.hero { text-align: center; padding: 0 20px 18px; max-width: 760px; margin: 0 auto; }
.lights {
  height: 18px; margin: 0 -20px 14px;
  background:
    radial-gradient(circle at 10px 9px, #ff5a5a 0 4px, transparent 5px) 0 0 / 60px 18px repeat-x,
    radial-gradient(circle at 30px 9px, #ffd45e 0 4px, transparent 5px) 0 0 / 60px 18px repeat-x,
    radial-gradient(circle at 50px 9px, #6fd0ff 0 4px, transparent 5px) 0 0 / 60px 18px repeat-x;
  filter: drop-shadow(0 0 5px rgba(255, 220, 120, .7));
  animation: glow 2.4s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }
.hero h1 {
  margin: 8px 0 6px;
  font: 400 clamp(1.9rem, 7.4vw, 4rem)/1.15 var(--script);
  overflow-wrap: anywhere;
  color: var(--gold);
  text-shadow: 0 2px 0 #7b5a1c, 0 0 22px rgba(232, 192, 102, .45);
}
.intro { margin: 0 auto 14px; max-width: 56ch; color: #e8dfc4; white-space: pre-line; }
.progress { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; max-width: 420px; margin: 0 auto; }
.progress span {
  display: block; height: 100%; width: 0; border-radius: inherit; transition: width .7s ease;
  background: repeating-linear-gradient(45deg, var(--red) 0 10px, #fff 10px 20px);
}
.statline { margin: 8px 0 0; font-size: .95rem; color: #d8cfae; }
.live { margin-left: 6px; font-size: .78rem; padding: 1px 8px 1px 18px; border-radius: 99px; background: rgba(255, 255, 255, .1); position: relative; }
.live::before { content: ""; position: absolute; left: 7px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #62d26f; box-shadow: 0 0 0 0 rgba(98, 210, 111, .7); animation: ping 2s infinite; }
.live.off::before { background: #c9b87a; animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(98, 210, 111, 0); } 100% { box-shadow: 0 0 0 0 rgba(98, 210, 111, 0); } }

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  padding: 10px 16px;
  background: rgba(6, 26, 22, .78);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(232, 192, 102, .25);
}
.seg { display: inline-flex; border: 1px solid rgba(232, 192, 102, .5); border-radius: 99px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: #f2e8c8; padding: 8px 16px; font: inherit; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--gold); color: #3b2a08; font-weight: 700; }
.toolbar input[type=search] {
  flex: 1 1 180px; max-width: 280px; padding: 8px 14px; border-radius: 99px;
  border: 1px solid rgba(232, 192, 102, .4); background: rgba(255, 255, 255, .08); color: #fff; font: inherit;
}
.toolbar input::placeholder { color: #bdb393; }
.ghost { background: transparent; color: var(--gold); border: 1px dashed rgba(232, 192, 102, .6); border-radius: 99px; padding: 7px 14px; font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid #ffe08a; outline-offset: 2px; }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- Liste ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
  position: relative; overflow: hidden;
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink);
  border-radius: 14px; padding: 16px 16px 16px 26px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  animation: rise .5s ease both; animation-delay: calc(var(--i, 0) * 40ms);
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: repeating-linear-gradient(45deg, var(--red) 0 8px, #fff 8px 16px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card.gone { animation: poof .6s ease forwards; pointer-events: none; }
@keyframes poof { to { opacity: 0; transform: scale(.92) translateY(-8px); } }
.card-main { min-width: 0; flex: 1; }
.card-title { margin: 0 0 4px; font: 700 1.1rem/1.3 var(--serif); overflow-wrap: anywhere; }
.card-note { margin: 0 0 6px; color: #6d5a49; font-size: .92rem; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .92rem; }
.price { font-weight: 700; color: #7a4b13; }
.shop { color: #0f5b45; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.card-side { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.qty { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f6d98c, var(--gold-d)); color: #3b2a08; line-height: 1; box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .25); }
.qty strong { font: 800 1.45rem/1 var(--sans); }
.qty small { font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; margin-top: -10px; }
.qty.bump strong { animation: bump .6s ease; }
@keyframes bump { 30% { transform: scale(1.6); color: var(--red-d); } 100% { transform: scale(1); } }

.btn {
  border: 0; border-radius: 99px; padding: 10px 20px; font: 700 1rem var(--sans); cursor: pointer; color: #fff;
  background: linear-gradient(180deg, #db3a40, var(--red-d));
  box-shadow: 0 3px 0 #5f0f13, 0 6px 12px rgba(0, 0, 0, .25);
  transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5f0f13; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: grayscale(.4); transform: none; }
.btn.secondary { background: #fff; color: var(--ink); box-shadow: 0 0 0 1px #cdbf9d inset; }
.btn.link { background: none; box-shadow: none; color: #6d5a49; text-decoration: underline; padding: 6px 10px; font-weight: 600; }

.empty { text-align: center; font: 1.2rem var(--serif); color: var(--gold); padding: 30px 10px; }

/* ---------- Baum ---------- */
.treewrap { max-width: 660px; margin: 0 auto; }
#tree { display: block; width: 100%; height: auto; overflow: visible; }
.hint { text-align: center; color: #cfc6a6; font-size: .95rem; margin: 6px 0 0; }
.tagslot { cursor: pointer; outline: none; }
.sway { transform-box: fill-box; transform-origin: 50% 0; animation: sway 4.5s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
#tree.calm .sway { animation: none; }
.tagslot:hover .sway, .tagslot:focus-visible .sway { animation-play-state: paused; }
@keyframes sway { from { transform: rotate(-3.5deg); } to { transform: rotate(3.5deg); } }
.tag { transform-box: fill-box; transform-origin: 50% 0; transition: transform .25s ease, opacity .6s ease; }
.tagslot:hover .tag, .tagslot:focus-visible .tag { transform: scale(1.25); }
.tagslot:focus-visible .paper { stroke: #fff; stroke-width: 2; }
.tagslot.gone { pointer-events: none; }
.tagslot.gone .tag { transform: translateY(90px) rotate(24deg); opacity: 0; }
.tagslot.instant .tag { transition: none !important; }
.tagslot.dim .tag { opacity: .22; }
.twinkle { animation: twinkle 1.8s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
@keyframes twinkle { from { opacity: .3; } to { opacity: 1; } }
.starglow { animation: starglow 3s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes starglow { from { transform: scale(.94); } to { transform: scale(1.06); } }

/* ---------- Dialog ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(2, 12, 10, .7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(180deg, var(--paper), var(--paper-2)); color: var(--ink);
  border-radius: 18px; padding: 24px 22px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  border-top: 8px solid var(--red); position: relative; animation: pop .25s ease;
}
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.panel:focus { outline: none; }
.panel h2 { margin: 0 28px 6px 0; font: 700 1.35rem/1.25 var(--serif); overflow-wrap: anywhere; }
.panel .x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: #7a6a58; cursor: pointer; padding: 4px 8px; }
.panel p { margin: 6px 0; }
.panel .note { color: #6d5a49; }
.panel label { display: block; font-weight: 700; margin: 14px 0 4px; }
.panel .help { font-size: .86rem; color: #7a6a58; margin: 3px 0 0; }
.panel select, .panel input[type=text] { width: 100%; padding: 11px 12px; font: 1rem var(--sans); border: 1px solid #cdbf9d; border-radius: 10px; background: #fff; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.notice { margin: 10px 0 0; padding: 9px 12px; border-radius: 10px; background: #fde7d7; border: 1px solid #e8a77a; color: #6a2d0b; }
.summary { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px dashed #cdbf9d; }
.big { font-size: 3rem; text-align: center; margin: 4px 0; }
.mine-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #e6dabb; }
.mine-row:last-child { border-bottom: 0; }

.foot { text-align: center; padding: 10px 0 26px; color: #a99f80; font-size: .9rem; }

@media (max-width: 520px) {
  .card { flex-wrap: wrap; }
  .card-side { flex-direction: row; width: 100%; justify-content: space-between; }
  .card-side .btn { margin-left: auto; }
  .toolbar { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Zugangsseite ---------- */
.gate { position: relative; z-index: 1; max-width: 420px; margin: 8px auto 40px; padding: 0 16px; }
.gate .panel { animation: none; }
.gate form { margin: 0; }
.gate input[type=password] { width: 100%; padding: 11px 12px; font: 1rem var(--sans); border: 1px solid #cdbf9d; border-radius: 10px; background: #fff; color: var(--ink); }
.gate .notice { margin-top: 12px; }
.foot a { color: inherit; }
