:root {
  /* === Material Design 3 — тёмная ЧЕРНО-ФИОЛЕТОВАЯ схема, seed #7C4DFF (DESIGN.md §1) ===
     Два фиолета по ролям: --md-primary #7C4DFF — ЗАЛИВКА (filled/FAB/активный
     сегмент/progress) + белый --md-on-primary; --md-primary-text #A78BFF —
     акцентный текст/иконки/бордеры на тёмном. */
  --md-primary: #7C4DFF;
  --md-on-primary: #FFFFFF;
  --md-primary-text: #A78BFF;
  --md-primary-hover: #7448F0;
  --md-primary-press: #6B41E0;
  --md-primary-container: #3E2A72;
  --md-on-primary-container: #E4D9FF;
  --md-secondary: #B9AED6;
  --md-on-secondary: #241C3E;
  --md-secondary-container: #332B52;
  --md-on-secondary-container: #E6DFFA;
  --md-tertiary: #EFCA9E;
  --md-on-tertiary: #3F2B00;
  --md-tertiary-container: #5C3F00;
  --md-on-tertiary-container: #FFDFAC;
  --md-error: #FFB4AB;
  --md-on-error: #601410;
  --md-error-container: #8C1D18;
  --md-on-error-container: #FFDAD6;
  --md-success: #85D8A5;
  --md-on-success: #00381F;
  --md-success-container: #175334;
  --md-on-success-container: #A6F2C5;
  --md-surface: #0F0A18;
  --md-on-surface: #FFFFFF;
  --md-surface-dim: #0C0714;
  --md-surface-bright: #332A4E;
  --md-surface-container-lowest: #080510;
  --md-surface-container-low: #140E22;
  --md-surface-container: #1A1330;
  --md-surface-container-high: #231A3E;
  --md-surface-container-highest: #2D2350;
  --md-on-surface-variant: #B4AECF;
  --md-outline: #8D86A8;
  --md-outline-variant: #453B63;
  --md-inverse-surface: #FFFFFF;
  --md-inverse-on-surface: #1A1330;
  --md-inverse-primary: #7C4DFF;
  --md-scrim: #000;
  --md-shadow: #000;

  /* Elevation (§3): тонированные тени тёмной темы, только у плавающих поверхностей. */
  --md-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px 1px rgba(0, 0, 0, 0.2);
  --md-elevation-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 6px 2px rgba(0, 0, 0, 0.2);
  --md-elevation-3: 0 4px 8px 3px rgba(0, 0, 0, 0.25);

  /* Shape / Spacing (§3). */
  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-xl: 28px;
  --shape-full: 999px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Motion (§5): стандартная и «подчёркнутая» кривые в M3 идентичны. */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --ease-decel: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-accel: cubic-bezier(0.3, 0, 0.8, 0.15);
  --ease-spring: cubic-bezier(0.42, 1.67, 0.21, 0.9);
  --dur-short: 200ms;
  --dur-medium: 400ms;
  --dur-long: 600ms;

  /* === Легаси-алиасы: весь старый CSS подтягивается на MD3, имена не тронуты. ===
     accent-fill — ЗАЛИВКА (#7C4DFF) с белым on-primary; accent — акцентный
     текст/иконки/бордеры (#A78BFF). Hover/press — явные токены primary-hover/press. */
  --bg: var(--md-surface);
  --surface: var(--md-surface-container-low);
  --surface2: var(--md-surface-container-high);
  --accent: var(--md-primary-text);
  --accent-press: var(--md-primary-press);
  --accent-fill: var(--md-primary);
  --accent-fill-hover: var(--md-primary-hover);
  --accent-fill-press: var(--md-primary-press);
  --violet2: var(--md-on-primary-container);
  --text: var(--md-on-surface);
  --secondary: var(--md-on-surface-variant);
  --muted: var(--md-on-surface-variant);
  --success: var(--md-success);
  --danger: var(--md-error);
  /* Раритеты кейсов — игровая семантика (DESIGN.md §1), не ломать. */
  --r-common: #B3AEC6;
  --r-rare: #9ECBFF;
  --r-epic: #C4A0FF;
  --r-legendary: #EFCA9E;
  --focus: var(--md-primary-text);
  --radius-card: var(--shape-md);
  --radius-pill: var(--shape-full);
  --shadow-pop: var(--md-elevation-2);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  /* M3 body-l 16/24 (DESIGN.md §2). */
  font: 400 16px/1.5 "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

html.locked, body.locked { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; }

h1, h2, h3, p { margin: 0; }

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.muted { color: var(--secondary); }

.noscript { padding: 48px 20px; text-align: center; color: var(--secondary); }

/* Boot and fatal screens */

.boot {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

.boot-logo {
  font-size: 30px; font-weight: 700; letter-spacing: 0.2px;
  background: linear-gradient(92deg, var(--md-on-surface) 25%, var(--md-on-primary-container) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.fatal {
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.fatal-msg { font-size: 18px; font-weight: 700; }

/* Skeleton shimmer */

.skel {
  border-radius: var(--shape-md);
  /* Ton-пульс по §4: surface-container-high + подсветка on-surface 8%. */
  background: linear-gradient(100deg, var(--md-surface-container-high) 40%, color-mix(in srgb, var(--md-on-surface) 8%, var(--md-surface-container-high)) 50%, var(--md-surface-container-high) 60%);
  background-size: 200% 100%;
  animation: shimmer 1s linear infinite;
}

.skel-cover { width: 220px; height: 120px; border-radius: var(--radius-card); }
.skel-line { width: 180px; height: 20px; }
.skel-line-sm { width: 120px; }

@keyframes shimmer { to { background-position: -200% 0; } }

/* Header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 8px;
  background: var(--bg);
}

/* Логотип градиентом по всему слову: спаны без своего цвета наследуют прозрачную заливку. */
.logo {
  font-size: 22px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
  background: linear-gradient(92deg, var(--md-on-surface) 25%, var(--md-on-primary-container) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Логотип в шапке ведёт на главную: внешний вид кнопки уже сброшен базовым reset, радиус нужен только под фокус-кольцо. */
.logo-btn { border-radius: 10px; }

.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  flex: none;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}

/* Баланс — единственный сжимаемый элемент шапки: длинное число на 320-360px даёт эллипсис, а не горизонтальный перелив. */
.pill-balance { background: var(--md-surface-container); flex: 0 1 auto; min-width: 0; font-variant-numeric: tabular-nums; }
.pill-balance .js-balance { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-balance:hover { background: var(--md-surface-container-highest); }

.pill-accent { background: var(--md-primary); color: var(--md-on-primary); font-weight: 700; }

/* Плюс-кнопка пополнения: компактная, чтобы баланс вмещался целиком без эллипсиса. */
.pill-deposit { width: 44px; padding: 0; justify-content: center; flex: none; }
.pill-accent:hover { background: var(--accent-fill-hover); }
.pill-accent:active { background: var(--accent-fill-press); }

.gem { line-height: 1; }

/* Алмаз баланса (SVG-символ из спрайта): кегль эмодзи, оптическая посадка по базовой линии. */
.dia {
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
}

/* Двойной алмаз денег (DIA в app.js): в Stars-режиме вместо ромба светится
   звезда. Чистые иконки (DIA_ICON/STAR_ICON) классов u-dia/u-star не носят
   и режиму не подчиняются. */
.dia .u-star { display: none; }
body.cur-stars .dia .u-dia { display: none; }
body.cur-stars .dia .u-star { display: block; }

.avatar-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}

.avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--violet2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
}

/* Chips row, search, sort */

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 14px 10px;
}

.tools-mid { flex: 1; min-width: 0; display: flex; }

.chips {
  /* Инсет-фейт краёв: ряд скроллится, крайние чипы уходят под мягкое затухание, а не обрезаются. */
  --edge: 14px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  margin-inline: calc(-1 * var(--edge));
  padding-inline: var(--edge);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  /* M3 filter chip (§4): визуальная пилюля 32px рисует ::before, строка остаётся тап-зоной 44px. */
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  position: relative;
  background: transparent;
  border-radius: 0;
  color: var(--md-on-surface-variant);
  font-size: 14px;
  font-weight: 500;
  transition: transform var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}

.chip::before {
  content: '';
  position: absolute;
  inset: 6px 0;
  z-index: -1;
  border-radius: var(--shape-sm);
  border: 1px solid var(--md-outline-variant);
  background: transparent;
  transition: background var(--dur-short) var(--ease-standard), border-color var(--dur-short) var(--ease-standard);
}

.chip:active { transform: scale(0.97); }
.chip:hover { color: var(--md-on-surface); }
.chip:hover::before { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); border-color: var(--md-outline); }
.chip.active { color: var(--md-on-secondary-container); }
.chip.active::before { background: var(--md-secondary-container); border-color: transparent; }

/* Пейджер полосы категорий: виден только когда чипы не влезли, в конце ряда иконка разворачивается.
   FAZE D: ряд = [скролл чипов][‹][›] флекс-рядом с gap 8. Инсет-фейт .chips делал вынос
   полосы на -14px в обе стороны — из-за этого стрелка ложилась поверх последнего чипа.
   Внутри .tools-mid вынос снят: полоса остаётся в своём боксе, маска-затухание работает
   по её краям и под кнопки не заходит. */
.chips-page[hidden] { display: none; }
.tools-mid .chips {
  margin-inline: 0;
  --edge: 10px;
  padding-inline: var(--edge);
}
/* M3 tonal icon button (§4): 44×44, secondary-container, radius full.
   Составной селектор — специфичность выше базового .icon-btn независимо от порядка. */
.icon-btn.chips-page { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--shape-full); }
.icon-btn.chips-page:hover { color: var(--md-on-secondary-container); }
.chips-page-ic { display: grid; place-items: center; transition: transform var(--dur-short) var(--ease-standard); }
.chips-page-ic.back { transform: rotate(180deg); }

.icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--md-on-surface-variant);
  transition: color var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard);
}

.icon-btn:hover { color: var(--md-on-surface); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn[aria-expanded="true"] { color: var(--md-primary-text); background: color-mix(in srgb, var(--md-primary) 14%, transparent); }

.sort-ic { display: grid; place-items: center; transition: transform var(--dur-short) var(--ease-standard); }
.sort-ic.down { transform: rotate(180deg); }

.search-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  /* Outlined text field (§4): единый radius 8, бордер outline. */
  border-radius: var(--shape-sm);
  border: 1px solid var(--md-outline);
  background: transparent;
  color: var(--text);
  padding: 0 16px;
  font: inherit;
}

.search-input::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
.search-input:focus { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }

/* Main screen */

.screen {
  padding: 4px 14px calc(108px + env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
}

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 20px 2px 10px;
}

/* Вертикальный запас внутри clip-бокса: выносные кириллицы (у, р, д) не срезаются overflow:hidden. */
/* title-l 22/28 500 — заголовок секции/экрана (M3 §2). */
.sec-head h2 { font-size: 22px; font-weight: 500; min-width: 0; line-height: 28px; padding: 2px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-count { color: var(--secondary); font-size: 13px; font-weight: 600; flex: none; margin-left: auto; }
.sec-find { margin-left: 6px; align-self: center; flex: none; }

.grid-cases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* min-width:0 на grid-детях: иначе nowrap-содержимое (цена, имя) раздвигает колонку. */
.grid-cases > * { min-width: 0; }

.case-card {
  /* M3 filled card (§4): одна поверхность surface-container, обложка фулл-блидом сверху,
     футер (название/редкости/цена) внутри карточки. State layer + lift — аппендом FAZE B. */
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
  background: var(--md-surface-container);
  border-radius: var(--shape-lg);
  border: 0;
  overflow: hidden;
  text-align: left;
  transition: transform var(--dur-short) var(--ease-standard), box-shadow var(--dur-short) var(--ease-standard);
}

.case-card:hover { transform: translateY(-2px); box-shadow: var(--md-elevation-1); }
.case-card:active { transform: scale(0.97); }

.case-cover {
  position: relative;
  display: grid;
  place-items: center;
  height: 118px;
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--cf, var(--md-surface-container)), var(--ct, var(--md-surface-container-high)));
}

.spark { position: absolute; color: rgba(255, 255, 255, 0.55); font-size: 10px; }
.spark:nth-child(1) { top: 12px; left: 45%; }
.spark:nth-child(2) { top: 44%; right: 10px; font-size: 13px; color: color-mix(in srgb, var(--md-on-primary-container) 75%, transparent); }
.spark:nth-child(3) { bottom: 10px; left: 16px; font-size: 8px; }

.badge-new {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
}

.case-foot {
  /* Футер карточки: название (title-m) своей строкой, рядом редкости, цена-чип справа
     (и переносится под них, если не влезает). min-width:0 — чтобы nowrap-чип не
     раздвигал колонку сетки. */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  gap: 6px 8px;
  padding: 10px 12px 12px;
}

.case-name {
  /* title-m 16/24 500 (§2): своей строкой, чтобы редкости и цена не ели имя. */
  flex: 1 1 100%;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-price {
  /* Tonal-чип цены (§4): secondary-container, radius full, label-l.
     flex: 0 1 auto + max-width 100% — чип не выползает за карточку: если не влез
     рядом с редкостями, переносится, а если и в своей строке шире колонки — режется. */
  flex: 0 1 auto;
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--shape-full);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty { padding: 36px 12px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty-title { font-size: 16px; font-weight: 600; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--md-error) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-error) 35%, transparent);
  border-radius: 14px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 14px;
}

/* Buttons — M3 button system (§4): pill, label-l 14/500, слои состояния через ::after (в конце файла). */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  min-height: 48px;
  padding: 0 24px;
  border-radius: var(--shape-full);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.1px;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard), opacity var(--dur-short) var(--ease-standard);
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; }

/* filled: primary / on-primary (автентичная тёмная M3 — светлая заливка, тёмный текст). */
.btn-primary { background: var(--md-primary); color: var(--md-on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--accent-fill-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-fill-press); }

/* tonal: secondary-container / on-secondary-container. */
.btn-secondary { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--md-on-secondary-container) 8%, var(--md-secondary-container)); }

/* outlined: бордер 1px outline + primary-текст. */
.btn-neutral { background: transparent; border: 1px solid var(--md-outline); color: var(--md-primary-text); border-radius: var(--shape-full); }
.btn-neutral:hover:not(:disabled) { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.btn-neutral:active:not(:disabled) { transform: scale(0.97); background: color-mix(in srgb, var(--md-primary) 12%, transparent); }
.btn-neutral:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.btn-lg { width: 100%; min-height: 52px; font-size: 16px; line-height: 24px; border-radius: var(--shape-full); }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 14px; border-radius: var(--shape-full); }

/* Tab bar — M3 Navigation Bar (§4): плоский surface-container, 80px + safe-area, без glass. */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  gap: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  background: var(--md-surface-container);
  border: 0;
  border-radius: 0;
  z-index: 20;
}

.tabbtn {
  flex: 1;
  min-width: 0;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 16px 0 0;
  border-radius: 0;
  color: var(--md-on-surface-variant);
  /* label-m 12/16 500 (спека tabbar допускает 11-12) */
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  position: relative;
  z-index: 1;
  transition: color var(--dur-short) var(--ease-standard);
}

.tabbtn svg { width: 24px; height: 24px; }
.tabbtn.active { color: var(--md-on-surface); background: transparent; }
.tabbtn.active svg { color: var(--md-on-primary-container); }

/* Скользящая пилюля активной вкладки: позиция через --i (механика app.js не тронута),
   видимый индикатор 64×32 radius-full рисует ::after; шагTranslate = ширина слота.
   Пилюля — primary-container, иконка — on-primary-container (DESIGN.md §1). */
.tab-ind {
  position: absolute;
  z-index: 0;
  top: 12px;
  height: 32px;
  left: 0;
  width: 25%;
  border-radius: var(--shape-full);
  background: transparent;
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform var(--dur-medium) var(--ease-spring);
  pointer-events: none;
}

.tab-ind::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 32px;
  border-radius: var(--shape-full);
  background: var(--md-primary-container);
}

/* Тактильность: прижатие иконки при нажатии, пружинка при активации вкладки */
.tabbtn svg { transition: transform var(--dur-short) var(--ease-standard); }
.tabbtn:active svg { transform: scale(0.85); }
.tabbtn.active svg { animation: tabPop var(--dur-medium) var(--ease-spring); }
@keyframes tabPop { 0% { transform: scale(0.75); } 60% { transform: scale(1.12); } 100% { transform: none; } }

/* Games stub */

.stub {
  padding: 56px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.stub-icon { color: var(--md-outline); }
.stub-title { font-size: 22px; font-weight: 500; line-height: 28px; }

/* Bonuses */

.cards { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title { font-size: 22px; font-weight: 500; line-height: 28px; }

.demo-note {
  color: var(--secondary);
  font-size: 13px;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
}

/* Upgrades */

.hscroll {
  --edge: 14px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  /* внутренний скролл ряда не должен «протаскивать» страницу (задача 4) */
  overscroll-behavior-x: contain;
  padding: 2px var(--edge) 8px;
  margin-inline: calc(-1 * var(--edge));
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--edge), #000 calc(100% - var(--edge)), transparent);
}

.hscroll::-webkit-scrollbar { display: none; }

.inv-pill {
  position: relative;
  flex: 0 0 108px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--surface);
  border: 2px solid var(--surface2);
  border-radius: 16px;
  transition: border-color var(--dur-short) var(--ease-standard);
}

.inv-pill:hover { border-color: var(--md-surface-container-highest); }
.inv-pill.sel { border-color: var(--accent); }

.ip-name { font-size: 12px; font-weight: 600; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-val { font-size: 12px; color: var(--secondary); }

.badge-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--md-primary);
  color: var(--md-on-primary);
  display: grid;
  place-items: center;
}

.chance-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 14px 16px 10px;
  margin: 12px 0;
}

/* Ставка с баланса: нативный range с акцентным бегунком, без кастомного трека. */
.up-bal { margin: 2px 0 4px; }

.up-bal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.up-bal-label { font-size: 13px; font-weight: 600; color: var(--secondary); }

/* Сумма ставки — кнопка: тап открывает ручной ввод. Ховер подсвечивает и подчёркивает пунктиром. */
.up-bal-val {
  background: none;
  border: 0;
  border-bottom: 1px dotted transparent;
  padding: 0 0 1px;
  margin: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-short) var(--ease-standard), border-color var(--dur-short) var(--ease-standard);
}

.up-bal-val:hover:not(:disabled) { color: var(--accent); border-bottom-color: currentColor; }
.up-bal-val:active:not(:disabled) { transform: scale(0.97); }
.up-bal-val:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.up-bal-val:disabled { cursor: default; opacity: 0.6; }

/* Поле ручного ввода ставки: заменяет кнопку-сумму на её месте. Компактное,
   редактируется само число: акцентное подчёркивание вместо рамки и колец. */
.up-bal-edit {
  width: 5ch;
  text-align: right;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 0;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--md-primary) 22%, transparent);
  padding: 0 0 1px;
  caret-color: var(--accent);
  outline: none;
}

.up-bal-edit:focus,
.up-bal-edit:focus-visible { outline: none; }

/* Кастомный слайдер: трек 6px почти чёрный, заполнение фиолетовое слева от бегунка.
   Процент заполнения приходит из JS переменной --sl-p (paintSlider). */
.up-slider {
  width: 100%;
  height: 44px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.up-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent-fill) var(--sl-p, 0%), var(--md-surface-container-highest) var(--sl-p, 0%));
}

.up-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent-fill);
  border: 2px solid var(--md-on-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.up-slider::-moz-range-track { height: 6px; border-radius: 999px; background: var(--md-surface-container-highest); }
.up-slider::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent-fill); }
.up-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-fill);
  border: 2px solid var(--md-on-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.up-slider:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 999px; }

.up-slider:disabled { opacity: 0.45; cursor: not-allowed; }

/* Upgrade wheel: the sector stays static, the needle spins past it. */
.wheel-wrap { position: relative; width: min(300px, 100%); margin: 8px auto 6px; }

/* Низкие экраны: колесо, карточка шанса и панель «Крутить» ужимаются так,
   чтобы колесо было видно целиком без скролла, иначе фиксированная панель
   и таббар съедают его нижнюю половину. */
@media (max-height: 700px) {
  .chance-card { padding: 10px 16px 8px; }
  .up-slider { height: 36px; }
  .wheel-wrap { width: min(220px, 100%); margin: 4px auto 2px; }
  .wheel-pct { font-size: 26px; }
  .wheel-pct-sm { font-size: 18px; }
  .wheel-gift { width: 56px; height: 56px; border-radius: 12px; }
  span.wheel-gift { font-size: 34px; }
  .up-bar { padding: 10px 14px; }
  .up-hint { display: none; }
  .up-qchip { min-height: 38px; padding: 3px 10px; }
}

@media (max-height: 600px) {
  .wheel-wrap { width: min(180px, 100%); }
  .wheel-pct { font-size: 20px; }
  .wheel-gift { width: 46px; height: 46px; border-radius: 10px; }
  span.wheel-gift { font-size: 28px; }
  /* Чипы быстрого подбора приносят высоту в жертву колесу: ставка и цель
     по-прежнему доступны слайдером и пикерами. Спецификность .up-bar,
     чтобы перебить базовый .up-qrow ниже по файлу. */
  .up-bar .up-qrow { display: none; }
}

/* Кольцо-вердикт на колесе: зелёное при выигрыше, красное при проигрыше.
   Появляется в момент остановки иглы, модалка результата идёт следом. */
.wheel-flash {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 3px solid transparent;
  opacity: 0;
  pointer-events: none;
}

.wheel-wrap.res-win .wheel-flash { border-color: var(--md-success); animation: wheelFlash 900ms ease-out both; }
.wheel-wrap.res-lose .wheel-flash { border-color: var(--md-error); animation: wheelFlash 900ms ease-out both; }

