/* =====================================================================
   base.css — структура и поведение. НЕ содержит цветов/радиусов/теней:
   всё визуальное берётся из переменных темы (css/theme-*.css).
   Смена стиля = подмена theme-файла + папки assets.
   ===================================================================== */

/* ---------- Reset & app shell ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

html {
  /* Флюидный масштаб: всё сверстано в rem, поэтому тянется под любой девайс.
     390px → 16px; 320px → ~13.5px; 480px+ → 19px (кап). */
  font-size: clamp(13.5px, 4.1vw, 21px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: var(--fw-body, 700);
  color: var(--c-text);
  background: var(--c-bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  /* Mobile-app требования */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* убирает double-tap zoom */
  position: fixed; inset: 0;  /* фиксируем, чтобы iOS не скроллил страницу */
}

img, svg { display: block; -webkit-user-drag: none; user-drag: none; pointer-events: none; }
button, a { pointer-events: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
a { color: inherit; text-decoration: none; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* Текстовые блоки: любой текст, любой длины — переносится, не ломает сетку */
.t, [data-text] { overflow-wrap: anywhere; word-break: normal; text-wrap: balance; min-width: 0; }
.t-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }         /* одна строка */
.t-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } /* две строки */
.t-fit { font-size: clamp(0.7em, 4vw, 1em); } /* ужимаемый заголовок */

/* ---------- Safe area & layout regions ---------- */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gutter: 1rem;          /* боковой отступ 16 */
  --topbar-h: 3.5rem;      /* 56 */
  --bottombar-h: 5.25rem;  /* 84 */
  --center-btn: 6rem;      /* 96 */
  --hit: 2.75rem;          /* минимальная зона тапа 44 */
  --app-max-w: 900px;      /* ВЕБ: единственное ограничение — максимальная ширина; по бокам фон темы */
}

.app {
  position: fixed; inset: 0;
  width: 100%; height: 100dvh;
  max-width: var(--app-max-w, 40rem); margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--c-bg) var(--bg-image, none) center / cover no-repeat;
  isolation: isolate;
}

/* Верхняя зона: safe-area + topbar */
.topbar {
  padding: calc(var(--sat) + 0.5rem) calc(var(--gutter) + var(--sar)) 0 calc(var(--gutter) + var(--sal));
  display: flex; align-items: center; gap: 0.5rem; min-height: calc(var(--topbar-h) + var(--sat));
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.topbar__center { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
.topbar__right { margin-left: auto; }

/* Игровая/контентная зона */
.stage { position: relative; min-height: 0; overflow: hidden; }
.hud-left, .hud-right { position: absolute; top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.hud-left  { left: calc(var(--gutter) + var(--sal)); }
.hud-right { right: calc(var(--gutter) + var(--sar)); }
.stage__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 0 5rem; pointer-events: none; }
.stage__center > * { pointer-events: auto; }

/* Нижний бар: 2 + центральная + 2, стоит на safe-area */
.bottombar {
  position: relative;
  padding: 0 calc(0.75rem + var(--sar)) calc(var(--sab) + 0.5rem) calc(0.75rem + var(--sal));
}
.bottombar__bar {
  height: var(--bottombar-h);
  display: flex; align-items: stretch; gap: 0.25rem; padding: 0.5rem;
  background: var(--bar-bg); border-radius: var(--r-xl); box-shadow: var(--bar-shadow);
}
.bottombar__tab {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  border-radius: var(--r-l); font-size: 0.7rem; color: var(--c-muted); position: relative;
}
.bottombar__tab .ico { width: 1.6rem; height: 1.6rem; }
.bottombar__tab.is-active { background: var(--tab-active-bg); color: var(--tab-active-fg); }
.bottombar__tab:active { transform: translateY(2px); }
.bottombar__spacer { flex: 0 0 var(--center-btn); }
.bottombar__center {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 0.5rem + var(--bottombar-h) - var(--center-btn) * 0.65);
  transform: translateX(-50%);
  width: var(--center-btn); height: var(--center-btn); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font-size: 0.7rem; color: var(--btn-accent-fg);
  background: var(--btn-accent-bg); box-shadow: var(--btn-accent-shadow), 0 0 0 0.375rem var(--c-bg);
}
.bottombar__center .ico { width: 2.1rem; height: 2.1rem; }
.bottombar__center:active { transform: translateX(-50%) translateY(3px); box-shadow: var(--btn-accent-shadow-pressed), 0 0 0 0.375rem var(--c-bg); }

/* Вариант 2: центральная кнопка НЕ вылезает за бар — обычный таб, но стилизованный.
   <nav class="bottombar bottombar--flat"> … <button class="bottombar__tab bottombar__tab--main"> */
.bottombar--flat .bottombar__spacer { display: none; }
.bottombar--flat .bottombar__center { display: none; }
.bottombar__tab--main { flex: 1.3 1 0; background: var(--btn-accent-bg); color: var(--btn-accent-fg); box-shadow: var(--btn-accent-shadow-inbar); font-size: 0.75rem; }
.bottombar__tab--main .ico { width: 1.9rem; height: 1.9rem; }
.bottombar__tab--main:active { box-shadow: var(--btn-accent-shadow-pressed); }
.bottombar__tab--main.is-active { background: var(--btn-accent-bg); color: var(--btn-accent-fg); }

/* Баннер рекламы (опционально) */
.adslot { height: 3.125rem; margin: 0 var(--gutter) 0.5rem; border-radius: var(--r-m); border: 2px dashed var(--c-line); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--c-muted); }

