*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #1c2433;
  --bg-mid: #2a3548;
  --accent: #6b8cae;
  --accent-soft: #8fa8c4;
  --text: #eef2f7;
  --text-muted: rgba(238, 242, 247, 0.62);
  --surface: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.12);
  --btn-bg: linear-gradient(135deg, #7a9bbf, #5a7a9a);
  --note-bg: #fef9e7;
  --note-text: #2a2a2a;
  --red: #b42318;
  --red-bright: #c93025;
  --cream: #f4f4f0;
  --soft-black: #141414;
  --soft-white: #f0f0eb;
}

body.theme-correct {
  --bg-deep: #141414;
  --bg-mid: #1e1e1e;
  --accent: #b42318;
  --accent-soft: #c93025;
  --text: #f0f0eb;
  --text-muted: rgba(240, 240, 235, 0.65);
  --surface: rgba(244, 244, 240, 0.06);
  --border: rgba(244, 244, 240, 0.14);
  --btn-bg: linear-gradient(135deg, #c93025, #b42318);
}

html { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(ellipse at 50% 20%, var(--bg-mid) 0%, var(--bg-deep) 72%);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 1.2s ease, color 0.8s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body.theme-correct {
  background: radial-gradient(ellipse at 50% 25%, #2a1515 0%, var(--bg-deep) 70%);
}

.hidden { display: none !important; }

.app {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 3rem;
  position: relative;
  z-index: 2;
}

.panel {
  width: min(92vw, 420px);
  text-align: center;
  animation: fadeUp 0.6s ease-out both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

.emoji-hero { font-size: clamp(2.5rem, 12vw, 3.5rem); margin-bottom: 0.75rem; }
.emoji-hero.wiggle { animation: wiggle 2s ease-in-out infinite; }

h1 {
  font-size: clamp(1.35rem, 5vw, 1.6rem);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.lead {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

.step-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-soft);
  margin-bottom: 0.5rem;
}

.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.85rem 1.6rem;
  background: var(--btn-bg);
  color: #fff;
  transition: transform 0.15s ease, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.feedback {
  min-height: 1.4rem;
  font-size: 0.88rem;
  margin-top: 0.75rem;
  color: var(--accent-soft);
}
.feedback.err { color: #e07070; }

.progress-dots {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.progress-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}
.progress-dots span.on { background: var(--accent-soft); transform: scale(1.15); }

/* Date picker */
.date-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
  text-align: left;
  align-items: end;
}
.date-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.date-picker label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
  min-height: 1.2em;
}
.date-picker select {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23aaa' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

/* Color tiles */
.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 1.25rem 0;
}
.color-tile {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}
.color-tile:active { transform: scale(0.95); }
.color-tile.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(0,0,0,0.35);
  transform: scale(1.04);
}
.color-tile.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(0,0,0,0.5);
  text-shadow: 0 1px 2px rgba(255,255,255,0.5);
}
.color-tile[data-id="white"].selected::after,
.color-tile[data-id="yellow"].selected::after { color: rgba(0,0,0,0.45); }

.pick-hint { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* Sparkles layer */
.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}
.sparkle {
  position: absolute;
  top: -2rem;
  font-size: 1rem;
  animation: fall linear forwards;
  opacity: 0.35;
}
.sparkle-burst {
  animation: burstOut 1.4s ease-out forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(220deg); opacity: 0.12; }
}
@keyframes burstOut {
  0% { transform: scale(0.4) translateY(10vh); opacity: 1; }
  100% { transform: scale(1.4) translateY(-55vh) rotate(200deg); opacity: 0; }
}

body[data-sparkle="1"] .sparkle { opacity: 0.45; }
body[data-sparkle="2"] .sparkle { opacity: 0.55; }
body[data-sparkle="3"] .sparkle { opacity: 0.7; }

/* Envelope */
.envelope-wrap {
  margin: 2rem 0;
  cursor: pointer;
  display: inline-block;
}
.envelope {
  font-size: 5rem;
  display: inline-block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.4));
  transition: transform 0.2s;
}
.envelope-wrap.shake .envelope { animation: shake 0.6s ease-in-out infinite; }
.envelope-wrap:hover .envelope { transform: scale(1.05); }

/* Cards / sticky notes */
.cards-stage {
  position: relative;
  min-height: 340px;
  width: min(92vw, 360px);
  margin: 0 auto;
  perspective: 900px;
}

.sticky {
  width: 100%;
  min-height: 280px;
  padding: 1.65rem 1.45rem;
  background: var(--note-bg);
  color: var(--note-text);
  border-radius: 6px;
  box-shadow: 2px 6px 18px rgba(0, 0, 0, 0.28), 0 1px 0 rgba(255, 255, 255, 0.45) inset;
  text-align: left;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.22rem;
  line-height: 1.65;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%) rotate(var(--rot, -1deg)) translateY(var(--lift, 0)) scale(var(--scale, 1));
  transform-origin: center top;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.sticky.deck-card.back-card {
  filter: brightness(0.94);
  pointer-events: none;
}
.sticky.back-card-shadow {
  min-height: 260px;
  background: #f5efd8;
  box-shadow: 1px 3px 10px rgba(0, 0, 0, 0.18);
}