@keyframes wheelFlash {
  0% { opacity: 0; transform: scale(0.92); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.07); }
}

.wheel-rotor { width: 100%; }
.wheel-rotor svg { display: block; width: 100%; height: auto; }

.wheel-needle {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  pointer-events: none;
}

.wheel-needle::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 14px solid var(--text);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.wheel-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.wheel-pct { font-size: 34px; font-weight: 700; }
.wheel-pct-sm { font-size: 22px; }
.wheel-word { font-size: 12px; color: var(--secondary); }

/* Арт выбранной цели в центре колеса (и эмодзи-фолбэк того же класса). */
.wheel-gift { width: 72px; height: 72px; border-radius: 14px; }
img.wheel-gift { object-fit: cover; }
span.wheel-gift { display: flex; align-items: center; justify-content: center; font-size: 44px; line-height: 1; }

/* Upgrades screen: sticky action bar keeps Крутить reachable at any scroll. */
/* Панель «Крутить» (86px отступ + ~140px высота) поверх таббара: 160px хватало
   только на панель, нижние чипы упирались в неё. */
/* Выделение текста на экране отключено: игла колеса — прозрачный блок
   размером с круг, при драге пальцем браузер выделял невидимое вокруг
   и серые рамки двигались за круткой. */
.up-screen {
  padding-bottom: calc(240px + env(safe-area-inset-bottom, 0px));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Две равные кнопки-карточки: инвентарь и цель. */
.up-pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 2px 4px; }

.up-picker {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 52px; padding: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--md-outline-variant); border-radius: 16px;
  color: var(--text); text-align: left;
}

.up-picker:hover { background: var(--surface2); }

.up-picker-title { font-size: 15px; font-weight: 700; }

.up-picker-count { font-size: 13px; font-weight: 600; color: var(--secondary); }

/* Модалки-списки (инвентарь/цель): шире обычной, сетка плотнее. */
.modal-box.picker-box { max-width: 560px; }

/* Шапка пикера: заголовок + счётчик + крест в одном ряду, без наложения. */
.picker-head { display: flex; align-items: center; gap: 10px; }
.picker-head h2 { flex: 1; margin: 0; font-size: 22px; font-weight: 500; line-height: 28px; }
.picker-head .sec-count { color: var(--secondary); font-size: 14px; font-weight: 600; }
.picker-box .modal-close { position: static; width: 36px; height: 36px; flex: none; }

/* Тулбар фильтров под шапкой модалки: строки переносятся, на узких экранах без переполнения. */
.picker-tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Поиск и селекты на поверхности модалки: outlined-field, border outline, радиус 8. */
.picker-tools .picker-search {
  flex: 1 1 170px;
  min-width: 0;
  height: 40px;
  background: transparent;
  border-radius: var(--shape-sm);
  border-color: var(--md-outline);
}

.up-select {
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: var(--shape-sm);
  padding: 8px 10px;
  height: 40px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
}

.picker-tools .up-select { flex: 1 1 140px; }

.picker-tools .up-select.up-select-sort { flex: 0 1 auto; }

/* Ряд чипов иксов/процентов + «Сбросить»: чипы скроллятся, кнопка всегда на виду. */
.up-chips-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.up-chips-row .chips { flex: 1; min-width: 0; margin-top: 0; --edge: 0; }

/* Чипы внутри модалки: фон светлее коробки + рамка, иначе не видно на тёмном. */
.up-chips-row .chip {
  min-height: 34px;
  padding: 0 13px;
  font-size: 13px;
  background: var(--surface2);
  border: 1px solid var(--md-outline-variant);
}

.up-chips-row .chip:hover { background: var(--surface2); }
.up-chips-row .chip.active { background: var(--accent-fill); border-color: transparent; }

.up-chips-row .link-btn { flex: none; }

/* Постраничная навигация целей. */
.up-page { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }

.up-page .btn-sm { min-height: 36px; padding: 0 12px; }

.up-page .muted { font-size: 13px; }

/* Кнопки-пикеры коллекции/подарка в тулбаре цели (в стиле .up-select). */
.up-select.up-pick-btn { display: flex; align-items: center; gap: 8px; text-align: left; }

.up-pick-ava { width: 20px; height: 20px; border-radius: 6px; object-fit: cover; flex: none; }

.up-pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.up-pick-chev { flex: none; color: var(--secondary); font-size: 11px; }

/* Нижний шит выбора коллекции/подарка. */
.up-pick-sheet { display: flex; flex-direction: column; }

.up-pick-search { margin-top: 12px; }

.up-pick-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 4px;
}

.up-pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  transition: background var(--dur-short) var(--ease-standard);
}

.up-pick-row:hover { background: var(--surface2); }
.up-pick-row.sel { background: var(--surface2); box-shadow: inset 0 0 0 1.5px var(--accent); }

.up-pick-art { flex: none; width: 40px; height: 40px; display: grid; place-items: center; }

.up-pick-img { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; }

span.up-pick-img { display: flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; }

.up-pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.up-pick-rname {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-pick-sub { font-size: 12px; color: var(--secondary); }

.up-pick-price { flex: none; font-size: 13px; font-weight: 700; color: var(--secondary); }

.up-pick-check { margin-left: 2px; }

.up-pick-empty { padding: 16px 4px; text-align: center; }

.up-pick-foot { display: flex; gap: 10px; margin-top: 12px; }

.up-pick-foot .btn { flex: 1; }

.picker-box .targets { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (min-width: 520px) {
  .picker-box .targets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.up-picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }

.up-picker-sum { font-size: 14px; font-weight: 600; }

.up-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  width: min(440px, calc(100% - 24px));
  padding: 12px 14px;
  /* M3: плоский container вместо glass-панели (§7). */
  background: var(--md-surface-container);
  border: 0;
  border-radius: var(--shape-lg);
  box-shadow: var(--md-elevation-2);
  z-index: 19;
}

/* Панель — колонка по центру: подсказка, ряд чипов быстрого подбора, «Крутить». */
.up-bar-col { display: flex; flex-direction: column; align-items: center; gap: 9px; width: 100%; }

.up-hint { flex: none; width: 100%; margin: 0; font-size: 13px; line-height: 1.35; color: var(--secondary); text-align: center; }

/* Ровно шесть чипов в один ряд: без переноса, чуть ужимаются. */
.up-qrow { display: flex; flex-wrap: nowrap; justify-content: center; gap: 6px; }

.up-qchip {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; flex: 0 1 auto;
  min-height: 42px; padding: 4px 11px; white-space: nowrap;
  border-radius: 999px; font-weight: 700; font-size: 13px;
  background: var(--surface2); color: var(--text); border: 1px solid var(--md-outline-variant);
}

.up-qchip-top { line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Подпись шанса на чипе икса: x2 означает выплату, шанс при ней около 42%. */
.up-qchip-sub { font-size: 10px; font-weight: 600; line-height: 1.1; color: var(--secondary); }

.up-qchip:disabled { opacity: 0.45; }

.up-qchip[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* Молния/шестерня — маленькие круглые кнопки в заголовке «Шанс успеха», над колесом.
   Иконки векторные (спрайт в index.html), цвет — currentColor: активная молния белеет на акценте. */
.up-qicon { min-width: 34px; min-height: 34px; padding: 0; flex: none; }

.uic { display: block; width: 17px; height: 17px; }

.sec-tools { display: flex; align-items: center; align-self: center; gap: 6px; flex: none; }

.up-qgroup { width: 100%; }

.up-qgroup-title { margin: 12px 0 6px; font-size: 13px; font-weight: 600; color: var(--secondary); }

.up-qrow-inputs { gap: 8px; }

.up-qrow-inputs .up-qinput { flex: 1 1 0; min-height: 40px; }

.up-qinput {
  min-width: 0; min-height: 40px; border-radius: var(--shape-sm); padding: 0 10px; text-align: center;
  border: 1px solid var(--md-outline); background: transparent;
  color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums;
}
.up-qinput:focus { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }

.up-qinput-bad { border-color: var(--danger); }

.up-qreset { margin-top: 4px; }

.up-go { flex-shrink: 0; width: 100%; max-width: 280px; margin: 0 auto; min-height: 48px; padding: 0 22px; border-radius: 14px; font-size: 16px; }
.up-go:disabled { opacity: 0.45; }

/* Case rewards: informational tiles, not controls. */
.rw-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rw-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 10px 6px 8px;
  background: var(--surface);
  border-top: 2px solid var(--rc, var(--r-common));
  border-radius: 14px;
  text-align: center;
}

.rw-name { font-size: 11px; font-weight: 600; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rw-val { font-size: 11px; color: var(--secondary); }

/* Compact rewards hint on case cards. */
.case-drops {
  display: flex;
  gap: 3px;
  padding: 0;
  font-size: 17px;
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
}


.targets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.target {
  position: relative;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  background: var(--surface);
  border: 2px solid var(--rc, var(--r-common));
  border-radius: 16px;
  transition: box-shadow var(--dur-short) var(--ease-standard);
}

.target.sel { box-shadow: 0 0 0 2px var(--accent); }

.t-name { font-size: 12px; font-weight: 600; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-val { font-size: 12px; color: var(--secondary); }


/* Rarity colors */

[data-rarity="common"] { --rc: var(--r-common); --rc-rgb: 179, 174, 198; }
[data-rarity="rare"] { --rc: var(--r-rare); --rc-rgb: 158, 203, 255; }
[data-rarity="epic"] { --rc: var(--r-epic); --rc-rgb: 196, 160, 255; }
[data-rarity="legendary"] { --rc: var(--r-legendary); --rc-rgb: 239, 202, 158; }

.rarity-label { color: var(--rc, var(--secondary)); font-weight: 600; }

.rarity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rc, var(--secondary));
}

/* Layers: modals, sheets, case screen */

.layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  /* Scrim M3 (§4): rgba(0,0,0,.5). */
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-short) var(--ease-accel), visibility var(--dur-short);
}

.layer.open { opacity: 1; visibility: visible; transition: opacity var(--dur-vt) var(--ease-decel), visibility var(--dur-vt); }

.modal-layer { align-items: center; padding: 20px; }
.sheet-layer { align-items: flex-end; }

.modal-box {
  position: relative;
  width: 100%;
  max-width: 360px;
  /* На низких экранах длинная модалка скроллится внутри; vh — фолбэк для WebView без dvh. */
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  /* Center dialog (§4): radius 28, surface-container-high, elevation lvl3. */
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl);
  padding: 20px 16px 16px;
  box-shadow: var(--md-elevation-3);
  /* FAZE C (§5): вход scale(.94)+fade 300ms decel, выход scale(.96)+fade 200ms accel. */
  transform: scale(0.94);
  transition: transform var(--dur-short) var(--ease-accel);
}

.layer.open .modal-box { transform: none; transition: transform var(--dur-vt) var(--ease-decel); }
.layer.closing .modal-box { transform: scale(0.96); transition: transform var(--dur-short) var(--ease-accel); }

/* Результат-модалка: та же форма входа, чуть больший ход. */
.result-layer { align-items: center; padding: 20px; }
.modal-box.result-box { transform: scale(0.94) translateY(8px); transition: transform var(--dur-short) var(--ease-accel); }

.layer.open .modal-box.result-box { transform: none; transition: transform var(--dur-vt) var(--ease-decel); }
.layer.closing .modal-box.result-box { transform: scale(0.96); transition: transform var(--dur-short) var(--ease-accel); }

/* Конфетти поверх слоя результата. */
.confetti-canvas { position: fixed; inset: 0; z-index: 50; pointer-events: none; }

.modal-close { position: absolute; top: 10px; right: 10px; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  /* dvh: на низком экране с динамическими панелями шапка шита не уходит за верхний срез. */
  max-height: 82dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Bottom sheet (§4): radius 28 сверху, elevation lvl3, grab-handle через ::before. */
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl) var(--shape-xl) 0 0;
  padding: 20px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--md-elevation-3);
  transform: translateY(100%);
  /* FAZE C (§5): вход decel 300ms, выход accel 200ms (кривые модалок, слайд сохранён). */
  transition: transform var(--dur-short) var(--ease-accel);
}

.sheet::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  margin-left: -16px;
  width: 32px;
  height: 4px;
  border-radius: var(--shape-full);
  background: var(--md-outline);
}

.layer.open .sheet { transform: none; transition: transform var(--dur-vt) var(--ease-decel); }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

/* headline-s 24/32 — заголовок диалога/листа (M3 §2, §4). */
.sheet-title { font-size: 24px; font-weight: 400; line-height: 32px; }
.sheet-sub { font-size: 16px; font-weight: 500; line-height: 24px; margin: 16px 0 8px; }

.sheet-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border-radius: 16px;
  padding: 12px 16px;
  margin-top: 14px;
}

.big-balance { font-size: 20px; font-weight: 700; }

.inv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  /* M3 list row (§4): min-h 56, divider outline-variant. */
  min-height: 56px;
  padding: 8px 0;
  border-bottom: 1px solid var(--md-outline-variant);
}

.inv-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.inv-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rarity-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--secondary);
}

.inv-val { font-size: 13px; color: var(--secondary); flex: none; }

.btn-sell { flex: none; min-height: 44px; padding: 0 12px; font-size: 13px; border-radius: 12px; }

.inv-list .inv-row:last-child { border-bottom: 0; }

.inv-empty { padding: 20px 0; }

/* Пополнение: один лист-шаблон для демо и реала. Фокус-иерархия: крупное поле
   суммы, чипы, строка кошелька, CTA прижат к низу листа. Токены существующие. */
.dep-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  color: var(--secondary);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 3px;
}

.dep-over {
  display: block;
  margin: 2px 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
}

.dep-hero {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 6px 16px;
  /* Outlined field: та же механика, радиус 8 и outline-бордер (§4). */
  border: 1px solid var(--md-outline);
  border-radius: var(--shape-sm);
  background: transparent;
}

/* Кольцо фокуса несёт обёртка: input бесшовный внутри поля. */
.dep-hero:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.dep-hero-demo { justify-content: center; }

/* Заголовок-сумма пополнения: headline-m 28/36, табличные цифры (M3 §2). */
.dep-hero-val { font-size: 28px; font-weight: 400; line-height: 36px; font-variant-numeric: tabular-nums; }

.dep-input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 28px;
  font-weight: 400;
  line-height: 36px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.dep-input:disabled { opacity: 0.45; }

.dep-input:focus { outline: none; }

.dep-suffix { flex: none; font-size: 15px; font-weight: 700; color: var(--secondary); }

.dep-hint { margin: 8px 2px 0; font-size: 13px; text-align: center; }

.dep-error { margin: 8px 2px 0; font-size: 13px; font-weight: 600; color: var(--danger); text-align: center; }

/* Сетка чипов: одинаковые ячейки, непоместившийся чип садится в свою колонку,
   а не растягивается на всю строку. */
.dep-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-top: 14px; }

.dep-chip {
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}

.dep-chip:hover { color: var(--text); }

.dep-chip.sel { background: var(--accent-fill); color: var(--md-on-primary); }

.dep-chip:disabled { opacity: 0.45; }

/* Сегмент способа пополнения (TON/Stars): пластика чипов, но свой класс:
   глобальные переключатели суммы трогают все .dep-chip разом, табам это вредно. */
.dep-method { display: flex; gap: 8px; margin: 12px 2px 0; }

/* Панель способа пополнения: обе панели живут в DOM, скрытая — под hidden
   (переключение способа не перерисовывает форму, чтобы не дёргать высоту). */
.dep-pane[hidden] { display: none; }

.dep-tab {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface2);
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}

.dep-tab .dia { vertical-align: 0; }

.dep-tab:hover { color: var(--text); }

.dep-tab.sel { background: var(--accent-fill); color: var(--md-on-primary); }

/* Лист выбора валюты: строки-кнопки, конвертированный баланс справа,
   выбранную валюту отмечает акцентное кольцо с точкой. */
.cur-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.cur-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface2);
  color: var(--text);
  width: 100%;
  text-align: left;
}

.cur-row:hover { background: var(--md-surface-container-highest); }

.cur-ic { flex: none; display: inline-flex; }

.cur-ic .dia { width: 20px; height: 20px; vertical-align: 0; }

.cur-name { flex: 1; min-width: 0; font-weight: 700; }

.cur-bal { flex: none; font-size: 14px; font-weight: 700; color: var(--secondary); }

.cur-radio {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--md-outline);
  display: grid;
  place-items: center;
}

.cur-radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
}

.cur-row.sel .cur-radio { border-color: var(--accent); }

.cur-row.sel .cur-radio::after { background: var(--accent-fill); }

.dep-wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface2);
}

button.dep-wallet {
  width: 100%;
  border: 1px dashed var(--md-outline);
  background: none;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
}

button.dep-wallet:hover:not(:disabled) { color: var(--text); }

button.dep-wallet:disabled { opacity: 0.45; }

.dep-wallet-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

/* CTA дожимается к низу листа при скролле: фон перекрывает контент. */
.dep-cta {
  position: sticky;
  bottom: 0;
  margin: 16px -16px calc(-18px - env(safe-area-inset-bottom, 0px));
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}

.dep-cta .btn { width: 100%; }

.dep-center { padding: 24px 4px; text-align: center; }

.dep-note { margin-top: 2px; }

.dep-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 0 4px;
  text-align: center;
}

.dep-done-title { font-size: 17px; font-weight: 700; }

.dep-gem { width: 64px; height: 64px; }

.dep-gem svg { display: block; width: 100%; height: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .dep-gem { animation: dep-pop 0.2s ease-out; }
}

@keyframes dep-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Кошелёк TON в профиле: строка адреса с «Отключить» или кнопка на всю ширину. */
.wallet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  margin-top: 12px;
  padding: 6px 12px;
  background: var(--surface2);
  border-radius: 14px;
}

.wallet-row-bad { background: color-mix(in srgb, var(--md-error) 10%, transparent); border: 1px solid color-mix(in srgb, var(--md-error) 35%, transparent); }

.wallet-info { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }

.wallet-net {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--secondary);
}

.wallet-addr { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wallet-msg { flex: 1; min-width: 0; font-size: 13px; }

.wallet-btn { width: 100%; margin-top: 12px; }

/* Case screen overlay */

.case-layer {
  z-index: 30;
  align-items: stretch;
  background: var(--bg);
}

.case-screen {
  width: 100%;
  max-width: 480px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}

.cs-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
}

.cs-title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  padding: 2px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Крупное имя кейса в теле экрана (десктоп): на мобиле скрыт, там имя в шапке. */
.cs-h1 { display: none; }

.cs-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 16px calc(32px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
}

/* Кнопка открытия липнет к низу экрана кейса: список наград длинный, без этого
   кнопка уезжает за пределы вьюпорта и приходится её вылавливать скроллом. */
#csCta {
  position: sticky;
  bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  margin: -6px -16px 0;
  padding: 10px 16px 4px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(22, 21, 30, 0));
}

.cs-cover {
  position: relative;
  display: grid;
  place-items: center;
  height: 190px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: linear-gradient(135deg, var(--cf, var(--md-surface-container)), var(--ct, var(--md-surface-container-high)));
}

/* Сгенерированная обложка (cover.image): на карточке фулл-блид, на экране
   кейса компактный квадрат целиком: квадратный арт в полосе 190px режет
   углы и раздувает героя. */
.case-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

img.cs-cover-art {
  width: 160px;
  height: 160px;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}

/* Низкие экраны: обложка компактнее, иначе липкая кнопка открытия накрывает пилюли количества. */
@media (max-height: 700px) {
  .cs-cover { height: 148px; }
  img.cs-cover-art { width: 124px; height: 124px; }
}

.cs-cover .spark:nth-child(1) { top: 20px; left: 42%; font-size: 14px; }

#csCount:empty { display: none; }

.cta-stack { display: flex; gap: 8px; }
/* Основная кнопка растёт, «Быстро» компактная справа: стек из двух кнопок в высоту
   отъедал экран и наваливался на пилюли количества. */
.cta-stack .btn-primary { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; }
.cta-stack .btn-secondary { flex: none; width: auto; padding: 0 16px; }

#csCta:empty { display: none; }
.cs-cover .spark:nth-child(2) { top: 40%; right: 22px; font-size: 18px; }
.cs-cover .spark:nth-child(3) { bottom: 20px; left: 28px; font-size: 11px; }

/* Roulette */

/* Roulette: контейнер — container-тон, затухание краёв в тон контейнера (механику не трогаем). */
.roulette {
  position: relative;
  height: 128px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--md-surface-container);
}

.rl-strip {
  display: flex;
  height: 100%;
  align-items: stretch;
  will-change: transform;
}

.rl-tile {
  flex: 0 0 88px;
  margin-right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  background: var(--surface2);
  border-radius: 12px;
  text-align: center;
}

.rl-name { font-size: 11px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-val { font-size: 11px; color: var(--secondary); }

.rl-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: 0 44px;
  text-align: center;
  color: var(--secondary);
  font-size: 13px;
}

.rl-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--focus);
  box-shadow: 0 0 14px color-mix(in srgb, var(--md-primary) 90%, transparent);
  z-index: 2;
}

.roulette::before,
.roulette::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  z-index: 1;
  pointer-events: none;
}

.roulette::before { left: 0; background: linear-gradient(90deg, var(--md-surface-container), transparent); }
.roulette::after { right: 0; background: linear-gradient(-90deg, var(--md-surface-container), transparent); }

/* Mass open: one horizontal reel per case, staggered stops */

.roulette.multi { height: auto; padding: 10px; }
.roulette.multi::before,
.roulette.multi::after { content: none; }

.mrls { display: flex; flex-direction: column; gap: 6px; }

.mrl {
  position: relative;
  height: 48px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface2);
}

.mrl-strip {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 100%;
  gap: 6px;
  will-change: transform;
}

.mrl-tile {
  flex: 0 0 64px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: var(--surface);
  border-radius: 9px;
}

