/* Вёрстка под iPhone 16 (393×852): один экран за раз, всё по центру колонки,
   каждый блок выглядит как стикер — тёмный контур, белая обводка, мягкая тень. */
:root {
  --sage-1: #A9C79B;
  --sage-2: #D2DDA2;
  --cream: #FFF8EC;
  --ink: #4A2E1F;
  --tiger: #F2A541;
  --tiger-dark: #E8913A;
  --dragon: #7B5EA7;
  --blush: #F7C6D0;
  --wrong: #E5534B;
  --right: #6DAE5B;
  --white: #FFFFFF;

  --f-bubbles: "Rubik Bubbles", "Nunito", system-ui, sans-serif;
  --f-hand: "Neucha", "Comic Sans MS", cursive;
  --f-body: "Nunito", system-ui, -apple-system, sans-serif;

  --line: 2.5px solid var(--ink);
  --sticker: 0 0 0 5px var(--white), 0 8px 0 5px rgba(74, 46, 31, .18);
  --press: 0 5px 0 var(--ink);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --gutter: 16px;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: linear-gradient(170deg, var(--sage-1), var(--sage-2));
  color: var(--ink);
  font: 500 16px/1.45 var(--f-body);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' fill='none' stroke='%233C5028' stroke-opacity='.17' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M30 38c-6-8-18-2-12 7l12 11 12-11c6-9-6-15-12-7z'/%3E%3Cpath d='M120 20l4 9 10 1-7 7 2 10-9-5-9 5 2-10-7-7 10-1z'/%3E%3Ccircle cx='118' cy='112' r='14'/%3E%3Cpath d='M118 112c0-5 6-5 6 0s-9 7-11 0 5-13 13-9'/%3E%3Cpath d='M28 118c8-6 16 6 24 0s16 6 24 0'/%3E%3Cpath d='M70 70l10-6 10 6-10 6z'/%3E%3C/svg%3E");
  background-size: 160px;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

/* ---------- экраны ---------- */
.screen {
  position: fixed; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.stack {
  min-height: 100%;
  max-width: 393px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center;
}
.stack > * { animation: pop .6s var(--spring) both; animation-delay: calc(var(--i, 0) * 80ms); }
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.92); } }

/* ---------- общие элементы ---------- */
.eyebrow { font: 26px/1 var(--f-hand); color: var(--dragon); margin: 0; }
.big {
  margin: 0; font: 400 64px/.95 var(--f-bubbles); color: var(--tiger);
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink); text-wrap: balance;
}
.title {
  margin: 0; font: 400 34px/1.05 var(--f-bubbles); color: var(--dragon); text-wrap: balance;
}
.dates { font: 22px/1 var(--f-hand); margin: 0; }

.bubble {
  position: relative; margin: 6px 0 0;
  background: var(--white); border: var(--line); border-radius: 22px;
  padding: 10px 18px; font: 22px/1.2 var(--f-hand); max-width: 92%;
}
.bubble::after {
  content: ""; position: absolute; left: 28px; top: -12px; width: 18px; height: 18px;
  background: var(--white); border-left: var(--line); border-top: var(--line);
  transform: rotate(45deg);
}

.btn {
  font: 800 18px/1 var(--f-body); background: var(--tiger);
  border: var(--line); border-radius: 999px; padding: 17px 36px;
  box-shadow: var(--press); cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: translateY(4px) scale(1.03, .94); box-shadow: 0 1px 0 var(--ink); }
:focus-visible { outline: 3px dashed var(--dragon); outline-offset: 4px; }

.bob { animation: pop .6s var(--spring) both, bob 3.2s ease-in-out .6s infinite; animation-delay: calc(var(--i, 0) * 80ms), 0s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }

/* ---------- обложка ---------- */
.hero-sticker { width: 72%; }

