/* GERONIMO 2.0 — тёмная мистика: глубокий фиолет, золото, ambient-свечение.
   Без внешних шрифтов (PWA живёт офлайн): serif + mono из системы. */

:root {
  --bg: #0a0a11;
  --panel: rgba(20, 19, 33, .78);
  --panel-solid: #14131f;
  --line: #262440;
  --line-soft: #1d1b32;
  --text: #dedbe9;
  --dim: #837fa0;
  --accent: #cfa8ff;
  --accent-deep: #8a63d2;
  --gold: #e8c98a;
  --danger: #e89a8a;
  --glow: rgba(207, 168, 255, .32);
  --radius: 10px;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Iowan Old Style", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

/* --- ambient: два медленных пятна света за контентом --- */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%;
  pointer-events: none; will-change: transform;
}
body::before {
  width: 70vmax; height: 70vmax; top: -30vmax; left: -25vmax;
  background: radial-gradient(circle, rgba(103, 70, 178, .16), transparent 62%);
  animation: drift-a 26s ease-in-out infinite alternate;
}
body::after {
  width: 60vmax; height: 60vmax; bottom: -28vmax; right: -22vmax;
  background: radial-gradient(circle, rgba(232, 201, 138, .07), transparent 60%);
  animation: drift-b 34s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(9vmax, 7vmax); } }
@keyframes drift-b { to { transform: translate(-8vmax, -6vmax); } }

#app { max-width: 480px; margin: 0 auto; padding: 24px 20px 72px; }

.view { animation: fade .4s cubic-bezier(.16, 1, .3, 1); }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* --- типографика --- */
h1 {
  font-family: var(--mono);
  font-size: 22px; font-weight: 400; letter-spacing: .35em;
  text-align: center; margin-bottom: 28px; color: var(--text);
  text-shadow: 0 0 26px var(--glow);
}
.lead { color: var(--dim); margin-bottom: 14px; }
.glyph { font-size: 26px; color: var(--accent); text-align: center; margin: 44px 0 10px;
  text-shadow: 0 0 18px var(--glow); }

/* --- сфера (орб): центр всех церемоний --- */
.orb-scene { display: flex; flex-direction: column; align-items: center; padding: 40px 0 24px; }
.orb {
  position: relative; width: 168px; height: 168px; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #f1e7ff 0%, #cfa8ff 22%, #6d4bb8 58%, #1b142f 100%);
  box-shadow:
    0 0 70px var(--glow),
    0 0 24px rgba(207, 168, 255, .25),
    inset -18px -22px 44px rgba(10, 8, 22, .55),
    inset 10px 12px 30px rgba(255, 255, 255, .12);
  animation: orb-float 5.5s ease-in-out infinite;
}
.orb::after { /* кольцо-шиммер вокруг сферы */
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(207,168,255,.5) 82%, transparent 94%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  animation: orb-ring 7s linear infinite;
}
.orb.small { width: 96px; height: 96px; }
.orb.dim { filter: saturate(.4) brightness(.7); animation-duration: 8s; }
.orb.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.orb.tappable:active { transform: scale(.96); }
@keyframes orb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes orb-ring { to { transform: rotate(360deg); } }

.orb.burst { animation: orb-burst .75s cubic-bezier(.16, 1, .3, 1) forwards; }
@keyframes orb-burst {
  40% { transform: scale(1.08); filter: brightness(1.6); }
  100% { transform: scale(1.9); opacity: 0; filter: brightness(2.4) blur(6px); }
}
.spark { /* частицы разлёта */
  position: absolute; left: 50%; top: 50%; color: var(--gold); font-size: 15px;
  pointer-events: none; opacity: 0;
  animation: spark-fly .9s cubic-bezier(.16, 1, .3, 1) forwards;
}
@keyframes spark-fly {
  10% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; }
}

.orb-hint { margin-top: 30px; color: var(--dim); font-size: 14px; text-align: center;
  animation: hint-breathe 2.6s ease-in-out infinite; }
@keyframes hint-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.rune-line { font-family: var(--mono); font-size: 12.5px; letter-spacing: .22em;
  color: var(--accent); text-align: center; margin: 8px 0 4px; }

