/* Таромыч — мини-апп. Оформление: «стол Таромыча» (см. DESIGN-NOTES.md).
   Индиго-сукно, золочёный обрез карт (линия, не свечение), голос персонажа
   набран PT Serif (кириллический шрифт ParaType), вордмарк — Cormorant.
   Тёмный вид зафиксирован намеренно — не зависит от темы Telegram. */

/* --- Шрифты (self-hosted, кириллица + латиница) ----------------------- */

@font-face {
  font-family: "Cormorant"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/cormorant-600-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Cormorant"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/cormorant-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: "PT Serif"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/ptserif-400-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Serif"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/ptserif-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: "PT Serif"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("fonts/ptserif-400i-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Serif"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("fonts/ptserif-400i-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: "PT Serif"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("fonts/ptserif-700-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "PT Serif"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("fonts/ptserif-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

/* --- Токены ----------------------------------------------------------- */

:root {
  --ink: #160E24;
  --cloth: #241640;
  --cloth-raised: #2E1E4E;
  --gilt: #C9A24B;
  --gilt-bright: #E4C87E;
  --rose: #C98DA0;
  --parchment: #EDE4D3;
  --parchment-dim: #A99DB8;
  --hairline: rgba(201, 162, 75, 0.28);
  --border-soft: rgba(233, 224, 208, 0.10);

  --serif: "PT Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --display: "Cormorant", "PT Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.62;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: rgba(201, 162, 75, 0.32); color: var(--parchment); }

:focus-visible {
  outline: 2px solid var(--gilt-bright);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Ночь за столом: фон -------------------------------------------- */

.night {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--ink);
}

.night::before { /* туманность юзера — задавлена и обесцвечена до «ночного неба» */
  content: "";
  position: absolute;
  inset: 0;
  background: url("bg.png") center top / cover no-repeat;
  filter: saturate(0.5) brightness(0.52) contrast(1.05);
}

.night::after { /* виньетка + тёплый огонёк свечи снизу */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(56% 40% at 50% 114%, rgba(206, 142, 68, 0.14) 0%, rgba(206, 142, 68, 0) 70%),
    radial-gradient(145% 92% at 50% -4%, rgba(22, 14, 36, 0.42) 0%, rgba(20, 13, 33, 0.80) 46%, rgba(18, 11, 30, 0.97) 100%);
}

#app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.hidden { display: none !important; }

/* --- Дом: за столом ------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}

.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: 0.05em;
  color: var(--gilt);
  line-height: 1;
}

.balance {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(46, 30, 78, 0.4);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 15px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  color: var(--parchment);
  font-variant-numeric: lining-nums tabular-nums;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.balance-star { color: var(--gilt); font-size: 13px; }
.balance:active { border-color: var(--gilt); }

.greeting {
  font-size: 21px;
  line-height: 1.5;
  color: var(--parchment);
  margin: 0 0 26px;
  max-width: 25ch;
  text-wrap: balance;
}

.greeting.sm {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--parchment-dim);
  max-width: 46ch;
  margin-bottom: 18px;
}

/* Приглашение к карте дня — единственный «громкий» элемент экрана */
.daily-invite {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  text-align: left;
  background: rgba(46, 30, 78, 0.32);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  color: var(--parchment);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.daily-invite:active { border-color: var(--gilt); background: rgba(46, 30, 78, 0.5); }

.daily-invite-text { display: flex; flex-direction: column; gap: 3px; }
.daily-invite-title { font-weight: 700; font-size: 17px; }
.daily-invite-sub { font-style: italic; font-size: 13.5px; color: var(--parchment-dim); }

/* Рубашка карты — рисованный мотив (двойная звезда + золочёный обрез) */
.tarot-back {
  flex-shrink: 0;
  display: block;
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 320'%3E%3Crect x='9' y='9' width='202' height='302' rx='6' fill='none' stroke='%23C9A24B' stroke-width='1.5'/%3E%3Crect x='15.5' y='15.5' width='189' height='289' rx='3' fill='none' stroke='%23C9A24B' stroke-opacity='0.4' stroke-width='0.9'/%3E%3Cg transform='translate(110 168)' fill='none' stroke='%23C9A24B' stroke-width='1.3' stroke-linejoin='round'%3E%3Cpath d='M0,-54 L13,-13 L54,0 L13,13 L0,54 L-13,13 L-54,0 L-13,-13 Z'/%3E%3Cpath d='M0,-35 L9,-9 L35,0 L9,9 L0,35 L-9,9 L-35,0 L-9,-9 Z' stroke-opacity='0.5'/%3E%3Ccircle r='2.6' fill='%23C9A24B' stroke='none'/%3E%3C/g%3E%3Cg stroke='%23C98DA0' stroke-width='1.2' stroke-linecap='round'%3E%3Cpath d='M26,26 h12 M26,26 v12'/%3E%3Cpath d='M194,26 h-12 M194,26 v12'/%3E%3Cpath d='M26,294 h12 M26,294 v-12'/%3E%3Cpath d='M194,294 h-12 M194,294 v-12'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-position: center;
}

.daily-invite .tarot-back {
  width: 58px;
  height: 84px;
  border-radius: 5px;
}

#daily-flip-card .tarot-back { border-radius: 8px; }

/* Расклады и Профиль — панели потише, чем карта дня, но с фоном */
.home-panel {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(38, 24, 58, 0.42);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 15px 18px;
  margin-bottom: 12px;
  color: var(--parchment);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.home-panel:active { border-color: var(--gilt); background: rgba(46, 30, 78, 0.55); }
.home-panel.compact { padding: 13px 18px; margin-bottom: 0; }

.home-panel-title {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  margin-bottom: 3px;
}
.home-panel.compact .home-panel-title { margin-bottom: 1px; }

.home-panel-note {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  color: var(--parchment-dim);
  max-width: 44ch;
}

/* --- Внутренние экраны: шапка ------------------------------------- */

.bar {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

.back {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 2px 0;
  margin-bottom: 12px;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--gilt);
  cursor: pointer;
}
.back::before { content: "\2190"; margin-right: 7px; }
.back:active { color: var(--gilt-bright); }

.bar-title {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 25px;
  line-height: 1.1;
  color: var(--parchment);
}

/* --- Карта дня --------------------------------------------------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 14px 0 8px;
}

.card-flip { width: 162px; height: 274px; perspective: 1000px; }

.card-face {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
}

.card-back { transition: transform 0.55s ease; }
.card-back.revealed { animation: flip-reveal 0.55s ease forwards; }

@keyframes flip-reveal {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0); }
}

.stage-line {
  font-size: 15px;
  font-style: italic;
  color: var(--parchment-dim);
  text-align: center;
  max-width: 28ch;
  margin: 0;
}

/* --- Кнопка-действие ------------------------------------------- */

.act {
  display: block;
  width: 100%;
  background: var(--gilt);
  color: var(--ink);
  border: 1px solid var(--gilt);
  border-radius: 8px;
  padding: 14px 20px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.1s ease;
}

.act:active { background: var(--gilt-bright); transform: translateY(1px); }
.act:disabled { opacity: 0.5; }

.act.ghost {
  background: none;
  color: var(--parchment);
  border-color: var(--hairline);
  font-weight: 400;
  margin-top: 10px;
}
.act.ghost:active { background: rgba(201, 162, 75, 0.08); transform: none; }

/* --- Расклады: список ----------------------------------------- */

.spread-list { display: flex; flex-direction: column; gap: 12px; }

.spread-option {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(38, 24, 58, 0.42);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--parchment);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.spread-option:active { border-color: var(--gilt); background: rgba(46, 30, 78, 0.55); }

.spread-option-title {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  margin-bottom: 3px;
}
.spread-option-meta { display: block; font-size: 13px; font-style: italic; color: var(--parchment-dim); }

/* --- Поля ввода --------------------------------------------- */

.field {
  width: 100%;
  background: rgba(22, 14, 36, 0.5);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 12px 14px;
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  margin-bottom: 14px;
}
.field:focus { border-color: var(--gilt); }
.field::placeholder { color: var(--parchment-dim); font-style: italic; }

/* --- Расклад: результат + разговор -------------------------- */

.reading { margin-bottom: 18px; }

.drawn-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.card-mini {
  flex-shrink: 0;
  width: 60px;
  height: 94px;
  border: 1.5px solid var(--gilt);
  border-radius: 5px;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.42);
}

.card-mini-glyph {
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  line-height: 1;
  color: var(--gilt-bright);
}
.card-mini.reversed .card-mini-glyph { transform: rotate(180deg); }

.card-mini-suit { font-size: 9px; letter-spacing: 0.04em; color: var(--parchment-dim); }

.card-mini::after {
  content: "\2726";
  font-size: 8px;
  color: var(--gilt);
  opacity: 0.55;
}

.drawn-card-body { flex: 1; min-width: 0; padding-top: 2px; }

.drawn-card-position {
  display: block;
  font-style: italic;
  font-size: 12.5px;
  color: var(--rose);
  margin-bottom: 2px;
}

.drawn-card-name { display: block; font-weight: 700; font-size: 15.5px; margin-bottom: 4px; }
.drawn-card-meaning { display: block; font-size: 13px; line-height: 1.5; color: var(--parchment-dim); }

.interpretation {
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--parchment);
  white-space: pre-wrap;
  padding-top: 14px;
  margin-top: 6px;
  border-top: 1px solid var(--hairline);
}

.chat-thread { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 16px; }

.chat-bubble {
  max-width: 88%;
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  color: var(--parchment);
  background: var(--cloth-raised);
  border: 1px solid var(--hairline);
  border-radius: 10px 10px 2px 10px;
  padding: 9px 13px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  color: var(--parchment);
  padding-left: 14px;
  border-left: 1.5px solid var(--rose);
}

.ask-row { display: flex; gap: 8px; align-items: stretch; }
.ask-row .field { margin-bottom: 0; }

.ask-send {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--gilt);
  border-radius: 6px;
  padding: 0 16px;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--gilt);
  cursor: pointer;
}
.ask-send:active { background: rgba(201, 162, 75, 0.1); }

.quota { font-size: 12.5px; font-style: italic; color: var(--parchment-dim); margin: 10px 0 0; }

/* --- Профиль: гроссбух ------------------------------------- */

.ledger { margin: 0 0 24px; }

.ledger > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--hairline);
}
.ledger > div:last-child { border-bottom: none; }

