:root {
  --bg: #0F1A30;
  --bg-2: #16243F;
  --card: #1C2C4C;
  --card-2: #233657;
  --line: rgba(255, 255, 255, 0.08);
  --text: #F4F1EA;
  --muted: #9AA8C2;
  --gold: #FFC93C;
  --gold-2: #FFB300;
  --red: #E5533D;
  --green: #4CC38A;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; overflow-x: hidden; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(24px + var(--safe-bottom));
}

button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }

/* ---------- Анимация смены экранов ---------- */

.screen { animation: screenIn 0.45s cubic-bezier(.2, .8, .2, 1) both; }
.screen.leaving { animation: screenOut 0.25s ease-in both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes screenOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---------- Галерея ---------- */

.hero {
  padding: calc(28px + var(--safe-top)) 20px 8px;
  text-align: center;
}
.hero-logo {
  font-weight: 900;
  font-size: 30px;
  letter-spacing: -0.5px;
  line-height: 1.05;
}
.hero-logo span { color: var(--gold); }
.hero-sub { color: var(--muted); font-weight: 500; font-size: 14px; margin-top: 8px; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0 4px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 10px 15px;
  border-radius: 99px;
  background: var(--bg-2);
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.tab.active { background: var(--gold); color: #2A1D00; }

.cat-about { padding: 12px 18px 0; color: var(--muted); font-size: 13px; font-weight: 600; }

.cat-banner {
  margin: 0 16px 10px;
  width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1.5px solid rgba(255, 201, 60, .35);
  text-align: left;
}
.cat-banner .icon { font-size: 28px; }
.cat-banner .cb-main { flex: 1; }
.cat-banner .t { font-weight: 800; font-size: 15px; }
.cat-banner .s { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.cat-banner .cb-price { font-weight: 900; font-size: 16px; color: var(--gold); white-space: nowrap; }
.cat-banner .cb-price small { font-size: 11px; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.char-card {
  position: relative;
  text-align: left;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .15s;
}
.char-card:active { transform: scale(.97); }
.char-card .portrait { display: block; width: 100%; aspect-ratio: 1; }
.char-card.locked .portrait { filter: saturate(.35) brightness(.7); }
.char-card .info { padding: 10px 12px 12px; }
.char-card .name { font-weight: 800; font-size: 15px; }
.char-card .tagline { color: var(--muted); font-size: 12px; font-weight: 500; margin-top: 3px; line-height: 1.3; }
.char-card .meta { margin-top: 8px; font-size: 11px; font-weight: 700; color: var(--gold); }

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  background: var(--green);
  color: #0B2117;
}
.badge.lock { background: rgba(10, 16, 30, .75); color: var(--gold); backdrop-filter: blur(6px); }
.badge.soon { background: rgba(10, 16, 30, .75); color: var(--muted); }

.pass-banner {
  margin: 4px 16px 0;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #3A2A6B, #6B2F5E 60%, #A8452F);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  width: calc(100% - 32px);
}
.pass-banner .icon { font-size: 34px; }
.pass-banner .t { font-weight: 800; font-size: 16px; }
.pass-banner .s { font-size: 12px; font-weight: 500; opacity: .85; margin-top: 3px; }

.empty-tab {
  margin: 16px;
  padding: 28px 20px;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.5;
}
.empty-tab b { color: var(--text); display: block; font-size: 17px; margin-bottom: 6px; }

/* ---------- Верхняя панель истории ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--card);
  display: grid;
  place-items: center;
  font-size: 17px;
  flex-shrink: 0;
}
.icon-btn:disabled { opacity: .35; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: 12px; color: var(--muted); font-weight: 600; }
.pill {
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--card);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

/* ---------- Сцена ---------- */

.stage {
  position: relative;
  margin: 0 12px;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
.stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage svg.enter { animation: artIn .6s cubic-bezier(.2, .8, .2, 1) both; }
.stage svg.exit { animation: artOut .6s ease both; }
@keyframes artIn {
  from { opacity: 0; transform: scale(1.06); }
  to { opacity: 1; transform: none; }
}
@keyframes artOut {
  to { opacity: 0; transform: scale(.98); }
}

.scene-body { padding: 18px 18px 0; }
.scene-title {
  font-weight: 900;
  font-size: 22px;
  line-height: 1.15;
  margin: 0 0 10px;
}
.scene-text p {
  margin: 0 0 10px;
  font-size: 15.5px;
  line-height: 1.5;
  font-weight: 500;
  color: #E3E6EE;
}
.scene-text p.line { padding-left: 12px; border-left: 3px solid var(--gold); color: var(--text); }
.scene-text b { color: var(--gold); font-weight: 800; }

.fade-swap { animation: textIn .5s .1s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes textIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.question { margin: 16px 0 10px; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }

.choices { display: flex; flex-direction: column; gap: 9px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  border-radius: 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  transition: transform .12s, background .2s, border-color .2s;
  animation: textIn .45s cubic-bezier(.2, .8, .2, 1) both;
}
.choice:nth-child(1) { animation-delay: .2s; }
.choice:nth-child(2) { animation-delay: .28s; }
.choice:nth-child(3) { animation-delay: .36s; }
.choice:active { transform: scale(.98); background: var(--card-2); }
.choice .emo { font-size: 22px; flex-shrink: 0; }
.choice .txt { flex: 1; }
.choice .seen { font-size: 11px; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.choice.picked { border-color: var(--gold); background: var(--card-2); }

/* ---------- Концовка ---------- */

.ending-head { padding: 18px 18px 0; }
.ending-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--card);
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
}
.ending-tag.new { background: var(--gold); color: #2A1D00; animation: pop .5s .3s both; }
.ending-tag.secret { background: linear-gradient(90deg, #FFC93C, #FF8A3C); color: #2A1D00; }
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: none; opacity: 1; }
}

.reality {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1E3A5F, #1C2C4C);
  border: 1px solid rgba(255, 201, 60, .25);
}
.reality .h { font-weight: 900; font-size: 13px; letter-spacing: .6px; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.reality p { margin: 0; font-size: 14.5px; line-height: 1.5; font-weight: 500; }
.reality .note { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--gold); }

.actions { display: grid; gap: 9px; margin-top: 18px; }
.btn {
  padding: 15px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 15px;
  background: var(--card);
  transition: transform .12s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--gold); color: #2A1D00; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.hint { margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Коллекция концовок ---------- */

.collection-head { padding: 6px 18px 0; }
.collection-head h2 { margin: 0; font-size: 24px; font-weight: 900; }
.collection-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.progress { height: 8px; border-radius: 99px; background: var(--card); margin-top: 14px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .6s; }

.end-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.end-card {
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
}
.end-card .thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden; }
.end-card .thumb svg { width: 100%; height: 100%; display: block; }
.end-card .lockface {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: repeating-linear-gradient(45deg, #1A2944, #1A2944 10px, #1E2F4E 10px, #1E2F4E 20px);
}
.end-card .cap { padding: 9px 11px 11px; font-size: 12.5px; font-weight: 800; line-height: 1.25; }
.end-card .cap small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; margin-bottom: 2px; }
.end-card.locked .cap { color: var(--muted); }

/* ---------- Нижняя шторка оплаты ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(5, 9, 18, .6);
  animation: fadeIn .2s both;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 21;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  padding: 22px 18px calc(22px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--bg-2);
  animation: sheetIn .35s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetIn { from { transform: translate(-50%, 100%); } }
.sheet h3 { margin: 0 0 4px; font-size: 21px; font-weight: 900; }
.sheet .sub { color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 16px; }
.offer {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 15px;
  border-radius: 16px;
  background: var(--card);
  margin-bottom: 9px;
  border: 1.5px solid transparent;
}
.offer.best { border-color: var(--gold); background: var(--card-2); }
.offer .o-main { flex: 1; }
.offer .o-main b { display: block; font-size: 15px; font-weight: 800; }
.offer .o-main span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.offer .price { font-weight: 900; font-size: 17px; color: var(--gold); white-space: nowrap; }
.offer .flag { white-space: nowrap; font-size: 10px; font-weight: 900; background: var(--gold); color: #2A1D00; padding: 3px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }
.pay-note { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 8px; }

/* ---------- Ссылки на документы ---------- */

.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  padding: 22px 16px 8px;
  font-size: 12px;
  font-weight: 600;
}
.legal-links a, .pay-note a { color: var(--muted); }

/* ---------- Тост ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 30;
  transform: translate(-50%, 30px);
  opacity: 0;
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 14px;
  background: #F4F1EA;
  color: #10192C;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Анимации внутри иллюстраций ---------- */

.art .bob { animation: bob 3.2s ease-in-out infinite; }
.art .eyes { transform-box: fill-box; transform-origin: center; animation: blink 4.6s infinite; }
.art .flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flame .5s ease-in-out infinite alternate; }
.art .sway { transform-box: fill-box; transform-origin: 50% 0%; animation: sway 3s ease-in-out infinite alternate; }
.art .float { animation: floaty 6s ease-in-out infinite alternate; }
.art .twinkle { animation: twinkle 2.4s ease-in-out infinite alternate; }
.art .wave { animation: wave 4s ease-in-out infinite alternate; }
.art .glow { animation: glow 2.6s ease-in-out infinite alternate; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.6px); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.1); } }
@keyframes flame { from { transform: scale(1, 1); } to { transform: scale(.88, 1.12); } }
@keyframes sway { from { transform: skewX(-3deg); } to { transform: skewX(3deg); } }
@keyframes floaty { from { transform: translateX(0); } to { transform: translateX(14px); } }
@keyframes twinkle { from { opacity: .25; } to { opacity: 1; } }
@keyframes wave { from { transform: translateX(-6px); } to { transform: translateX(6px); } }
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