.mrl-val {
  font-size: 10px;
  color: var(--secondary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mrl-mark {
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 2px;
  margin-left: -1px;
  background: var(--focus);
  box-shadow: 0 0 10px color-mix(in srgb, var(--md-primary) 90%, transparent);
  z-index: 2;
}

/* Выигрышную плитку не подсвечиваем, пока рулетки крутятся: итог раскрывается только после остановки. */
.mrls.done .mrl-tile.hit {
  border: 1px solid var(--rc, var(--focus));
  box-shadow: 0 0 14px color-mix(in srgb, var(--md-primary) 45%, transparent);
}
.mrl.stopped .mrl-mark { opacity: 0.45; }

/* Batch count selector: keypad grid, selected chip filled with accent */

.cnt-block { margin: 2px 0 14px; }

.cnt-label {
  display: block;
  font-size: 12px;
  color: var(--secondary);
  margin-bottom: 8px;
}

.cnt-grid { display: grid; gap: 6px; justify-content: center; }

.cnt {
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--md-outline-variant);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

.cnt.sel {
  background: var(--md-primary);
  border-color: transparent;
  color: var(--md-on-primary);
  box-shadow: var(--md-elevation-1);
}

/* Loot grid for mass open */

.mw-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  max-height: 320px;
  overflow-y: auto;
}

.mw-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px 8px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--md-on-surface) 6%, transparent);
  border-top: 2px solid var(--rc, var(--r-common));
  border-radius: 12px;
  text-align: center;
  min-width: 0;
}

.mw-name { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-val { font-size: 10px; color: var(--secondary); }

/* Win and result modals */

.win-name { text-align: center; font-size: 24px; font-weight: 400; line-height: 32px; margin-top: 6px; }
.win-rarity { text-align: center; margin-top: 4px; }
/* Цена результата — label-l 14/20 500 (§2). */
.win-val { text-align: center; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--md-on-surface-variant); margin-top: 6px; }

.result-title { text-align: center; font-size: 24px; font-weight: 400; line-height: 32px; }
.result-title.ok { color: var(--success); }
.result-title.bad { color: var(--danger); }

/* Toasts */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  /* M3 snackbar (§4): inverse-surface, radius 8, elevation lvl2, rise через decel/medium. */
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  border-radius: var(--shape-sm);
  border-left: 3px solid var(--md-primary);
  min-height: 48px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--md-elevation-2);
  animation: toast-in var(--dur-vt) var(--ease-decel);
  transition: opacity var(--dur-short) var(--ease-accel), transform var(--dur-short) var(--ease-accel);
}

.toast.ok { border-left-color: var(--md-success); }
.toast.err { border-left-color: var(--md-error); }
.toast.out { opacity: 0; transform: scale(0.96); }

@keyframes toast-in {
  /* FAZE C (§5): rise + blur-fade — 16px снизу и расфокус на входе. */
  from { opacity: 0; transform: translateY(16px); filter: blur(6px); }
}

/* Profile page */

.profile-layer { z-index: 30; }

.profile-body {
  display: flex;
  flex-direction: column;
  padding: 6px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

.profile-head-fill { flex: 1; }
.profile-logo {
  font-size: 20px;
  background: linear-gradient(92deg, var(--md-on-surface) 25%, var(--md-on-primary-container) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.profile-card { gap: 0; }

.profile-top { display: flex; align-items: center; gap: 14px; }

.profile-avatar {
  flex: none;
  display: grid;
  place-items: center;
  padding: 3px;
  border-radius: 50%;
  background: var(--surface2);
}

.avatar-lg .avatar-img,
.avatar-lg .avatar-fallback { width: 64px; height: 64px; }

.avatar-lg .avatar-fallback { font-size: 24px; }

.profile-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.profile-name { font-size: 22px; font-weight: 500; line-height: 28px; padding: 2px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-un { font-size: 14px; padding: 1px 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-div { height: 1px; background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); margin: 14px 0; }

.profile-bal { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.profile-bal-label { font-size: 13px; }
/* Большой баланс профиля — кнопка смены валюты: глобальный reset кнопок уже
   снял фон/рамку, радиус нужен под фокус-кольцо. */
.profile-bigbal { display: flex; align-items: center; gap: 8px; font-size: 30px; font-weight: 700; border-radius: 12px; }

.profile-btns { display: flex; gap: 10px; margin-top: 14px; }
.profile-btns .btn { flex: 1; min-width: 0; }

/* Уровень: медаль, переход к следующему уровню и полоса прогресса. */
.lvl-row { display: flex; align-items: flex-start; gap: 10px; }
.lvl-ic { flex: none; color: var(--secondary); margin-top: 2px; }
.lvl-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.lvl-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.lvl-names { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.lvl-from { font-weight: 700; }
.lvl-arrow { color: var(--secondary); margin: 0 5px; }
.lvl-next { color: var(--secondary); }
.lvl-remain { flex: none; font-size: 13px; white-space: nowrap; }

.lvl-bar {
  /* M3 linear progress (§4): трек 4px outline-variant, заливка primary. */
  display: block;
  height: 4px;
  border-radius: var(--shape-full);
  background: var(--md-outline-variant);
  overflow: hidden;
}

.lvl-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent-fill); }

/* Секция с иконкой, заголовком и подписью справа от кнопки. */
.profile-sec-head { display: flex; align-items: flex-start; gap: 10px; margin: 18px 2px 10px; }
.psh-ic { flex: none; color: var(--secondary); margin-top: 2px; }
.psh-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.psh-mid h2 { font-size: 22px; font-weight: 500; line-height: 28px; }
.psh-sub { font-size: 13px; }

.link-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 44px;
  padding: 0 4px 0 12px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
  transition: color var(--dur-short) var(--ease-standard);
}

.link-btn:hover { color: var(--text); }

.profile-support { display: block; margin: 14px auto 2px; }

.profile-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px; margin: 18px auto 6px; }
.profile-legal .link-btn { font-size: 13px; color: var(--muted); }
.profile-legal .link-btn:hover { color: var(--text); }

.legal-layer { z-index: 40; align-items: center; padding: 16px; }
.legal-box {
  width: min(560px, 100%);
  height: min(84vh, 760px);
  display: flex;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl);
  overflow: hidden;
  box-shadow: var(--md-elevation-3);
}
.legal-frame { flex: 1; width: 100%; border: 0; }

.legal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: var(--surface2);
}
.link-chev { display: grid; place-items: center; }

/* Плитки топ-инвентаря: редкостная кромка и лёгкая заливка цветом редкости. */
.inv-tile {
  flex: 0 0 96px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--rc, var(--r-common));
  border-radius: 16px;
  background: var(--surface);
  background: color-mix(in srgb, var(--rc, var(--r-common)) 12%, var(--surface));
}

.it-val { font-size: 12px; font-weight: 700; }

/* Лучший выигрыш: фиолетовая рамка малой прозрачности, значение цветом --violet2. */
.best-win {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--md-on-primary-container) 35%, transparent);
  border-radius: var(--radius-card);
}

.bw-tile {
  flex: none;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--surface2);
  border-radius: 14px;
}

.bw-none-ic { color: var(--secondary); }

.bw-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bw-label { font-size: 12px; color: var(--secondary); }
.bw-val { font-size: 22px; font-weight: 700; color: var(--violet2); }
.bw-game { font-size: 13px; }
.bw-none { font-size: 15px; font-weight: 600; }

/* Сетка 2x2 со статистикой: minmax не даёт плиткам разъехаться на 320px. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 16px;
}

.stat-label { font-size: 12px; color: var(--secondary); }
.stat-val { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }

/* История операций: плотные строки как в инвентаре, сумма справа со знаком.
   Минус для списаний — U+2212, табличные цифры не прыгают по ширине. */
.tx-list { display: flex; flex-direction: column; }

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* M3 list row (§4): min-h 56. */
  min-height: 56px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--md-outline-variant);
}

.tx-row:last-child { border-bottom: 0; }

.tx-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.tx-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-date { font-size: 12px; color: var(--secondary); }
.tx-amt { flex: none; font-size: 14px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amt.tx-plus { color: var(--success); }
.tx-state { padding: 4px 2px 0; }

/* Arena */

.arena-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  margin: 6px 2px 10px;
}
.arena-back {
  /* M3 icon button: 44×44, tonal-поверхность, radius full. */
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: var(--shape-full); background: var(--md-surface-container);
  color: var(--md-on-surface-variant); cursor: pointer;
}
.arena-back:hover { color: var(--md-on-surface); background: var(--md-surface-container-high); }
.arena-back:active { transform: scale(0.92); }

/* Банк-чип: M3 tonal chip h32 radius 8 (§4). */
.arena-bank {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  border-radius: var(--shape-sm);
  background: var(--md-secondary-container); color: var(--md-on-secondary-container);
  font-size: 14px; font-weight: 500; min-width: 0;
}
.arena-bank b { font-weight: 700; white-space: nowrap; }

/* Статус всегда своей строкой под банком и табами: если оставить его в общем ряду,
   меняющаяся ширина каунтдауна то влезает, то переносит строку, и вся шапка прыгает. */
.arena-status {
  flex: 1 1 100%;
  order: 9;
  margin-left: 0;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arena-live { color: var(--success); }

/* Табы комнат: M3 filter chips — ячейка 44 (тап-таргет §6), пилюля 32 рисует ::before,
   selected = filled secondary-container (унаследовано от .chip.active). */
.arena-tabs { display: flex; gap: 6px; flex: none; }
.arena-tab { min-height: 44px; padding: 0 14px; font-size: 13px; font-weight: 500; }


/* Каталог игр: одна живая карточка «Арена»; диагональные сектора перекликаются с зонами на поле. */
/* M3 §4: hero-карточка = filled tonal primary-container, radius 16; state layer + lift — аппендом. */
.games-hub { padding: 6px 12px 0; }
.game-hero {
  position: relative; display: block; width: 100%; min-height: 200px;
  padding: 0; border: 0; border-radius: var(--shape-lg); overflow: hidden; cursor: pointer;
  background: var(--md-primary-container); color: var(--md-on-primary-container); text-align: left; font: inherit;
  -webkit-tap-highlight-color: transparent; transition: transform var(--dur-short) var(--ease-standard), box-shadow var(--dur-short) var(--ease-standard);
}
.game-hero:active { transform: scale(0.97); }
.game-hero > span { position: absolute; }
.hero-slice { inset: 0; background: var(--md-surface-container-highest); clip-path: polygon(58% 0, 100% 0, 100% 100%, 34% 100%); }
.hero-wedge-y { inset: 0; background: var(--md-secondary-container); clip-path: polygon(62% 0, 100% 0, 100% 54%); }
.hero-wedge-d { inset: 0; background: var(--md-surface-dim); clip-path: polygon(100% 58%, 100% 100%, 48% 100%); }
.hero-art {
  left: 50%; top: 42%; width: 96px; height: 96px; margin: -48px 0 0 -48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 13, 24, 0.62); border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(16, 13, 24, 0.18);
}
.hero-art svg { width: 54px; height: 54px; }
.hero-pills { left: 16px; top: 14px; display: flex; gap: 8px; }
.hero-pill {
  /* Пилюля-чип (§4): h28-32, radius 8, border outline-variant, вторичный текст. */
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 3px 10px; border-radius: var(--shape-sm);
  border: 1px solid var(--md-outline-variant); background: var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
  font-size: 12px; font-weight: 500; letter-spacing: 0.02em;
}
.hero-live i { width: 6px; height: 6px; border-radius: 50%; background: var(--md-success); }
.hero-ava {
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 3px rgba(16, 13, 24, 0.35);
}
.hero-ava .avatar-img, .hero-ava .avatar-fallback { width: 100%; height: 100%; }
.hero-ava-1 { right: 14px; top: 14px; }
.hero-ava-2 { right: 18px; bottom: 16px; }
.hero-title { left: 16px; bottom: 14px; right: 110px; font-size: 28px; font-weight: 500; line-height: 1.15; }
.hero-title small { display: block; margin-top: 5px; font-size: 12.5px; font-weight: 500; color: color-mix(in srgb, var(--md-on-primary-container) 85%, transparent); }

/* Поле: компактный квадрат с зонами Вороного; зум ведёт камера из JS и живёт внутри поля. */
/* vh, а не dvh: размер квадрата не должен меняться посреди раунда. Поле сжимается так,
   чтобы хеш и игроки влезали над панелью ставок: минус высота хрома вокруг поля. */
.arena-field-zoom {
  position: relative;
  width: clamp(180px, min(100%, 46vh, calc(100vh - 350px)), 320px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  /* Рамка поля — outline-токен (§4); сектора-зоны остаются артом. */
  box-shadow: inset 0 0 0 1px var(--md-outline-variant);
  will-change: transform;
  transform: scale(1);
  transition: width 260ms ease;
}

/* В прямом эфире панель ставок скрыта: поле отъедает её высоту и растёт. */
#arenaRoot.is-playing .arena-field-zoom {
  width: clamp(180px, min(100%, 46vh, calc(100vh - 290px)), 340px);
}

/* Виньетка финального зума: края темнеют, взгляд держится на точке приземления. */
.arena-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--vx, 50%) var(--vy, 50%), transparent 34%, rgba(9, 8, 14, 0.62) 100%);
  opacity: 0;
  transition: opacity 600ms ease;
  z-index: 2;
}
.arena-field-zoom.arena-zoom .arena-vignette { opacity: 1; }

.arena-field { position: absolute; inset: 0; }
.arena-field svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.arena-zone { transition: filter 300ms ease; stroke: var(--md-outline); }
.arena-zone.zone-flash { filter: brightness(1.25); }

/* Бейджи едут за центром зоны при морфе; px в SVG-трансформе = единицы viewBox */
.arena-badge { transition: transform 460ms cubic-bezier(0.22, 0.61, 0.36, 1); }
.arena-noanim .arena-badge { transition: none; }

/* Строка честности: хеш раунда под полем, тихая и без интерактива. */
.arena-hash {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--secondary);
}

/* Табличка @имени над шаром: якорь в мире поля, растёт вместе с зумом. */
.arena-ball-name {
  position: absolute;
  transform: translate(-50%, -150%);
  color: var(--md-on-surface);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 3;
}

.arena-wait {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 20px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  background: rgba(21, 20, 28, 0.45);
}

/* Центральное кольцо — разметка поля в режиме ожидания, тихая и в тоне акцента. */
.arena-wait::before {
  content: '';
  width: 56px;
  height: 56px;
  border: 1.5px dashed color-mix(in srgb, var(--md-primary-text) 40%, transparent);
  border-radius: 50%;
}

/* Шар: белый диск с синим прицелом, стрелка направления вращается вокруг центра. */
.arena-ball {
  position: absolute;
  width: 9%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.arena-ball-disc { position: absolute; inset: 0; display: block; }
.arena-ball-disc svg { width: 100%; height: 100%; display: block; }

.arena-ball-rot { position: absolute; inset: 0; transform-origin: 50% 50%; }

.arena-ball-arrow {
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #fff;
}

/* Список игроков под полем — M3 list rows (§4): min-h 56, аватар 40 radius full
   с цветным кольцом зоны, имя title-m, ставка supporting body-m on-surface-variant. */
.arena-prow {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 4px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--md-outline-variant);
  border-radius: 0;
  margin-bottom: 0;
}
.arena-prow:last-child { border-bottom: 0; }

.arena-prow.me {
  background: color-mix(in srgb, var(--md-primary) 8%, transparent);
  border-bottom-color: transparent;
  border-radius: var(--shape-md);
}

/* Leading-аватар 40: фото/инициал, кольцо = цвет зоны игрока на поле. */
.ap-ava {
  flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--md-surface-container-highest); color: var(--md-on-surface-variant);
  font-size: 15px; font-weight: 600;
  box-shadow: 0 0 0 2px var(--apc, var(--md-outline-variant));
}
.ap-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.ap-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 500; line-height: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-stake { flex: none; font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); }
.ap-share { flex: none; min-width: 40px; text-align: right; font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); }

.arena-nobody { padding: 12px 2px; }

