/* ============================================================
   «Мне про тебя сказали карты» — свайп-игра атрибуции.
   Единственная тема — таро (data-theme="tarot" статикой в html);
   светлая база ниже — наследие, поверх неё таро-оверрайды.
   ============================================================ */

:root {
  /* палитра-база: пастельная лаванда */
  --bg-top: #f6f1ff;
  --bg-mid: #e9defb;
  --bg-low: #d3c0f4;
  --cloud-pink: #ffd9ee;
  --cloud-lilac: #e6d6ff;
  --ink: #2b2150;
  --ink-soft: #6b5c99;
  --ink-faint: #9c8fc4;
  --card: #ffffff;
  --violet: #7c3aed;
  --violet-soft: #a78bfa;
  --violet-pale: #ede9fe;
  --gold: #f7c948;
  --yes: #10b981;
  --yes-soft: #d1fae5;
  --no: #f43f5e;
  --no-soft: #ffe4ea;
  --shadow-lg: 0 18px 40px -12px rgba(90, 54, 178, .35);
  --shadow-sm: 0 4px 14px -4px rgba(90, 54, 178, .25);
  --radius: 24px;

  /* тематизируемые переменные (дефолт = facedex) */
  --accent: #ef4444;          /* покеболльный красный */
  --accent-soft: #fee2e2;
  --stamp-yes-bg: #10b981;
  --stamp-no-bg: #64748b;
  font-size: 16px;
}

/* «Арканы» — таро-читальня: дерево, пергамент, витражное золото.
   Единственная тема (выбор дизайна убран 2026-07-21). */
html[data-theme="tarot"] {
  --bg-top: #2e2019;
  --bg-mid: #3d2b1f;
  --bg-low: #241812;
  --cloud-pink: #7c5c9e;      /* витражные отсветы вместо облаков */
  --cloud-lilac: #9e6b4a;
  --ink: #3a2a1a;
  --ink-soft: #6d5335;
  --ink-faint: #96794f;
  --card: #f3e7cd;            /* пергамент */
  --violet: #6d4c2a;          /* «фиолет» кнопок → морёное дерево */
  --violet-soft: #c9a227;     /* золото */
  --violet-pale: #e7d9b8;
  --accent: #c9a227;
  --accent-soft: #f0e3bd;
  --stamp-yes-bg: #4a6741;    /* сукно ломберного стола */
  --stamp-no-bg: #7b2d26;     /* сургуч */
  --shadow-lg: 0 18px 40px -12px rgba(20, 10, 4, .6);
  --shadow-sm: 0 4px 14px -4px rgba(20, 10, 4, .45);
}

/* Шрифты (self-hosted): --font-body — тело/интерфейс,
   --font-display — звание, рейтинг и имя на карте. */
html[data-theme="tarot"] {
  --font-body: 'Literata', Georgia, serif;
  --font-display: 'Philosopher', Georgia, serif;
}

html[data-theme="tarot"] body { font-family: var(--font-body); }

