:root {
  --plum: #2a1240;
  --plum-deep: #160a26;
  --rose: #f3c6d3;
  --rose-deep: #d98aa6;
  --gold: #e9c77b;
  --gold-deep: #b98a3a;
  --cream: #fff6ec;
  --ink: #3b2440;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --script: 'Great Vibes', 'Brush Script MT', cursive;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--plum-deep);
  font-family: var(--serif);
  color: var(--cream);
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

.hidden { display: none !important; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(42, 18, 64, 0.55), rgba(10, 4, 20, 0.85));
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 20;
}
.overlay.show { opacity: 1; pointer-events: auto; }

#intro { background: radial-gradient(ellipse at 50% 30%, #3d1d5c 0%, #1b0c2e 55%, #0b0414 100%); z-index: 30; }
#intro::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 30% 70%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 15%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 60%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 85%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 20% 90%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 35%, #fff6 50%, transparent 51%);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.4; } to { opacity: 1; } }

#login { z-index: 31; background: radial-gradient(ellipse at 50% 30%, #3d1d5c 0%, #1b0c2e 55%, #0b0414 100%); }

.intro-card, .gift-card, .calendar-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  text-align: center;
  padding: 32px 28px 26px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255, 246, 236, 0.10), rgba(255, 220, 235, 0.05));
  border: 1px solid rgba(233, 199, 123, 0.45);
  box-shadow: 0 0 0 6px rgba(233, 199, 123, 0.06), 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(243, 198, 211, 0.08);
  backdrop-filter: blur(6px);
}

.flourish { color: var(--gold); letter-spacing: 0.6em; font-size: 14px; opacity: 0.85; }

h1 {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(46px, 11vw, 72px);
  line-height: 1.05;
  margin: 10px 0 4px;
  color: var(--rose);
  text-shadow: 0 0 24px rgba(243, 198, 211, 0.55), 0 0 2px #fff;
}
.recipient { font-size: 22px; font-style: italic; color: var(--gold); margin: 6px 0 10px; }
.greeting { font-size: 19px; line-height: 1.45; color: #f5e9f0; margin: 0 0 18px; }
.signature { font-family: var(--script); font-size: 26px; color: var(--rose); margin: 18px 0 0; }

.hints {
  display: grid; gap: 7px;
  text-align: left;
  font-size: 16px;
  color: #e9dbe6;
  margin: 0 auto 22px;
  max-width: 400px;
}
.hints .key {
  display: inline-block; min-width: 64px; text-align: center;
  padding: 1px 6px; margin-right: 8px;
  border: 1px solid rgba(233, 199, 123, 0.4); border-radius: 6px;
  font-size: 13px; color: var(--gold);
}

.btn-gold {
  font-family: var(--serif);
  font-size: 20px; font-weight: 700;
  letter-spacing: 0.04em;
  color: #3a2208;
  padding: 12px 30px;
  border: none; border-radius: 999px;
  background: linear-gradient(180deg, #fbe7b0 0%, #e9c77b 45%, #c99a46 100%);
  box-shadow: 0 4px 18px rgba(233, 199, 123, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s;
}
.btn-gold:hover:not(:disabled) { transform: translateY(-1px) scale(1.03); box-shadow: 0 6px 26px rgba(233, 199, 123, 0.7), inset 0 1px 0 #fff; }
.btn-gold:disabled { opacity: 0.6; cursor: wait; }

#login input {
  width: 100%; max-width: 300px;
  font: inherit; font-size: 20px; text-align: center;
  padding: 10px 16px; margin: 0 0 16px;
  border-radius: 12px; border: 1px solid rgba(233, 199, 123, 0.5);
  background: rgba(255, 255, 255, 0.08); color: var(--cream);
  outline: none;
}
.login-error { color: #ffb3c6; min-height: 1.2em; margin: 10px 0 0; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
  z-index: 10;
}
#zone-name {
  font-family: var(--script);
  font-size: clamp(26px, 6vw, 38px);
  color: var(--rose);
  text-shadow: 0 0 14px rgba(243, 198, 211, 0.6), 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: opacity 0.8s;
}
.hud-buttons { display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.hud-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(233, 199, 123, 0.55);
  background: rgba(30, 12, 46, 0.55);
  color: var(--gold);
  font-size: 19px; font-family: var(--serif); font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.2s, transform 0.15s;
}
.hud-btn:hover { background: rgba(80, 36, 110, 0.7); transform: scale(1.06); }
.hud-btn.off { opacity: 0.5; }
#star-counter {
  white-space: nowrap;
  padding: 8px 14px; border-radius: 999px;
  background: rgba(30, 12, 46, 0.55);
  border: 1px solid rgba(233, 199, 123, 0.4);
  color: var(--gold); font-size: 17px; font-weight: 700;
  backdrop-filter: blur(4px);
}
#star-counter.bump { animation: bump 0.6s ease; }
@keyframes bump { 40% { transform: scale(1.35); box-shadow: 0 0 24px var(--gold); } }

#hover-label {
  position: fixed; z-index: 9;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(30, 12, 46, 0.7);
  border: 1px solid rgba(233, 199, 123, 0.5);
  color: var(--cream); font-size: 16px;
  pointer-events: none;
  opacity: 0; transform: translate(-50%, -150%);
  transition: opacity 0.15s;
  white-space: nowrap;
}
#hover-label.show { opacity: 1; }