/* Панель входа: ряд инструментов и чипы ставок живут внутри #arenaJoin с его паддингом. */
.arena-tools { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
/* Во время проката ставки не нужны: панель убирается целиком, поле и игроки получают место. */
#arenaRoot.is-playing .arena-tools,
#arenaRoot.is-playing #arenaJoin { display: none; }
.arena-tools .arena-chips { flex: 1; min-width: 0; margin: 0; }
/* Кнопки-инструменты фиксированы: чипы между ними сжимаются, а не выталкивают строку */
.arena-tool { flex: none; }
.arena-tool.auto-on { color: var(--accent); background: color-mix(in srgb, var(--md-primary) 14%, transparent); box-shadow: 0 0 0 2px var(--accent); }
.arena-chips { display: flex; gap: 8px; margin: 12px 0 10px; }
/* Своя сумма ставки может оказаться шире flex-доли: эллипсис держит пилюлю целой. */
.arena-chip { flex: 1; min-width: 0; padding: 0 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Join-кнопка: filled pill h48 (§3/§4). */
.arena-go { width: 100%; min-height: 48px; }

.arena-mine { margin: 14px 2px 2px; color: var(--secondary); font-size: 13px; font-weight: 600; }
.arena-mine b { color: var(--text); }

.arena-joined {
  margin-top: 12px;
  padding: 13px 16px;
  background: var(--surface);
  border-radius: 14px;
  text-align: center;
  font-weight: 600;
}

/* Модалка победителя */
.arena-win-title { font-size: 20px; }
.arena-win-val { font-size: 26px; font-weight: 700; color: var(--violet2); }

.aw-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.aw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 12px;
  font-size: 14px;
}

.aw-row.win { background: color-mix(in srgb, var(--md-success) 12%, transparent); }

.aw-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.aw-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-stake { flex: none; font-size: 13px; }
.aw-share { flex: none; min-width: 38px; text-align: right; font-size: 13px; }

/* Seed для сверки sha256(seed) == hash: полный, тихий, безопасно переносится. */
.aw-seed {
  margin-top: 10px;
  font-size: 11px;
  text-align: center;
  word-break: break-all;
}

/* Комиссия под суммой выигрыша: победитель получает банк за вычетом этой строки. */
/* Смена рума: fade-through по M3 (§5); направления keyframes сохранены, смещение — 12px. */
@keyframes roomInR { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes roomInL { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
#arenaRoot.room-in-r { animation: roomInR var(--dur-medium) var(--ease-decel); }
#arenaRoot.room-in-l { animation: roomInL var(--dur-medium) var(--ease-decel); }

/* Конфетти: один залп, куски удаляются вместе со слоем. */
.cf-wrap { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.cf {
  position: absolute;
  top: -8px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  animation: cf-fly var(--dur) ease-out var(--delay) forwards;
}

@keyframes cf-fly {
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* Wide screens */

@media (min-width: 520px) {
  #app { border-inline: 1px solid var(--md-outline-variant); }
}

@media (max-width: 370px) {
  .pill { padding: 0 10px; font-size: 13px; }
  .logo { font-size: 20px; }
  .tools { padding-left: 10px; padding-right: 10px; }
  .screen { padding-left: 10px; padding-right: 10px; }
  .arena-tabs { gap: 4px; }
  .arena-tab { padding: 0 9px; font-size: 12px; }
  .arena-tools { gap: 6px; }
  .up-qchip { padding: 4px 8px; font-size: 12px; }
}

/* 320px: логотип + баланс + «Пополнить» + аватар otherwise не помещаются в одну строку. */
@media (max-width: 340px) {
  .topbar { padding-left: 10px; padding-right: 10px; }
  .pill { padding: 0 8px; font-size: 12px; }
  .chips, .hscroll { --edge: 10px; }
}

/* Reduced motion (§5): всё мгновенно/отключено, включая новые state layer и spring-индикатор. */

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

  .tab-ind { transition: none !important; }
  .btn::after,
  .icon-btn::after { transition: none !important; }
  .game-hero:hover { transform: none !important; }
  /* FAZE D: слои и микродвижения новых компонентов (list rows, text button,
     copy-кнопка входа, lift карточки) — тоже гасятся здесь. */
  .profile-list .list-row::after,
  .text-btn::after,
  .text-btn,
  .login-code-copy,
  .case-card::after { transition: none !important; }
  .profile-list .list-row:active,
  .text-btn:active,
  .login-code-copy:active { transform: none !important; }
}

/* Редактор суммы быстрой ставки арены */
.arena-chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.arena-chips-hint { margin: 2px 2px 0; font-size: 12px; color: var(--secondary); }
.arena-amt-title { margin: 0; font-size: 24px; font-weight: 400; line-height: 32px; }
.arena-amt-label { display: block; margin: 14px 2px 8px; font-size: 13px; font-weight: 600; color: var(--secondary); }
.arena-amt-input {
  width: 100%;
  height: 48px;
  /* Outlined field (§4). */
  border-radius: var(--shape-sm);
  border: 1px solid var(--md-outline);
  background: transparent;
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.arena-amt-input:focus { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }
.arena-amt-input::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
.arena-amt-hint { margin: 8px 2px 0; font-size: 12px; color: var(--secondary); }
.arena-amt-hint.bad { color: var(--danger); }

/* Шит автоплея: комнаты — тумблеры-пилюли, суммы — чипы */
.auto-rooms { display: flex; gap: 10px; margin: 10px 0 4px; }
.auto-pill { flex: 1; min-height: 44px; cursor: pointer; position: relative; }
.auto-pill input { position: absolute; opacity: 0; pointer-events: none; }
.auto-pill-face {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.auto-pill:hover .auto-pill-face { background: var(--md-surface-container-highest); }
.auto-pill input:checked + .auto-pill-face { background: var(--accent-fill); color: var(--md-on-primary); }
.auto-pill input:focus-visible + .auto-pill-face { outline: 2px solid var(--focus); outline-offset: 2px; }

.auto-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 10px 0 4px; }
.auto-chip {
  min-height: 44px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.auto-chip:hover { background: var(--md-surface-container-highest); }
.auto-chip.active { background: var(--accent-fill); color: var(--md-on-primary); }
.auto-actions { display: flex; gap: 10px; margin-top: 18px; }
.auto-actions .btn { flex: 1; }

/* Блок ставки всегда виден: липнет к низу над таб-баром, пока не доскроллил.
   M3: поверхность surface-container-high + elevation lvl2, паддинг 12/16 (§3, §4). */
#arenaJoin {
  position: sticky;
  bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  margin: 0 -14px;
  padding: 12px 16px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-lg) var(--shape-lg) 0 0;
  box-shadow: var(--md-elevation-2);
}
#arenaJoin:empty { display: none; }

/* После базового правила: вынос панели равен паддингу экрана, иначе край режется overflow-x: clip. */
@media (max-width: 370px) {
  #arenaJoin { margin-inline: -10px; padding-left: 10px; padding-right: 10px; }
}

/* Экран «Заработок»: промо-ролики за просмотры */
.earn-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 16px 22px; text-align: center; }
.earn-hero-ico { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: var(--shape-lg); background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.earn-hero-ico svg { width: 34px; height: 34px; }
.earn-hero-title { font-size: 24px; font-weight: 400; line-height: 32px; max-width: 280px; }
.earn-hero-pay { font-size: 14px; color: var(--secondary); }
.earn-hero-pay b { font-size: 40px; font-weight: 700; color: var(--violet2); line-height: 1; }

.earn-link { display: flex; flex-direction: row; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 14px; text-align: left; cursor: pointer; font: inherit; }
.earn-link-ico { display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; border-radius: var(--shape-md); background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.earn-link-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.earn-link-txt b { font-size: 16px; }
.earn-link-chev { flex: none; color: var(--secondary); }

.earn-tier-head, .earn-rate-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.earn-tier-head { margin-top: 10px; color: var(--secondary); font-size: 12px; font-weight: 600; text-align: center; }
.earn-rate { margin-top: 12px; }
.earn-rate-name { font-size: 14px; }
.earn-rate-cells { margin-top: 4px; }
.earn-pay { text-align: center; font-size: 20px; font-weight: 700; color: var(--violet2); }
.earn-note { margin-top: 14px; font-size: 13px; line-height: 1.45; }

.earn-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.earn-steps li { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.earn-step-n { display: flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--surface2); font-size: 14px; font-weight: 700; }

.earn-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.earn-rules li { position: relative; padding-left: 18px; font-size: 14px; line-height: 1.4; }
.earn-rules li::before { content: ''; position: absolute; left: 2px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-fill); }

.earn-cta-note { margin: 2px 8px 10px; text-align: center; font-size: 14px; line-height: 1.4; }
.earn-cta { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* Смена вкладок: M3 fade-through (§5) — кривые/длительности обновлены, имена и структура keyframes те же. */
@keyframes screenInR { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes screenInL { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes screenInFade { from { opacity: 0; } to { opacity: 1; } }
#screen.screen-in-r { animation: screenInR var(--dur-medium) var(--ease-decel); }
#screen.screen-in-l { animation: screenInL var(--dur-medium) var(--ease-decel); }
#screen.screen-in-fade { animation: screenInFade var(--dur-medium) var(--ease-decel); }

/* Лёгкий вход контента при рендере экрана и каскад плиток/чипов (stagger 30ms по §5). */
@keyframes screenInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

#screen.screen-in-up { animation: screenInUp var(--dur-medium) var(--ease-decel); }

.anim-rise { animation: riseIn var(--dur-medium) var(--ease-decel) both; animation-delay: calc(var(--i, 0) * 30ms); }

/* Still-рендер: интерактивные перерисовки не переигрывают входные анимации. */
.still .anim-rise { animation: none; }
.still .up-bar { animation: none; }

/* Пульс цифры баланса при изменении. */
.js-balance { display: inline-block; }

@keyframes balPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.1); color: var(--accent); }
  100% { transform: scale(1); color: inherit; }
}

.bal-pulse { animation: balPulse var(--dur-medium) var(--ease-standard); }

/* Липкая панель апгрейда: вход снизу лёгким слайдом. */
@keyframes upBarIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.up-bar { animation: upBarIn var(--dur-medium) var(--ease-decel); }

/* ===== Фото реальных подарков =====
   Подарок приходит квадратным фото с собственной подложкой: рисуем его
   скруглённым квадратом-карточкой. Эмодзи-фолбэк (старые предметы и ошибка
   загрузки) получает прежние размеры глифа через span-правила тех же классов.
   Габариты плиток мульти-рулетки (64+6) не трогаем: на них завязана математика её прокрутки.
   Шаг большой ленты app.js меряет по живой плитке (reelMetrics), поэтому её размер
   в media-блоке десктопа можно менять свободно. */

img.rw-img, img.rl-img, img.mrl-img, img.mw-img, img.win-img,
img.case-gift-img, img.cs-gift-img, img.inv-img, img.it-img,
img.ip-img, img.t-img, img.bw-img, img.drop-img {
  display: block;
  flex: none;
  object-fit: cover;
  background: color-mix(in srgb, var(--md-on-surface) 6%, transparent);
}

img.rw-img { width: 44px; height: 44px; border-radius: 10px; }
img.rl-img { width: 64px; height: 64px; border-radius: 10px; }
/* Плитка мульти-рулетки 64x36: фото держим в бюджете эмодзи (~20px), иначе
   min-content раздувает плитку мимо flex-basis и ломает шаг 70px. */
img.mrl-img { width: 20px; height: 20px; border-radius: 6px; }
img.mw-img { width: 40px; height: 40px; border-radius: 10px; }
img.win-img { width: 96px; height: 96px; border-radius: 10px; margin: 0 auto; }
img.case-gift-img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
img.cs-gift-img {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
img.inv-img { width: 36px; height: 36px; border-radius: 10px; }
img.it-img { width: 44px; height: 44px; border-radius: 10px; }
img.ip-img { width: 44px; height: 44px; border-radius: 10px; }
img.t-img { width: 44px; height: 44px; border-radius: 10px; }
img.bw-img { width: 40px; height: 40px; border-radius: 10px; }
img.drop-img { width: 22px; height: 22px; border-radius: 6px; }

/* Эмодзи-фолбэк: те же классы на span, размеры глифа прежние (span.X покрывает и .art-fallback). */
span.rw-img { font-size: 26px; line-height: 1.2; }
span.rl-img { font-size: 36px; line-height: 1.1; }
span.mrl-img { font-size: 18px; line-height: 1; }
span.mw-img { font-size: 26px; line-height: 1.1; }
span.win-img { display: block; font-size: 72px; text-align: center; line-height: 1.25; }

/* Грам-алмаз вместо заглушки подарка: результат чисто балансовой ставки.
   Двойной, как DIA: в Stars-режиме вместо ромба — золотая звезда. */
.win-dia {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  filter: drop-shadow(0 8px 22px rgba(48, 161, 245, 0.35));
}
.win-dia .u-star { display: none; }
body.cur-stars .win-dia .u-dia { display: none; }
body.cur-stars .win-dia .u-star { display: block; }
body.cur-stars .win-dia { filter: drop-shadow(0 8px 22px rgba(251, 185, 41, 0.35)); }
span.case-gift-img { font-size: 50px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
span.cs-gift-img { font-size: 80px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
span.inv-img { font-size: 30px; line-height: 1.2; flex: none; }
span.it-img { font-size: 30px; line-height: 1.2; }
span.ip-img { font-size: 32px; line-height: 1.2; }
span.t-img { font-size: 30px; line-height: 1.2; }
span.bw-img { font-size: 30px; line-height: 1; }
span.drop-img { font-size: 17px; line-height: 1.3; }

/* Коллекция под названием выигрыша. */
.win-sub { text-align: center; font-size: 13px; color: var(--secondary); margin-top: 2px; }

/* Рефералка и бесплатные кейсы */

/* Карточка бесплатного кейса: вместо цены статусная пилюля. Она шире цены, поэтому
   на узком экране переходит под название, а не укорачивает его. */
.case-foot-free { flex-wrap: wrap; row-gap: 4px; }
/* Название занимает всю строку: пилюля статуса всегда ниже, справа, как у «Бесплатно». */
.case-foot-free .case-name { flex-basis: 100%; }
.case-foot-free .case-price { margin-left: auto; }
.case-price-free { font-weight: 500; white-space: nowrap; }

/* Приз «На баланс» из «Подарка дня»: арта нет, в квадрате предмета стоит алмаз денег. */
span.art-bal { display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); }
span.art-bal .dia { vertical-align: 0; }
span.rl-img.art-bal { width: 64px; height: 64px; border-radius: 10px; font-size: 36px; }
span.rw-img.art-bal { width: 44px; height: 44px; border-radius: 10px; font-size: 26px; }
span.drop-img.art-bal { width: 22px; height: 22px; border-radius: 6px; font-size: 14px; }

/* Сумма приза на баланс: крупно, цветом зачисления как в истории операций. */
.bal-win-val { text-align: center; font-size: 30px; font-weight: 700; color: var(--success); margin-top: 4px; }

/* Карточка подарка из NFT-кейса. */
.gift-art { display: grid; place-items: center; width: 112px; height: 112px; margin: 0 auto; background: var(--surface2); border-radius: 22px; }
.gift-cap { text-align: center; font-size: 13px; margin-top: 10px; }
.gift-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 14px; }
.gift-row b { font-weight: 700; white-space: nowrap; }
/* Ряд полос: по одной на каждого нужного друга; длинный ряд переносится. */
.gift-bars { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.gift-bars i { flex: 1 0 8px; height: 8px; border-radius: var(--radius-pill); background: var(--surface2); }
.gift-bars i.on { background: var(--accent-fill); }
.gift-note { font-size: 13px; line-height: 1.45; margin-top: 12px; }
/* Плитки наград на поверхности модалки: без подложки сливаются с фоном. */
.gift-drops .rw-tile { background: var(--surface2); }

/* Карточка «Приглашай друзей» в «Заработке». */
.ref-lead { font-size: 15px; }
.ref-lead b { font-size: 20px; font-weight: 700; color: var(--violet2); }
.ref-link { font-size: 13px; color: var(--secondary); overflow-wrap: anywhere; }
.ref-btns { display: flex; flex-wrap: wrap; gap: 10px; }
.ref-btns .btn { flex: 1 1 140px; min-width: 0; padding: 0 12px; }
/* Три показателя в ряд; плитки на поверхности карточки светлее, иначе не видны. */
.ref-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ref-stats .stat-tile { padding: 10px 8px; background: var(--surface2); }
.ref-gift { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 6px 6px 6px 12px; background: var(--surface2); border-radius: 14px; }
.ref-gift-txt { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }

/* Замороженный подарок в инвентаре: бейдж второй строкой, под названием; тап открывает карточку. */
.inv-row-locked { flex-wrap: wrap; row-gap: 4px; }
.lock-badge { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 44px; margin-left: 46px; padding: 0 8px 0 12px; border-radius: var(--radius-pill); background: var(--surface2); font-size: 12px; font-weight: 700; transition: background var(--dur-short) var(--ease-standard); }
.lock-badge:hover { background: var(--md-surface-container-highest); }
.lock-badge:active { background: var(--md-surface-container-highest); }

/* Веб-версия (вне Telegram): экран входа, cookie-баннер, выход из аккаунта */

/* Экран входа: пластика фатального экрана (центр, max-width, gap), лого как в буте. */
.login-screen {
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 24px 24px 8px;
  text-align: center;
}

.login-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.login-title { font-size: 22px; font-weight: 500; line-height: 28px; }

.login-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.login-actions .btn { width: 100%; }
.login-actions a { text-decoration: none; }

.login-status { min-height: 20px; font-size: 14px; color: var(--secondary); }

.login-note { padding: 12px 0 8px; font-size: 12px; color: var(--secondary); }

/* Cookie-баннер: над таб-баром, ширина и центровка как у него; без таб-бара
   (экран входа) прижимается ниже. Фон непрозрачный, текст не читается сквозь контент.
   z-index 25: выше таб-бара (20), но под полноэкранными слоями (30+). */
.cookie-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  width: min(440px, calc(100% - 24px));
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
}

.cookie-banner.solo { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }

.cookie-text { font-size: 13px; line-height: 1.5; color: var(--text); }

.cookie-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.cookie-more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--violet2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.cookie-more:hover { color: var(--md-on-surface); text-decoration: underline; }
.cookie-more:active { color: var(--md-on-surface); }

.cookie-banner .btn-sm { flex: none; }

/* Выход в профиле: сдержанный danger-текст в ряду link-кнопок. */
.profile-logout { display: block; margin: 2px auto; color: var(--danger); }

/* Код /login на экране входа: запасной путь, если Telegram потерял start-параметр. */
.login-code {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin: 16px auto 0;
  padding: 12px 14px;
  max-width: 340px;
  background: var(--surface2);
  border: 1px solid color-mix(in srgb, var(--md-on-surface) 6%, transparent);
  border-radius: 14px;
}
.login-code-hint { color: var(--secondary); font-size: 12px; }
.login-code-val { font-size: 20px; font-weight: 700; letter-spacing: 2px; color: var(--violet2); }
.login-code-copy {
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--md-primary-text) 40%, transparent);
  color: var(--violet2);
  font-weight: 700;
  cursor: pointer;
}
.login-code-copy:hover { border-color: var(--accent); }
.login-code-copy:active { background: color-mix(in srgb, var(--md-primary) 12%, transparent); }

/* Десктоп по системе rubup.pro: контент во всю ширину без рамок, тихая текстовая
   навигация в шапке, карточки — чистые тайлы с именем и ценой под картинкой. */
@media (min-width: 768px) {
  body {
    /* M3: плоская surface без glow-градиента (§7); компоновка не тронута. */
    background: var(--md-surface);
  }
  #app {
    display: flex;
    flex-direction: column;
    max-width: 1560px;
    padding: 0;
    border: none;
    box-shadow: none;
  }
  #app > .topbar {
    order: 0;
    position: sticky;
    top: 0;
    z-index: 21;
    height: 68px;
    padding: 0 36px;
    align-items: center;
    background: var(--md-surface-container);
    border-bottom: 1px solid var(--md-outline-variant);
  }
  #app > .topbar .logo { font-size: 26px; }
  #app > .tabbar {
    order: 1;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: none;
    height: 68px;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    z-index: 22;
  }
  #app > .tabbar .tab-ind { display: none; }
  #app > .tabbar .tabbtn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 18px;
    flex-direction: row;
    gap: 8px;
    background: transparent;
    border-radius: var(--shape-full);
    font-size: 14px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
  }
  #app > .tabbar .tabbtn svg { opacity: 0.75; }
  /* FAZE D: активный пункт верхней навигации — пилюля primary-container
     с иконкой on-primary-container, как индикатор таббара (§4), а не серая подложка. */
  #app > .tabbar .tabbtn.active {
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
  }
  #app > .tabbar .tabbtn.active svg { opacity: 1; }
  #app > .screen { order: 2; padding: 26px 36px 72px; }
  .sec-head h2 { font-size: 24px; }
  .grid-cases { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
  /* Карточка остаётся M3-поверхностью и на десктопе: lift + elevation вместо «подписей под обложкой». */
  .case-card:hover { transform: translateY(-3px); box-shadow: var(--md-elevation-2); }
  .case-card:active { transform: scale(0.98); }
  .case-cover { height: 158px; }
  .case-foot { padding: 12px 14px 14px; }
  .games-hub { padding: 0; }
  .game-hero { border-radius: 26px; min-height: 340px; }
  /* FAZE D: на десктопе таббара снизу нет — cookie-баннер становится snackbar
      bottom-left (left-anchored), а не центрированной плашкой. */
  .cookie-banner { bottom: 24px; left: 36px; transform: none; width: min(480px, calc(100% - 72px)); }
  .cookie-banner.solo { bottom: 24px; }
}
/* Узкий десктоп: в шапке хватает места только на иконки навигации. */
@media (min-width: 768px) and (max-width: 1099px) {
  #app > .tabbar .tabbtn span { display: none; }
  #app > .tabbar .tabbtn { padding: 0 14px; }
}
.profile-logout:hover { text-decoration: underline; }