/* светлые тексты на тёмном дереве (вне карточек) */
html[data-theme="tarot"] .auth-note,
html[data-theme="tarot"] .actions-legend,
html[data-theme="tarot"] .progress-label,
html[data-theme="tarot"] .loading-text,
html[data-theme="tarot"] .empty-state h2,
html[data-theme="tarot"] .empty-state p { color: #d9c49a; }

html[data-theme="tarot"] .icon-btn,
html[data-theme="tarot"] .btn-secondary,
html[data-theme="tarot"] .action-btn { background: var(--card); }

html[data-theme="tarot"] .btn-primary {
  background: linear-gradient(135deg, #6d4c2a 10%, #9e6b1f 90%);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .55);
}

html[data-theme="tarot"] .progress-track { background: rgba(243, 231, 205, .25); }

html[data-theme="tarot"] .card,
html[data-theme="tarot"] .overlay-card,
html[data-theme="tarot"] .sheet {
  border: 1.5px solid #b98f4f;
  outline: 4px solid rgba(185, 143, 79, .35);
  outline-offset: -9px;       /* двойная «арт-нуво» окантовка пергамента */
}

html[data-theme="tarot"] .qr-frame { border-color: #b98f4f; background: var(--card); }

/* --- таро-ассеты (нанобанан, нарезка cut_assets.py) --- */

/* шар-маскот: виден только в таро, чиби-маскот прячется */
.orb { display: none; }
html[data-theme="tarot"] .orb { display: block; }
.orb-lg { width: 104px; }
.orb-md { width: 80px; }
.orb-mini { width: 30px; }

/* фон: тёмное дерево поверх арт-нуво паттерна */
html[data-theme="tarot"] body {
  background:
    linear-gradient(180deg, rgba(32, 20, 12, .86) 0%, rgba(22, 13, 8, .93) 100%),
    url(/static/assets/tarot/tile.webp) center / 420px auto repeat;
}
html[data-theme="tarot"] .bg { display: none; }

/* хиро реги: гадалка с шаром, заголовок в самом арте */
.tarot-hero { display: none; }
html[data-theme="tarot"] .tarot-hero {
  display: block;
  max-height: 64dvh;
  width: auto; max-width: 100%;
  border-radius: 18px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .6);
}

/* карта = рамка с лилиями v3: фото ПОД рамкой с запасом за кромку окна
   (окно 15.67/18.81/68.66/54.46), имя — на рисованной плашке
   (18.84/78.93/62.13/14.99). Ассет с готовой альфой, апскейл ×2 под ретину. */
html[data-theme="tarot"] .card {
  inset: 0;
  margin: auto;
  /* ширина ведущая, высота из пропорции — иначе max-width ломает aspect-ratio */
  width: 100%;
  height: auto;
  max-height: 100%;
  aspect-ratio: 1072 / 1414;
  display: block;
  background: none;
  box-shadow: none;
  border: none;
  outline: none;
  border-radius: 0;
  padding: 0;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, .5));
}
/* рамка — отдельным слоем ПОВЕРХ фото: так фото можно класть с запасом,
   а кромка окна накрывается самим ажуром (без щелей по контуру) */
html[data-theme="tarot"] .card::after {
  content: "";
  position: absolute; inset: 0;
  background: url(/static/assets/tarot/frame-lilies.webp) center / 100% 100% no-repeat;
  pointer-events: none;
  z-index: 2;
}
html[data-theme="tarot"] .card-photo {
  position: absolute;
  /* с запасом за кромку окна (окно 16.3/19.8/66.2/51.9) — рамка перекроет */
  left: 14.0%; top: 17.1%;
  width: 72.0%; height: 57.6%;
  flex: none;
  border-radius: 0;
  overflow: hidden;
  background: #e7d9b8;
  z-index: 1;
}
html[data-theme="tarot"] .card-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}
html[data-theme="tarot"] .card-no {
  top: 6px; left: 6px;
  background: rgba(243, 231, 205, .92);
  font-size: .68rem;
  padding: 3px 8px;
}
html[data-theme="tarot"] .card-q { display: none; }
html[data-theme="tarot"] .card-info {
  position: absolute;
  z-index: 3;
  left: 19.2%; top: 78.6%;
  width: 61.5%; height: 15.5%;
  padding: 2px 6px;
  display: grid; align-content: center;
  text-align: center;
  pointer-events: none;
  /* плашка нарисована в самой рамке — подложка не нужна */
}
html[data-theme="tarot"] .card-name {
  font-family: var(--font-display);
  font-weight: 400;
  display: grid; gap: 1px;
  overflow: hidden;
}
html[data-theme="tarot"] .name-surname {
  font-size: 1.3rem; line-height: 1.12;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-theme="tarot"] .name-given {
  font-size: 1rem; line-height: 1.15;
  color: #5c452b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-theme="tarot"] .card-hint {
  margin: 1px 0 0;
  font-size: .62rem;
  line-height: 1.25;
  color: #7a5c33;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

html[data-theme="tarot"] .checkpoint-pct {
  background: linear-gradient(120deg, #e8c96a, #9e6b1f);
  -webkit-background-clip: text; background-clip: text;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  /* ⚠️ без японских фолбэков: кириллица в Hiragino Maru Gothic растягивается
     полноширинными глифами (выглядит как гигантский letter-spacing) */
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-low) 100%) fixed;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); overflow: hidden;
}

/* ---------- фон: мягкие облачка и блёстки ---------- */