/* ---------- Icons (SVG sprite) ---------- */
.ico { width: 1.5rem; height: 1.5rem; fill: currentColor; flex: 0 0 auto; }
.ico--s { width: 1rem; height: 1rem; } .ico--l { width: 2rem; height: 2rem; }

/* ---------- Buttons ---------- */
.btn {
  --_bg: var(--btn-secondary-bg); --_fg: var(--btn-secondary-fg); --_sh: var(--btn-secondary-shadow); --_shp: var(--btn-secondary-shadow-pressed);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--hit); padding: 0 1.25rem; border-radius: var(--r-l);
  font-family: var(--font-display); font-weight: var(--fw-display, 800); font-size: 1rem; line-height: 1;
  text-transform: var(--btn-case, none); letter-spacing: var(--btn-tracking, 0);
  color: var(--_fg); background: var(--_bg); box-shadow: var(--_sh);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
  white-space: nowrap; user-select: none;
}
.btn .t { white-space: normal; }
/* состояния */
.btn:active, .btn.is-pressed { transform: translateY(var(--btn-press, 4px)); box-shadow: var(--_shp); }
.btn:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.btn.is-disabled, .btn:disabled { --_bg: var(--btn-disabled-bg); --_fg: var(--btn-disabled-fg); --_sh: var(--btn-disabled-shadow); --_shp: var(--btn-disabled-shadow); pointer-events: none; }
.btn.is-loading { pointer-events: none; color: transparent; }
.btn.is-loading::after { content: ""; position: absolute; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 3px solid var(--_fg); border-right-color: transparent; animation: spin .8s linear infinite; }
.btn.is-locked::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--btn-locked-overlay); }
.btn.is-highlight { animation: pulse 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { filter: brightness(1); transform: scale(1);} 50% { filter: brightness(1.08); transform: scale(1.03);} }
/* варианты */
.btn--primary  { --_bg: var(--btn-primary-bg);  --_fg: var(--btn-primary-fg);  --_sh: var(--btn-primary-shadow);  --_shp: var(--btn-primary-shadow-pressed); }
.btn--reward   { --_bg: var(--btn-reward-bg);   --_fg: var(--btn-reward-fg);   --_sh: var(--btn-reward-shadow);   --_shp: var(--btn-reward-shadow-pressed); }
.btn--accent   { --_bg: var(--btn-accent-bg);   --_fg: var(--btn-accent-fg);   --_sh: var(--btn-accent-shadow);   --_shp: var(--btn-accent-shadow-pressed); }
.btn--danger   { --_bg: var(--btn-danger-bg);   --_fg: var(--btn-danger-fg);   --_sh: var(--btn-danger-shadow);   --_shp: var(--btn-danger-shadow-pressed); }
.btn--info     { --_bg: var(--btn-info-bg);     --_fg: var(--btn-info-fg);     --_sh: var(--btn-info-shadow);     --_shp: var(--btn-info-shadow-pressed); }
/* семантические алиасы для магазина/лотов: три разные кнопки */
.btn--ad   { --_bg: var(--btn-reward-bg);  --_fg: var(--btn-reward-fg);  --_sh: var(--btn-reward-shadow);  --_shp: var(--btn-reward-shadow-pressed); }   /* за рекламу */
.btn--iap  { --_bg: var(--btn-iap-bg);     --_fg: var(--btn-iap-fg);     --_sh: var(--btn-iap-shadow);     --_shp: var(--btn-iap-shadow-pressed); }      /* за деньги */
.btn--free { --_bg: var(--btn-free-bg);    --_fg: var(--btn-free-fg);    --_sh: var(--btn-free-shadow);    --_shp: var(--btn-free-shadow-pressed); }     /* бесплатно */
.btn--ghost    { --_bg: transparent; --_fg: var(--c-muted); --_sh: none; --_shp: none; font-family: var(--font-body); text-decoration: var(--btn-ghost-underline, none); }
/* размеры */
.btn--xl { min-height: 4.75rem; padding: 0 2rem; font-size: 1.75rem; border-radius: var(--r-xl); }
.btn--l  { min-height: 4rem;    padding: 0 1.5rem; font-size: 1.25rem; border-radius: var(--r-xl); }
.btn--s  { min-height: 2.25rem; padding: 0 0.875rem; font-size: 0.75rem; border-radius: var(--r-m); --btn-press: 3px; }
.btn--block { display: flex; width: 100%; }
/* иконочные */
.btn--icon { width: var(--hit); height: var(--hit); padding: 0; border-radius: var(--r-l); }
.btn--icon.btn--l { width: 3.25rem; height: 3.25rem; }
.btn--icon.btn--round { border-radius: 50%; }
/* бейдж на кнопке */
.badge { position: absolute; right: -0.35rem; top: -0.35rem; min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem; border-radius: 999px; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; background: var(--badge-bg); color: var(--badge-fg); box-shadow: 0 0 0 2px var(--c-bg); }
.badge--count { right: -0.35rem; bottom: -0.35rem; top: auto; background: var(--c-panel); color: var(--c-text); box-shadow: var(--sh-s); }
.dot { position: absolute; right: -0.15rem; top: -0.15rem; width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--badge-bg); box-shadow: 0 0 0 2px var(--c-bg); }