#prompt {
  position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 11;
  animation: pulse 2s ease-in-out infinite;
}
#prompt:hover { transform: translateX(-50%) scale(1.04); }
#prompt.locked { background: linear-gradient(180deg, #e9dff0, #b9a7c8); color: #3b2440; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 34px rgba(233, 199, 123, 0.9), inset 0 1px 0 #fff; } }

#toast {
  position: fixed; left: 50%; top: 22%;
  transform: translate(-50%, 10px);
  z-index: 12;
  max-width: min(440px, calc(100% - 32px));
  padding: 14px 22px;
  border-radius: 16px;
  background: rgba(255, 246, 236, 0.92);
  color: var(--ink);
  font-size: 19px; line-height: 1.35; text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Joystick (Touch) ---------- */
#joystick {
  position: fixed; left: 24px; bottom: max(24px, env(safe-area-inset-bottom));
  width: 112px; height: 112px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(233, 199, 123, 0.35);
  z-index: 9;
  display: none;
}
body.touch.playing #joystick { display: block; }
#joystick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6e0, #e9c77b 60%, #a8782f);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* ---------- Geschenkkarte ---------- */
#card { z-index: 22; }
.gift-card {
  width: min(460px, 100%);
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.95), rgba(255, 245, 238, 0.97) 60%),
    #fff6ec;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 8px rgba(255, 246, 236, 0.12), 0 0 60px rgba(233, 199, 123, 0.5), 0 40px 90px rgba(0, 0, 0, 0.55);
  transform: scale(0.85) translateY(20px);
  transition: transform 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.gift-card::before {
  content: ''; position: absolute; inset: 8px; border-radius: 16px;
  border: 1px solid rgba(185, 138, 58, 0.45);
  pointer-events: none;
}
#card.show .gift-card { transform: none; }
.card-day {
  font-family: var(--script);
  font-size: 64px; line-height: 0.9;
  color: var(--rose-deep);
  text-shadow: 0 2px 0 #fff;
}
.card-emoji { font-size: 76px; margin: 4px 0 2px; filter: drop-shadow(0 6px 10px rgba(185, 138, 58, 0.35)); animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px) rotate(-3deg); } }
.gift-card h2 { font-size: 28px; margin: 6px 0 10px; color: #5a2a4e; }
.gift-card p { font-size: 19px; line-height: 1.5; margin: 0 0 12px; white-space: pre-line; }
#card-img-link { display: block; margin: 0 0 14px; }
#card-img-link[hidden] { display: none; }
#card-img {
  display: block; width: 100%; max-height: 46vh; object-fit: contain;
  border-radius: 10px; border: 2px solid var(--gold);
  box-shadow: 0 8px 24px rgba(90, 42, 78, 0.25); background: #fff;
}
.gift-card.left #card-text { text-align: left; }
.gift-card.code #card-text {
  text-align: left; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 13.5px/1.45 ui-monospace, "DejaVu Sans Mono", Menlo, monospace;
  background: #1b1f2e; color: #e8e4f4; padding: 12px 14px; border-radius: 10px;
}
.card-note { font-style: italic; color: var(--gold-deep); font-size: 17px !important; }
.close {
  position: absolute; top: 10px; right: 14px; z-index: 2;
  border: none; background: none; cursor: pointer;
  font-size: 30px; line-height: 1; color: inherit; opacity: 0.6;
}
.close:hover { opacity: 1; }

/* ---------- Kalender ---------- */
.calendar-card { width: min(560px, 100%); }
.calendar-card h2 { font-family: var(--script); font-weight: 400; font-size: 44px; margin: 0; color: var(--rose); }
.cal-sub { margin: 4px 0 16px; color: #e8d9e4; font-size: 17px; }
#cal-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
@media (max-width: 420px) {
  #cal-grid { gap: 6px; }
  .cal-day { font-size: 24px; border-radius: 9px; }
  .calendar-card h2 { font-size: 36px; }
  #zone-name { font-size: 24px; max-width: 40vw; line-height: 1.1; }
  .hud-btn { width: 38px; height: 38px; font-size: 17px; }
  #star-counter { padding: 6px 10px; font-size: 15px; }
}
body.touch .desk-only, body:not(.touch) .touch-only { display: none; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid rgba(233, 199, 123, 0.45);
  background: linear-gradient(160deg, rgba(243, 198, 211, 0.18), rgba(120, 70, 150, 0.15));
  color: var(--cream);
  font-family: var(--script); font-size: 30px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.cal-day:hover { transform: scale(1.07); background: rgba(243, 198, 211, 0.3); }
.cal-day .ico { position: absolute; right: 5px; bottom: 2px; font-family: var(--serif); font-size: 14px; }
.cal-day.opened { background: linear-gradient(160deg, rgba(233, 199, 123, 0.55), rgba(185, 138, 58, 0.35)); color: #fff; }
.cal-day.locked { opacity: 0.45; }
.cal-day.big { border-width: 2px; border-color: var(--gold); }
.cal-legend { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; font-size: 15px; color: #e8d9e4; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot.open { background: var(--gold); }
.dot.ready { background: var(--rose); }
.dot.locked { background: #6b5a78; }

#fade {
  position: fixed; inset: 0; z-index: 25;
  background: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity 0.7s ease;
}
#fade.on { opacity: 1; }
