:root {
  /* почти чёрный с тёплым отсветом сверху — свеча над столом, а не «мистика» */
  --bg: #14121b;
  --bg-deep: #09080d;
  --panel: #1c1926;
  --line: #2e2938;
  --gold: #c8a45c;
  --gold-dim: #7d6a3e;
  --text: #ece6da;
  --text-dim: #948d9c;
  --card-ratio: 1.667;   /* 600×1000 у сканов */
  --ease: cubic-bezier(.22,.75,.28,1);
}

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

/* иначе display:flex у .waiting перебивает атрибут hidden и блок торчит всегда */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(90% 55% at 50% -8%, rgba(200, 148, 74, .16) 0%, transparent 62%),
    radial-gradient(130% 90% at 50% 0%, #1d1a26 0%, var(--bg) 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------- звёздный фон */

.stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.stars i {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--gold);
  border-radius: 50%;
  opacity: .25;
  animation: twinkle 4s var(--ease) infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .10; transform: scale(.8); }
  50%      { opacity: .45; transform: scale(1.15); }
}

/* ---------------------------------------------------------- экраны */

.screen {
  position: relative;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  animation: rise .45s var(--ease);
}
.screen.active { display: flex; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- типографика */

.persona, .title {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: .06em;
  color: var(--gold);
  margin: 4px 0 10px;
  text-align: center;
}
.persona { font-size: 32px; }
.title   { font-size: 23px; }

.lead {
  margin: 0 0 20px;
  max-width: 30em;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
}

.disclaimer {
  margin-top: 26px;
  max-width: 30em;
  text-align: center;
  color: #6a6474;
  font-size: 11.5px;
  line-height: 1.5;
}

.hint { min-height: 18px; margin: 6px 0 10px; color: #cf8b6f; font-size: 13px; }

/* герб над именем */
.crest {
  width: 62px; height: 62px;
  margin: 10px 0 4px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background:
    radial-gradient(circle at 50% 50%, transparent 46%, var(--gold-dim) 47%, transparent 49%),
    conic-gradient(from 0deg, transparent 0 6%, var(--gold) 6% 7%, transparent 7% 12.5%);
  position: relative;
}
.crest::after {
  content: "";
  position: absolute; inset: 34%;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: inset -5px -1px 0 0 var(--bg);
}

/* ---------------------------------------------------------- кнопки */

.btn {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 8px 0 0;
  padding: 15px 18px;
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  background: linear-gradient(180deg, #232030, #1a1824);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s var(--ease), opacity .16s;
}
.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .38; }
.btn.ghost { background: none; border-color: var(--line); color: var(--text-dim); }

/* ---------------------------------------------------------- меню раскладов */

.spreads { width: 100%; max-width: 360px; }

.spread {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(32,29,42,.9), rgba(24,21,32,.9));
  cursor: pointer;
  transition: transform .16s var(--ease), border-color .16s;
}
.spread:active { transform: scale(.985); }
.spread.locked { opacity: .5; }
.spread .glyph { font-size: 24px; width: 30px; text-align: center; }
.spread .body { flex: 1; min-width: 0; }
.spread .name { font-size: 16px; margin-bottom: 3px; }
.spread .meta { font-size: 12.5px; color: var(--text-dim); }
.spread .price { color: var(--gold); font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------- поле вопроса */

textarea {
  width: 100%;
  max-width: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(9,8,13,.75);
  color: var(--text);
  font: inherit;
  font-size: 16px;   /* меньше 16px — iOS зумит страницу при фокусе */
  resize: none;
}
textarea:focus { outline: none; border-color: var(--gold-dim); }

/* ---------------------------------------------------------- карта */

.card {
  position: absolute;
  width: var(--cw);
  height: calc(var(--cw) * var(--card-ratio));
  perspective: 900px;
  transition: transform .55s var(--ease), opacity .35s;
  cursor: pointer;
}
.card .inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .62s var(--ease);
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(0,0,0,.55);
}
.card.flipped .inner { transform: rotateY(180deg); }

.card .side {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 8px;
  border: 1px solid var(--gold-dim);
  overflow: hidden;
  background: var(--panel);
}
.card .side img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .side.face { transform: rotateY(180deg); }
.card .side.face img.rev { transform: rotate(180deg); }

/* лёгкое дыхание у ещё не открытых карт — подсказывает, что можно тапнуть */
.card:not(.flipped) .inner { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* ---------------------------------------------------------- тасование */

.shuffle-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 360px;
  min-height: 250px;
  margin-bottom: 14px;
  touch-action: none;
}
/* анимации нарисованы с прозрачным фоном, поэтому ложатся прямо на градиент */
.shuffle-anim {
  width: 100%;
  max-width: 340px;
  height: auto;
  transition: transform .18s var(--ease);
}
.shuffle-anim.pulse { transform: scale(1.06); }

/* колода на экране вопроса: перебирается на каждой набранной букве,
   чтобы ритуал начинался раньше, чем человек дописал вопрос */
.mini-deck {
  position: relative;
  width: 100%;
  max-width: 300px;
  height: 104px;
  margin: 2px 0 10px;
  pointer-events: none;
}
.mini-deck .card {
  left: 50%;
  top: 4px;
  margin-left: calc(var(--cw) / -2);
  transition: transform .34s var(--ease);
}
.mini-deck .card .inner { animation: none; }

.progress {
  width: 100%; max-width: 340px; height: 3px;
  margin-bottom: 16px;
  border-radius: 3px;
  background: #262232;
  overflow: hidden;
}
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width .25s var(--ease);
}