/* Десктоп-зачистка остальных экранов (>=768px). Мобильные правила выше не тронуты. */
@media (min-width: 768px) {

  /* Модалки-«шиты» → центрированные окна вместо донных листов. */
  .sheet-layer { align-items: center; justify-content: center; padding: 24px; }
  .sheet {
    width: min(520px, 100%);
    max-height: calc(100vh - 48px);
    border-radius: var(--shape-xl);
    box-shadow: var(--md-elevation-3);
  }
  .sheet .dep-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .sheet .dep-chip { height: 44px; border-radius: var(--shape-full); }
  .sheet .dep-wallet { border: none; background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); border-radius: var(--shape-full); height: 48px; }
  .sheet .btn-primary { height: 56px; border-radius: var(--shape-full); }

  /* Заработок: контейнер по центру, компоненты крупнее и симметричнее. */
  #app > .screen > .cards { max-width: 1200px; margin: 0 auto; }
  .cards .card { border-radius: 20px; padding: 26px 30px; }
  .cards .card-title { font-size: 22px; }
  .ref-link {
    margin: 12px auto 0;
    padding: 12px 18px;
    max-width: 720px;
    text-align: center;
    background: color-mix(in srgb, var(--md-on-surface) 4%, transparent);
    border-radius: 14px;
    font-size: 14px;
    color: var(--text);
    user-select: all;
  }
  .ref-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; max-width: 900px; margin: 18px auto 0; }
  .ref-stats > * { min-height: 88px; border-radius: 16px; background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 14px 20px; }
  .earn-hero { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
  .earn-hero-title { font-size: 32px; white-space: nowrap; }
  .earn-hero-pay b { font-size: 44px; }
  .earn-tier-head, .earn-rate-cells { max-width: 1000px; margin-left: auto; margin-right: auto; }
  .earn-rate-name { text-align: center; }
  .earn-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .earn-steps li { background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); border-radius: 16px; padding: 20px; }
  .earn-rules { columns: 2; column-gap: 40px; max-width: 1000px; margin: 0 auto; }
  .earn-cta-note { font-size: 15px; }
  .cards .earn-cta { width: 480px; margin: 0 auto; display: flex; justify-content: center; }

  /* Игры: tonal-градиент из md-токенов вместо кликьев (арт-блок карточки, §4). */
  #app > .screen > .games-hub { max-width: 1200px; margin: 0 auto; }
  .game-hero {
    background: linear-gradient(115deg, var(--md-primary-container) 0%, color-mix(in srgb, var(--md-primary-container) 68%, #000) 55%, color-mix(in srgb, var(--md-primary-container) 45%, #000) 100%);
    color: var(--md-on-primary-container);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 320px;
    border-radius: var(--shape-xl);
  }
  .game-hero:hover { transform: translateY(-4px); box-shadow: var(--md-elevation-3); }
  .game-hero .hero-slice, .game-hero .hero-wedge { display: none; }
  .game-hero .hero-art { position: static; width: 88px; height: 88px; }
  .game-hero .hero-title { position: static; text-align: center; font-size: 40px; }
  .game-hero .hero-title small { font-size: 16px; color: color-mix(in srgb, var(--md-on-primary-container) 85%, transparent); }
  .game-hero .hero-pills { top: 18px; left: 18px; }
  .games-hub::after {
    content: 'Больше игр — скоро';
    display: block;
    margin: 40px 0 0;
    text-align: center;
    color: var(--secondary);
    font-size: 15px;
  }

  /* Арена-комната: центральная колонна 720px. */
  #app > .screen > #arenaRoot { max-width: 720px; margin: 0 auto; }
  .arena-hash { text-align: center; font-size: 12px; }

  /* Апгрейды: центр композиции, крупная типографика, док по центру. */
  #app > .screen > .up-screen { max-width: 1200px; margin: 0 auto; }
  .up-screen .chance-card .card-title,
  .up-screen .chance-card .sec-head h2 { flex: 1; text-align: center; font-size: 32px; }
  .up-screen .up-bal-row { max-width: 560px; margin-left: auto; margin-right: auto; }
  .up-screen #upBalBlock .up-slider { display: block; max-width: 560px; margin: 10px auto 0; }
  .up-screen .up-bar-col { max-width: 720px; margin: 0 auto; }
  .up-screen .up-qrow { justify-content: center; }
  .up-screen .up-qchip { min-height: 56px; border-radius: 14px; }
  .up-screen .up-go { width: 100%; height: 56px; border-radius: 16px; font-size: 18px; }

  /* Профиль: колонна 1200px, карточка игрока аккуратнее. */
  .case-screen.profile-page { max-width: 1200px; }
  .case-screen.profile-page .profile-card { border-radius: 24px; padding: 28px 30px; }
  .case-screen.profile-page .profile-name { font-size: 24px; }
  .case-screen.profile-page .pill-balance, .case-screen.profile-page .btn { min-height: 48px; }
  .case-screen.profile-page .profile-logout { display: block; width: 100%; max-width: 360px; margin: 14px auto; text-align: center; }
}

/* ============================================================
   Экран кейса: десктоп (>=768px).
   Мобильная вёрстка выше не тронута: правила ниже уточняют классы
   внутри .case-screen (или модалки результата) и включаются только
   на широких экранах. Шаг рулетки app.js меряет по живой плитке.
   ============================================================ */

@media (min-width: 768px) {

  /* Каркас: широкая колонка вместо мобильной 480px. */
  .case-screen { max-width: 1376px; }

  .case-screen .cs-head { gap: 12px; padding: 10px 18px; }
  /* Имя кейса на десктопе живёт крупным заголовком в теле, шапка: только назад и баланс. */
  .case-screen .cs-title { display: none; }
  .case-screen .cs-head .pill-balance { margin-left: auto; }

  /* Тело: линии-строки через wrap; экшн-ряд ниже собирается в одну строку
     из #csCount и #csCta через display:contents. */
  .case-screen .cs-body {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px 12px;
    max-width: none;
    padding: 12px 32px 48px;
  }
  .case-screen .cs-body > .cs-cover,
  .case-screen .cs-body > .cs-h1,
  .case-screen .cs-body > #csRewards { flex: 0 0 100%; }
  /* Строки количества и кнопок — отдельные ряды по центру (рулетка между ними). */
  .case-screen .cs-body > #csCount,
  .case-screen .cs-body > #csCta { flex: 0 0 100%; display: block; text-align: center; }

  /* Обложка: компактная, по центру; арт крупнее и со свечением. */
  .case-screen .cs-cover {
    max-width: 300px;
    height: 216px;
    border-radius: 24px;
  }
  .case-screen img.cs-cover-art {
    width: 172px;
    height: 172px;
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
  .case-screen img.cs-gift-img { width: 148px; height: 148px; }
  .case-screen span.cs-gift-img { font-size: 110px; }

  .case-screen .cs-h1 {
    display: block;
    margin: 0;
    font-size: 40px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
  }

  /* Экшн-ряд: пилюли количества и обе кнопки в один ряд по центру. */
  #csCount, #csCta { display: contents; }
  .case-screen .cnt-block { margin: 0; }
  .case-screen .cnt-label { display: none; }
  .case-screen .cnt-grid { display: flex; gap: 8px; justify-content: center; }
  .case-screen .cnt { width: 72px; height: 44px; border-radius: 22px; }
  .case-screen .cnt.sel {
    background: color-mix(in srgb, var(--md-primary) 14%, transparent);
    border: 2px solid var(--focus);
    color: var(--text);
    box-shadow: none;
  }

  #csCta .cta-stack {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }
  #csCta .btn-primary {
    flex: 0 0 auto;
    width: auto;
    height: 56px;
    min-height: 56px;
    padding: 0 32px;
    font-size: 17px;
    border-radius: var(--shape-full);
    background: var(--md-primary);
    box-shadow: var(--md-elevation-2);
  }
  #csCta .btn-primary:hover:not(:disabled) {
    background: var(--accent-fill-hover);
    box-shadow: var(--md-elevation-3);
  }
  #csCta .btn-secondary {
    flex: 0 0 auto;
    width: auto;
    height: 56px;
    min-height: 56px;
    padding: 0 24px;
    border-radius: var(--shape-full);
    background: var(--md-secondary-container);
  }

  /* Рулетка: широкая, по центру; плитки крупнее, шаг меряет reelMetrics. */
  .case-screen .roulette:not(.multi) {
    flex: 0 0 100%;
    max-width: 1040px;
    height: 160px;
    margin: 0 auto;
    /* Гарантированное симметричное затухание краёв поверх оверлеев. */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 72px, #000 calc(100% - 72px), transparent);
    mask-image: linear-gradient(90deg, transparent 0, #000 72px, #000 calc(100% - 72px), transparent);
  }
  .case-screen .roulette.multi { flex: 0 0 100%; }

  .case-screen .rl-tile {
    flex: 0 0 120px;
    border-radius: 14px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.3s ease, filter 0.3s ease;
  }
  .case-screen img.rl-img { width: 56px; height: 56px; }
  .case-screen span.rl-img { font-size: 40px; line-height: 1.1; }
  .case-screen .rl-name { font-size: 13px; max-width: 108px; }
  .case-screen .rl-val { font-size: 13px; }

  /* Маркер: линия со свечением и «наконечниками» у краёв окна. */
  .case-screen .rl-marker {
    width: 5px;
    margin-left: -2.5px;
    background: color-mix(in srgb, var(--md-primary) 90%, transparent);
    box-shadow: 0 0 24px color-mix(in srgb, var(--md-primary) 90%, transparent);
  }
  .case-screen .rl-marker::before,
  .case-screen .rl-marker::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
  }
  .case-screen .rl-marker::before { top: 0; border-top: 12px solid var(--md-primary); }
  .case-screen .rl-marker::after { bottom: 0; border-bottom: 12px solid var(--md-primary); }

  .case-screen .roulette:not(.multi)::before,
  .case-screen .roulette:not(.multi)::after { width: 80px; }

  /* Момент финиша: победитель подсвечен цветом редкости, остальные гаснут. */
  .case-screen .rl-hit {
    transform: scale(1.1);
    border: 2px solid rgb(var(--rc-rgb, 196, 160, 255));
    box-shadow: 0 0 0 4px rgba(var(--rc-rgb, 196, 160, 255), 0.35), 0 0 44px rgba(var(--rc-rgb, 196, 160, 255), 0.6);
    z-index: 3;
    animation: markerPulse 0.3s ease 3;
  }
  .case-screen .rl-strip.rl-done .rl-tile:not(.rl-hit) {
    opacity: 0.35;
    filter: saturate(0.4);
    transition: opacity 0.3s ease, filter 0.3s ease;
  }
  .case-screen .roulette:has(.rl-strip.rl-done) .rl-marker {
    animation: markerPulse 0.3s ease 3;
  }

  @keyframes markerPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.6); }
  }

  /* Награды: заголовок по центру, счётчик под ним. */
  .case-screen #csRewards .sec-head {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 10px 0 0;
  }
  .case-screen #csRewards .sec-head h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .case-screen #csRewards .sec-head h2::before,
  .case-screen #csRewards .sec-head h2::after {
    content: "✦";
    font-size: 18px;
    color: var(--accent);
  }
  .case-screen #csRewards .sec-head .sec-count {
    margin-left: 0;
    font-size: 14px;
  }

  /* Сетка дропов: 4 колонки, от 1280px до 6. */
  .case-screen #csRewards .rw-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
  }
  @media (min-width: 1280px) {
    .case-screen #csRewards .rw-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  }

  /* Тайл дропа: сплошная градиентная заливка тира вместо полоски сверху. */
  .case-screen #csRewards .rw-tile {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 2;
    padding: 14px;
    border: 1px solid rgba(var(--rc-rgb, 179, 174, 198), 0.5);
    border-radius: 16px;
    background: linear-gradient(165deg, rgba(var(--rc-rgb, 179, 174, 198), 0.5) 0%, rgba(var(--rc-rgb, 179, 174, 198), 0.16) 55%, rgba(255, 255, 255, 0.03) 100%), var(--surface);
    box-shadow: inset 0 -24px 44px rgba(0, 0, 0, 0.35), 0 0 24px rgba(var(--rc-rgb, 179, 174, 198), 0.15);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
  .case-screen #csRewards .rw-tile:hover {
    transform: translateY(-4px);
    box-shadow: inset 0 -24px 44px rgba(0, 0, 0, 0.35), 0 0 34px rgba(var(--rc-rgb, 179, 174, 198), 0.3);
  }
  .case-screen #csRewards .rw-tile[data-rarity="epic"] {
    background: linear-gradient(165deg, rgba(196, 160, 255, 0.5) 0%, rgba(212, 87, 156, 0.2) 55%, rgba(255, 255, 255, 0.03) 100%), var(--surface);
  }
  .case-screen #csRewards img.rw-img { width: 96px; height: 96px; border-radius: 14px; }
  .case-screen #csRewards span.rw-img { font-size: 64px; line-height: 1; }
  .case-screen #csRewards .rw-name {
    position: absolute;
    left: 14px;
    bottom: 26px;
    max-width: calc(100% - 28px);
    font-size: 15px;
  }
  .case-screen #csRewards .rw-val {
    position: absolute;
    left: 14px;
    bottom: 10px;
    font-size: 13px;
  }

  /* Модалка результата спина: шире, крупный арт, кнопки в ряд. */
  .modal-box:has(> .win-name) {
    width: min(560px, 100%);
    max-width: min(560px, 100%);
    padding: 28px 24px 24px;
  }
  .modal-box:has(> .win-name) img.win-img { width: 180px; height: 180px; border-radius: 18px; }
  .modal-box:has(> .win-name) span.win-img { font-size: 120px; }
  .modal-box:has(> .win-name) .win-dia { width: 180px; height: 180px; }
  .modal-box:has(> .win-name) .win-val { font-size: 14px; }
  .modal-box:has(> .win-name) .modal-actions {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }
}
@media (min-width: 768px) {
  /* Широкие экраны: шапка во всю ширину вьюпорта, лого по краям контентной колонки (1560px). */
  body { overflow-x: clip; }
  #app > .topbar {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    padding-left: max(36px, calc(50vw - 744px));
    padding-right: max(36px, calc(50vw - 744px));
  }
  /* Док апгрейда: в потоке колонны вместо мобильного fixed с отступом 86px. */
  .up-bar {
    position: static;
    bottom: auto;
    transform: none;
    width: auto;
    max-width: 720px;
    margin: 18px auto 0;
  }
  /* Тосты и cookie-баннер: к нижнему краю, таб-бара на десктопе нет. */
  .toasts { bottom: 24px; }
  .cookie-banner { bottom: 24px; width: min(520px, calc(100% - 48px)); }
}

/* Earn-десктоп: рефы и статы не разъезжаются на всю карточку. */
@media (min-width: 768px) {
  .ref-btns { width: 100%; max-width: 660px; margin: 14px auto 0; }
  .ref-stats { width: 100%; }
  .ref-stats .stat-tile { padding: 14px 20px; background: color-mix(in srgb, var(--md-on-surface) 4%, transparent); }
}

/* Масс-открытие кейса на десктопе: кап и фейды как у одиночной рулетки. */
@media (min-width: 768px) {
  .case-screen .roulette.multi { flex: 0 0 auto; width: 1040px; max-width: 100%; margin: 0 auto; }
  .case-screen .roulette.multi::before,
  .case-screen .roulette.multi::after { content: ''; width: 80px; z-index: 3; }
  .case-screen .roulette.multi::before { background: linear-gradient(90deg, var(--md-surface-container), transparent); }
  .case-screen .roulette.multi::after { background: linear-gradient(-90deg, var(--md-surface-container), transparent); }
  .case-screen .mrls { gap: 8px; }
  .case-screen .mrl { height: 56px; }
}

/* Earn-десктоп: заголовки карточек по центру, под стать симметричному контенту. */
@media (min-width: 768px) {
  #app > .screen > .cards .card-title { text-align: center; }
  .ref-lead { text-align: center; }
  .earn-rate-name { text-align: center; }
}

/* Лут-модалка масс-открытия: все подарки сразу, по центру, без обрезки. */
@media (min-width: 768px) {
  .modal-box:has(.mw-grid) { width: min(680px, 100%); }
  .modal-box:has(.mw-grid) > .muted { text-align: center; }
  .modal-box:has(.mw-grid) .win-name { text-align: center; }
  .modal-box:has(.mw-grid) .mw-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
    max-height: calc(100vh - 280px);
  }
  .modal-box:has(.mw-grid) .mw-tile { padding: 14px 8px 12px; gap: 5px; }
  .modal-box:has(.mw-grid) .mw-name { font-size: 12px; }
  .modal-box:has(.mw-grid) .mw-val { font-size: 11px; }
  .modal-box:has(.mw-grid) .modal-actions { margin-top: 18px; }
}

/* Награды кейса на широких экранах: плотная сетка мелких плиток вместо
   шести огромных, из-за которых сетка визуально «кончается» с пустотой. */
@media (min-width: 1280px) {
  .case-screen #csRewards .rw-grid {
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 8px;
  }
  .case-screen #csRewards .rw-tile { padding: 10px; border-radius: 12px; }
  .case-screen #csRewards img.rw-img { width: 56px; height: 56px; border-radius: 10px; }
  .case-screen #csRewards span.rw-img { font-size: 40px; }
  .case-screen #csRewards .rw-name { left: 10px; bottom: 22px; max-width: calc(100% - 20px); font-size: 12px; }
  .case-screen #csRewards .rw-val { left: 10px; bottom: 8px; font-size: 11px; }
}

/* ============================================================
   МОБИЛЬНАЯ ОБОЛОЧКА (UnderLuck, <768px) — НАЧАЛО
   Слой «раковины» переведён на MD3-токены (DESIGN.md §1-§4):
   плоские container-поверхности, диалоги/шиты radius 28 +
   elevation lvl3, тост inverse-surface. Токены — из :root.
   Десктоп не затронут: всё строго внутри max-width: 767.98px.
   ============================================================ */
@media (max-width: 767.98px) {

  /* Фон страницы: плоский M3 surface (glassmorphism/glow убраны, §7). */
  body {
    background: var(--md-surface);
  }

  /* Шапка: surface-container, тонкая линия снизу; высота и паддинги мобильной не тронуты. */
  .topbar {
    background: var(--md-surface-container);
    border-bottom: 1px solid var(--md-outline-variant);
  }

  /* Таб-бар: базовое правило — Navigation Bar; здесь только гарантируем плоский container без blur. */
  .tabbar {
    background: var(--md-surface-container);
    border: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Активная вкладка: индикатор primary-container (база) — переопределение синхронизировано. */
  .tabbar .tab-ind { background: transparent; }
  .tabbar .tab-ind::after { background: var(--md-primary-container); }

  /* Карточки: плоская container-поверхность M3, без теней на каждой (§3). */
  .card {
    background: var(--md-surface-container);
    border: 0;
    border-radius: var(--shape-md);
  }
  /* FAZE D: карточки секций (earn/upgrades) — плашка lg 16 (§3), а не md 12. */
  .cards .card {
    background: var(--md-surface-container);
    border: 0;
    border-radius: var(--shape-lg);
  }
  .card-title { font-weight: 500; }

  /* Кнопки: pill-система; высоты и тап-таргеты не тронуты. */
  .btn,
  .btn-sm { border-radius: var(--shape-full); }
  .btn-lg { border-radius: var(--shape-full); }
  .btn-secondary { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
  .btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--md-on-secondary-container) 8%, var(--md-secondary-container)); }

  /* Модалки: surface-container-high, radius 28, elevation lvl3. */
  .modal-box {
    background: var(--md-surface-container-high);
    border-radius: var(--shape-xl);
    box-shadow: var(--md-elevation-3);
  }

  /* Донные шиты: позиция bottom и анимация не тронуты; та же высота иерархии. */
  .sheet {
    background: var(--md-surface-container-high);
    border-radius: var(--shape-xl) var(--shape-xl) 0 0;
    border-top: 0;
    box-shadow: var(--md-elevation-3);
  }

  /* Тосты: inverse-surface (snackbar M3); cookie-баннер: container + тихая тень. */
  .toast {
    background: var(--md-inverse-surface);
    color: var(--md-inverse-on-surface);
    border-radius: var(--shape-sm);
  }
  .cookie-banner {
    background: var(--md-surface-container);
    border-color: var(--md-outline-variant);
    border-radius: var(--shape-lg);
    box-shadow: var(--shadow-pop);
  }
}
/* МОБИЛЬНАЯ ОБОЛОЧКА — КОНЕЦ */

/* ============================================================
   Кейсы на телефоне (<768px): сетка и экран кейса в стиле сайта.
   Тайлы кейсов — без рамок и заливки, имя и цена по центру под
   тайлом; имя кейса — крупный заголовок в теле экрана (базовый
   guard .cs-h1 { display: none } перекрыт ниже по файлу), в шапке
   остаются только «назад» и баланс; дропы — плотная сетка мелких
   плиток с абсолютными подписями, как в десктоп-блоке выше.
   Десктоп (>=768px) не затронут: правила включаются только на
   узких экранах. Рулетка, маркер и фейды общие — не трогаем.
   ============================================================ */
@media (max-width: 767.98px) {

  /* FAZE D: карточка остаётся M3-плашкой и на телефоне (обложка сверху, футер под
     ней). Прежний «чистый тайл» (background:transparent + колонка) ломал сетку:
     flex-basis:100% в column-контейнере растягивал имя на всю высоту футера, текст
     залезал на обложку, а nowrap-чип цены выползал за правый край колонки. */
  .case-card { background: var(--md-surface-container); border: 0; }
  .case-card:hover { transform: translateY(-3px); box-shadow: var(--md-elevation-2); }
  .case-card:active { transform: scale(0.98); }

  /* Подпись внутри карточки: имя title-m своей строкой, редкости и цена — рядом. */
  .case-foot { flex-direction: row; align-items: center; gap: 6px 8px; padding: 10px 12px 12px; }
  .case-name { font-size: 16px; font-weight: 500; text-align: left; }
  .case-price { margin-left: auto; }
  .case-foot-free .case-name { flex-basis: 100%; }
  .case-foot-free .case-price { margin-left: auto; }

  /* Экран кейса: имя кейса крупным заголовком в теле, шапка — назад и баланс. */
  .case-screen .cs-title { display: none; }
  .case-screen .cs-head .pill-balance { margin-left: auto; }
  .case-screen .cs-h1 {
    display: block;
    margin: 2px 0 0;
    /* headline-s 24/32 400 (M3 §2) */
    font-size: 24px;
    font-weight: 400;
    line-height: 32px;
    text-align: center;
  }

  /* Награды: плотная сетка мелких плиток, подписи поверх угла тайла. */
  .case-screen #csRewards .rw-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
  }
  .case-screen #csRewards .rw-tile {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 2;
    padding: 10px;
    border: 1px solid rgba(var(--rc-rgb, 179, 174, 198), 0.5);
    border-radius: 12px;
    background: linear-gradient(165deg, rgba(var(--rc-rgb, 179, 174, 198), 0.5) 0%, rgba(var(--rc-rgb, 179, 174, 198), 0.16) 55%, rgba(255, 255, 255, 0.03) 100%), var(--surface);
    box-shadow: inset 0 -24px 44px rgba(0, 0, 0, 0.35), 0 0 24px rgba(var(--rc-rgb, 179, 174, 198), 0.15);
  }
  .case-screen #csRewards .rw-tile[data-rarity="epic"] {
    background: linear-gradient(165deg, rgba(196, 160, 255, 0.5) 0%, rgba(212, 87, 156, 0.2) 55%, rgba(255, 255, 255, 0.03) 100%), var(--surface);
  }
  .case-screen #csRewards img.rw-img { width: 48px; height: 48px; border-radius: 10px; }
  .case-screen #csRewards span.rw-img { font-size: 34px; line-height: 1; }
  .case-screen #csRewards .rw-name {
    position: absolute;
    left: 10px;
    bottom: 22px;
    max-width: calc(100% - 20px);
    font-size: 12px;
  }
  .case-screen #csRewards .rw-val {
    position: absolute;
    left: 10px;
    bottom: 8px;
    font-size: 11px;
  }
}

/* ============================================================
   Мини-апп (<768px), подс-экраны: заработок, игры, арена,
   апгрейды, профиль. Кожа под десктоп-редизайн (rubup): те же
   поверхности rgba(255,255,255,0.03-0.04), радиусы 16-20,
   центровка текстов. Тап-таргеты (высоты кнопок/чипов, таб-бар)
   и вся вёрстка >=768px не затронуты: всё внутри одного блока.
   ============================================================ */
@media (max-width: 767.98px) {

  /* Заработок: заголовки карточек и лид рефералки по центру —
     как стало на десктопе; плитки статов на светлой поверхности. */
  #app > .screen > .cards .card-title { text-align: center; }
  .ref-lead { text-align: center; }
  .ref-stats > .stat-tile {
    background: color-mix(in srgb, var(--md-on-surface) 4%, transparent);
    border-radius: 16px;
  }

  /* Игры: баннер без диагональных клиньев — tonal-градиент из md-токенов
     по центральной оси, содержимое по центру, как на десктопе. */
  .game-hero {
    background: linear-gradient(115deg, var(--md-primary-container) 0%, color-mix(in srgb, var(--md-primary-container) 68%, #000) 55%, color-mix(in srgb, var(--md-primary-container) 45%, #000) 100%);
    color: var(--md-on-primary-container);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
  }
  .game-hero .hero-slice,
  .game-hero .hero-wedge { display: none; }
  .game-hero .hero-art { position: static; margin: 0; }
  .game-hero .hero-title {
    position: static;
    padding: 0 64px;
    text-align: center;
    font-size: 28px;
    font-weight: 500;
  }

  /* Арена: подпись статуса и хеш раунда по центру колонны (банк-чип уже в базе §4). */
  .arena-status { text-align: center; }
  .arena-hash { text-align: center; }

  /* Апгрейды: заголовок «Шанс успеха» по центру строки, 800. */
  .up-screen .chance-card .card-title,
  .up-screen .chance-card .sec-head h2 {
    flex: 1;
    text-align: center;
    font-weight: 700;
  }

  /* Профиль: карточка на полупрозрачной поверхности, радиус 20;
     «Выйти» — по центру карточки. */
  .profile-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
  }
  .profile-logout { text-align: center; }
}

/* ============================================================
   Мини-апп: награды вертикально по центру, рулетка как на сайте,
   плавное затухание подсветки.
   Перебивка блока выше (строки ~3378-3439): на тайлах 96px
   абсолютные подписи наезжали на арт — возвращаю колонку
   арт/имя/цена. Рулетка — укрупнена до рецепта сайта, чуть
   компактнее под 375px. Десктоп (>=768px) не затронут.
   ============================================================ */
@media (max-width: 767.98px) {
  .case-screen #csRewards .rw-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    aspect-ratio: auto;
    padding: 10px 6px 9px;
  }
  .case-screen #csRewards .rw-name { position: static; left: auto; bottom: auto; max-width: 100%; font-size: 11px; }
  .case-screen #csRewards .rw-val { position: static; left: auto; bottom: auto; font-size: 10px; }
  .case-screen #csRewards img.rw-img { width: 44px; height: 44px; border-radius: 8px; }
  .case-screen #csRewards span.rw-img { font-size: 30px; }
  .case-screen .rl-tile { flex: 0 0 104px; border-radius: 14px; transition: transform 0.45s ease, box-shadow 0.45s ease, border-color 0.45s ease, opacity 0.3s ease, filter 0.3s ease; }
  .case-screen img.rl-img { width: 48px; height: 48px; }
  .case-screen span.rl-img { font-size: 32px; }
  .case-screen .rl-name { font-size: 12px; max-width: 92px; }
  .case-screen .rl-val { font-size: 12px; }
  .case-screen .rl-hit { transition: transform 0.45s ease, box-shadow 0.45s ease, border-color 0.45s ease; }
}