.sticky.top-card {
  cursor: pointer;
  box-shadow: 3px 8px 24px rgba(0, 0, 0, 0.32), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}
.sticky.top-card.enter {
  animation: cardIn 0.4s ease-out both;
}
.sticky.top-card.promote {
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.sticky.top-card::after {
  content: 'tap →';
  position: absolute;
  bottom: 0.85rem;
  right: 1rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(42, 42, 42, 0.35);
  font-weight: 600;
}

.sticky.top-card.final-note {
  cursor: default;
}
.sticky.festive-note::after,
.sticky.top-card.final-note::after { display: none; }

.sticky.top-card.fly-right {
  animation: flyRight 0.42s ease-in forwards;
  pointer-events: none;
}
.sticky.top-card.fly-left {
  animation: flyLeft 0.42s ease-in forwards;
  pointer-events: none;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateX(-50%) rotate(var(--rot)) translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) rotate(var(--rot)) translateY(var(--lift)) scale(var(--scale)); }
}
@keyframes flyRight {
  to {
    transform: translateX(calc(-50% + 115vw)) rotate(14deg) translateY(var(--lift)) scale(var(--scale));
    opacity: 0;
  }
}
@keyframes flyLeft {
  to {
    transform: translateX(calc(-50% - 80vw)) rotate(-14deg) translateY(var(--lift)) scale(var(--scale));
    opacity: 0;
  }
}

.sticky.festive-note {
  background: linear-gradient(160deg, #fff5f5 0%, #ffe8e8 100%);
  border-top: 5px solid var(--red-bright);
  text-align: center;
}

.sticky.gift-note {
  background: linear-gradient(165deg, #fff8f8 0%, #ffe4e4 45%, #fef9e7 100%);
  border: 2px solid rgba(180, 35, 24, 0.35);
  box-shadow: 0 10px 32px rgba(180, 35, 24, 0.22), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
  text-align: center;
}
.sticky.gift-note.top-card.gift-pop {
  animation: giftPopIn 0.55s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes giftPopIn {
  0% { opacity: 0; transform: translateX(-50%) rotate(var(--rot)) scale(0.88) translateY(24px); }
  70% { transform: translateX(-50%) rotate(var(--rot)) scale(1.04) translateY(var(--lift)); }
  100% { opacity: 1; transform: translateX(-50%) rotate(var(--rot)) scale(var(--scale)) translateY(var(--lift)); }
}
.gift-reveal {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.45;
  color: #8a1818;
  margin: 1rem 0 0.65rem;
}
.gift-tag {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--red-bright);
  letter-spacing: 0.04em;
}
.sticky.gift-note p:first-child {
  font-size: 1.05rem;
  color: #3a3a3a;
}
.sticky.gift-note.top-card::after { display: none; }

.feliz-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.feliz-row span { font-size: 1.5rem; }
.feliz-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--red-bright);
  letter-spacing: 0.02em;
  margin: 0;
}
.feliz-sub {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #8a2020;
  margin-bottom: 1rem;
}
.tulip-photo {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 6px 20px rgba(180, 35, 24, 0.25);
}

.card-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
}
.card-counter {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: 0.35rem;
}

.signature {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  right: max(1rem, env(safe-area-inset-right));
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.5;
  z-index: 3;
}

.theme-flash {
  animation: themeFlash 0.8s ease-out;
}
@keyframes themeFlash {
  0% { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

.reveal-line {
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0.75rem 0;
  animation: fadeUp 0.5s ease-out both;
}
.reveal-line.delay-1 { animation-delay: 0.4s; }
.reveal-line.delay-2 { animation-delay: 0.9s; }
.reveal-line.delay-3 { animation-delay: 1.4s; }


.sticky p + p { margin-top: 0.85rem; }

.final-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1.25rem;
}
.final-card-actions .btn { width: 100%; }
.sticky .btn-ghost,
.final-card-actions .btn-ghost {
  background: rgba(42, 42, 42, 0.07);
  border: 1px solid rgba(42, 42, 42, 0.28);
  color: #2a2a2a;
}
.sticky .btn-ghost:active,
.final-card-actions .btn-ghost:active {
  background: rgba(42, 42, 42, 0.12);
}
.final-card-actions .btn-ghost { font-size: 0.88rem; }

.final-sparkle-burst {
  font-size: 2rem;
  margin-top: 1rem;
  letter-spacing: 0.3rem;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