/* ---------- секретный код ---------- */
#lock .stack { justify-content: flex-start; padding-top: 4vh; } /* чтобы с открытой клавиатурой всё было видно */
.lock-sticker { width: 150px; }
.lock-text { margin: 0; font: 800 20px/1.35 var(--f-body); text-wrap: balance; }
.pin { position: relative; display: flex; gap: 12px; }
.pin input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; font-size: 16px; /* 16px — чтобы iOS не зумил страницу */
  color: transparent; caret-color: transparent; background: none;
}
.pin .cell {
  width: 60px; height: 72px; display: grid; place-items: center;
  background: var(--white); border: var(--line); border-radius: 18px; box-shadow: var(--press);
  font: 400 40px/1 var(--f-bubbles); color: var(--dragon);
  transition: transform .15s var(--spring), background .2s;
}
.pin .cell.active { transform: translateY(-4px); background: #FFE9C7; }
.pin.wrong { animation: shake .4s ease-in-out; }
.pin.wrong .cell { animation: blink .45s ease-in-out 2; }
.pin.right .cell { background: var(--right); color: var(--white); animation: picked .5s var(--spring) both; }
.pin.right .cell:nth-child(3) { animation-delay: .06s; }
.pin.right .cell:nth-child(4) { animation-delay: .12s; }
.pin.right .cell:nth-child(5) { animation-delay: .18s; }
#lock .hint { align-self: center; }

/* ---------- карусель ---------- */
.carousel {
  width: calc(100% + 2 * var(--gutter)); margin-inline: calc(-1 * var(--gutter));
  display: flex; gap: 18px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 14px 11%; scroll-padding-inline: 11%;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 78%; margin: 0; scroll-snap-align: center; display: grid; gap: 14px; }
.photo {
  position: relative; aspect-ratio: 3 / 4; max-width: 100%;
  background: var(--white); border: var(--line); border-radius: 22px;
  box-shadow: var(--sticker); overflow: hidden;
  transform: rotate(var(--tilt, 0deg));
}
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo.empty { background: var(--cream); display: grid; place-items: center; }
.photo.empty img { width: 55%; height: auto; object-fit: contain; opacity: .9; }
.photo.empty span { position: absolute; bottom: 14px; inset-inline: 0; font: 18px/1.2 var(--f-hand); opacity: .7; }
.slide figcaption { font: 22px/1.2 var(--f-hand); text-wrap: balance; }
.dots { display: flex; gap: 8px; }
.photo-count {
  margin: 0; font: 700 15px/1 var(--f-body); font-variant-numeric: tabular-nums;
  background: var(--white); border: 2px solid var(--ink); border-radius: 999px; padding: 6px 14px;
}
.photo-count b { color: var(--tiger-dark); }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); background: var(--white); transition: background .2s, transform .2s; }
.dots i.on { background: var(--tiger); transform: scale(1.25); }