.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.bg-cloud {
  position: absolute; border-radius: 50%;
  filter: blur(46px); opacity: .55;
}
.bg-cloud-1 { width: 340px; height: 220px; top: -60px; left: -90px; background: var(--cloud-lilac); }
.bg-cloud-2 { width: 300px; height: 200px; top: 34%; right: -110px; background: var(--cloud-pink); opacity: .4; }
.bg-cloud-3 { width: 380px; height: 240px; bottom: -80px; left: -60px; background: #cdb6f5; opacity: .5; }

.bg-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #b9a4ec 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 12%, #d9b8f5 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 46%, #b9a4ec 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 64%, #cbb5f0 50%, transparent 51%),
    radial-gradient(2px 2px at 64% 82%, #d9b8f5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 42% 34%, #cbb5f0 50%, transparent 51%);
  opacity: .7;
}

/* ---------- каркас ---------- */

.shell {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  display: flex; flex-direction: column;
}

.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- заставка ---------- */

#screen-loading { align-items: center; justify-content: center; }
.loading-inner { display: grid; justify-items: center; gap: 14px; }
.loading-text { color: var(--ink-soft); font-weight: 600; }

/* ---------- регистрация ---------- */

#screen-auth { align-items: center; justify-content: center; }

.auth-inner {
  width: 100%; padding: 20px 24px 28px;
  display: grid; justify-items: center;
  text-align: center;
}


.invite-banner {
  margin-top: 16px;
  padding: 10px 18px;
  background: var(--violet-pale);
  border: 1.5px dashed var(--violet-soft);
  border-radius: 14px;
  color: var(--violet);
  font-weight: 700; font-size: .95rem;
}
.invite-banner.invalid { background: var(--no-soft); border-color: var(--no); color: var(--no); }

.auth-form {
  width: 100%; max-width: 330px;
  margin-top: 22px;
  display: grid; gap: 12px;
}

#nickname {
  width: 100%;
  padding: 15px 20px;
  font: inherit; font-size: 1.05rem; font-weight: 600;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 2px solid transparent;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color .15s;
}
#nickname:focus-visible { border-color: var(--violet-soft); }
#nickname::placeholder { color: var(--ink-faint); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 26px;
  border-radius: 18px;
  font-weight: 800; font-size: 1.05rem;
  transition: transform .12s, box-shadow .15s;
}
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 3px solid var(--violet-soft); outline-offset: 2px; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--violet) 10%, #a855f7 90%);
  box-shadow: 0 10px 24px -8px rgba(124, 58, 237, .55);
}
.btn-primary:disabled { opacity: .6; }

.btn-secondary {
  color: var(--violet);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-mini {
  padding: 8px 14px;
  border-radius: 12px;
  font-size: .85rem; font-weight: 700;
  color: #fff;
  background: var(--violet);
}

.form-error {
  margin-top: 12px;
  color: var(--no); font-weight: 700; font-size: .92rem;
}

.auth-note {
  margin-top: 20px;
  max-width: 300px;
  color: var(--ink-faint);
  font-size: .88rem; font-weight: 500;
  line-height: 1.45;
}

/* ---------- игра: шапка ---------- */

#screen-game { position: relative; }

/* нав-уголки: чаша (рейтинг) слева, свиток (настройки) справа */
/* равняем по ВЫСОТЕ: у чаши и свитка чуть разная ширина,
   при равной ширине медальоны получались разного размера */
.corner-nav {
  position: absolute; top: 0; z-index: 3;
  height: 200px; width: auto;
  padding: 0;
  transition: transform .12s;
}
.corner-nav img { height: 100%; width: auto; display: block; }
.corner-left { left: 0; transform-origin: top left; }
.corner-right { right: 0; transform-origin: top right; }
.corner-nav:active { transform: scale(.93); }
.corner-nav:focus-visible { outline: 3px solid #c9a227; outline-offset: -3px; }

.game-header {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 96px 0;
}

/* прогресс до сверки: 10 мини-карт внахлёст, заполняются рубашкой */
.progress { display: flex; align-items: center; padding-left: 9px; }

.pc {
  width: 22px;
  aspect-ratio: 683 / 1154;
  margin-left: -9px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, .25);
  background: rgba(255, 255, 255, .35);
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
  transition: transform .2s, filter .2s;
}
.pc.filled {
  background: url(/static/assets/tarot/card-back.webp) center / cover no-repeat;
  transform: translateY(-2px) rotate(-2deg);
}
.progress.almost .pc.filled:last-of-type { animation: glow .9s ease-in-out infinite; }
@keyframes glow { 50% { filter: brightness(1.3) saturate(1.3); } }

.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-ghost {
  color: var(--ink-faint);
  font-size: .92rem;
  padding: 10px 18px;
}

.settings-nick { color: var(--ink-soft); font-weight: 700; }

.auth-hero-wrap { position: relative; max-width: 100%; }
.auth-actions {
  display: flex; gap: 12px; justify-content: center; align-items: stretch;
  margin-top: 16px;
}
.btn-qr { padding: 14px 18px; }
html[data-theme="tarot"] .auth-actions {
  position: absolute;
  left: 0; right: 0; bottom: 4.5%;
  margin: 0;
}
html[data-theme="tarot"] .auth-actions .btn {
  box-shadow: 0 10px 24px -6px rgba(0, 0, 0, .65);
}
html[data-theme="tarot"] .auth-note { display: none; }   /* текст убираем */

/* ---------- звание и рейтинг над картой ---------- */

/* ступень: звание + баллы + место — одной плашкой */
.rank-line {
  display: grid; align-content: center; justify-items: center;
  width: min(84%, 360px);
  aspect-ratio: 1063 / 287;
  margin: 2px auto;
  padding: 0 8%;
  text-align: center;
  background: url(/static/assets/tarot/rank-plaque.webp) center / 100% 100% no-repeat;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .4));
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 400;
  line-height: 1.22;
  color: #e8c96a;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

