/* =====================================================================
   Пополнение Steam — Telegram Mini App.
   Палитра Steam, минимализм, сдержанные анимации. Один акцент — квитанция.
   Мобильная адаптация, тёмная тема, доступность, prefers-reduced-motion.
   ===================================================================== */

:root {
  --steam-bg-top: #1b2838;
  --steam-bg-bottom: #11151c;
  --steam-panel: #2a3f5a;
  --steam-panel-soft: #1f3047;
  --steam-line: #38506e;
  --steam-accent: #66c0f4;
  --steam-accent-strong: #1999ff;
  --steam-accent-press: #1283d6;
  --steam-text: #ffffff;
  --steam-text-dim: #c6d4e1;
  --steam-text-faint: #8aa0b6;
  --steam-ok: #6dbf3c;
  --steam-warn: #e0a93f;
  --steam-err: #e15555;

  --radius: 12px;
  --radius-lg: 16px;
  --gap: 16px;
  --tap: 50px;

  color-scheme: dark;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Motiva Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  color: var(--steam-text);
  background:
    radial-gradient(1100px 520px at 50% -8%, #2c4a6b 0%, transparent 62%),
    linear-gradient(180deg, var(--steam-bg-top) 0%, var(--steam-bg-bottom) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Фоновое сияние ------------------------------------------------------ */
.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.aurora__blob {
  position: absolute;
  width: 60vw;
  max-width: 420px;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.22;
}
.aurora__blob--1 {
  top: -10%; left: -15%;
  background: radial-gradient(circle, var(--steam-accent) 0%, transparent 70%);
  animation: drift1 18s ease-in-out infinite;
}
.aurora__blob--2 {
  top: 25%; right: -20%;
  background: radial-gradient(circle, var(--steam-accent-strong) 0%, transparent 70%);
  animation: drift2 22s ease-in-out infinite;
}

/* --- Контейнер ----------------------------------------------------------- */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    calc(env(safe-area-inset-right, 0px) + 18px)
    calc(env(safe-area-inset-bottom, 0px) + 24px)
    calc(env(safe-area-inset-left, 0px) + 18px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Шапка --------------------------------------------------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand__logo { width: 28px; height: 28px; flex: 0 0 auto; color: var(--steam-accent); }

/* --- Шаги ----------------------------------------------------------------- */
.step { display: flex; flex-direction: column; gap: var(--gap); }
.step:not(.is-hidden) { animation: step-in 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.step:not(.is-hidden) > * { animation: rise 0.42s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.step:not(.is-hidden) > *:nth-child(2) { animation-delay: 0.05s; }
.step:not(.is-hidden) > *:nth-child(3) { animation-delay: 0.10s; }
.step:not(.is-hidden) > *:nth-child(4) { animation-delay: 0.14s; }
.step:not(.is-hidden) > *:nth-child(5) { animation-delay: 0.18s; }
.step:not(.is-hidden) > *:nth-child(6) { animation-delay: 0.22s; }
.is-hidden { display: none !important; }

/* --- Герой (шаг 1) ------------------------------------------------------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 18px 0 6px;
}
.hero__mark {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  color: var(--steam-accent);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102,192,244,0.16) 0%, transparent 70%);
  animation: glow 3.6s ease-in-out infinite;
}
.hero__mark svg { width: 46px; height: 46px; }
.hero__title { margin: 4px 0 0; font-size: 25px; font-weight: 800; letter-spacing: -0.3px; }
.hero__sub { margin: 0; font-size: 15px; color: var(--steam-text-dim); }

.pill {
  margin-top: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--steam-accent);
  background: rgba(102, 192, 244, 0.12);
  border: 1px solid rgba(102, 192, 244, 0.35);
  border-radius: 999px;
}

/* --- Поля ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field__label {
  font-size: 13px; font-weight: 600; color: var(--steam-text-faint);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.field__input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  font-size: 16px; color: var(--steam-text);
  background: var(--steam-panel-soft);
  border: 1px solid var(--steam-line); border-radius: var(--radius);
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field__input::placeholder { color: var(--steam-text-faint); }
.field__input:focus-visible {
  border-color: var(--steam-accent);
  box-shadow: 0 0 0 3px rgba(102, 192, 244, 0.25);
}
.field__input[aria-invalid="true"] {
  border-color: var(--steam-err);
  box-shadow: 0 0 0 3px rgba(225, 85, 85, 0.2);
}
.field__amount { position: relative; display: flex; align-items: center; }
.field__amount .field__input { padding-right: 46px; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.field__suffix {
  position: absolute; right: 14px; font-size: 18px; font-weight: 700;
  color: var(--steam-text-faint); pointer-events: none;
}

.hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--steam-text-faint); min-height: 18px; }
.hint--error { color: var(--steam-err); }

/* --- Чипы быстрого выбора ------------------------------------------------ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  flex: 1 1 auto; min-width: 64px; min-height: 40px; padding: 0 10px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--steam-text-dim);
  background: var(--steam-panel-soft);
  border: 1px solid var(--steam-line); border-radius: 10px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.chip:hover { border-color: var(--steam-accent); color: var(--steam-text); }
.chip:active { transform: scale(0.96); }
.chip.is-active {
  color: var(--steam-text);
  border-color: var(--steam-accent);
  background: rgba(102, 192, 244, 0.14);
}

/* --- Калькулятор --------------------------------------------------------- */
.calc {
  padding: 14px 16px;
  background: var(--steam-panel-soft);
  border: 1px solid var(--steam-line);
  border-radius: var(--radius);
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.calc.is-empty { opacity: 0.6; }
.calc.is-active { border-color: rgba(102, 192, 244, 0.45); }
.calc__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.calc__label { font-size: 14px; color: var(--steam-text-dim); }
.calc__value { font-size: 22px; font-weight: 800; color: var(--steam-accent); font-variant-numeric: tabular-nums; }
.calc__approx { font-size: 15px; font-weight: 600; color: var(--steam-text-faint); }
.calc__note { margin: 6px 0 0; font-size: 12px; color: var(--steam-text-faint); line-height: 1.4; }

/* --- Кнопки -------------------------------------------------------------- */
.btn {
  position: relative; overflow: hidden;
  width: 100%; min-height: var(--tap); padding: 0 18px;
  font-size: 16px; font-weight: 700; font-family: inherit; color: var(--steam-text);
  border: 0; border-radius: var(--radius); cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(102, 192, 244, 0.4); }
.btn--primary {
  background: linear-gradient(135deg, var(--steam-accent-strong) 0%, var(--steam-accent-press) 100%);
  box-shadow: 0 8px 22px rgba(25, 153, 255, 0.28);
}
.btn--primary:hover { filter: brightness(1.08); }
/* мягкий блик при наведении */
.btn--primary::before {
  content: ""; position: absolute; top: 0; left: -60%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-20deg); transition: left 0.5s ease;
}
.btn--primary:hover::before { left: 130%; }
.btn--ghost { background: transparent; border: 1px solid var(--steam-line); color: var(--steam-text-dim); }
.btn--ghost:hover { border-color: var(--steam-accent); color: var(--steam-text); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { color: transparent; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

/* --- Карточка аккаунта --------------------------------------------------- */
.account {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--steam-panel-soft); border: 1px solid var(--steam-line); border-radius: var(--radius);
}
.account__avatar { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 8px; object-fit: cover; background: var(--steam-panel); }
.account__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.account__label { font-size: 12px; color: var(--steam-text-faint); text-transform: uppercase; letter-spacing: 0.6px; }
.account__name { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__change {
  flex: 0 0 auto; min-height: 36px; padding: 0 12px; font-size: 13px; font-weight: 600; font-family: inherit;
  color: var(--steam-accent); background: transparent; border: 1px solid var(--steam-line);
  border-radius: 8px; cursor: pointer;
}
.account__change:hover { border-color: var(--steam-accent); }

/* --- Квитанция (сигнатура) ----------------------------------------------- */
.receipt {
  position: relative; padding: 20px; overflow: hidden;
  background: linear-gradient(180deg, var(--steam-panel) 0%, var(--steam-panel-soft) 100%);
  border: 1px solid var(--steam-line); border-radius: var(--radius-lg);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4);
}
.receipt::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--steam-accent) 0%, var(--steam-accent-strong) 100%);
}
.receipt__head { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px dashed var(--steam-line); }
.receipt__avatar { width: 52px; height: 52px; flex: 0 0 auto; border-radius: 10px; object-fit: cover; background: var(--steam-panel-soft); }
.receipt__head-meta { min-width: 0; flex: 1 1 auto; }
.receipt__label { display: block; font-size: 12px; color: var(--steam-text-faint); text-transform: uppercase; letter-spacing: 0.6px; }
.receipt__name { display: block; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt__bonus {
  flex: 0 0 auto; padding: 4px 9px; font-size: 12px; font-weight: 700;
  color: var(--steam-ok); background: rgba(109, 191, 60, 0.14);
  border: 1px solid rgba(109, 191, 60, 0.4); border-radius: 999px; white-space: nowrap;
}
.receipt__rows { display: flex; flex-direction: column; gap: 12px; padding: 16px 0 4px; }
.receipt__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--steam-text-dim); }
.receipt__row b { font-size: 16px; font-weight: 700; color: var(--steam-text); font-variant-numeric: tabular-nums; }
.receipt__row--total { padding-top: 12px; border-top: 1px solid var(--steam-line); }
.receipt__row--total b { font-size: 24px; color: var(--steam-accent); }

.receipt__meter { margin-top: 16px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.receipt__meter i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--steam-accent), var(--steam-accent-strong)); transform-origin: left center; }
.receipt__timer { margin: 10px 0 0; font-size: 13px; color: var(--steam-text-faint); text-align: center; }
.receipt__timer--soon { color: var(--steam-warn); }

/* --- Статус -------------------------------------------------------------- */
.status { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 16px; text-align: center; }
.status__icon { position: relative; width: 84px; height: 84px; display: grid; place-items: center; border-radius: 50%; }
.status__icon--ok { background: rgba(109, 191, 60, 0.14); }
.status__icon--wait { background: rgba(102, 192, 244, 0.14); }
.status__icon--warn { background: rgba(224, 169, 63, 0.14); }
.status__icon--err { background: rgba(225, 85, 85, 0.14); }

/* SVG-галочка: видна только для ok, рисуется штрихом */
.status__check { width: 56px; height: 56px; display: none; }
.status__icon--ok .status__check { display: block; }
.status__check-ring { stroke: var(--steam-ok); stroke-width: 2.5; stroke-dasharray: 145; stroke-dashoffset: 145; }
.status__check-mark { stroke: var(--steam-ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 48; stroke-dashoffset: 48; }
.status__icon--ok.is-animating .status__check-ring { animation: draw 0.5s ease forwards; }
.status__icon--ok.is-animating .status__check-mark { animation: draw 0.4s ease 0.35s forwards; }

/* Глиф для warn/err */
.status__glyph { font-size: 40px; line-height: 1; font-weight: 700; }
.status__icon--ok .status__glyph { display: none; }
.status__icon--warn .status__glyph { color: var(--steam-warn); }
.status__icon--err .status__glyph { color: var(--steam-err); }
/* Спиннер для wait */
.status__icon--wait .status__glyph::after {
  content: ""; display: block; width: 36px; height: 36px;
  border: 3px solid rgba(102, 192, 244, 0.35); border-top-color: var(--steam-accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}

.status__title { margin: 0; font-size: 21px; font-weight: 800; }
.status__text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--steam-text-dim); max-width: 340px; }

/* --- Блок отзыва (на экране успеха) ------------------------------------- */
.review {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(109, 191, 60, 0.08);
  border: 1px solid rgba(109, 191, 60, 0.3);
  border-radius: var(--radius-lg);
}
.review__text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--steam-text-dim); }
.review__text b { color: var(--steam-ok); font-weight: 800; }
.btn--review {
  background: linear-gradient(135deg, #6dbf3c 0%, #4e9a2a 100%);
  box-shadow: 0 8px 22px rgba(109, 191, 60, 0.28);
}
.btn--review:hover { filter: brightness(1.08); }

/* --- Подвал -------------------------------------------------------------- */
.footer { margin: auto 0 0; padding-top: 8px; text-align: center; font-size: 12px; color: var(--steam-text-faint); }

/* --- Тосты --------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%) translateY(8px); max-width: 88%;
  padding: 12px 16px; font-size: 14px; line-height: 1.4; color: #fff;
  background: var(--steam-err); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 50;
}
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Анимации ------------------------------------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes step-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(102,192,244,0); } 50% { box-shadow: 0 0 28px 2px rgba(102,192,244,0.28); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes drift1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(16%, 10%); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-14%, 8%); } }

/* --- Доступность: меньше движения --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .status__check-ring, .status__check-mark { stroke-dashoffset: 0 !important; }
  .aurora { display: none; }
}

@media (max-width: 340px) {
  .app { padding-left: 14px; padding-right: 14px; }
  .receipt { padding: 16px; }
  .hero__title { font-size: 22px; }
}