/* ============================================================
   Мини-апп: визуал финиша рулетки — мобильное зеркало
   десктоп-блока (~3097-3113): подсветка победителя, затухание
   остальных, пульс маркера. JS вешает/снимает классы через
   2800мс; transition с border-color из блока выше даёт плавное
   затухание. keyframes markerPulse продублированы сюда, т.к.
   в базе они заперты в @media (min-width: 768px).
   ============================================================ */
@media (max-width: 767.98px) {
  .case-screen .rl-hit {
    transform: scale(1.08);
    border: 2px solid rgb(var(--rc-rgb, 196, 160, 255));
    box-shadow: 0 0 0 3px rgba(var(--rc-rgb, 196, 160, 255), 0.35), 0 0 32px rgba(var(--rc-rgb, 196, 160, 255), 0.6);
    z-index: 3;
    animation: markerPulse 0.3s ease 3;
  }
  .case-screen .rl-strip.rl-done .rl-tile:not(.rl-hit) {
    opacity: 0.35;
    filter: saturate(0.4);
    transition: opacity 0.3s ease, filter 0.3s ease;
  }
  .case-screen .roulette:has(.rl-strip.rl-done) .rl-marker {
    animation: markerPulse 0.3s ease 3;
  }
  @keyframes markerPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.6); }
  }
}

/* Масс-рулетка в языке одиночной: арт, имя, цена; stride в JS = 102. */
  .case-screen .mrl { height: 88px; border-radius: 12px; }
  .case-screen .mrl-tile {
    flex: 0 0 96px;
    height: 76px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px;
    border-radius: 10px;
    transition: border-color 0.45s ease, box-shadow 0.45s ease;
  }
  .case-screen img.mrl-img { width: 36px; height: 36px; border-radius: 8px; }
  .case-screen span.mrl-img { font-size: 24px; }
  .case-screen .mrl-name {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
  .case-screen .mrl-val { font-size: 10px; }
/* Кнопка-ссылка в шитах (Stars-инвойс в браузере): у <a> убрать подчёркнутость кнопки. */
a.btn { text-decoration: none; }


/* ============================================================
   Mines — одиночная игра: сетка 5×5, панель управления, честность.
   Десктоп (≥768, media внутри базового блока): панель справа от
   поля (340px) и шкала множителей у поля. Мобильная колонка —
   в блоке @media (max-width: 767.98px) в самом конце файла.
   Существующие селекторы не переопределяются.
   ============================================================ */

/* Хаб: карточки игр столбиком (на десктопе — рядом, см. media ниже). */
.games-hub { display: grid; gap: 14px; }

/* Карточка Mines: тёмная container-поверхность с тихим tonal-свечением первичным — тише, чем арена. */
.mines-hero {
  background:
    radial-gradient(130% 100% at 82% 6%, color-mix(in srgb, var(--md-primary) 26%, transparent), color-mix(in srgb, var(--md-primary) 8%, transparent) 48%, color-mix(in srgb, var(--md-primary) 0%, transparent) 72%),
    var(--md-surface-container);
  color: var(--md-on-surface);
  box-shadow: inset 0 0 0 1px var(--md-outline-variant);
}
.mines-hero .hero-title { right: 16px; } /* аватаров справа нет — подпись шире */

/* Каркас: поле с честностью и баннером, панель ниже (десктоп — справа).
   Баннер итога позиционируется внутри поля → .mines-field relative. */
.mines-root { margin: 6px 0 0; }
.mines-wrap { display: grid; gap: 12px; }
.mines-field { display: flex; gap: 12px; align-items: stretch; position: relative; }

/* Поле 5×5: квадратные плитки face-down. */
.mines-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.mine-tile {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; padding: 0;
  position: relative; overflow: hidden;
  border: 1px solid var(--md-outline-variant); border-radius: 12px;
  background: var(--md-surface-container-high);
  color: var(--text); font: inherit; cursor: pointer;
  /* Press/hover-отклик: transform ровно 120ms decel-standard (замер владельца:
     200ms давал «вязкое» нажатие), остальные свойства — прежний --dur-short. */
  transition: transform 120ms var(--ease-standard), border-color var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard);
}
/* M3 state layer (§1): hover 8% / pressed 12% on-surface, pressed scale .96. */
.mine-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--md-on-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}
.mine-tile:hover:not(:disabled)::after { opacity: 0.08; }
.mine-tile:active:not(:disabled) { transform: scale(0.96); }
.mine-tile:active:not(:disabled)::after { opacity: 0.12; }
.mine-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mine-tile:disabled { cursor: default; }
.mine-tile svg { width: 58%; height: 58%; display: block; pointer-events: none; position: relative; z-index: 1; }

/* Открытый гем: success-container, иконка on-success-container; ромб всплывает лёгким pop. */
.mine-tile.gem { background: var(--md-success-container); border-color: transparent; color: var(--md-on-success-container); }
.mine-tile.gem svg { animation: mines-pop 200ms ease-out; }
.mine-tile.gem.dim { opacity: 0.45; }

/* Мина: error-container / on-error-container; взорвавшаяся — хлопок. */
.mine-tile.mine { background: var(--md-error-container); border-color: transparent; color: var(--md-on-error-container); }
.mine-tile.mine svg { animation: mines-pop 200ms ease-out; }
.mine-tile.mine.boom { background: var(--md-error-container); box-shadow: 0 0 0 2px var(--md-error); }
.mine-tile.mine.boom svg { animation: mines-boom 280ms ease-out; }

@keyframes mines-pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes mines-boom {
  0% { transform: scale(0.4); }
  55% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Шкала множителей у поля: включается только на десктопе. */
.mines-ladder { display: none; }

/* Панель управления/итога: M3 container-поверхность без бордера (§4).
   Строка-заголовок «Mines» из панели убрана: игра названа в шапке экрана,
   часы истории — справа в той же шапке (правило .mines-title срезано вместе
   с разметкой, экран игры подогнан по высоте и каждая строка на счету). */
.mines-panel {
  background: var(--md-surface-container);
  border: 0;
  border-radius: var(--shape-lg);
  padding: 16px 14px;
}
.mines-label { display: block; margin: 12px 2px 7px; font-size: 12.5px; font-weight: 600; color: var(--secondary); }
.mines-input {
  width: 100%; height: 48px; padding: 0 14px;
  /* Outlined field (§4): border outline, radius 8, focus 2px primary без сдвига раскладки. */
  border: 1px solid var(--md-outline); border-radius: var(--shape-sm);
  background: transparent; color: var(--text);
  font: inherit; font-size: 18px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}
.mines-input:focus { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }
.mines-input::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
/* Чипы сумм/мин — M3 segmented buttons (§4): группа h40, border outline-variant,
   radius full, разделители между сегментами, выбранной сегмент secondary-container. */
.mines-chips {
  display: flex;
  gap: 0;
  margin: 8px 0 0;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-full);
  overflow: hidden;
}
.mines-chip {
  flex: 1 1 0; min-width: 0; height: 38px; padding: 0 4px;
  border: 0; border-right: 1px solid var(--md-outline-variant);
  border-radius: 0;
  background: transparent; color: var(--md-on-surface);
  font: inherit; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
  -webkit-user-select: none; user-select: none;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.mines-chip:last-child { border-right: 0; }
.mines-chip:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.mines-chip.sel { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.mines-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mines-hint { margin: 8px 2px 0; font-size: 12px; color: var(--secondary); }
.mines-err { margin: 10px 2px 0; font-size: 13px; font-weight: 600; color: var(--danger); }
.mines-go, .mines-cash { width: 100%; min-height: 48px; margin-top: 14px; }
.mines-mult { margin: 4px 2px 0; font-size: 14px; color: var(--secondary); }
.mines-mult b { color: var(--violet2); font-size: 18px; font-weight: 700; }
.mines-pot { margin: 10px 2px 0; font-size: 14px; color: var(--secondary); }
.mines-pot b { display: block; margin-top: 3px; font-size: 21px; font-weight: 700; color: var(--text); }

/* Баннер результата и строка честности под полем. */
.mines-banner { border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 700; text-align: center; }
.mines-banner.win { background: color-mix(in srgb, var(--md-success) 12%, transparent); color: var(--success); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-success) 35%, transparent); }
.mines-banner.lose { background: color-mix(in srgb, var(--md-error) 10%, transparent); color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-error) 35%, transparent); }
.mines-fair { margin: 2px 2px 0; font-size: 12px; color: var(--secondary); word-break: break-all; }

/* ---- Десктоп ≥768: панель управления справа 340px, шкала у поля ---- */
@media (min-width: 768px) {
  .games-hub { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
  .games-hub::after { grid-column: 1 / -1; }

  #app > .screen > #minesRoot { max-width: 1080px; margin: 0 auto; }
  /* Баннер итога живёт внутри поля (тостом), своей строкой сетки он больше не владеет. */
  .mines-wrap {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas:
      "field panel"
      "fair panel";
    align-items: start;
    gap: 14px 22px;
  }
  .mines-field { grid-area: field; max-width: 660px; }
  .mines-fair { grid-area: fair; max-width: 660px; }
  .mines-panel { grid-area: panel; }

  .mines-grid { gap: 10px; }
  .mines-ladder {
    display: flex; flex-direction: column; flex: 0 0 92px; width: 92px;
    align-self: stretch; overflow-y: auto; padding: 6px 0;
    background: var(--surface);
    border: 1px solid var(--md-outline-variant); border-radius: 12px;
    scrollbar-width: thin;
  }
  .ml-step {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    margin: 1px 6px; padding: 2px 10px; border-radius: 8px;
    font-size: 11px; color: var(--secondary);
  }
  .ml-step span { opacity: 0.55; }
  .ml-step b { font-weight: 700; font-variant-numeric: tabular-nums; }
  .ml-step.past { opacity: 0.45; }
  .ml-step.cur { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
  .ml-step.cur b { color: var(--violet2); font-weight: 700; }
}

/* ============================================================
   Mines — мобильная вёрстка (<768): колонкой, плитки 52px,
   тапы ≥44px, шкала множителей скрыта (текущий ×N — в панели).
   ============================================================ */
@media (max-width: 767.98px) {
  .games-hub { gap: 12px; }
  .mines-grid { grid-template-columns: repeat(5, 52px); justify-content: center; gap: 6px; }
  .mine-tile { border-radius: 11px; }
  .mines-ladder { display: none; }
  .mines-panel { padding: 14px 12px; }
  .mines-chip { min-height: 44px; }
}


/* ============================================================
   Mines — доводка после смоука. Перебивка собственных правил из
   базового Mines-блока: та же специфичность, ниже по файлу —
   выигрывает каскадом. Мобильные правила не затрагиваются
   (шкала <768px скрыта, .mines-ladder { display: none } в силе).
   ============================================================ */

/* Десктоп ≥768: шагам шкалы место под пятизначные множители — «×2230,99»
   (3 мины / 22 гема) и крупнее. Колонка шире, значения nowrap,
   фикс. ширина числа справа с табличными цифрами. */
@media (min-width: 768px) {
  .mines-ladder { flex-basis: 116px; width: 116px; }
  .ml-step {
    justify-content: space-between;
    gap: 6px;
    padding: 2px 8px;
    margin: 1px 5px;
    white-space: nowrap;
  }
  .ml-step b {
    min-width: 62px;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
}


/* ============================================================
   UnderLuck — история игр: экран списка, шит деталей партии,
   реплей раунда. Только аппенд: существующие правила (минесы,
   арена, шиты, .mines-grid/.mines-banner) не переопределяются.
   Колонка экрана центрируется по образцу арены (max-width 720px,
   margin auto) прямо в базе — отдельного desktop-блока нет.
   ============================================================ */

/* .hist-hub-btn упразднён: вход в историю — только кнопкой внутри игры. */

/* Управление списком: сегменты, сортировки, поиск, лист — колонка ≤720px. */
.hist-tabs, .hist-gtabs, .hist-sorts, .hist-search, .hist-list, .hist-empty {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.hist-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.hist-tabs > button {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px;
  background: var(--surface2); color: var(--secondary);
  font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.hist-tabs > button:hover { color: var(--text); }
.hist-tabs > button.sel { background: var(--accent-fill); color: var(--md-on-primary); }

.hist-gtabs { display: flex; gap: 6px; margin-bottom: 10px; }
.hist-gtabs > button {
  flex: 1 1 0; min-width: 0; min-height: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px;
  background: var(--surface2); color: var(--secondary);
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.hist-gtabs > button:hover { color: var(--text); }
.hist-gtabs > button.sel { background: var(--accent-fill); color: var(--md-on-primary); }

.hist-sorts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.hist-sort {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 32px; padding: 0 12px;
  border: 0; border-radius: var(--radius-pill);
  background: var(--surface2); color: var(--secondary);
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), color var(--dur-short) var(--ease-standard);
}
.hist-sort:hover { color: var(--text); }
.hist-sort.sel { background: color-mix(in srgb, var(--md-primary) 14%, transparent); color: var(--accent); }

.hist-search {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--md-outline); border-radius: var(--shape-sm);
  background: transparent; color: var(--text);
  font: inherit; font-size: 15px;
}
.hist-search::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
.hist-search:focus { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }

.hist-list { display: flex; flex-direction: column; gap: 12px; }
.hist-empty { padding: 40px 0; text-align: center; font-size: 14px; color: var(--secondary); }

/* Карточка партии — M3 list-row панель: container-тон, radius 16 (§4). */
.hist-card {
  padding: 14px;
  border: 0;
  border-radius: var(--shape-lg);
  background: var(--md-surface-container);
  transition: background var(--dur-short) var(--ease-standard);
}
.hist-card:hover { background: var(--md-surface-container-high); }

.hist-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.hist-mult {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--md-primary) 14%, transparent); color: var(--accent);
  font-size: 13px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hist-mult.zero { background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); color: var(--secondary); }
.hist-id {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

.hist-winner { display: flex; align-items: center; gap: 12px; }
.hw-ava {
  flex: none; width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); color: var(--secondary);
  font-size: 15px; font-weight: 600;
}
.hw-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hw-ava svg { width: 22px; height: 22px; }
.hw-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hw-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-date, .hw-chance { font-size: 12px; color: var(--secondary); }
.hw-win {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: 16px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hw-win svg { width: 15px; height: 15px; flex: none; }

.hist-actions { display: flex; gap: 10px; margin-top: 12px; }
.hist-btn-replay {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--md-outline-variant); border-radius: 12px;
  background: var(--surface2); color: var(--text);
  font-size: 13px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), border-color var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard);
}
.hist-btn-replay:hover { background: var(--md-surface-container-highest); border-color: var(--md-outline); }
.hist-btn-replay:active { transform: scale(0.97); }
.hist-btn-legit {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 0; border-radius: var(--shape-full);
  background: var(--md-primary); color: var(--md-on-primary);
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard);
}
.hist-btn-legit:hover { background: var(--accent-fill-hover); }
.hist-btn-legit:active { background: var(--accent-fill-press); transform: scale(0.97); }
.hist-actions svg { width: 16px; height: 16px; flex: none; }

/* ---- Шит деталей партии. ---- */
.hgd-date { margin: 0 2px 12px; font-size: 13px; color: var(--secondary); }
.hgd-pills { display: flex; gap: 8px; margin: 0 2px 12px; }
.hgd-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 0; padding: 6px 10px;
  border-radius: 10px;
  background: var(--md-outline-variant);
  color: var(--secondary);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hgd-copy {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 8px; background: none;
  color: var(--secondary); cursor: pointer;
}
.hgd-copy svg { width: 14px; height: 14px; display: block; }
.hgd-copy:hover { color: var(--text); }
.hgd-copy:active { color: var(--accent); transform: scale(0.92); }

.hgd-rows { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.hgd-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent; border-radius: 14px;
  background: var(--surface2); color: var(--text);
}
/* Победитель: зелёный тинт от .mines-banner.win; своя строка — акцентный бордер. */
.hgd-row.winner { border-color: color-mix(in srgb, var(--md-success) 40%, transparent); background: color-mix(in srgb, var(--md-success) 8%, transparent); }
.hgd-row.me { border-color: color-mix(in srgb, var(--md-primary-text) 35%, transparent); }
.hgd-ava {
  flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--md-on-surface) 6%, transparent); color: var(--secondary);
  font-size: 13px; font-weight: 600;
}
.hgd-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hgd-ava svg { width: 20px; height: 20px; }
.hgd-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hgd-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hgd-sub { font-size: 12px; color: var(--secondary); }
.hgd-row.winner .hgd-name span,
.hgd-row.winner .hgd-name i,
.hgd-row.winner .hgd-name em,
.hgd-row.winner .hgd-name small {
  margin-left: 6px; font-size: 11px; font-weight: 700; font-style: normal; color: var(--success);
}
.hgd-win { flex: none; font-size: 15px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hgd-row.winner .hgd-win { color: var(--success); }
/* Модалка партии (референс владельца): главное число строки — СТАВКА игрока
   справа, выплата победителя — зелёный чип под ставкой; доля — серый процент
   под именем. Слово «Winner» из строки убрано: победителя даёт зелёный фон. */
.hgd-stake {
  flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  font-size: 15px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.hgd-prize { font-size: 12px; font-weight: 700; color: var(--success); }
.hgd-main > .muted { font-size: 12px; line-height: 16px; }

/* Key/value: ключ приглушён, значение справа контрастное; выигрыш зелёным, «Мина» красным. */
.hgd-kv {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--secondary);
}
.hgd-kv > *:last-child {
  color: var(--text); font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums;
}
.hgd-kv + .hgd-kv { margin-top: 6px; }
.hgd-kv .win, .hgd-kv.win > *:last-child { color: var(--success); }
.hgd-kv .lose, .hgd-kv.lose > *:last-child { color: var(--danger); }

/* Кнопка верификации честности: акцент → зелёная/красная по исходу. */
.hgd-legit {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; margin-top: 14px; padding: 0 24px;
  border: 0; border-radius: var(--shape-full);
  background: var(--md-primary); color: var(--md-on-primary);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: transform var(--dur-short) var(--ease-standard), background var(--dur-short) var(--ease-standard), opacity var(--dur-short) var(--ease-standard);
}
.hgd-legit:hover { background: var(--accent-fill-hover); }
.hgd-legit:active { background: var(--accent-fill-press); transform: scale(0.97); }
.hgd-legit.legit-wait { opacity: 0.7; }
.hgd-legit.legit-ok { background: var(--md-success-container); color: var(--md-on-success-container); cursor: default; transform: none; }
.hgd-legit.legit-bad { background: var(--md-error-container); color: var(--md-on-error-container); cursor: default; transform: none; }

/* ---- Реплей: тотал, полотно с зонами и шаром, сетка, баннер. ---- */
.hrp-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  max-width: 720px; margin: 10px auto 0;
  font-size: 14px; color: var(--secondary);
}
.hrp-total b, .hrp-total strong, .hrp-total > span:last-child {
  font-size: 18px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hrp-field {
  position: relative; width: 100%;
  max-width: 720px; margin: 12px auto;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--md-outline-variant);
  border-radius: 16px;
  background: var(--md-surface-container-lowest); /* полотно чуть темнее поверхности */
  overflow: hidden;
}
.hrp-zone { position: absolute; border: 1px solid var(--md-outline-variant); border-radius: 10px; }
/* Победитель — только outline-рамка, без glow (§7). */
.hrp-zone.winner { border: 2px solid var(--md-primary-text); box-shadow: none; }
/* Шар: без transition — позиции водит JS через rAF/по шагам. */
.hrp-ball {
  position: absolute; top: 0; left: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; z-index: 2;
  will-change: transform;
}
.hrp-ball svg, .hrp-ball img { width: 100%; height: 100%; display: block; }
.hrp-grid-wrap { max-width: 720px; margin: 12px auto 0; }
/* Сетка 5×5 переиспользует .mines-grid выше — здесь только центрирование и вписывание. */
.hrp-grid-wrap > .mines-grid { flex: none; width: min(100%, 440px); margin: 0 auto; }
.hrp-banner { max-width: 720px; margin: 12px auto 0; }

/* ============================================================
   История/шит/реплей — мобильные отличия (<768): компактнее
   карточки, тапы 44px у действий, пилюли переносятся, реплей
   повыше. Минес-плитки и панель уже настроены выше — не тронуты.
   ============================================================ */
@media (max-width: 767.98px) {
  .hist-card { padding: 12px; }
  .hist-btn-replay, .hist-btn-legit { min-height: 44px; }
  .hgd-pills { flex-wrap: wrap; }
  .hrp-field { aspect-ratio: 4 / 3; }
}

/* ============================================================
   Живые экраны игр: ряд «Повтор / Legit check» для только что
   закончившейся партии (арена — под списком игроков, mines —
   под seed в панели). Кнопки — существующие .btn, легит растёт.
   ============================================================ */
.hist-quick {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.hist-quick .btn {
  flex: 0 0 auto;
  min-height: 40px;
}
.hist-quick .btn-primary { flex: 1; }

/* Реплей арены настоящим рендером: пропорции/фон/радиус как у
   живого поля (.arena-field-zoom), svg-полотно растягивается как
   .arena-field svg; шар позиционируется .arena-ball от relative. */
.hrp-field.arena-like {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 0;
}
.hrp-field.arena-like > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 767.98px) {
  .hist-quick .btn { min-height: 44px; }
  .hrp-field.arena-like { aspect-ratio: 4 / 3; }
}