/* ---------- игра: колода ---------- */

.deck {
  position: relative;
  flex: 1; min-height: 0;
  width: 95%;
  margin: 2px auto;
  touch-action: none;
}

.card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 12px 0;
  user-select: none; -webkit-user-select: none;
  transition: transform .42s cubic-bezier(.3, 1.1, .4, 1), opacity .4s;
  will-change: transform;
}
.card.dragging { transition: none; }
.card.flying { opacity: 0; pointer-events: none; }
.card.enter { animation: deal .38s cubic-bezier(.24, 1.3, .45, 1); }
@keyframes deal { from { transform: translateY(16px) scale(.96); } }

.card-photo {
  position: relative;
  flex: 1; min-height: 0;
  border-radius: calc(var(--radius) - 10px);
  overflow: hidden;
  background: var(--violet-pale);
}
.card-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* номер записи — как номер в дексе */
.card-no {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  color: var(--ink-soft);
  font-size: .78rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
}

.card-info {
  padding: 14px 8px 16px;
  text-align: center;
}

.card-q {
  font-size: .72rem; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;             /* единственный трекинг — ярлык-«бровь» */
  color: var(--accent);
  margin-bottom: 3px;
}

.card-name {
  font-size: 1.45rem; font-weight: 800;
  line-height: 1.15;
}

.card-hint {
  margin-top: 3px;
  color: var(--ink-faint);
  font-size: .88rem; font-weight: 600;
  min-height: 1.2em;
}

/* штампы при драге */
.stamp {
  position: absolute; top: 26px; z-index: 4;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 1.15rem; font-weight: 900;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}
.stamp-yes { left: 20px; transform: rotate(-11deg); background: var(--stamp-yes-bg); }
.stamp-no { right: 20px; transform: rotate(11deg); background: var(--stamp-no-bg); }

/* ---------- игра: кнопки-дублёры ---------- */

/* нижняя навигация: плашка со стрелками и шаром */
.actions {
  position: relative;
  width: min(50%, 260px);
  margin: 2px auto calc(8px + env(safe-area-inset-bottom));
}
.actions-bar {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .5));
}
.hit {
  position: absolute; top: 6%; bottom: 8%;
  width: 34%;
  border-radius: 14px;
}
.hit-no { left: 2%; }
.hit-yes { right: 2%; }
.hit-orb { left: 38%; width: 24%; top: -4%; bottom: -4%; border-radius: 50%; }
.hit:active { background: radial-gradient(closest-side, rgba(255, 235, 170, .35), transparent); }