.ledger dt { font-size: 14.5px; color: var(--parchment-dim); }
.ledger dd {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  color: var(--parchment);
  font-variant-numeric: lining-nums tabular-nums;
}

/* --- История раскладов ---------------------------------- */

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(38, 24, 58, 0.42);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 13px 16px;
  color: var(--parchment);
  font-family: var(--serif);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.history-item:active { border-color: var(--gilt); }

.history-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
}
.history-item-spread { font-weight: 700; font-size: 14.5px; }
.history-item-date { flex-shrink: 0; font-size: 12px; font-style: italic; color: var(--parchment-dim); }
.history-item-cards { display: block; font-size: 13px; color: var(--parchment-dim); }
.history-item-q { display: block; margin-top: 3px; font-size: 12.5px; font-style: italic; color: var(--rose); }

/* --- Пополнить ------------------------------------------- */

.on-hand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.on-hand span { font-size: 14px; font-style: italic; color: var(--parchment-dim); }
.on-hand strong {
  font-weight: 700;
  font-size: 18px;
  color: var(--gilt);
  font-variant-numeric: lining-nums tabular-nums;
}

.package-list { display: flex; flex-direction: column; }

.package-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  padding: 16px 0;
  color: var(--parchment);
  font-family: var(--serif);
  cursor: pointer;
}
.package-option:last-child { border-bottom: none; }
.package-option:active .package-option-credits { color: var(--gilt-bright); }

.package-option-credits { font-size: 16px; font-weight: 700; }
.package-option-price {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--gilt);
  font-variant-numeric: tabular-nums;
}

.fineprint {
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.7;
  color: var(--parchment-dim);
  margin-top: 18px;
}

/* --- Служебное ----------------------------------------- */

.error-banner {
  border-left: 2px solid var(--rose);
  padding: 4px 0 4px 12px;
  font-size: 13.5px;
  color: var(--rose);
  margin-bottom: 14px;
}

.empty-hint {
  font-style: italic;
  color: var(--parchment-dim);
  font-size: 14px;
  padding: 22px 0;
}

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