/* --- reveal: карточка задания проявляется --- */
.reveal-card { animation: reveal-up .7s cubic-bezier(.16, 1, .3, 1) both; }
.reveal-card.d1 { animation-delay: .15s; }
.reveal-card.d2 { animation-delay: .3s; }
@keyframes reveal-up {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* --- кнопки --- */
.btn {
  display: block; width: 100%; text-align: left; position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); padding: 14px 16px; margin-bottom: 10px; min-height: 48px;
  font: inherit; font-size: 16px; cursor: pointer;
  transition: border-color .2s, box-shadow .25s, transform .1s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .sub { display: block; font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.ghost { background: transparent; }
.btn.primary {
  border-color: var(--accent-deep);
  background: linear-gradient(160deg, rgba(207, 168, 255, .13), rgba(20, 19, 33, .9) 55%);
  box-shadow: 0 0 22px rgba(207, 168, 255, .12);
}
.btn.primary:hover { box-shadow: 0 0 30px rgba(207, 168, 255, .25); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.selected { border-color: var(--gold); box-shadow: 0 0 16px rgba(232, 201, 138, .14); }
.btn.selected::after { content: "✦"; color: var(--gold); position: absolute; top: 12px; right: 14px; }

/* лесенка ставок */
.rung { display: flex; align-items: baseline; gap: 12px; }
.rung .amount { font-family: var(--mono); font-size: 19px; color: var(--gold); letter-spacing: .04em; }
.rung .label { color: var(--dim); font-size: 13.5px; }

/* --- формы --- */
.field { margin: 26px 0 14px; }
.field label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
input, textarea {
  width: 100%; background: var(--panel-solid); border: 1px solid var(--line);
  color: var(--text); padding: 12px 14px; border-radius: 8px; min-height: 46px;
  font: inherit; outline: none; transition: border-color .2s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 14px rgba(207, 168, 255, .1); }

.check { display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; color: var(--dim); margin-top: 14px; cursor: pointer; }
.check input { width: auto; min-height: auto; margin-top: 3px; accent-color: var(--accent); }

/* --- шапка экрана --- */
.top { display: flex; align-items: center; gap: 12px;
  margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--line-soft); }
.mark { font-family: var(--mono); font-size: 14px; letter-spacing: .12em; color: var(--accent); }
.who { margin-left: auto; font-size: 13px; color: var(--dim); }
.back { background: none; border: none; color: var(--dim); font-size: 18px; cursor: pointer;
  padding: 8px 10px; margin: -8px 0 -8px -10px; min-width: 44px; min-height: 44px;
  touch-action: manipulation; }
.back:hover { color: var(--text); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }

/* --- карточки --- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; margin-bottom: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.card.clickable { cursor: pointer; transition: border-color .2s, box-shadow .25s, transform .1s; }
.card.clickable:hover { border-color: var(--accent); box-shadow: 0 0 20px rgba(207, 168, 255, .1); }
.card.clickable:active { transform: scale(.985); }
.card .tag { font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  letter-spacing: .1em; text-transform: lowercase; }
.card h3 { font-size: 17px; font-weight: 500; margin: 6px 0 8px; }
.card p { color: var(--text); }
.card .meta { font-size: 12.5px; color: var(--dim); margin-top: 10px; }

/* герой-статус на главном: одна ось состояния */
.hero-state {
  position: relative; overflow: hidden;
  border: 1px solid var(--accent-deep); border-radius: 12px;
  background: linear-gradient(165deg, rgba(207, 168, 255, .1), rgba(16, 15, 27, .92) 60%);
  padding: 20px 18px; margin-bottom: 22px;
  box-shadow: 0 0 30px rgba(207, 168, 255, .08);
}
.hero-state .state-label { font-family: var(--mono); font-size: 11.5px; letter-spacing: .18em;
  color: var(--gold); margin-bottom: 10px; }
.hero-state h2 { font-size: 19px; font-weight: 500; margin-bottom: 8px; }
.hero-state p { color: var(--dim); font-size: 14.5px; }
.hero-state .btn { margin: 16px 0 0; }

.section-title { font-size: 13px; color: var(--dim); letter-spacing: .08em; margin: 26px 0 10px; }

/* узоры веток: нестабильные глючат (JS-тикер), закреплённые дышат */
.sprite { image-rendering: pixelated; flex: none;
  filter: drop-shadow(0 0 7px rgba(207, 168, 255, .3)); }
.sigil-hero { filter: drop-shadow(0 0 14px rgba(207, 168, 255, .45)); }
.sigil-stable { animation: sigil-breathe 3.2s ease-in-out infinite; }
@keyframes sigil-breathe {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(207, 168, 255, .22)); }
  50% { filter: drop-shadow(0 0 13px rgba(207, 168, 255, .55)); }
}
.t-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.t-head h3 { margin-bottom: 0; }