/* слоты подсказки шара: карты персоны или пергаментные заглушки */
.hint-slots {
  display: flex; gap: 12px; justify-content: center;
  width: 100%;
  margin-top: 6px;
}
.hint-slot {
  width: 42%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: #efe3c4;   /* пергаментная заливка, если персону ещё не видели */
  border: 2px solid #b98f4f;
  box-shadow: inset 0 0 18px rgba(122, 92, 51, .35);
}
.hint-slot img { width: 100%; height: 100%; object-fit: cover; }

/* шар в центре — индикатор близкой сверки */
.actions.almost::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 24%; aspect-ratio: 1;
  transform: translate(-50%, -52%);
  border-radius: 50%;
  box-shadow: 0 0 26px 10px rgba(232, 201, 106, .5);
  animation: glow .9s ease-in-out infinite;
  pointer-events: none;
}

/* ---------- пустое состояние ---------- */

.empty-state {
  flex: 1;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  text-align: center; padding: 0 30px;
}
.empty-state h2 { font-size: 1.4rem; font-weight: 800; }
.empty-state p { color: var(--ink-soft); font-weight: 600; }
.empty-actions { display: flex; gap: 26px; margin-top: 18px; justify-content: center; align-items: flex-start; }

/* кнопки-эмблемы: те же чаша и свиток, что в верхних углах */
.emblem-btn {
  display: grid; justify-items: center; align-content: end; gap: 10px;
  width: 116px;
  padding: 0;
  transition: transform .12s;
}
.emblem-btn img {
  height: 84px; width: auto;      /* чаша и свиток разной ширины — равняем по высоте */
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, .55));
}
.emblem-btn span {
  font-size: .82rem; font-weight: 700;
  color: #d9c49a;
}
.emblem-btn:active { transform: scale(.94); }

/* ---------- оверлеи ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(43, 33, 80, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px;
}

.overlay-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 26px 24px 24px;
  display: grid; grid-template-columns: 100%; justify-items: center; gap: 8px;
  text-align: center;
  animation: pop .3s cubic-bezier(.24, 1.3, .45, 1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.checkpoint-eyebrow {
  font-size: .74rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent);
}

.checkpoint-pct {
  font-size: 4rem; font-weight: 900; line-height: 1;
  background: linear-gradient(120deg, var(--violet), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}

.checkpoint-caption { color: var(--ink-soft); font-weight: 600; font-size: .92rem; }

.checkpoint-pioneer {
  font-size: 1.05rem; font-weight: 700;
  color: var(--ink); line-height: 1.4;
}

.checkpoint-title {
  margin-top: 2px;
  font-size: 1.15rem; font-weight: 800;
  color: var(--violet);
}

.overlay-card .btn { margin-top: 10px; min-width: 150px; }

.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.confetti {
  position: absolute; top: -14px;
  width: 9px; height: 13px;
  border-radius: 2px;
  animation: fall var(--dur, 3s) linear var(--delay, 0s) forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(var(--spin, 480deg)); opacity: .1; }
}

/* ---------- шторка лидерборда ---------- */

.overlay-sheet { align-items: flex-end; padding: 0; }

.sheet {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 12px 22px calc(20px + env(safe-area-inset-bottom));
  max-height: 76dvh;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .32s cubic-bezier(.24, 1.2, .5, 1);
}
@keyframes rise { from { transform: translateY(40%); } }

.sheet-handle {
  width: 44px; height: 5px;
  border-radius: 999px;
  background: var(--violet-pale);
  margin: 0 auto;
}

.sheet-title { font-size: 1.25rem; font-weight: 800; text-align: center; }

.leaderboard-body { overflow-y: auto; min-height: 0; }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint);
  text-align: left; padding: 6px 4px;
}
.lb-table td { padding: 8px 4px; font-weight: 600; border-top: 1px solid var(--violet-pale); }
.lb-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Имена стали двухсловными («Медовый Оракул») и вдвое длиннее прежних «Маг №417».
   Цифровые колонки ужимаем до содержимого, ник забирает весь остаток — иначе
   каждая строка переносится в две и в рейтинг влезает 6 позиций вместо десяти. */
.lb-table th:nth-child(2), .lb-table td:nth-child(2) { width: 100%; }
/* Ник — одна строка всегда: на узких экранах (320px) двухсловные имена вроде
   «Сумеречный Архивариус» всё равно не влезают целиком даже урезав соседние
   колонки — обрезаем многоточием, а не переносим. Перенос удваивал высоту
   строки, и в рейтинг влезало 6 позиций вместо десяти. */