/* ============================================================
   Реплей-шит обязан влезать в любой вьюпорт: квадрат поля
   ограничен по высоте (46dvh / 40dvh на мобиле), ширина ужмается
   от лимита высоты — width:auto у блока растягивается, а не
   ужимается, поэтому сторона считается как min(100%, лимит).
   vh-фолбэк перед dvh — тот же приём, что у .sheet.
   ============================================================ */
.hrp-field.arena-like {
  max-height: 46vh;
  width: min(100%, 46vh);
  max-height: 46dvh;
  width: min(100%, 46dvh);
  max-width: 100%;
  margin: 0 auto;
}
/* Гарантия скролла, если контент шита всё же выше лимита: жест не уходит
   в страницу за шитом. */
.sheet.hrp-sheet { overscroll-behavior: contain; }

@media (max-width: 767.98px) {
  .hrp-field.arena-like {
    max-height: 40vh;
    width: min(100%, calc(40vh * 4 / 3));
    max-height: 40dvh;
    width: min(100%, calc(40dvh * 4 / 3));
  }
}

/* Мини-апп: поле реплея арены — квадрат 1:1 (SVG-контент 100×100, любой
   другой аспект растягивает зоны в эллипсы) и вписано в высоту экрана. */
@media (max-width: 767.98px) {
  .hrp-field.arena-like {
    aspect-ratio: 1 / 1;
    width: min(100%, 46vh);
    width: min(100%, 46dvh);
    margin: 0 auto;
  }
}
/* Кнопка догрузки страницы истории — по центру под списком. */
.hist-more-wrap { display: flex; justify-content: center; margin: 14px 0 6px; }

/* Поле реплея на мобиле: снять старый потолок 40dvh — при 1:1 высота
   следует из ширины, потолок лишь ломает квадрат (получался прямоугольник). */
@media (max-width: 767.98px) {
  .hrp-field.arena-like { max-height: none; }
}

/* ============================================================
   Реплей — полноэкранный слой по референсу: шапка с заголовком,
   Total, большое поле, секция Players · N крупными карточками,
   Hash-пилюля по центру, большая «Закрыть» внизу. Десктоп —
   центрированная карточка ≤560px, мобилка — вся высота экрана.
   ============================================================ */
.hrp-layer { align-items: stretch; }
/* Полноэкранный реплей: surface-dim фон, без glow; тень — только плавающему
   десктопному окну (elevation lvl3, §3). */
.hrp-box {
  width: 100%; max-width: 560px;
  height: 100vh; height: 100dvh;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--md-surface-dim); color: var(--text);
}
@media (min-width: 768px) {
  .hrp-box { height: auto; max-height: 92vh; max-height: 92dvh; margin: auto; border-radius: var(--shape-xl); box-shadow: var(--md-elevation-3); }
}
.hrp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.hrp-title { margin: 0; font-size: 24px; font-weight: 400; line-height: 32px; }
.hrp-box .hrp-total { max-width: none; margin: 0; flex: none; }
/* Поле — сторона по высоте экрана (54dvh), квадрат 1:1; специфичность
   перекрывает прежние sheet-лимиты 46/40dvh. */
.hrp-box .hrp-field.arena-like {
  aspect-ratio: 1 / 1;
  flex: none;
  max-height: none;
  width: min(100%, 54vh);
  width: min(100%, 54dvh);
  max-width: 100%;
  margin: 0 auto;
}
.hrp-box .hrp-grid-wrap { flex: none; }
.hrp-box .hrp-head, .hrp-box .hrp-players-top, .hrp-box .hrp-hash { flex: none; }
.hrp-players { display: flex; flex-direction: column; gap: 10px; }
.hrp-players-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: 4px;
}
.hrp-players-top b { font-size: 18px; font-weight: 700; }
.hrp-prow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid transparent;
  background: var(--surface2); color: var(--text);
}
.hrp-prow.winner { border-color: color-mix(in srgb, var(--md-success) 40%, transparent); background: color-mix(in srgb, var(--md-success) 8%, transparent); }
.hrp-prow .hgd-ava { width: 44px; height: 44px; font-size: 15px; }
.hrp-prow .hgd-name { font-size: 16px; font-weight: 700; }
.hrp-prow .hgd-sub { font-size: 13px; }
.hrp-prow .hgd-win { font-size: 17px; font-weight: 700; }
.hrp-win-tag { color: var(--success); font-weight: 700; }
.hrp-hash { display: flex; justify-content: center; }
.hrp-close { width: 100%; margin-top: auto; flex: none; }

/* История на мобиле — компактнее: сорты одной строкой с горизонтальным
   скроллом (без переноса в две строки), тапы плотнее, Chance акцентом. */
@media (max-width: 767.98px) {
  .hist-tabs > button { min-height: 40px; }
  .hist-gtabs > button { min-height: 32px; }
  .hist-sorts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
  .hist-sorts::-webkit-scrollbar { display: none; }
  .hist-sort { flex: none; min-height: 30px; }
  .hist-search { height: 40px; font-size: 14px; }
  .hist-list { gap: 10px; }
  .hist-card .hw-chance.muted { color: var(--accent); }
}

/* ============================================================
   Поиск истории — нормальный дизайн: тёмная капсула, лупа слева,
   прозрачный инпут внутри. Прежние правила легли на div-обёртку,
   а сам input остался нативным серым прямоугольником — перекрываем.
   ============================================================ */
.hist-search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--md-outline); border-radius: var(--shape-sm);
  background: transparent;
}
.hist-search:focus-within { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); }
.hist-search .hs-ico { flex: none; display: inline-flex; color: var(--md-on-surface-variant); }
.hist-search .hs-ico svg { width: 18px; height: 18px; display: block; }
#histSearch {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; padding: 0;
}
#histSearch::placeholder { color: var(--md-on-surface-variant); opacity: 0.6; }
@media (max-width: 767.98px) {
  .hist-search { height: 40px; }
  #histSearch { font-size: 14px; }
}

/* === Входы на сайт (лист сессий) === */
.profile-sessions { display: block; margin: 6px auto 2px; }
.sess-note { margin: 2px 0 10px; font-size: 12.5px; line-height: 1.45; }
.sess-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  /* M3 list row (§4): min-h 56, divider outline-variant. */
  min-height: 56px;
  padding: 10px 2px; border-top: 1px solid var(--md-outline-variant);
}
.sess-row:first-child { border-top: 0; }
.sess-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sess-dev { font-weight: 500; font-size: 16px; line-height: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-cur { color: var(--md-success); font-size: 11px; font-weight: 600; margin-left: 6px; }
.sess-seen { font-size: 12px; color: var(--md-on-surface-variant); }
.sess-kick { flex: none; padding: 7px 12px; font-size: 13px; }
.sess-foot { margin-top: 12px; }
.sess-foot .btn { width: 100%; }
.sess-empty { padding: 14px 2px; font-size: 13px; }

/* ============================================================
   FAZE A — Material Design 3: хром-слой (аппенд по правилу
   DESIGN.md «новые правила — аппендом»). Классы не переименованы,
   layout-правила не удалены; здесь только state layers, формы
   и доводка типографики поверх перевода токенов выше.
   ============================================================ */

/* --- Слои состояния (§1): hover 8% / pressed 12% on-цветом, opacity 100ms. ---
   currentColor у кнопок — это on-цвет (on-primary / on-secondary-container…),
   поэтому заливка слоя точна для filled/tonal/outlined/text вариантов. */
.btn::after,
.icon-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}

.btn:hover:not(:disabled)::after { opacity: 0.08; }
.btn:active:not(:disabled)::after { opacity: 0.12; }
.btn:disabled::after { opacity: 0; }

.icon-btn { position: relative; overflow: hidden; }
.icon-btn:hover::after { opacity: 0.08; }
.icon-btn:active::after { opacity: 0.12; }

/* Игровая hero-карточка: state layer + мягкий lift (без glow-тени, §7). */
.game-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--md-on-primary-container);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}
.game-hero:hover::after { opacity: 0.08; }
.game-hero:active::after { opacity: 0.12; }
.game-hero:hover { transform: translateY(-2px); box-shadow: var(--md-elevation-1); }

/* --- Чипы в модалках: тот же filter-chip, визуал = вся ячейка (там ряд 34px). --- */
.up-chips-row .chip {
  min-height: 34px;
  padding: 0 13px;
  font-size: 13px;
  background: transparent;
  border-color: transparent;
}
.up-chips-row .chip::before {
  inset: 0;
  background: var(--md-surface-container-highest);
  border-color: var(--md-outline-variant);
}
.up-chips-row .chip:hover::before { background: var(--md-surface-container-highest); }
.up-chips-row .chip.active { background: transparent; color: var(--md-on-secondary-container); }
.up-chips-row .chip.active::before { background: var(--md-secondary-container); border-color: transparent; }

/* --- Кнопочные/табовые пилюли: pill-система (кнопки M3 = full radius). --- */
.btn-sell,
.up-go,
.hist-btn-replay,
.hgd-copy { border-radius: var(--shape-full); }
.cnt,
.up-qchip { border-radius: var(--shape-full); }
.hist-tabs > button,
.hist-gtabs > button { border-radius: var(--shape-full); }
.hist-sort { border: 1px solid var(--md-outline-variant); background: transparent; border-radius: var(--shape-full); font-weight: 500; }
.hist-sort:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); color: var(--md-on-surface); }
.hist-sort.sel { background: var(--md-secondary-container); border-color: transparent; color: var(--md-on-secondary-container); }

/* --- Пилюли значений (hist/hgd): чип-стиль §4 — radius 8, outline-variant. --- */
.hist-mult { border-radius: var(--shape-sm); border: 1px solid var(--md-outline-variant); background: transparent; color: var(--md-primary-text); font-weight: 500; }
.hist-mult.zero { color: var(--md-on-surface-variant); }
.hgd-pill { border-radius: var(--shape-sm); border: 1px solid var(--md-outline-variant); background: transparent; color: var(--md-on-surface-variant); font-weight: 500; }
.hgd-row { border-radius: var(--shape-md); }
.hrp-prow { border-radius: var(--shape-md); }

/* --- Sticky-CTA листа: фон обязан совпадать с поверхностью шита (container-high). --- */
.dep-cta { background: var(--md-surface-container-high); }

/* --- Списки (§4): title-m для названий строк, supporting — on-surface-variant. --- */
.hw-name { font-size: 16px; font-weight: 500; line-height: 24px; }
.up-pick-rname { font-size: 16px; font-weight: 500; line-height: 24px; }
.inv-name { font-size: 16px; font-weight: 500; line-height: 24px; }
.tx-name { font-size: 16px; font-weight: 500; line-height: 24px; }
.hgd-name { font-size: 16px; font-weight: 500; line-height: 24px; }
.rarity-line, .tx-date, .hgd-sub, .hw-date, .hw-chance, .up-pick-sub, .ip-val, .t-val, .rw-val, .mw-val, .rl-val, .inv-val, .stat-label { color: var(--md-on-surface-variant); }

/* --- Табличные цифры (§2): балансы, суммы ставок, цены, счётчики. --- */
.js-balance,
.big-balance,
.profile-bigbal,
.up-bal-val,
.up-bal-edit,
.up-picker-sum,
.case-price,
.cnt,
.up-qchip,
.mines-pot b,
.mines-mult b,
.arena-bank b,
.ap-stake,
.ap-share,
.aw-stake,
.aw-share,
.stat-val,
.earn-pay,
.bw-val,
.dep-wallet,
.wallet-addr { font-variant-numeric: tabular-nums; }

/* --- Текст-кнопки: link = primary label (M3 text button). --- */
.link-btn { color: var(--md-primary-text); }
.link-btn:hover { color: var(--md-primary-text); text-decoration: underline; }
.profile-legal .link-btn { color: var(--md-on-surface-variant); }
.profile-legal .link-btn:hover { color: var(--md-on-surface); }
.sess-kick { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--shape-full); }

/* --- Поля-обёртки с фокус-кольцом: outlined-механика как у инпутов (§4). --- */
.dep-hero:focus-within { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); outline: none; }

/* --- Десктоп: те же pill-радиусы кнопок (layout не меняем, только форму зализываем). --- */
@media (min-width: 768px) {
  .up-screen .up-go { border-radius: var(--shape-full); }
  .up-screen .up-qchip { border-radius: var(--shape-full); }
  .case-screen .cnt { border-radius: var(--shape-full); }
  .cards .card { border-radius: var(--shape-lg); }
}

/* --- Reduced motion: state layer-переходы и lift тоже гасятся (§5). --- */
@media (prefers-reduced-motion: reduce) {
  .game-hero:hover { transform: none; box-shadow: none; }
  .btn::after,
  .icon-btn::after,
  .game-hero::after { transition: none; }
}

/* Доводка FAZE A: danger-текст выхода не должен тонуть под text-button-правилом выше. */
.profile-logout { color: var(--md-error); }
/* Toast на inverse-surface: внутренние подписи наследуют тёмный текст, а не light-muted. */
.toast .muted { color: inherit; opacity: 0.75; }


/* ============================================================
   FAZE B — игровые экраны (кейсы, арена, mines, история/реплеи).
   Аппенд поверх перевода токенов: state layers, формы, доводка
   типографики. Существующие селекторы не переименованы, layout
   не удалён; новые классы (.ap-ava, .hist-head, .hist-title,
   .hist-close) добавлены. Mobile-first: десктоп — в media ниже.
   ============================================================ */

/* --- Кейсы: карточка = surface-container со state layer + lift,
   как у .game-hero (§1/§4). Обложка-арт (градиенты --cf/--ct) не
   перекрашивается; футер внутри карточки: name title-m, drops, цена-чип. --- */
.case-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--md-on-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}
.case-card:hover::after { opacity: 0.08; }
.case-card:active::after { opacity: 0.12; }
/* Ряд редкостей живёт внутри футера карточки (markup: drops перенесён в .case-foot). */
.case-foot .case-drops { order: 2; flex: 0 1 auto; min-width: 0; }
.case-foot .case-name { order: 1; }
.case-foot .case-price { order: 3; }

/* --- Чипы-фильтры кейсов: selected уже secondary-container (§4).
   Проверка — .chip.active::before задаёт тон выше. --- */

/* --- Арена: список игроков — M3 list rows (§4). Аватар 40 radius full
   с цветным кольцом зоны; имя title-m; ставка supporting body-m.
   .ap-dot убран из разметки, правило оставлено без использования. --- */
.ap-ava .avatar-img, .ap-ava .avatar-fallback { width: 100%; height: 100%; }
.ap-ava .avatar-fallback { background: transparent; color: inherit; font-weight: 600; }

/* --- История игр: шапка экрана — заголовок title-l слева, кнопка закрытия
   (.icon-btn) справа; на десктопе ряд центрируется в колонку 720px, чтобы
   заголовок не прижимался вправо. .hist-title перебивает тон-чип .arena-bank. --- */
.hist-head { align-items: center; }
.hist-title {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: var(--md-on-surface);
  font-size: 22px;
  font-weight: 500;
  line-height: 28px;
}
@media (min-width: 768px) {
  .hist-root .arena-head, .hist-root > .arena-head { max-width: 720px; margin-left: auto; margin-right: auto; }
}
/* Результат партии: win — success-container чип, loss — нейтральный (§4). */
.hist-mult {
  background: var(--md-success-container);
  border-color: transparent;
  color: var(--md-on-success-container);
  font-weight: 500;
}
.hist-mult.zero { background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }
/* Строки деталей/реплея — container-тон + radius 16. */
.hgd-row, .hrp-prow { background: var(--md-surface-container); border-radius: var(--shape-lg); }

/* --- Mines: часы истории — в шапке экрана, напротив выхода (указание владельца).
   Заголовок .mines-title из панели срезан вместе с разметкой. --- */
.arena-head .mines-hist { margin-left: auto; }

/* --- История/реплей: карточки/панели → container-тон + radius 16/28,
   тень elevation lvl3 только у плавающих слоёв (§3). --- */
.hrp-box .hgd-pills, .hrp-box .hgd-rows { max-width: none; }
/* Победитель в деталях/реплее — on-success-container тон, не glow. */
.hgd-row.winner { background: var(--md-success-container); border-color: transparent; }
.hgd-row.winner .hgd-win { color: var(--md-on-success-container); }
.hrp-prow.winner { background: var(--md-success-container); border-color: transparent; }
.hrp-prow.winner .hgd-win { color: var(--md-on-success-container); }

/* --- Открытие кейса: панель результата = M3 dialog (radius 28,
   surface-container-high, elevation lvl3). Кнопка «Продолжить/Готово»
   — filled pill. Механику спина не трогаем: только контейнеры/кнопки. --- */
.modal-box:has(> .win-name) .modal-actions .btn-primary { border-radius: var(--shape-full); }

/* --- Десктоп ≥768: двухколоночные игровые сетки уже в базовых media-блоках
   выше; здесь только доводим state-layer lift карточек кейсов. --- */
@media (min-width: 768px) {
  .case-card:hover { transform: translateY(-3px); box-shadow: var(--md-elevation-2); }
}

/* --- Reduced motion (§5): lift/state-layer карточек гасятся. --- */
@media (prefers-reduced-motion: reduce) {
  .case-card:hover { transform: none; box-shadow: none; }
  .case-card::after { transition: none; }
  .mine-tile::after { transition: none; }
}


/* ============================================================
   FAZE D — профиль, входы, экран входа, earn/upgrades, ≥1024.
   Аппендом поверх FAZE A/B (правило DESIGN.md): классы не
   переименованы, layout-правила не удалены; добавлены только
   новые хуки (.profile-list, .list-row, .text-btn, .ref-field,
   .sess-head-act, .stat-money). Разметка: «Выйти» уехало из
   карточки в шапку, «отозвать все» — в шапку листа сессий.
   Mobile-first: всё десктопное — внутри media-блоков ниже.
   ============================================================ */

/* --- Кейсы (доводка Задачи 0): обложка сверху с верхним скруглением,
   ряд редкостей — иконки 16px, чтобы чип цены влезал рядом. --- */
.case-cover { border-radius: var(--shape-lg) var(--shape-lg) 0 0; }
.case-drops { gap: 4px; }
.case-drops img.drop-img,
.case-drops span.drop-img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 16px;
}
.case-drops span.drop-img.art-bal { width: 16px; height: 16px; font-size: 10px; }

/* --- Профиль: «Выйти» = icon-button справа вверху шапки (§8: выход сверху).
   Снимаем прежнюю геометрию текстовой ссылки (display:block, margin auto,
   ≥768 width:100%/max-width:360) — специфичность бьёт оба старых блока. --- */
.profile-page .profile-head .profile-logout {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  max-width: none;
  margin: 0;
  padding: 0;
  text-align: center;
  color: var(--md-error);
  border-radius: var(--shape-full);
}

.profile-page .profile-head .profile-logout:hover,
.profile-page .profile-head .profile-logout:active { text-decoration: none; }
.profile-page .profile-head .profile-logout svg { width: 22px; height: 22px; }

/* --- M3 list rows (§4): min-h 56, leading-иконка 24, label title-m,
   divider outline-variant между строками, тап-таргет 56. --- */
.profile-list { display: flex; flex-direction: column; margin: 6px -4px 0; }

.profile-list .list-row {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 56px;
  margin: 0;
  padding: 0 8px;
  text-align: left;
  border-radius: var(--shape-sm);
  color: var(--md-on-surface);
}

.profile-list .list-row + .list-row { border-top: 1px solid var(--md-outline-variant); }

.profile-list .list-row::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--md-on-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}

.profile-list .list-row:hover::after { opacity: 0.08; }
.profile-list .list-row:active { transform: scale(0.99); }
.profile-list .list-row:active::after { opacity: 0.12; }
.profile-list .lr-ic { flex: none; display: inline-flex; width: 24px; height: 24px; color: var(--md-on-surface-variant); }
.profile-list .lr-ic svg { display: block; width: 24px; height: 24px; }
.profile-list .lr-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: 0.1px;
}

/* --- Легал-строка: label-m on-surface-variant, разделитель «·», перенос. --- */
.profile-legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 0; margin: 18px auto 6px; }
.profile-legal .link-btn {
  min-height: 44px;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--md-on-surface-variant);
}

.profile-legal .link-btn:hover { color: var(--md-on-surface); text-decoration: underline; }
.profile-legal .link-btn + .link-btn::before {
  content: '·';
  margin: 0 8px;
  color: var(--md-outline);
  font-weight: 400;
}

/* --- Прогресс уровня: подпись label-m, имена перехода title-m (не 700). --- */
.lvl-remain { font-size: 12px; font-weight: 500; line-height: 16px; }
.lvl-names,
.lvl-from { font-weight: 500; }

/* --- Лист входов: заголовок headline-s, действия справа вверху (§8). --- */
.sess-head { align-items: center; flex-wrap: wrap; row-gap: 4px; }
.sess-head .sheet-title { flex: 1 1 auto; min-width: 0; }
.sess-head-act { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }
#sessFoot:empty { display: none; }

/* M3 text button (§4): h40, pad 0 12, radius full, label-l primary-text. */
.text-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  background: transparent;
  border-radius: var(--shape-full);
  color: var(--md-primary-text);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
  transition: color var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard);
}

.text-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms var(--ease-standard);
}

.text-btn:hover::after { opacity: 0.08; }
.text-btn:active { transform: scale(0.97); }
.text-btn:active::after { opacity: 0.12; }
.text-btn[disabled] { opacity: 0.38; }

/* «Отозвать все» — отзыв сессий, значит error-текст кнопка. */
.text-btn.sess-all { color: var(--md-error); }

