:root {
  --bg1: #6c4a9e; /* gengar purple */
  --bg2: #f7c3d8; /* barbie powder pink */
  --ink: #3a2530;
  --muted: #8a6b78;
  --accent: #e8487a;
  --accent-2: #ff8a5c;
  --card: rgba(255, 255, 255, 0.78);
  --line: rgba(58, 37, 48, 0.12);
  --ok: #2fa56b;
  --bad: #d9435e;
  --radius: 24px;
  --serif: ui-serif, "New York", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--bg1);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(170deg, var(--bg1) 0%, #a86fb8 45%, var(--bg2) 100%);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Background blobs */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg span {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite alternate;
}
.bg span:nth-child(1) { width: 320px; height: 320px; background: #8a5cc4; top: -80px; left: -100px; }
.bg span:nth-child(2) { width: 280px; height: 280px; background: #ffb6d5; bottom: -60px; right: -90px; animation-delay: -6s; }
.bg span:nth-child(3) { width: 220px; height: 220px; background: #e3c6ff; top: 45%; left: 55%; animation-delay: -12s; }
@keyframes float {
  to { transform: translate(40px, 60px) scale(1.15); }
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.screen { opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.screen.in { opacity: 1; transform: none; }

.card {
  background: var(--card);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: 0 24px 50px -24px rgba(160, 50, 90, 0.4);
}
.card + .card { margin-top: 16px; }
.center { text-align: center; }

.emoji { font-size: 56px; line-height: 1; text-align: center; margin-bottom: 8px; }
.lock { transition: transform 0.4s cubic-bezier(.3, 1.6, .5, 1); }
.lock.open { transform: scale(1.25) rotate(-10deg); }

.title {
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 8px 0 12px;
}
.lead { color: var(--muted); line-height: 1.55; margin: 0 0 20px; font-size: 16px; }
.riddle {
  background: #fff;
  border: 1.5px dashed rgba(232, 72, 122, 0.35);
  border-radius: 16px;
  padding: 16px;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 18px;
  white-space: pre-line;
}

/* Progress */
.progress { margin: 0 4px 14px; }
.progress-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
}
.bar { height: 6px; background: rgba(255, 255, 255, 0.8); border-radius: 99px; overflow: hidden; }
.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.7s ease;
}

.question {
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.3;
  margin: 0 0 20px;
}
.q-img { display: block; width: 100%; border-radius: 16px; margin-bottom: 18px; }

/* Inputs & buttons (font-size >= 16px stops iOS from zooming in on focus) */
.input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(232, 72, 122, 0.15); }
.input.ok { border-color: var(--ok); background: #f1faf5; }

.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 24px -12px rgba(232, 72, 122, 0.8);
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn.ghost {
  background: #fff;
  color: var(--accent);
  border: 1.5px solid rgba(232, 72, 122, 0.3);
  box-shadow: none;
}

.msg { min-height: 1.4em; margin: 12px 0 0; font-size: 15px; line-height: 1.4; color: var(--muted); text-align: center; }
.msg.bad { color: var(--bad); }

.options { display: grid; gap: 10px; }
.option {
  font: inherit;
  font-size: 16px;
  text-align: left;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.option:active { transform: scale(0.98); }
.option:disabled { opacity: 0.5; cursor: default; }
.option.ok { border-color: var(--ok); background: #e8f7ef; color: #1c6b45; font-weight: 600; }
.option.ok:disabled { opacity: 1; }
.option.bad { border-color: var(--bad); background: #fdecef; color: var(--bad); text-decoration: line-through; }

.after { display: none; }
.after.show { display: block; animation: pop 0.4s ease; }
.reaction { margin: 20px 0 4px; text-align: center; font-size: 17px; line-height: 1.45; }

/* Final */
.wishes p { font-size: 17px; line-height: 1.65; margin: 0 0 14px; white-space: pre-line; }
.signature { font-family: var(--serif); font-style: italic; font-size: 1.2rem; text-align: right; margin-top: 18px; }

.gift-title { font-family: var(--serif); font-size: 1.35rem; line-height: 1.3; margin: 0 0 16px; text-align: center; }
.scratch {
  position: relative;
  height: 120px;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  border: 2px dashed rgba(232, 72, 122, 0.35);
  display: grid;
  place-items: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.code-label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-align: center;
}
.scratch-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  transition: opacity 0.6s ease;
}
.scratch-cover.gone { opacity: 0; pointer-events: none; }
.scratch-hint { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 0; }

.parcel-info { display: none; margin-top: 18px; }
.parcel-info.show { display: block; animation: pop 0.5s ease; }
.rows { display: grid; gap: 10px; margin: 0 0 6px; }
.row { background: #fff; border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); }
.row dt { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.row dd { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }
.note { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; margin: 14px 0 0; }

/* Animations */
.shake { animation: shake 0.4s; }
@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }

@media (prefers-reduced-motion: reduce) {
  .bg span { animation: none; }
  .screen { transition: opacity 0.3s; transform: none; }
}
