/* Тайный Санта от Дона Мороза. Стиль: афиша итальянской комедии 60-х, красная бумага, рваные записки, сургуч. */
:root {
  --wine: #8e1b22; --deep: #5e0f16; --cream: #f2e6cf; --aged: #e3d2b0; --ink: #1b1414; --gold: #c9a04e; --tang: #f2701d;
  --serif: "Literata", Georgia, serif; --display: "Playfair Display", Georgia, serif; --mono: "PT Mono", "Courier New", monospace;
  --shadow: drop-shadow(0 6px 10px rgba(0, 0, 0, .38));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { overflow-x: hidden; } /* iPhone: страница не сдвигается вбок */
body { background: var(--wine) url("assets/red.jpg") 0 0 / 256px auto; color: var(--cream); font: 17px/1.42 var(--serif); overflow-x: hidden; overflow-x: clip; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
#snow, #confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#snow { z-index: 1; opacity: .75; } #confetti { z-index: 60; }
#app { position: relative; z-index: 2; max-width: 430px; margin: 0 auto; padding: 46px 14px 40px; min-height: 100vh; overflow-x: clip; }
#app.with-tabs { padding-bottom: 110px; }

/* гирлянда из флажков */
.garland { position: absolute; top: 0; left: 0; right: 0; margin: 0 auto; width: min(100%, 430px); height: 44px; z-index: 5; pointer-events: none; transform-origin: top center; animation: sway 5s ease-in-out infinite; }
.garland svg { width: 100%; height: 100%; }
@keyframes sway { 0%, 100% { transform: rotate(-.6deg); } 50% { transform: rotate(.6deg); } }

.screen { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.stagger > *:nth-child(2) { animation-delay: .07s; } .stagger > *:nth-child(3) { animation-delay: .14s; }
.stagger > *:nth-child(4) { animation-delay: .21s; } .stagger > *:nth-child(5) { animation-delay: .28s; }
.stagger > *:nth-child(n+6) { animation-delay: .35s; }

h1, h2, h3, p { margin: 0; }
.title { font: italic 900 34px/1.1 var(--display); color: var(--cream); text-shadow: 2px 2px 0 var(--deep); }
.h-paper { font: italic 900 23px/1.2 var(--display); color: var(--wine); }
.h-ink { font: italic 900 23px/1.2 var(--display); color: var(--ink); }
.say { font: italic 400 17px/1.4 var(--serif); color: var(--cream); }
.link { color: var(--cream); font-size: 16px; text-decoration: underline; text-underline-offset: 3px; }
.center { text-align: center; }
.mark { font-family: "IBM Plex Mono", var(--mono); font-weight: 700; color: var(--wine); text-decoration: underline; text-underline-offset: 3px; font-style: normal; }
.serif .mark { font-family: var(--serif); font-weight: 600; }
.lettering { filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .15)); }
.flake { position: absolute; width: 16px; height: 16px; opacity: .75; pointer-events: none; }

/* рваная бумага: верхний край, лист, нижний край */
.paper { position: relative; margin: 54px 0; padding: 2px 22px; color: var(--ink); background: url("assets/paper-mid.webp") center / 100% 100% no-repeat; filter: var(--shadow); }
.paper::before, .paper::after { content: ""; position: absolute; left: 0; right: 0; aspect-ratio: 603 / 81; background: center / 100% 100% no-repeat; }
.paper::before { bottom: calc(100% - 1px); background-image: url("assets/paper-top.webp"); }
.paper::after { top: calc(100% - 1px); background-image: url("assets/paper-bottom.webp"); }
.paper > * + * { margin-top: 12px; }
.paper + .paper { margin-top: 112px; }
.paper.tl { transform: rotate(-.6deg); } .paper.tr { transform: rotate(.6deg); }
.paper .txt { font: 17px/1.42 var(--serif); }
.paper .typed { font: 16px/1.45 var(--mono); }
.typed p + p { margin-top: 10px; }
.paper .lbl { font: 600 17px/1.35 var(--serif); display: block; margin-bottom: 6px; }

/* кнопки из рваной бумаги */
.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 62px; padding: 8px 22px; font: 700 22px/1.1 var(--display); color: var(--ink); background: url("assets/btn-orange.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .4)); transition: transform .12s; margin-top: 18px; text-align: center; }
.btn:active { transform: scale(.97) rotate(-.5deg); }
.btn.cream { background-image: url("assets/btn-cream.webp"); }
.btn.sm { width: auto; min-height: 52px; font-size: 18px; padding: 6px 22px; margin-top: 4px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* шапки экранов */
.head { position: relative; min-height: 190px; }
.head .don { position: absolute; right: -22px; top: -22px; width: 190px; z-index: 0; }
.head .lettering { position: relative; z-index: 1; width: 222px; margin-left: -8px; }
.tree { position: absolute; width: 124px; pointer-events: none; }

/* выбор себя */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 4px; margin-top: 6px; }
.person { display: flex; flex-direction: column; align-items: center; position: relative; transition: transform .15s; }
.person:active { transform: scale(.95); }
.person .ph { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; object-position: bottom; filter: drop-shadow(2px 4px 3px rgba(0, 0, 0, .35)); animation: bob 4s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -.45s); }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-1.2deg); } }
.tag { display: inline-block; margin-top: -16px; padding: 3px 12px 4px; font: 700 16px/1.2 "Alegreya", var(--serif); color: var(--ink); background: url("assets/btn-cream.webp") center / 100% 100% no-repeat; transform: rotate(-2deg); position: relative; z-index: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); text-align: center; max-width: 104%; }
.person .seal { position: absolute; top: 4px; right: 10px; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d8434c, #8e1b22 70%); border: 2px solid var(--deep); box-shadow: 0 2px 3px rgba(0, 0, 0, .4); z-index: 2; }
.casebox { display: flex; align-items: center; gap: 6px; margin-top: 26px; }
.case { width: 168px; flex: none; margin: 0 0 0 -22px; transform: rotate(-6deg); }
.casebox p { font: 21px/1.3 "Neucha", var(--serif); color: var(--cream); transform: rotate(-2deg); }

/* шифр */
.dots { display: flex; justify-content: center; gap: 18px; margin: 20px 0; }
.dots i { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--cream); transition: background .15s, transform .15s; }
.dots i.on { background: var(--tang); transform: scale(1.12); }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 332px; margin: 0 auto; }
.keypad button { height: 62px; font: 700 30px/1 var(--display); color: var(--ink); background: url("assets/btn-cream.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)); transition: transform .1s; display: grid; place-items: center; }
.keypad button:active { transform: scale(.92); }
.keypad .blank { visibility: hidden; }
.pin-ph { width: 150px; margin: 0 auto; }

/* письмо */
.letter-don { width: 270px; margin: -18px auto -40px; position: relative; z-index: 0; }
.letter { z-index: 1; }
.letter .stamp { position: absolute; right: 14px; top: -34px; width: 96px; transform: rotate(-7deg); margin: 0; }
/* рука Дона: его письмо и все, что он говорит игроку с бумаги; записки людей тоже от руки */
.letter .typed, .paper .hand { font: 21px/1.4 "Neucha", var(--serif); }
.letter .mark, .hand .mark { font-family: inherit; font-weight: 400; }
.letter .sign { font: italic 900 22px/1.3 var(--display); text-align: right; }
.caret::after { content: "▍"; color: var(--wine); animation: blink .8s infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: .15; } }

/* конверты */
.velvet { margin: -40px -14px 0; padding: 70px 14px 60px; background: #7a1219 url("assets/velvet.jpg") center top / cover; box-shadow: inset 0 14px 18px -8px rgba(0, 0, 0, .55); }
.envs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px 12px; }
.env { position: relative; display: grid; place-items: center; aspect-ratio: 600 / 417; transition: transform .22s cubic-bezier(.2, 1.3, .4, 1); }
.env img { width: 100%; filter: drop-shadow(1px 4px 4px rgba(0, 0, 0, .45)); }
.env b { position: absolute; left: 50%; top: 53%; transform: translate(-50%, -50%); font: 700 21px/1 var(--display); color: #f2d27f; text-shadow: 0 1px 0 #40050a; }
.env:not(.taken):active { transform: scale(.94) rotate(-2deg); }
.env:not(.taken) { animation: wiggle 6s ease-in-out infinite; animation-delay: calc(var(--i) * -.7s); }
@keyframes wiggle { 0%, 88%, 100% { transform: none; } 92% { transform: rotate(-2.5deg); } 96% { transform: rotate(2.5deg); } }
@media (hover: hover) {
  .env:not(.taken):hover { animation: none; transform: translateY(-7px) rotate(-2.5deg) scale(1.05); z-index: 2; }
  .env:not(.taken):hover img { filter: drop-shadow(2px 12px 10px rgba(0, 0, 0, .55)); }
  .env:not(.taken):hover b { color: #fff3c4; text-shadow: 0 0 10px rgba(255, 220, 130, .9), 0 1px 0 #40050a; }
  .person:hover { transform: translateY(-4px) scale(1.04); }
  .btn:hover, .keypad button:hover, .chip:hover { transform: translateY(-2px) rotate(-.4deg); }
}
.env img, .env b { transition: filter .2s, color .2s, text-shadow .2s; }
.env.taken img { width: 82%; margin-top: -18%; }
.env.taken .tag { position: absolute; bottom: -4px; font-size: 14px; margin: 0; transform: rotate(-4deg); }

/* модальное окно и вскрытие */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 4, 6, .86); display: grid; place-items: center; padding: 18px; animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.overlay.scroll { place-items: start center; overflow-y: auto; padding-top: 70px; padding-bottom: 70px; }
.overlay .paper { width: 100%; max-width: 380px; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.opening { width: 100%; max-width: 380px; text-align: center; }
.opening img { width: 240px; margin: 0 auto 24px; animation: tremble .9s ease-in-out infinite; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .6)); }
@keyframes tremble { 0%, 100% { transform: rotate(-2deg); } 25% { transform: rotate(2deg) translateY(-3px); } 50% { transform: rotate(-1deg); } 75% { transform: rotate(3deg) translateY(2px); } }
.opening p { min-height: 54px; font: italic 900 21px/1.3 var(--display); color: var(--cream); transition: opacity .45s; }

/* твоя цель */
.hush { display: flex; align-items: center; gap: 4px; margin: -14px 0 8px -24px; }
.hush img { width: 168px; flex: none; }
.hush p { font: italic 900 18px/1.3 var(--display); text-shadow: 2px 2px 0 var(--deep); }
.envwrap { position: relative; width: 100%; max-width: 372px; margin: 0 auto; aspect-ratio: 358 / 545; }
.envwrap .back, .envwrap .front { position: absolute; left: 0; bottom: 0; width: 100%; }
.envwrap .back { filter: var(--shadow); }
.envwrap .card { position: absolute; left: 9.2%; width: 81.6%; top: 0; height: 91%; background: url("assets/paper.webp") center / 100% 100% no-repeat; color: var(--ink); transform: rotate(-2deg) translateY(46%); transition: transform 1.5s cubic-bezier(.2, .9, .25, 1.05); padding: 9% 8% 0; }
.envwrap.out .card { transform: rotate(-2deg); }
.card .row { display: flex; align-items: flex-start; justify-content: space-between; }
.card .chest { width: 46%; margin-top: 7%; opacity: 0; transform: scale(2.4) rotate(-14deg); transition: all .45s cubic-bezier(.3, 1.5, .5, 1) 1.5s; }
.envwrap.out .chest { opacity: 1; transform: none; }
.card .ph { width: 50%; }
.card .lbl2 { font: 600 22px/1.2 var(--serif); margin-top: 6%; }
.card .name { font: italic 900 78px/1 var(--display); color: var(--wine); text-shadow: 2px 2px 0 var(--ink); margin-top: 1%; white-space: nowrap; overflow: hidden; padding: 0 6px 6px 0; }
.card .dl { font: 15px/1.3 var(--mono); text-align: center; margin-top: 3%; }
.codex { margin-top: 12px; }
.codex li { list-style: none; position: relative; padding-left: 26px; font: 16px/1.45 var(--mono); }
.codex li::before { content: ""; position: absolute; left: 0; top: 11px; width: 14px; height: 3px; background: var(--tang); }
.codex ul { margin: 0; padding: 0; display: grid; gap: 10px; }

/* досье */
.dossier-head { position: relative; min-height: 186px; }
.dossier-head .lettering { width: 214px; }
.dossier-head .sub { font: italic 900 26px/1 var(--display); text-shadow: 2px 2px 0 var(--deep); margin: -4px 0 0 44px; }
.cat { position: absolute; right: 0; top: -8px; width: 118px; transition: transform .2s; }
.cat:active { transform: scale(.94) rotate(-3deg); }
.bubble { position: absolute; right: 6px; top: 132px; max-width: 230px; padding: 8px 12px; background: var(--cream); color: var(--ink); font: 15px/1.3 var(--serif); border-radius: 14px 2px 14px 14px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35)); animation: pop .3s both; z-index: 3; }
.clip { position: absolute; left: 30px; top: -74px; width: 24px; transform: rotate(-8deg); z-index: 2; margin: 0; }
.field { width: 100%; border: 1.2px dashed var(--ink); background: rgba(255, 255, 255, .6); padding: 12px 14px; font: 16px/1.4 var(--mono); color: var(--ink); outline: none; border-radius: 0; display: block; }
textarea.field { min-height: 96px; resize: vertical; }
.field:focus { background: rgba(255, 255, 255, .85); border-style: solid; }
.field::placeholder { font: italic 16px/1.4 var(--serif); color: rgba(27, 20, 20, .55); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px 9px; font: 15px/1.2 var(--serif); color: var(--ink); background: url("assets/btn-cream.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.chip:active { transform: scale(.94); }
.addlink { display: flex; gap: 8px; }
.addlink .field { flex: 1; min-width: 0; }
.addlink.typed button { display: block; }
.addlink button { display: none; flex: none; width: 58px; font: 700 30px/1 var(--display); color: var(--ink); background: url("assets/btn-orange.webp") center / 100% 100% no-repeat; }
.hint { font: 15px/1.35 var(--serif); opacity: .8; }
.wish { display: flex; gap: 12px; align-items: center; padding: 8px 10px 8px 8px; background: rgba(255, 255, 255, .72); box-shadow: 0 2px 3px rgba(0, 0, 0, .25); text-decoration: none; color: var(--ink); position: relative; }
.wish .pic { width: 60px; height: 60px; flex: none; display: grid; place-items: center; background: var(--shop, #3d4b66); color: #fff; font: 700 15px/1 "IBM Plex Mono", var(--mono); overflow: hidden; }
.wish .pic img { width: 100%; height: 100%; object-fit: cover; }
.wish .t { font: 600 16px/1.3 var(--serif); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wish .s { font: 14px/1.3 var(--serif); opacity: .75; }
.wish .x { position: absolute; top: 0; right: 4px; font-size: 20px; padding: 6px; }
.wish input { width: 100%; background: transparent; border: 0; border-bottom: 1px dashed rgba(27, 20, 20, .4); padding: 3px 0; font: 15px/1.3 var(--serif); outline: none; }
.wish > div:not(.pic) { min-width: 0; flex: 1; }

/* штаб */
.hq-head { position: relative; min-height: 148px; }
.hq-head .lettering { width: 176px; }
.hq-head .tree { right: -6px; top: -20px; }
.target-head { display: flex; align-items: center; gap: 12px; }
.target-head { padding: 10px 0 6px 8px; gap: 20px; }
.tmark { position: relative; flex: none; width: 96px; }
.tmark img { width: 100%; display: block; }
.tmark .ring { position: absolute; left: -13px; top: -11px; width: calc(100% + 26px); height: calc(100% + 20px); overflow: visible; pointer-events: none; transform: rotate(-9deg); }
.tmark .ring path { fill: none; stroke: #c4161f; stroke-width: 3; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .88; stroke-dasharray: 1; stroke-dashoffset: 1; animation: ringdraw 1.3s .45s ease-out forwards; }
@keyframes ringdraw { to { stroke-dashoffset: 0; } }
.target-head small { font: 600 17px/1 var(--serif); color: var(--wine); display: block; }
.target-head b { font: italic 900 44px/1.05 var(--display); display: block; white-space: nowrap; overflow: hidden; padding-right: 6px; }
.target-head > div { min-width: 0; flex: 1; }
.note { padding: 10px 14px; font: 20px/1.4 "Neucha", var(--serif); max-width: 88%; white-space: pre-wrap; word-wrap: break-word; }
.note.me { background: var(--aged); margin-left: auto; transform: rotate(.6deg); }
.note.them { background: rgba(255, 255, 255, .75); color: var(--wine); transform: rotate(-.6deg); }
.sendrow { display: flex; gap: 8px; align-items: stretch; }
.sendrow .field { flex: 1; min-width: 0; min-height: 52px; height: 52px; resize: none; }
.sendrow button { flex: none; padding: 0 16px; font: 700 17px/1 var(--display); color: var(--ink); background: url("assets/btn-orange.webp") center / 100% 100% no-repeat; }
.count { display: flex; gap: 10px; margin-top: 12px; }
.count div { flex: 1; text-align: center; padding: 6px 0 10px; background: url("assets/btn-cream.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)); }
.count b { display: block; font: italic 900 42px/1.1 var(--display); color: var(--wine); }
.count b.tick { animation: tick .4s; }
@keyframes tick { 0% { transform: translateY(-6px); opacity: .3; } }
.count span { font: 700 15px/1 "Alegreya", var(--serif); color: var(--ink); }
.faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 6px; }
.faces figure { margin: 0; text-align: center; flex: 0 0 calc((100% - 18px) / 4); min-width: 0; }
.faces img { width: 100%; aspect-ratio: 1; object-fit: contain; object-position: bottom; }
.faces .off img { opacity: .3; filter: grayscale(1); }
.ledger-t { margin: 16px 0 6px; }
.ledger { font: 16px/1.3 var(--mono); display: grid; gap: 6px; margin-bottom: 10px; }
.ledger p { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.ledger i { flex: 1; border-bottom: 2px dotted currentColor; opacity: .45; transform: translateY(-3px); }
.ledger b { font-family: "IBM Plex Mono", var(--mono); font-weight: 700; color: var(--wine); min-width: 2ch; text-align: right; }
.faces figcaption { font: 12px/1.2 var(--serif); margin-top: 2px; }
.rule { margin: 26px 6px 8px; padding: 20px 26px 22px; font: italic 900 19px/1.3 var(--display); color: var(--ink); background: url("assets/btn-cream.webp") center / 100% 100% no-repeat; filter: var(--shadow); transform: rotate(-1.5deg); }
.rot { min-height: 70px; transition: opacity .35s; }
.unread { display: inline-block; min-width: 22px; padding: 0 6px; height: 22px; border-radius: 11px; background: var(--tang); color: var(--ink); font: 700 13px/22px var(--serif); text-align: center; margin-left: 8px; vertical-align: 3px; }
.alert { display: block; width: 100%; margin: 0 0 14px; padding: 14px 20px 15px; font: 700 19px/1.2 var(--display); color: var(--ink); text-align: center; background: url("assets/btn-orange.webp") center / 100% 100% no-repeat; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .4)); animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 80%, 100% { transform: none; } 86% { transform: rotate(-1.4deg) scale(1.02); } 92% { transform: rotate(1.4deg) scale(1.02); } }
.overlay .note { max-width: 100%; }
.tabs { position: fixed; left: 0; right: 0; margin: 0 auto; bottom: 0; width: min(100%, 430px); z-index: 20; display: flex; gap: 6px; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); background: var(--ink); box-shadow: 0 -4px 12px rgba(0, 0, 0, .45); }
.tabs button { flex: 1; height: 50px; font: 700 19px/1 var(--display); color: var(--cream); position: relative; }
.tabs button.on { color: var(--ink); background: url("assets/btn-orange.webp") center / 100% 100% no-repeat; }

.toast { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; bottom: 96px; transform: translateY(40px); opacity: 0; z-index: 70; background: var(--cream); color: var(--ink); padding: 12px 18px; font: 600 16px/1.35 var(--serif); max-width: 88vw; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); transition: all .3s cubic-bezier(.2, 1.3, .4, 1); text-align: center; pointer-events: none; }
.toast.on { transform: none; opacity: 1; }
table.adm { width: 100%; border-collapse: collapse; font: 15px/1.3 var(--serif); }
table.adm td, table.adm th { padding: 8px 4px; border-bottom: 1px solid rgba(27, 20, 20, .25); text-align: left; }
table.adm img { width: 40px; }

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