/* Строки входов: min-h 68 (две строки текста + pill h40), действие справа. */
.sess-row { min-height: 68px; gap: 12px; padding: 12px 2px; }
.sess-seen { font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); }
.sess-kick {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

/* --- Экран входа: лого 700 с «Luck» акцентным текстом, filled pill h48 ≤320,
   код — outlined-карточка, статус/note по шкале M3. --- */
.boot-logo { font-weight: 700; }
.boot-logo span {
  background: none;
  -webkit-text-fill-color: var(--md-primary-text);
  color: var(--md-primary-text);
}

.login-actions { width: 100%; max-width: 320px; margin: 0 auto; }
.login-actions .btn { width: 100%; min-height: 48px; }
.login-status { font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); }
.login-note { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--md-on-surface-variant); }

.login-code {
  padding: 16px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-lg);
}

.login-code-val {
  font-family: inherit;
  font-size: 28px;
  font-weight: 400;
  line-height: 36px;
  letter-spacing: 1px;
  color: var(--md-on-surface);
  font-variant-numeric: tabular-nums;
}

.login-code-copy {
  min-height: 40px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: var(--shape-full);
  color: var(--md-primary-text);
  font-size: 14px;
  font-weight: 500;
  transition: color var(--dur-short) var(--ease-standard), transform var(--dur-short) var(--ease-standard);
}

.login-code-copy:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); border-color: transparent; }
.login-code-copy:active { background: color-mix(in srgb, var(--md-on-surface) 12%, transparent); transform: scale(0.97); }

/* --- Заработок: реферальная ссылка = readonly outlined field + кнопка-copy 44. --- */
.ref-field {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 4px 4px 4px 14px;
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: var(--shape-sm);
}

.ref-field:focus-within { border-color: var(--md-primary-text); box-shadow: 0 0 0 1px var(--md-primary-text); }
.ref-field .ref-link {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  max-width: none;
  text-align: left;
  background: none;
  border-radius: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--md-on-surface);
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.ref-field .ref-copy-ic { flex: none; }

/* Мини-карточки статистики: caption label-m сверху, значение title-l, деньги — tertiary. */
.stat-label { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--md-on-surface-variant); }
.stat-val { font-size: 22px; font-weight: 500; line-height: 28px; }
.stat-money .stat-val { color: var(--md-tertiary); }

/* «Сколько платим» и правила — list rows с divider outline-variant. */
.earn-tier-head { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--md-on-surface-variant); }
.earn-rate { margin-top: 0; padding: 10px 0; border-top: 1px solid var(--md-outline-variant); }
.earn-rate-name { font-size: 16px; font-weight: 500; line-height: 24px; }
.earn-rate-name b { font-weight: 500; }
.earn-pay { font-size: 14px; line-height: 20px; }
.earn-rules { gap: 0; }
.earn-rules li { padding: 10px 0 10px 18px; border-top: 1px solid var(--md-outline-variant); font-size: 14px; line-height: 20px; }
.earn-rules li::before { top: 17px; }

/* «Крутить»: filled pill h48 (форма уже в FAZE A/B), disabled = 38% (§4). */
.up-go:disabled { opacity: 0.38; }

/* --- Десктоп ≥1024 (DESIGN.md §6): колонка контента 1180, паддинг 24,
   профиль в две колонки (360 + остаток), snackbar cookie слева снизу. --- */
@media (min-width: 1024px) {
  #app > .screen {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 24px 64px;
  }
  /* Шапка в одну линию с контентной колонкой (1180 + паддинг 24). */
  #app > .topbar { padding-left: max(24px, calc(50vw - 566px)); padding-right: max(24px, calc(50vw - 566px)); }
  .case-screen.profile-page { max-width: 1180px; }

  /* Профиль: левая колонка — карточка игрока (баланс + прогресс + список),
     правая — инвентарь, история, статистика. */
  .profile-body {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    padding: 8px 0 32px;
  }
  .profile-body > .profile-card { grid-column: 1; grid-row: 1 / span 3; align-self: start; }
  #profileInv { grid-column: 2; grid-row: 1; }
  #profileTx { grid-column: 2; grid-row: 2; }
  #profileStats { grid-column: 2; grid-row: 3; }
  /* Grid-дети: minmax(0,1fr) трека само по себе не гарантирует сжатия —
     min-width:0 снимает min-content-распирание (nowrap-строки, hscroll). */
  .profile-body > * { min-width: 0; }
  /* Full-bleed горизонтальных рядов (margin-inline −14px) нужен мобильным
     экранам с паддингом 16px. В десктоп-колонке профиля он выносил .hscroll
     за карточку: у скроллящегося .profile-page появлялся горизонтальный
     скролл, ряд инвентаря «вылезал за край», правые колонки уезжали.
     Здесь ряды прижаты к карточке; внутренний скролл — только у .hscroll. */
  .profile-page .hscroll { margin-inline: 0; padding-inline: 0; -webkit-mask-image: none; mask-image: none; }
  /* Страховки: слой профиля не листается вбок (скроллбар снизу = этот блок),
     горизонтальный жест внутри hscroll не «протаскивает» страницу. */
  .case-screen.profile-page { overflow-x: hidden; overscroll-behavior-x: contain; }
  .profile-page .hscroll { overscroll-behavior-x: contain; }
  /* Пару кнопок баланса не тянем на всю колонку. */
  .profile-btns { max-width: 360px; margin: 14px auto 0; }

  /* Cookie-баннер: snackbar bottom-left (таббара снизу на десктопе нет). */
  .cookie-banner { left: 24px; bottom: 24px; width: min(520px, calc(100% - 48px)); }
}

/* --- Reduced motion (§5): новые state layer и lift гасятся вместе с остальными. --- */
@media (prefers-reduced-motion: reduce) {
  .profile-list .list-row::after,
  .text-btn::after,
  .login-code-copy,
  .case-card::after { transition: none !important; }
  .profile-list .list-row:active { transform: none; }
  .text-btn:active,
  .login-code-copy:active { transform: none; }
}

/* --- Доводка FAZE D (earn): карточка шанса — плашка 16; сумма hero не рвёт
   «за 1 000 000 просмотров» по цифрам — ряд переносится целиком. --- */
.chance-card { border-radius: var(--shape-lg); }
.earn-hero-pay { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 8px; }
.earn-hero-pay b,
.earn-hero-pay span { white-space: nowrap; }

/* ============================================================
   FAZE C — Motion (§5 DESIGN.md, паттерны transitions.dev).
   View Transitions, shared-element morph игры, M3 ripple,
   digit roll баланса, skeleton→content reveal, shake ошибок.
   JS-гаранты: vtRun/ripple/reveal/shake не срабатывают под
   prefers-reduced-motion; CSS-гашение ниже — страховка.
   ============================================================ */

:root {
  --dur-vt: 300ms;     /* fade-through и «децел-входы» новых паттернов */
  --dur-reveal: 250ms; /* скелетон → контент */
  --dur-ripple: 450ms; /* M3 ripple */
}

/* --- 1. View Transitions: screen-change fade-through ±6px, направление
       задают root-классы vt-fwd/vt-back (зеркало для screen-in-l). --- */

@keyframes ulVtOldFwd { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-6px); } }
@keyframes ulVtNewFwd { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ulVtOldBack { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(6px); } }
@keyframes ulVtNewBack { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

html.vt-fwd::view-transition-old(root) { animation: ulVtOldFwd var(--dur-vt) var(--ease-emphasized) both; }
html.vt-fwd::view-transition-new(root) { animation: ulVtNewFwd var(--dur-vt) var(--ease-emphasized) both; }
html.vt-back::view-transition-old(root) { animation: ulVtOldBack var(--dur-vt) var(--ease-emphasized) both; }
html.vt-back::view-transition-new(root) { animation: ulVtNewBack var(--dur-vt) var(--ease-emphasized) both; }

/* профиль-слой: вход ведёт сам слой (scrim+box), корень не дергаемся */
html.vt-layer::view-transition-old(root),
html.vt-layer::view-transition-new(root) { animation: none; }

/* --- 2. Shared-element morph: карточка игры «перетекает» в экран игры. --- */

::view-transition-group(game-hero) {
  animation-duration: var(--dur-medium);
  animation-timing-function: var(--ease-emphasized);
  z-index: 3;
}

/* --- 3. Ripple (M3): currentColor, scale 0→1, opacity .18→0. --- */

.ul-rip-host { position: relative; overflow: hidden; }

.ul-ripple {
  position: absolute;
  border-radius: var(--shape-full);
  background: currentColor;
  opacity: 0.18;
  transform: scale(0);
  pointer-events: none;
  animation: ulRipple var(--dur-ripple) ease-out forwards;
}

@keyframes ulRipple { to { transform: scale(1); opacity: 0; } }

/* --- 4. Digit roll баланса: новые цифры въезжают снизу с blur-кроссфейдом.
       Блок остаётся inline-block с tabular-nums — анимируется только вход. --- */

@keyframes balPopIn {
  from { opacity: 0; transform: translateY(40%); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

.js-balance.pop-in { animation: balPopIn var(--dur-vt) var(--ease-decel); }

/* --- 6. Скелетон → контент: одноразовый reveal контейнера, стаггер детей 30ms
       (максимум 6, дальше — общим фейдом контейнера). --- */

@keyframes ulRevealFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ulRevealRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.skel-reveal { animation: ulRevealFade var(--dur-reveal) var(--ease-decel) both; }

.skel-reveal > :nth-child(1) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; }
.skel-reveal > :nth-child(2) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; animation-delay: 30ms; }
.skel-reveal > :nth-child(3) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; animation-delay: 60ms; }
.skel-reveal > :nth-child(4) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; animation-delay: 90ms; }
.skel-reveal > :nth-child(5) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; animation-delay: 120ms; }
.skel-reveal > :nth-child(6) { animation: ulRevealRise var(--dur-reveal) var(--ease-decel) both; animation-delay: 150ms; }

/* --- 8. Shake: неверное действие (мало баланса / API-ошибка / код входа). --- */

@keyframes ulShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.ul-shake { animation: ulShake var(--dur-vt) var(--ease-standard); }

/* Mines-панель: кроссфейд контента при смене фазы (idle↔живая↔итог).
   Навешивание класса — в updateMinesPanel, только на смену фазы. */
@keyframes minesPanelIn { from { opacity: 0; } to { opacity: 1; } }

/* --- 10. Reduced motion: гашение новых паттернов и View Transitions
       (js-гарант основной, здесь — CSS-страховка). --- */

@media (prefers-reduced-motion: reduce) {
  .ul-ripple,
  .ul-shake,
  .js-balance.pop-in,
  .skel-reveal,
  .skel-reveal > *,
  #minesRoot #minesPanel.mines-panel-swap { animation: none !important; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.01ms !important; }
  ::view-transition-group(game-hero) { animation-duration: 0.01ms !important; }
}


/* ============================================================
   Mines во вьюпорте (указание владельца): экран игры целиком
   умещается по высоте, листать нечего.
   • Панель — две компактные строки: ставка+быстрые чипы и
     «мины»+кнопка запуска; живой ряд партии — одной строкой.
   • Мобильная колонка (<768) зафиксирована на 100dvh за вычетом
     шапки, отступов и таббара; поле 5×5 вписывается в МЕНЬШУЮ
     из сторон (контейнерные единицы), CTA стоит над таббаром.
   • Баннер итога — snackbar поверх плиток, строка честности —
     одна строка; на низких экранах (≤640) подписи и подсказки
     уходят, всё свободное место достаётся полю.
   Всё под #minesRoot: сетка реплеев (.hrp-grid-wrap > .mines-grid),
   арена, кейсы и прочие экраны не затронуты; id, классы и
   data-action прежние.
   ============================================================ */

/* --- Панель управления: строки ставки и мин (моб. и десктоп). --- */
#minesRoot .mines-panel { display: flex; flex-direction: column; gap: 8px; }
#minesRoot .mines-bet-row,
#minesRoot .mines-act-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
#minesRoot .mines-bet-col,
#minesRoot .mines-act-col {
  position: relative;
  flex: 1 1 96px; min-width: 68px;
  display: flex; flex-direction: column;
}
#minesRoot .mines-bet-col { flex-basis: 76px; }
#minesRoot .mines-label { margin: 0 2px 4px; font-size: 11px; line-height: 16px; font-weight: 500; }
#minesRoot .mines-input { width: 100%; height: 44px; font-size: 16px; }
#minesRoot .mines-chips { margin: 0; min-width: 0; }
/* Пять сумм влезают одной строкой даже на 320px (базисы 76+8+180 = 264 при
   внутренних 268): кегль 12px и плотная посадка, перенос — только ниже 300px. */
#minesRoot .mines-chips-amt { flex: 1 1 180px; min-width: 168px; }
#minesRoot .mines-chips-cnt { flex: 1 1 auto; }
#minesRoot .mines-chip { height: 44px; min-height: 44px; padding: 0 4px; font-size: 12.5px; }
#minesRoot .mines-chips-amt .mines-chip { padding: 0 2px; font-size: 12px; }
/* Валюта в быстрых чипах избыточна — ставка и CTA показывают её и так,
   зато ряд из пяти чипов влезает в 320px одной строкой. */
#minesRoot .mines-chips .dia { display: none; }
/* Ставка в подписи CTA меняет ширину («0,5»→«25 000») и гоняет ряд чипов
   туда-сюда: слот шире самого длинного типового labels + табличные цифры. */
#minesRoot .mines-go { flex: 0 0 auto; width: auto; min-width: 152px; min-height: 48px; margin-top: 0; padding: 0 12px; font-variant-numeric: tabular-nums; }
#minesRoot .mines-cash { margin-top: 0; }
#minesRoot .mines-hint { margin: 0 2px; }
#minesRoot .mines-min { font-size: 11px; line-height: 16px; }
/* Место под ошибку зарезервировано: её появление не дёргает поле и панель. */
#minesRoot .mines-err { margin: 0 2px; min-height: 18px; line-height: 18px; font-size: 12.5px; }
/* Живая строка партии: ставка · мины · множитель · выигрыш — равные ячейки
   с подписью над значением. Один ряд держится и на 320px, поэтому поле не
   проседает по высоте, когда начинается игра. */
#minesRoot .mines-live { display: flex; gap: 10px; }
#minesRoot .mines-live > * { flex: 1 1 0; min-width: 0; margin: 0; font-size: 11px; line-height: 16px; }
#minesRoot .mines-live b { display: block; margin: 1px 0 0; font-size: 15px; line-height: 20px; white-space: nowrap; }
/* Итог партии — snackbar поверх плиток (поле relative и на моб., и на десктопе):
   в потоке баннер сдвигал бы панель, а на десктопе ещё и влезал бы в ряд шкале. */
#minesRoot .mines-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  /* Итог — у ВЕРХА поля: нижний ряд плиток (и «Забрать»/CTA под ним) остаётся
     полностью виден; при итоге все клетки уже вскрыты, верх перекрывать безопасно. */
  top: 6px;
  z-index: 3;
  margin: 0 auto;
  max-width: 420px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 18px;
  pointer-events: none;
}
#minesRoot .mines-banner.win {
  background: var(--md-success-container);
  color: var(--md-on-success-container);
  box-shadow: var(--md-elevation-3);
}
#minesRoot .mines-banner.lose {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
  box-shadow: var(--md-elevation-3);
}

/* --- Мобильная колонка на всю доступную высоту, поле по меньшей стороне. --- */
@media (max-width: 767.98px) {
  #app:has(#minesRoot) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  #app:has(#minesRoot) > .screen {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 2px;
    /* 80px таббара + 8 зазора; safe-area — как в базовом паддинге экрана. */
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    /* Страховка: если места не хватает совсем (альбомная ориентация, 320px
       высоты), экран игры листается сам — поле не схлопывается в ноль. */
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #minesRoot {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 0;
  }
  /* Шапка в один ряд: выход — статус — история (статус не переносится). */
  #minesRoot > .arena-head { margin: 0 2px 6px; }
  #minesRoot .arena-status {
    flex: 0 1 auto;
    order: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #minesRoot .mines-wrap {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 8px;
  }
  #minesRoot .mines-field {
    flex: 1 1 auto;
    min-height: 160px;
    align-items: center;
    justify-content: center;
    container-type: size;
  }
  #minesRoot .mines-grid {
    flex: 0 1 auto;
    margin: auto;
    gap: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    /* Фолбэк без контейнерных запросов: поле растянется по клеткам,
       скролла всё равно не будет. */
    width: 100%;
    height: 100%;
  }
  @supports (width: 1cqh) {
    /* Квадрат по меньшей из сторон — как в референсе. */
    #minesRoot .mines-grid { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
  }
  /* Панель держит высоту idle-состояния во всех фазах (замер живьём:
     idle 204/144, живая 105 → скачок поля прыгал по сетке). Живое
     содержимое центрируется внутри высоты. Поле min(100cqw,100cqh) отсюда
     стабилично: сетка не прыгает при старте/итоге. */
  #minesRoot .mines-panel { flex: 0 0 auto; padding: 8px 12px; min-height: 208px; justify-content: center; }
  /* Итог — absolute поверх сетки (pointer-events:none); прежний резерв полосы
     42px через :has убран: он сам и был источником скачка поля при итоге.
     Строка честности — фикс-слот 16px во всех фазах (idle JS её не трогает
     вовсе — style null, после reset прячет в display:none): !important держит
     её в потоке пустой, ellipsis — в одну строку. Иначе поле прыгает на 16-24px. */
  #minesRoot .mines-fair { display: block !important; min-height: 16px; }
  /* Кроссфейд контента панели только при смене фазы (класс навешивает
     updateMinesPanel; пересборка чипов/множителя её не трогает). */
  @media (prefers-reduced-motion: no-preference) {
    #minesRoot #minesPanel.mines-panel-swap { animation: minesPanelIn 140ms var(--ease-decel); }
  }
  #minesRoot .mines-fair {
    flex: 0 0 auto;
    margin: 0 2px;
    font-size: 11px;
    line-height: 16px;
    word-break: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* --- Низкие экраны: подписи (имя поля остаётся доступным), подсказка
       минимума и зазоры уходят — свободная высота достаётся полю. --- */
@media (max-width: 767.98px) and (max-height: 640px) {
  #minesRoot .mines-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #minesRoot .mines-min { display: none; }
  #minesRoot .mines-grid { gap: 4px; }
  /* Компактная idle-панель низких экранов (замер 320×568: 144px) — свой резерв,
     иначе общая min-height отъела бы у поля ~60px. */
  #minesRoot .mines-panel { min-height: 148px; }
}

/* --- Десктоп ≥768: двухколоночная раскладка осталась, но нижний запас
       экрана (72px под таббар) здесь не нужен — с ним строка честности
       в активной партии вылезала за окно. Шкала множителей не должна
       раздувать поле: при 1–3 минам её содержимое выше сетки, поэтому
       потолок = ширина поля минус сама шкала (то есть высота сетки). --- */
@media (min-width: 768px) {
  #app:has(#minesRoot) > .screen { padding-bottom: 40px; }
  #minesRoot .mines-field { container-type: inline-size; }
  #minesRoot .mines-ladder { max-height: calc(100cqi - 128px); }
}

/* ============================================================
   Зажатие кнопок (указание владельца): при press+drag браузер
   выделял label белым прямоугольником (тот самый «белый квадрат»
   усугублялся ripple-кругом в tabbtn — ripple с таббара снят).
   Только интерактив-кнопки/плитки: поля ввода и текстовые
   поверхности (user-select:all у ref-ссылок и т.п.) не тронуты.
   ============================================================ */
button,
.tabbtn,
.chip,
.mines-chip,
.list-row,
.game-hero,
.case-card,
.hist-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ============================================================
   Лист «Инвентарь» (кнопка «Все» из профиля): вместо растянутых
   строк — плитки покрупнее (указание владельца). Хук — #invList:
   он есть только в этом шите, классы .inv-list/.inv-row/.inv-val/
   .btn-sell и разметка не тронуты.
   ============================================================ */
.sheet:has(#invList) .inv-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
/* Скелетоны загрузки — на всю ширину, не «половинки» в сетке. */
.sheet:has(#invList) .inv-list > .skel { grid-column: 1 / -1; }
.sheet:has(#invList) .inv-row {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 150px;
  padding: 12px;
  border-bottom: 0;
  background: var(--md-surface-container);
  border-radius: var(--shape-lg);
  text-align: center;
}
.sheet:has(#invList) span.inv-img { font-size: 40px; line-height: 1.15; }
.sheet:has(#invList) img.inv-img { width: 56px; height: 56px; border-radius: 14px; }
.sheet:has(#invList) .inv-meta { flex: 0 1 auto; width: 100%; align-items: center; gap: 2px; }
/* Имя остаётся с ellipsis (базовое правило), сумма — обычной строкой. */
.sheet:has(#invList) .inv-val { font-size: 13px; }
/* «Продать» — во всю плитку, тап-таргет 44; кнопка всегда внизу ряда. */
.sheet:has(#invList) .btn-sell { width: 100%; min-height: 44px; margin-top: auto; }
/* Замороженный подарок: бейж под кнопкой по центру, без мобильного отступа. */
.sheet:has(#invList) .inv-row-locked { flex-wrap: wrap; }
.sheet:has(#invList) .lock-badge { margin-left: 0; flex-wrap: wrap; justify-content: center; max-width: 100%; }
/* Десктоп ≥768: лист — центрированный модал-диалог (шиты уже центрируются
   базовым правилом), шире обычных: 640, сетка 3 колонки; ≥1024 — 4. */
@media (min-width: 768px) {
  /* Базовый .sheet на десктопе: width min(520px,100%) + max-width 480 — для
     этого листа нужен диалог 640, переопределяем обе границы. */
  .sheet:has(#invList) { width: min(640px, 100%); max-width: 640px; max-height: 80vh; }
  .sheet:has(#invList) .inv-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .sheet:has(#invList) .inv-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