.lb-table td:nth-child(2) {
  font-size: .9rem; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 0;   /* заставляет колонку сжиматься до общей ширины таблицы (width:100% выше её растягивает обратно) */
}
.lb-table th:first-child, .lb-table td:first-child { padding-right: 2px; }
.lb-table .num { white-space: nowrap; font-size: .85rem; }
.lb-table th.num { font-size: .64rem; letter-spacing: .04em; }
/* заливка ровная, а не градиент: градиент рисовался в КАЖДОЙ ячейке заново,
   и своя строка читалась как три полосы со стыками */
.lb-table tr.me td {
  background: var(--violet-pale);
  font-weight: 800;
}
.lb-table tr.me td:first-child { border-radius: 10px 0 0 10px; }
.lb-table tr.me td:last-child { border-radius: 0 10px 10px 0; }

.lb-empty, .lb-note {
  text-align: center; color: var(--ink-soft);
  font-weight: 600; font-size: .92rem; padding: 8px 0;
}

.sheet-close { align-self: center; }

/* ---------- модал приглашения ---------- */

.invite-sub { color: var(--ink-soft); font-weight: 600; font-size: .92rem; }

.qr-frame {
  margin-top: 8px;
  padding: 12px;
  background: #fff;
  border: 2.5px dashed var(--violet-soft);
  border-radius: 20px;
}
.qr-frame img { border-radius: 8px; }


/* ---------- reduced motion ---------- */

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

/* ---------- гейт устройства и сплеш правил ---------- */

#screen-desktop, #screen-splash { align-items: center; justify-content: center; }

.desktop-inner, .splash-inner {
  display: grid; justify-items: center; gap: 12px;
  padding: 20px 26px;
  text-align: center;
  max-width: 420px;
}
.desktop-inner .tarot-hero { max-height: 34dvh; }

.desktop-title, .splash-title {
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 400;
  color: #e8c96a;
}
.desktop-sub { color: #d9c49a; font-size: .92rem; }

.splash-text {
  color: #e6d6b4;
  font-size: 1rem; line-height: 1.5;
}
.splash-text b { color: #e8c96a; font-weight: 700; }
.splash-inner .btn { margin-top: 8px; min-width: 170px; }

/* ---------- «ты ли это?» при возврате по куке ---------- */

#screen-welcome { align-items: center; justify-content: center; }

.welcome-inner {
  display: grid; justify-items: center; gap: 14px;
  margin: auto;              /* центрируем в пространстве НАД «нет» */
  padding: 20px 26px;
  text-align: center;
  max-width: 420px;
}
.welcome-eyebrow { color: #d9c49a; font-size: .95rem; }
.welcome-nick {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 400; line-height: 1.2;
  color: #e8c96a;
  text-wrap: balance;
}
.welcome-inner .btn { margin-top: 6px; min-width: 170px; }

/* «нет» — внизу экрана, чтобы не соперничал с «да» */
.welcome-deny {
  margin: 0 auto 28px;
  color: #c8b28a;
}

/* перевыбрать предложенное имя */
.btn-reroll {
  justify-self: center;
  margin-top: -4px;
  padding: 6px 14px;
  font-size: .85rem;
  color: #d9c49a;
}

/* ---------- сводка в свитке ---------- */

.settings-nick {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 400;
  color: var(--ink);
}
.settings-stats {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px;
  width: 100%;
  margin: 2px 0 6px;
  padding: 10px 12px;
  border-top: 1px solid rgba(122, 92, 51, .35);
  border-bottom: 1px solid rgba(122, 92, 51, .35);
  font-size: .9rem;
}
.settings-stats dt { color: var(--ink-soft); text-align: left; }
.settings-stats dd {
  margin: 0; text-align: right; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- сканер приглашения ---------- */

.scan-frame {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 18px;
  overflow: hidden;
  background: #2e2019;
  border: 2.5px dashed #b98f4f;
}
.scan-frame video { width: 100%; height: 100%; object-fit: cover; }
.scan-card .invite-sub { min-height: 2.4em; }

.auth-caption {
  margin-top: 10px;
  color: #d9c49a;
  font-size: .92rem;
  text-align: center;
}