/* ---------- Pills (валюта, таймер, лейблы) ---------- */
.pill { display: inline-flex; align-items: center; gap: 0.375rem; height: 2.5rem; padding: 0 0.25rem 0 0.25rem; border-radius: 999px; background: var(--pill-bg); box-shadow: var(--pill-shadow); font-size: 0.95rem; white-space: nowrap; }
.pill__ico { width: 1.75rem; height: 1.75rem; border-radius: 50%; flex: 0 0 auto; background: var(--asset-coin) center / contain no-repeat; }
.pill__ico--gem { background-image: var(--asset-gem); border-radius: 0; }
.pill__val { padding-right: 0.5rem; }
.pill__plus { width: 1.75rem; height: 1.75rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--btn-primary-bg); color: var(--btn-primary-fg); box-shadow: var(--sh-inset-s); }
.pill--timer { padding: 0 0.75rem; color: var(--c-danger-text); gap: 0.25rem; }
.tag { display: inline-flex; align-items: center; height: 1.5rem; padding: 0 0.6rem; border-radius: var(--r-s); font-size: 0.7rem; font-family: var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.tag--new { background: var(--c-danger); color: #fff; } .tag--free { background: var(--c-primary); color: #fff; } .tag--ad { background: var(--c-reward); color: var(--c-reward-text); } .tag--iap { background: var(--c-accent); color: #fff; } .tag--info { background: var(--c-info); color: #fff; } .tag--sale { background: var(--c-reward); color: var(--c-reward-text); }

/* ---------- Avatar / level ---------- */
.avatar { position: relative; width: 3rem; height: 3rem; border-radius: 50%; background: var(--c-panel) var(--asset-avatar) center / cover; box-shadow: var(--pill-shadow); }
.avatar__lvl { position: absolute; left: 50%; bottom: -0.5rem; transform: translateX(-50%); height: 1.125rem; padding: 0 0.45rem; border-radius: 999px; background: var(--c-accent); color: #fff; font-size: 0.7rem; display: flex; align-items: center; box-shadow: 0 0 0 2px var(--c-bg); }

/* ---------- Progress ---------- */
.progress { position: relative; height: 1.375rem; border-radius: 999px; background: var(--progress-track); box-shadow: var(--progress-track-shadow); overflow: hidden; }
.progress__fill { position: absolute; left: 3px; top: 3px; bottom: 3px; width: var(--p, 0%); border-radius: 999px; background: var(--progress-fill); box-shadow: var(--progress-fill-shadow); transition: width .4s ease; }
.progress--reward .progress__fill { background: var(--progress-fill-reward); }
.progress--accent .progress__fill { background: var(--progress-fill-accent); }
.progress--danger .progress__fill { background: var(--progress-fill-danger); }
.progress__label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; }
.progress--s { height: 0.875rem; } .progress--s .progress__fill { left: 2px; top: 2px; bottom: 2px; }
/* с узлами по краям */
.progress-row { display: flex; align-items: center; gap: 0.5rem; }
.progress-row .progress { flex: 1 1 0; }
.node { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; background: var(--c-accent-soft); flex: 0 0 auto; }
.node--done { background: var(--c-primary); color: #fff; }
.node--muted { background: var(--c-panel); color: var(--c-muted); box-shadow: var(--sh-inset-s); }
/* кольцо-таймер */
.ring { --p: 0; --size: 4.5rem; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; font-size: 0.85rem;
  background: conic-gradient(var(--c-info) calc(var(--p) * 1%), var(--progress-track) 0); }
.ring::before { content: ""; grid-area: 1/1; width: calc(var(--size) - 1.1rem); height: calc(var(--size) - 1.1rem); border-radius: 50%; background: var(--c-panel); }
.ring > * { grid-area: 1/1; }

/* ---------- Panels / cards / tiles ---------- */
.panel { background: var(--c-panel); border-radius: var(--r-xl); box-shadow: var(--panel-shadow); }
.panel--inset { background: var(--c-bg); box-shadow: var(--sh-inset-s); }

/* Универсальный тайл: фон-картинка на весь блок через --bg, поверх — контент.
   <div class="tile" style="--bg:url(...)"> */
.tile {
  position: relative; overflow: visible; border-radius: var(--r-l);
  background: var(--tile-bg); box-shadow: var(--tile-shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.375rem; padding: 0.5rem;
  min-height: var(--tile-h, 7rem); isolation: isolate;
}
.tile::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--bg, none) center / cover no-repeat; z-index: -1; }
.tile::after  { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--tile-scrim, none); z-index: -1; }
.tile__head { width: calc(100% + 1rem); margin: -0.5rem 0 0; padding: 0.35rem 0.25rem; text-align: center; font-size: 0.7rem; border-radius: var(--r-l) var(--r-l) 0 0; background: var(--c-locked-dk); color: var(--c-muted); }
.tile--active .tile__head { background: var(--c-reward); color: var(--c-reward-text); }
.tile--done .tile__head { background: var(--c-primary); color: #fff; }
.tile__body { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.tile__name { font-size: 0.8rem; text-align: center; }
.tile__cta { width: 100%; }
.tile__cta .btn { width: 100%; padding: 0 0.4rem; font-size: 0.72rem; gap: 0.25rem; min-width: 0; }
.tile__cta .btn .ico { width: 0.9rem; height: 0.9rem; }
.tile--active { box-shadow: var(--tile-shadow-active); }
.tile--done { background: var(--c-primary-soft); box-shadow: var(--tile-shadow-done); }
.tile--locked { background: var(--c-locked-bg); box-shadow: var(--tile-shadow-locked); color: var(--c-muted); }
.tile--locked::before { filter: grayscale(1) opacity(.5); }
.tile--gold { background: var(--tile-gold-bg); box-shadow: var(--tile-gold-shadow); }
.tile__lock { position: absolute; inset: 0; border-radius: inherit; display: flex; align-items: center; justify-content: center; background: var(--c-locked-overlay); }
.tile__corner { position: absolute; left: -0.25rem; top: -0.35rem; }
.tile__corner--r { left: auto; right: -0.25rem; }
.tile__check { position: absolute; right: -0.25rem; top: -0.25rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--c-primary); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--c-bg); }
.tile__check .ico { width: 0.9rem; height: 0.9rem; }

/* Сетки */
.grid { display: grid; gap: 0.75rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }
.center { text-align: center; }

/* Список-строка (квесты, магазин) */
.listrow { display: flex; align-items: center; gap: 0.625rem; min-height: 4.125rem; padding: 0.5rem 0.5rem 0.5rem 0.625rem; border-radius: var(--r-l); background: var(--c-panel); box-shadow: var(--tile-shadow); }
.listrow__ico { width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem; overflow: hidden; border-radius: var(--r-m); background: var(--c-accent-soft); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.listrow__ico img { width: 1.5rem; height: 1.5rem; }
.listrow__main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.listrow__title { font-size: 0.85rem; line-height: 1.1; }
.listrow__aside { flex: 0 0 auto; width: 3.9rem; min-height: 3.1rem; border-radius: var(--r-m); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem; font-size: 0.7rem; background: var(--c-bg); box-shadow: var(--sh-inset-s); }
.listrow--ready { box-shadow: var(--tile-shadow-active); }
.listrow--done { background: var(--c-primary-soft); color: var(--c-primary-text); }
.listrow--done .listrow__title { text-decoration: line-through; opacity: .8; }
.listrow--locked { background: var(--c-locked-bg); color: var(--c-muted); box-shadow: var(--tile-shadow-locked); }

/* Табы / тогглы / чекбокс */
.tabs { display: flex; gap: 0.25rem; padding: 0.25rem; border-radius: 999px; background: var(--c-panel); box-shadow: var(--panel-shadow); }
.tabs__tab { flex: 1 1 0; min-height: 2.25rem; border-radius: 999px; font-family: var(--font-display); font-size: 0.8rem; color: var(--c-muted); position: relative; }
.tabs__tab.is-active { background: var(--tab-active-bg); color: var(--tab-active-fg); box-shadow: var(--sh-inset-s); }
.toggle { position: relative; width: 4.25rem; height: 2.375rem; border-radius: 999px; background: var(--c-locked-bg); box-shadow: var(--sh-inset-top); transition: background .2s; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: calc(2.375rem - 6px); height: calc(2.375rem - 6px); border-radius: 50%; background: var(--c-panel); box-shadow: var(--sh-s); transition: transform .2s; }
.toggle.is-on { background: var(--c-primary); } .toggle.is-on::after { transform: translateX(1.875rem); }
.check { width: 1.875rem; height: 1.875rem; border-radius: var(--r-s); background: var(--c-panel); box-shadow: inset 0 0 0 3px var(--c-locked-bg); display: flex; align-items: center; justify-content: center; color: #fff; }
.check.is-on { background: var(--c-primary); box-shadow: var(--sh-inset-s); }

/* ---------- MODAL SYSTEM ----------
   Один каркас для всех окон. Тип задаётся классом на .modal:
   .modal--popup   — центрированная карточка поверх затемнения
   .modal--sheet   — полноэкранная панель со скроллом (магазин, альбом)
   .modal--full    — полноэкранный оверлей без карточки (Special gift, reveal)
*/
.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto;
  padding: calc(var(--sat) + 1rem) calc(var(--gutter) + var(--sar)) calc(var(--sab) + 1rem) calc(var(--gutter) + var(--sal)); }
.modal__scrim { position: absolute; inset: 0; background: var(--modal-scrim); backdrop-filter: var(--modal-blur, none); -webkit-backdrop-filter: var(--modal-blur, none); }
.modal__win { position: relative; width: 100%; max-width: 22rem; max-height: 100%; display: flex; flex-direction: column;
  background: var(--c-panel); border-radius: var(--r-xxl); box-shadow: var(--modal-shadow); }
.modal__head { position: relative; flex: 0 0 auto; padding: 1.75rem 1.25rem 0; text-align: center; }
.modal__ribbon { position: absolute; left: 50%; top: -1.65rem; transform: translateX(-50%); min-height: 3.375rem; padding: 0 1.5rem; border-radius: 999px;
  background: var(--ribbon-bg); color: var(--ribbon-fg); box-shadow: var(--ribbon-shadow); font-family: var(--font-display); font-size: 1.375rem; line-height: 1; display: flex; align-items: center; white-space: nowrap; max-width: calc(100% - 2rem); overflow: hidden; text-overflow: ellipsis; }
.modal__title { font-family: var(--font-display); font-size: 1.75rem; line-height: 1; }
.modal__subtitle { font-size: 0.8rem; color: var(--c-muted); margin-top: 0.35rem; padding: 0 2rem; }
.modal__close { position: absolute; right: 0.75rem; top: 0.75rem; z-index: 2; }
.modal__close--out { right: -0.5rem; top: -0.5rem; }
.modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.875rem; align-items: stretch; }
.modal__body > * { flex-shrink: 0; }
.modal__body { padding-top: 1.25rem; }
.grid { padding: 0.35rem 0.25rem 0; margin: -0.35rem -0.25rem 0; }
.modal__body--center { align-items: center; text-align: center; }
.modal__foot { flex: 0 0 auto; padding: 0 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.625rem; }
.modal__foot--row { flex-direction: row; }
.modal__foot--row > .btn { flex: 1 1 0; }
.modal__fade { position: sticky; bottom: -1rem; height: 2rem; margin: -2rem -1.25rem -1rem; background: linear-gradient(transparent, var(--c-panel)); pointer-events: none; flex: 0 0 auto; }

/* sheet: панель на весь экран (с учётом safe-area), шапка цветная */
.modal--sheet { padding: 0; align-items: stretch; }
.modal--sheet .modal__win { max-width: var(--app-max-w, 40rem); margin: 0 auto; height: 100%; border-radius: 0; box-shadow: none; background: var(--c-bg); }
.modal--sheet .modal__head { padding: calc(var(--sat) + 0.75rem) var(--gutter) 0.75rem; background: var(--sheet-head-bg); border-radius: 0 0 var(--r-xxl) var(--r-xxl); box-shadow: var(--panel-shadow); display: flex; align-items: center; gap: 0.625rem; text-align: left; }
.modal--sheet .modal__title { flex: 1 1 0; text-align: center; font-size: 1.5rem; }
.modal--sheet .modal__body { padding: 1rem var(--gutter) calc(var(--sab) + 1rem); }
.modal--sheet .modal__foot { padding: 0.5rem var(--gutter) calc(var(--sab) + 0.75rem); background: linear-gradient(transparent, var(--c-bg) 40%); }

/* full: оверлей на весь экран, контент по центру, без карточки */
.modal--full { padding: 0; }
.modal--full .modal__scrim { background: var(--full-bg); }
.modal--full .modal__win { max-width: none; height: 100%; background: transparent; box-shadow: none; border-radius: 0; padding: calc(var(--sat) + 1rem) var(--gutter) calc(var(--sab) + 1rem); }
.modal--full .modal__body { align-items: center; justify-content: center; text-align: center; overflow: visible; }
.modal--full .modal__foot { align-items: center; }
.modal--full .modal__foot .btn { width: min(100%, 18.5rem); }
.modal--full .modal__close { top: calc(var(--sat) + 1rem); right: var(--gutter); }
.rays { position: absolute; left: 50%; top: 45%; width: 200vmax; height: 200vmax; transform: translate(-50%, -50%); border-radius: 50%; background: var(--rays); animation: rays 40s linear infinite; pointer-events: none; }
@keyframes rays { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* screen: игровой экран целиком (HUD геймплея, забег) — тот же .app-каркас внутри окна */
.modal--screen { padding: 0; }
.modal--screen .modal__scrim { background: transparent; }
.modal--screen .modal__win { max-width: none; height: 100%; border-radius: 0; box-shadow: none; background: transparent; }
.modal--screen .modal__body { padding: 0; overflow: hidden; }
.modal--screen .app { position: absolute; }
.modal--screen .modal__close { display: none; }

/* анимации появления */
.modal { animation: fade .18s ease both; }
.modal--popup .modal__win { animation: pop .22s cubic-bezier(.2,.9,.3,1.2) both; }
.modal--sheet .modal__win { animation: slide .22s ease both; }
.modal.is-closing { animation: fade .15s ease reverse both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide { from { transform: translateY(6%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; width: 100%; }
.field__label { font-size: 0.75rem; color: var(--c-muted); padding-left: 0.5rem; }
.input { display: flex; align-items: center; gap: 0.5rem; min-height: 3.25rem; padding: 0 0.75rem 0 0.875rem; border-radius: var(--r-l); background: var(--input-bg, var(--c-bg)); box-shadow: var(--input-shadow, var(--sh-inset-top)); color: var(--c-text); }
.input .ico { color: var(--c-muted); }
.input input { flex: 1 1 0; min-width: 0; border: 0; background: transparent; font: inherit; font-weight: 700; color: inherit; outline: none; -webkit-user-select: text; user-select: text; }
.input input::placeholder { color: var(--c-muted); opacity: .8; }
.input:focus-within { box-shadow: var(--input-shadow, var(--sh-inset-top)), 0 0 0 3px var(--c-focus); }
.input.is-error { box-shadow: 0 0 0 3px var(--c-danger); }
.field__hint { font-size: 0.7rem; color: var(--c-muted); padding-left: 0.5rem; } .is-error + .field__hint { color: var(--c-danger-text); }
.divider { display: flex; align-items: center; gap: 0.75rem; width: 100%; color: var(--c-muted); font-size: 0.75rem; }
.divider::before, .divider::after { content: ""; flex: 1 1 0; height: 2px; background: var(--c-line); opacity: .6; }
/* Кнопки соц-логина: слот .btn__brand под официальный логотип провайдера (asset из его brand kit) */
.btn--social { --_bg: var(--social-bg, #FFFFFF); --_fg: var(--social-fg, #1F1F1F); --_sh: var(--btn-secondary-shadow); --_shp: var(--btn-secondary-shadow-pressed); justify-content: flex-start; padding: 0 1rem; font-family: var(--font-body); text-transform: none; letter-spacing: 0; }
.btn--social .btn__brand { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; border-radius: 50%; background: var(--brand, var(--c-locked-dk)) center / 60% no-repeat; display: grid; place-items: center; font-size: 0.8rem; font-weight: 900; color: #fff; }
.btn--social .btn__label { flex: 1 1 0; text-align: center; }
.btn--social.btn--apple { --social-bg: #000000; --social-fg: #FFFFFF; --_sh: none; --_shp: none; }
.btn--social.btn--google { --social-bg: #FFFFFF; --social-fg: #1F1F1F; }
.btn--social.btn--facebook { --social-bg: #1877F2; --social-fg: #FFFFFF; --_sh: inset 0 -6px 0 #0F5FCC; --_shp: inset 0 -2px 0 #0F5FCC; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: calc(var(--sat) + 5rem); transform: translateX(-50%); z-index: 200; padding: 0.6rem 1.25rem; border-radius: 999px; background: var(--c-panel); box-shadow: var(--panel-shadow); font-family: var(--font-display); font-size: 1.1rem; color: var(--c-danger-text); animation: pop .2s ease both; pointer-events: none; }

/* ---------- Debug launcher (главная) ---------- */
.launcher__fab { position: absolute; right: calc(var(--gutter) + var(--sar)); bottom: 0.5rem; z-index: 5; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--c-panel); color: var(--c-muted); box-shadow: var(--sh-s); display: grid; place-items: center; opacity: .7; }
.launcher:not(.is-open) { display: none; }
.launcher.is-open { display: grid; z-index: 4; }
.launcher { position: absolute; left: 50%; bottom: 0.5rem; transform: translateX(-50%); width: min(100% - 2rem, 22rem); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.375rem; padding: 0.5rem; border-radius: var(--r-l); background: color-mix(in srgb, var(--c-panel) 80%, transparent); box-shadow: var(--panel-shadow); }
.launcher__btn { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.35rem 0; border-radius: var(--r-m); font-size: 0.55rem; color: var(--c-muted); }
.launcher__btn .ico { width: 1.25rem; height: 1.25rem; color: var(--c-text); }
.launcher__btn:active { background: var(--c-bg); }

/* ---------- Helpers ---------- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--c-muted); }
.small { font-size: 0.75rem; }
.strike { text-decoration: line-through; color: var(--c-muted); }
.price { font-family: var(--font-display); font-size: 1.75rem; color: var(--c-danger-text); }
.display { font-family: var(--font-display); font-weight: var(--fw-display, 800); }
.h1 { font-size: 2.5rem; line-height: 1; } .h2 { font-size: 1.75rem; line-height: 1; } .h3 { font-size: 1.25rem; line-height: 1.1; }
.num-xl { font-family: var(--font-display); font-size: 4rem; line-height: 1; letter-spacing: -0.02em; }

/* Веб/десктоп: приложение центрировано, ограничено только --app-max-w; вокруг — фон темы */
html, body { background: var(--c-bg); }
@media (min-width: 700px) { .app { box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 0 80px rgba(0,0,0,.18); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