/* коллекция закреплённых веток */
.collection { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 14px; margin-bottom: 10px; }
.coll-item { display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 6px 10px; border: 1px solid var(--line-soft); border-radius: 10px;
  background: var(--panel); cursor: pointer; min-height: 44px;
  transition: border-color .2s, transform .1s; touch-action: manipulation; }
.coll-item:hover { border-color: var(--accent); }
.coll-item:active { transform: scale(.96); }
.coll-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.coll-lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--dim); }

/* шер-щит */
.scrim { position: fixed; inset: 0; z-index: 95; background: rgba(4, 4, 10, .62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease; }
.sheet { width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sheet-up .3s cubic-bezier(.16, 1, .3, 1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-preview { display: block; max-height: 38vh; max-width: 100%; margin: 0 auto 16px;
  border-radius: 10px; border: 1px solid var(--line); }

.status-line { font-size: 13.5px; margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--line); color: var(--dim); }
.status-line .ok { color: var(--gold); }

.stats { font-size: 13px; color: var(--dim); margin-bottom: 22px; }
.stats b { color: var(--gold); font-weight: 400; }

/* второстепенные действия на главном — компактная сетка */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.actions .btn { margin: 0; font-size: 14.5px; padding: 12px 14px; }
.actions .btn.wide { grid-column: 1 / -1; }
.badge { color: var(--gold); font-family: var(--mono); font-size: 12px; }

/* --- ключ-артефакт --- */
.key-card {
  position: relative; border-radius: 14px; padding: 26px 20px 22px; margin: 20px 0;
  text-align: center; background: linear-gradient(170deg, #191430, #0e0c1a 70%);
  border: 1px solid transparent; overflow: hidden;
}
.key-card::before { /* мерцающая рамка */
  content: ""; position: absolute; inset: 0; border-radius: 14px; padding: 1px;
  background: conic-gradient(from var(--key-angle, 0deg), var(--gold), var(--accent), #3a2f63, var(--gold));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: key-spin 6s linear infinite;
}
@property --key-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes key-spin { to { --key-angle: 360deg; } }
.key-card .k-title { font-family: var(--mono); font-size: 11px; letter-spacing: .3em;
  color: var(--dim); text-transform: lowercase; }
.key-card .k-code { font-family: var(--mono); font-size: 25px; letter-spacing: .22em;
  color: var(--gold); margin: 16px 0; user-select: all; word-break: break-all;
  text-shadow: 0 0 22px rgba(232, 201, 138, .3); }
.key-card .k-meta { font-size: 12px; color: var(--dim); }

.code-badge {
  font-family: var(--mono); font-size: 24px; letter-spacing: .3em;
  color: var(--gold); text-align: center; padding: 18px;
  border: 1px dashed var(--line); border-radius: var(--radius); margin: 14px 0;
  user-select: all;
}

/* --- toast --- */
.toast {
  position: fixed; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--accent); border-radius: 8px;
  color: var(--text); padding: 11px 18px; font-size: 14px; max-width: 90%;
  z-index: 100; animation: fade .25s ease;
  box-shadow: 0 6px 28px rgba(0, 0, 0, .5), 0 0 18px rgba(207, 168, 255, .12);
}

.terms-note { font-size: 12.5px; color: var(--dim); text-align: center; margin-top: 18px; }
.terms-note a { color: var(--dim); text-decoration: underline; }

/* пилюля переезда: старый адрес зовёт домой */
.migrate-pill {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 85; white-space: nowrap;
  background: linear-gradient(160deg, rgba(232, 201, 138, .16), var(--panel-solid) 60%);
  border: 1px solid var(--gold); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 13px; padding: 9px 18px;
  cursor: pointer; touch-action: manipulation; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 0 18px rgba(232, 201, 138, .18);
  animation: fade .3s ease;
}
.migrate-pill span { display: block; font-size: 11px; color: var(--dim); }
.migrate-pill:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* пилюля обновления: живёт поверх всего, пока человек не применит */
.update-pill {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 90; max-width: 92%;
  background: linear-gradient(160deg, rgba(207, 168, 255, .16), var(--panel-solid) 60%);
  border: 1px solid var(--accent); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 12px 20px;
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
  box-shadow: 0 6px 28px rgba(0, 0, 0, .5), 0 0 22px rgba(207, 168, 255, .2);
  animation: fade .3s ease;
}
.update-pill[disabled] { opacity: .6; }

/* --- чат пары --- */
.chat-box { display: flex; flex-direction: column; gap: 8px; margin: 16px 0;
  min-height: 120px; }
.msg { max-width: 82%; padding: 10px 12px; border-radius: 12px; font-size: 15px;
  background: var(--panel); border: 1px solid var(--line); align-self: flex-start;
  animation: fade .25s ease; }
.msg.mine { align-self: flex-end; border-color: var(--accent-deep);
  background: linear-gradient(160deg, rgba(207, 168, 255, .1), var(--panel) 60%); }
.msg.system { align-self: center; background: transparent; border: none;
  color: var(--dim); font-size: 13px; text-align: center; max-width: 100%; }
.msg .who { font-family: var(--mono); font-size: 11px; color: var(--accent); margin-bottom: 3px; }
.msg audio { width: 220px; max-width: 100%; display: block; }
.msg video { width: 100%; max-width: 260px; border-radius: 8px; display: block; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.chat-input textarea { flex: 1; resize: none; min-height: 46px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 13px; padding: 0 12px;
  min-width: 46px; min-height: 46px; cursor: pointer; white-space: nowrap;
  touch-action: manipulation; transition: border-color .2s; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn.recording { border-color: var(--gold); color: var(--gold); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .5; } }

/* --- онбординг --- */
.onb-step { margin-bottom: 22px; }
.onb-step .num { font-family: var(--mono); color: var(--accent); font-size: 13px; letter-spacing: .1em; }
.onb-step p { color: var(--text); margin-top: 4px; }

/* --- лендинг --- */
.hero { padding-bottom: 8px; text-align: center; }
.tagline { font-family: var(--mono); font-size: 13px; letter-spacing: .14em;
  color: var(--gold); margin: 14px 0 8px; }
.tagline-sub { font-size: 13.5px; color: var(--dim); margin: 0 auto 26px; max-width: 340px; }
.land-text { color: var(--text); margin-bottom: 14px; text-align: left; }
.land-sect { margin-top: 44px; }
.land-sect::before { /* разделитель-глиф вместо монотонной линии */
  content: "✦"; display: block; text-align: center;
  color: var(--accent); opacity: .45; font-size: 13px; margin-bottom: 30px;
  text-shadow: 0 0 14px var(--glow);
}
.sect-mark { font-family: var(--mono); font-size: 12.5px; letter-spacing: .14em;
  color: var(--accent); margin-bottom: 16px; }

/* истории: каждая ветка окрашивает свою карточку */
.card.story { border-left: 3px solid var(--bc, var(--accent)); }
.card.story .tag { color: var(--bc, var(--accent)); }

/* таймлайн шагов: нить судьбы с узлами */
.steps { position: relative; padding-left: 32px; }
.steps::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px;
  background: linear-gradient(180deg, var(--accent-deep), var(--gold) 65%, transparent);
  opacity: .45;
}
.steps .onb-step { position: relative; margin-bottom: 28px; }
.steps .onb-step::before {
  content: "✦"; position: absolute; left: -31px; top: 1px;
  color: var(--gold); font-size: 12px; text-shadow: 0 0 10px rgba(232, 201, 138, .6);
}
.steps .num { color: var(--gold); letter-spacing: .18em; }

/* блок регистрации — приглашение-артефакт */
#register-block {
  border: 1px solid var(--accent-deep); border-radius: 14px;
  padding: 26px 20px 22px;
  background: linear-gradient(170deg, rgba(207, 168, 255, .09), rgba(14, 12, 26, .92) 60%);
  box-shadow: 0 0 34px rgba(207, 168, 255, .1);
}
#register-block::before { display: none; }

/* лендинг для вошедшего: регистрация спрятана, есть путь назад в ветку */
.logged-intro #register-block { display: none; }
.back-float {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); z-index: 80; white-space: nowrap;
  background: var(--panel-solid); border: 1px solid var(--accent); border-radius: 999px;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 12px 22px;
  cursor: pointer; touch-action: manipulation;
  box-shadow: 0 6px 28px rgba(0, 0, 0, .55), 0 0 18px rgba(207, 168, 255, .15);
}
.back-float:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mantra { border-left: 2px solid var(--gold); padding: 6px 0 6px 14px; margin: 16px 0;
  color: var(--gold); font-size: 14px; font-style: italic; text-align: left; }
.branches-line { font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  color: var(--accent); margin: 14px 0; }
.land-sect .lead a { color: var(--dim); text-decoration: underline; }

.pulse { text-align: center; color: var(--dim); font-size: 14px; padding: 24px 0; }
.pulse::after { content: "…"; animation: dots 1.2s steps(3) infinite; }
@keyframes dots { to { content: ""; } }

/* --- доступность: движение по запросу --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; }
  body::before, body::after { animation: none; }
}