/* ---------------------------------------------------------- снятие колоды */

.cut-zone {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: 340px;
  touch-action: manipulation;
}
.cut-zone .slice {
  position: absolute;
  left: 50%;
  width: 128px;
  height: 6px;
  margin-left: -64px;
  border-radius: 2px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, #232030, #17151f);
  transition: transform .3s var(--ease), border-color .2s, opacity .3s;
}
.cut-zone .slice.hot { border-color: var(--gold); transform: translateX(9px); }
.cut-zone .cutline {
  position: absolute;
  left: 50%; width: 190px; margin-left: -95px;
  height: 0;
  border-top: 1px dashed var(--gold);
  opacity: 0;
  transition: opacity .2s, top .12s var(--ease);
}
.cut-zone .cutline.on { opacity: .9; }

/* ---------------------------------------------------------- стол */

.table {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 4px 0 18px;
}

.card .label {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: 132%;
  margin-left: -66%;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity .4s .25s;
  pointer-events: none;
}
.card.flipped .label { opacity: 1; }
.card .label b { display: block; color: var(--gold); font-weight: 400; font-size: 12.5px; }

/* Подписи под каждой картой помещаются только в раскладах на 1-3 карты.
   Для Кельтского креста они уезжают в список под столом. */
.legend {
  width: 100%;
  max-width: 360px;
  margin: 0 0 20px;
  padding: 0 0 0 24px;
  list-style: decimal;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}
.legend li {
  margin-bottom: 7px;
  opacity: .25;
  transition: opacity .45s var(--ease);
}
.legend li.on { opacity: 1; }
.legend li b { color: var(--gold); font-weight: 400; }
.legend li span { display: block; color: var(--text); }

/* ---------------------------------------------------------- толкование */

.waiting {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 10px 0 30px;
  padding-top: 26px;
}
.waiting p { margin: 0; color: var(--text-dim); font-size: 14px; }
.waiting .orb {
  position: absolute;
  top: 0;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold);
  animation: orbit 1.4s ease-in-out infinite;
}
.waiting .orb:nth-child(1) { left: calc(50% - 20px); animation-delay: 0s; }
.waiting .orb:nth-child(2) { left: calc(50% - 4px);  animation-delay: .18s; }
.waiting .orb:nth-child(3) { left: calc(50% + 12px); animation-delay: .36s; }
@keyframes orbit {
  0%, 100% { transform: translateY(0); opacity: .3; }
  50%      { transform: translateY(-9px); opacity: 1; }
}

.reading { width: 100%; max-width: 360px; animation: rise .5s var(--ease); }
.reading-head {
  margin-bottom: 14px;
  padding-left: 12px;
  border-left: 2px solid var(--gold-dim);
  color: var(--text-dim);
  font-style: italic;
  font-size: 14px;
}
.reading-text {
  margin-bottom: 22px;
  font-size: 16px;
  line-height: 1.68;
}
.reading-text p { margin: 0 0 14px; }
.reading-text p.in { animation: rise .5s var(--ease) both; }

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

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translate(-50%, 20px);
  max-width: 300px;
  padding: 12px 18px;
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  background: rgba(20,18,27,.97);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
  z-index: 50;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