/* ---------- выбор ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; }
.card {
  border: var(--line); border-radius: 24px; padding: 12px 8px 14px;
  display: grid; gap: 8px; justify-items: center; align-content: end; cursor: pointer;
  font: 800 16px/1.15 var(--f-body);
  box-shadow: var(--press);
  transition: transform .12s, box-shadow .12s;
}
.card:nth-child(1) { background: #FFE9C7; }
.card:nth-child(2) { background: #E4F0D8; }
.card:nth-child(3) { background: #ECE3F7; }
.card:nth-child(4) { background: #FCE3E9; }
.card img { height: 118px; width: auto; object-fit: contain; }
.card:active { transform: translateY(4px) scale(1.04, .93); box-shadow: 0 1px 0 var(--ink); }
.card.picked { animation: picked .5s var(--spring) both; }
.cards.done .card:not(.picked) { opacity: .35; transition: opacity .3s; }
.card { position: relative; }
.card.used { cursor: default; filter: grayscale(.85); opacity: .5; box-shadow: 0 2px 0 var(--ink); transform: translateY(3px); }
.used-badge {
  position: absolute; top: 10px; right: -6px; transform: rotate(8deg);
  background: var(--white); border: 2px solid var(--ink); border-radius: 999px;
  padding: 3px 10px; font: 18px/1 var(--f-hand);
}
@keyframes picked { 40% { transform: scale(1.1) rotate(-3deg); } 100% { transform: scale(1.05); } }

/* ---------- квиз ---------- */
.quiz-head { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.quiz-head img { width: 76px; height: 76px; object-fit: contain; flex: none; }
.quiz-head .eyebrow { font-size: 24px; }
.counter { margin: 4px 0 0; font: 700 14px/1 var(--f-body); opacity: .7; font-variant-numeric: tabular-nums; }
.progress { width: 100%; height: 16px; border: var(--line); border-radius: 999px; background: var(--white); overflow: hidden; }
.progress i {
  display: block; height: 100%;
  background: repeating-linear-gradient(-45deg, var(--tiger) 0 10px, var(--tiger-dark) 10px 20px);
  transition: width .6s var(--spring);
}
.qq { font: 800 22px/1.3 var(--f-body); margin: 6px 0 0; text-wrap: balance; }
.opts { display: grid; gap: 12px; width: 100%; }
.opt {
  font: 700 17px/1.25 var(--f-body); text-align: left;
  background: var(--white); border: var(--line); border-radius: 18px; padding: 15px 18px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .3s;
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.opt.tried { opacity: .45; }
.opt.wrong { animation: blink .5s ease-in-out 2, shake .4s ease-in-out; }
.opt.right { background: var(--right); color: var(--white); animation: picked .5s var(--spring) both; }
.opts.locked .opt { pointer-events: none; }
@keyframes blink { 50% { background: var(--wrong); color: var(--white); } }
@keyframes shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
.hint { align-self: flex-start; }

/* ---------- подарок ---------- */
.giftbox {
  position: relative; width: 230px; height: 270px;
  background: none; border: 0; padding: 0; cursor: pointer;
  animation: pop .6s var(--spring) both, wiggle 3s ease-in-out 1.2s infinite;
}
.giftbox .box, .giftbox .lid {
  position: absolute; border: 3px solid var(--ink);
  background: linear-gradient(90deg, transparent calc(50% - 17px), var(--dragon) calc(50% - 17px) calc(50% + 17px), transparent calc(50% + 17px)), var(--blush);
}
.giftbox .box { left: 12px; right: 12px; bottom: 6px; height: 160px; border-radius: 0 0 24px 24px; box-shadow: var(--sticker); }
.giftbox .lid { left: 0; right: 0; bottom: 162px; height: 54px; border-radius: 18px; z-index: 1; box-shadow: 0 5px 0 rgba(74, 46, 31, .25); }
.giftbox .lid::before, .giftbox .lid::after {
  content: ""; position: absolute; top: -40px; width: 58px; height: 42px;
  background: var(--dragon); border: 3px solid var(--ink); border-radius: 50%;
}
.giftbox .lid::before { right: 50%; transform: rotate(25deg); transform-origin: right bottom; }
.giftbox .lid::after { left: 50%; transform: rotate(-25deg); transform-origin: left bottom; }
.giftbox.shake { animation: shakebox .7s ease-in-out; }
.giftbox.open .lid { animation: lidoff .7s cubic-bezier(.2, .7, .3, 1) forwards; }
.giftbox.open .box { animation: boxout .5s ease-in .35s forwards; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 95% { transform: rotate(-2deg); } }
@keyframes shakebox { 20% { transform: rotate(-6deg) scale(1.03); } 40% { transform: rotate(6deg) scale(1.06); } 60% { transform: rotate(-6deg) scale(1.08); } 80% { transform: rotate(4deg) scale(1.1); } }
@keyframes lidoff { to { transform: translate(-60px, -320px) rotate(-40deg); opacity: 0; } }
@keyframes boxout { to { transform: scale(.6); opacity: 0; } }

.reveal { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.reveal > * { animation: pop .7s var(--spring) both; animation-delay: calc(var(--i, 0) * 140ms); }
.gift-card {
  width: 100%; background: var(--cream); border: var(--line); border-radius: 28px;
  box-shadow: var(--sticker); padding: 22px 18px; display: grid; gap: 14px; justify-items: center;
}
.gift-card img { width: 52%; }
.gift-card .gift-sticker-big { width: 78%; }
.gift-title { margin: 0; font: 400 32px/1.05 var(--f-bubbles); color: var(--tiger); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); text-wrap: balance; }
.gift-text { margin: 0; font: 600 17px/1.45 var(--f-body); text-wrap: pretty; }

.ticket {
  width: 100%; display: grid; grid-template-columns: 1fr auto; text-align: left;
  background: var(--white); border: var(--line); border-radius: 18px; overflow: hidden;
  -webkit-mask: radial-gradient(circle 11px at calc(100% - 52px) 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 11px at calc(100% - 52px) 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 11px at calc(100% - 52px) 0, transparent 98%, #000) top / 100% 51% no-repeat,
                radial-gradient(circle 11px at calc(100% - 52px) 100%, transparent 98%, #000) bottom / 100% 51% no-repeat;
}
.ticket-main { padding: 14px 14px 14px 16px; min-width: 0; display: grid; gap: 8px; }
.ticket-label { margin: 0; font: 800 11px/1 var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--dragon); }
.ticket-event { margin: 0; font: 800 19px/1.2 var(--f-body); }
.ticket dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14px; }
.ticket dt { opacity: .6; }
.ticket dd { margin: 0; font-weight: 700; }
.ticket-stub {
  width: 52px; border-left: 2.5px dashed var(--ink); background: var(--tiger);
  display: grid; place-items: center;
  font: 800 12px/1 var(--f-body); letter-spacing: .14em; text-transform: uppercase;
  writing-mode: vertical-rl;
}

.final-bubble { text-align: center; }
.final-bubble::after { left: calc(50% - 9px); }
.signature { display: block; margin-top: 4px; color: var(--dragon); }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- финал ---------- */
#finale .big { font-size: 50px; }
#finale .hero-sticker { width: 68%; }
