/* ═══════════════════════════════════════════════════════════════════
   Оформление казино.

   Основа — глубокий обсидиан с золотом как единственным фирменным
   акцентом. Мягкий объём неоскевоморфизма сохранён, но подсвечен
   стеклом и свечением: поверхности не «выдавлены из пластилина», а
   выглядят гранёными.

   Светлая тема — не инверсия тёмной, а самостоятельная: тёплый жемчуг
   вместо серого, чтобы золото на нём не выглядело грязным.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-lux: cubic-bezier(0.22, 1, 0.36, 1);

  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 26px;
  --r-xl: 34px;

  --gold: #e8b64c;
  --gold-lit: #ffdc8a;
  --gold-deep: #a9761d;
  --green: #3ddc84;
  --red: #ff5a4e;
  --blue: #4da3ff;
  --violet: #a97bf0;
}

/* ── Тёмная тема ── */
html[data-theme="dark"] {
  --bg: #0d1015;
  --bg-deep: #070a0e;
  --bg-lift: #141922;
  --surface: #151a23;
  --surface-hi: #1b212c;
  --text: #f2f5fa;
  --text-dim: #8792a5;
  --text-mute: #5d6779;

  --shadow-dark: rgba(0, 0, 0, 0.72);
  --shadow-light: rgba(255, 255, 255, 0.045);
  --edge: rgba(255, 255, 255, 0.075);
  --edge-hi: rgba(255, 255, 255, 0.14);
  --glass: rgba(255, 255, 255, 0.04);
  --glow: rgba(232, 182, 76, 0.16);
}

/* ── Светлая тема ── */
html[data-theme="light"] {
  --bg: #eceef3;
  --bg-deep: #e0e4ec;
  --bg-lift: #f4f6fa;
  --surface: #f0f2f7;
  --surface-hi: #f8fafd;
  --text: #171c26;
  --text-dim: #6b7688;
  --text-mute: #949dae;

  --shadow-dark: rgba(150, 162, 184, 0.55);
  --shadow-light: rgba(255, 255, 255, 1);
  --edge: rgba(255, 255, 255, 0.85);
  --edge-hi: rgba(255, 255, 255, 1);
  --glass: rgba(255, 255, 255, 0.6);
  --glow: rgba(232, 182, 76, 0.22);
}

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

html, body { margin: 0; height: 100%; overscroll-behavior: none; }

body {
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  background: var(--bg);
}

/* Атмосфера: два мягких пятна света сверху. Дают глубину, но не мешают тексту. */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(78% 42% at 18% -8%, var(--glow), transparent 62%),
    radial-gradient(62% 38% at 92% 2%, rgba(169, 123, 240, .12), transparent 60%);
}
html[data-theme="light"] body::before { opacity: .75; }

#app, .tabbar, .sheet, #toasts, #levelup { position: relative; z-index: 1; }

/* ── Поверхности ─────────────────────────────────────────────────── */

.neo {
  position: relative;
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  border-radius: var(--r-lg);
  box-shadow:
    0 10px 26px -8px var(--shadow-dark),
    0 2px 6px -2px var(--shadow-dark),
    inset 0 1px 0 var(--edge-hi),
    inset 0 0 0 1px var(--edge);
}

.neo-sm { box-shadow: 0 6px 16px -6px var(--shadow-dark), inset 0 1px 0 var(--edge); }

.neo-in {
  background: var(--bg-deep);
  border-radius: var(--r-md);
  box-shadow:
    inset 0 2px 10px var(--shadow-dark),
    inset 0 -1px 0 var(--edge),
    0 1px 0 var(--edge);
}

/* ── Каркас ──────────────────────────────────────────────────────── */

#app {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: 10px 16px calc(94px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}

.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 2px 18px; }

.avatar {
  width: 46px; height: 46px; border-radius: 16px; flex: none;
  background: var(--surface) center/cover;
  display: grid; place-items: center;
  font-size: 19px; font-weight: 700; color: var(--text-dim);
  box-shadow: 0 6px 16px -6px var(--shadow-dark), inset 0 0 0 1px var(--edge),
              inset 0 1px 0 var(--edge-hi);
}

.who { flex: 1; min-width: 0; }
.who .name { font-weight: 660; font-size: 15.5px; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .rank { font-size: 12.5px; color: var(--text-dim); display: flex;
  align-items: center; gap: 5px; margin-top: 1px; }

.balance {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 15px 10px 17px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 720; font-size: 16px;
  letter-spacing: -.02em;
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  box-shadow: 0 6px 18px -8px var(--shadow-dark), inset 0 0 0 1px var(--edge),
              inset 0 1px 0 var(--edge-hi);
}
.balance #balance, .balance #sheetBalance {
  background: linear-gradient(160deg, var(--gold-lit), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.balance .coin { font-size: 14px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.3)); }
.balance.bump { animation: bump .5s var(--ease-spring); }
@keyframes bump { 0%{transform:scale(1)} 38%{transform:scale(1.09)} 100%{transform:scale(1)} }

/* ── Экраны ──────────────────────────────────────────────────────── */

.screen { display: none; animation: fadeUp .42s var(--ease-out); }
.screen.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

h2.section {
  font-size: 12px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-mute); margin: 26px 4px 11px; font-weight: 700;
}

/* ── Карточка уровня ─────────────────────────────────────────────── */

.level-card { padding: 18px 18px 16px; overflow: hidden; }
.level-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 100% at 88% -20%, var(--glow), transparent 58%);
}
.level-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.level-title { font-size: 19px; font-weight: 720; letter-spacing: -.025em;
  display: flex; align-items: center; gap: 9px; }
.level-num { font-size: 11.5px; color: var(--text-mute); font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; }

.bar { height: 9px; border-radius: 999px; background: var(--bg-deep);
  box-shadow: inset 0 2px 5px var(--shadow-dark), 0 1px 0 var(--edge); overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0; border-radius: 999px; position: relative;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold) 45%, var(--gold-lit));
  box-shadow: 0 0 14px var(--glow);
  transition: width 1.1s var(--ease-lux);
}
/* Блик, пробегающий по заполненной части — деталь, которая оживляет полосу. */
.bar > i::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  animation: sheen 3.4s ease-in-out infinite;
}
@keyframes sheen { 0%, 65% { transform: translateX(-110%) } 100% { transform: translateX(110%) } }

.bar-legend { display: flex; justify-content: space-between; font-size: 11.5px;
  color: var(--text-mute); margin-top: 9px; font-variant-numeric: tabular-nums; }

/* ── Плитки игр ──────────────────────────────────────────────────── */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tile {
  position: relative; overflow: hidden; cursor: pointer;
  padding: 18px 15px 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  box-shadow: 0 12px 28px -12px var(--shadow-dark), inset 0 0 0 1px var(--edge),
              inset 0 1px 0 var(--edge-hi);
  transition: transform .38s var(--ease-spring), box-shadow .3s ease;
}
/* Каждой игре свой оттенок свечения — стол узнаётся боковым зрением. */
.tile::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .9;
  background: radial-gradient(105% 78% at 82% -12%, var(--tile-glow, var(--glow)), transparent 60%);
}
.tile::after {
  content: ""; position: absolute; right: -14px; bottom: -20px;
  font-size: 92px; line-height: 1; opacity: .06; pointer-events: none;
  content: attr(data-art);
}
.tile:active { transform: scale(.965) translateY(1px);
  box-shadow: 0 4px 12px -6px var(--shadow-dark), inset 0 0 0 1px var(--edge); }

.tile[data-game="koi_queen"]  { --tile-glow: rgba(255, 122, 162, .3); }
.tile[data-game="gator_gold"] { --tile-glow: rgba(72, 200, 140, .28); }
.tile[data-game="roulette"]   { --tile-glow: rgba(228, 78, 62, .28); }
.tile[data-game="slots"]      { --tile-glow: rgba(232, 182, 76, .3); }
.tile[data-game="dice"]       { --tile-glow: rgba(77, 163, 255, .26); }
.tile[data-game="coinflip"]   { --tile-glow: rgba(232, 182, 76, .24); }
#pokerTile      { --tile-glow: rgba(77, 163, 255, .26); }
#blackjackTile  { --tile-glow: rgba(169, 123, 240, .28); }
#rocketTile     { --tile-glow: rgba(255, 138, 76, .3); }

.tile .ico { font-size: 32px; line-height: 1; margin-bottom: 13px; position: relative;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.tile .t { font-weight: 700; font-size: 16.5px; letter-spacing: -.025em; position: relative; }
.tile .s { font-size: 12px; color: var(--text-dim); margin-top: 3px; position: relative;
  letter-spacing: -.005em; }
.tile.soon { opacity: .4; pointer-events: none; }
.tile.soon .badge { position: absolute; top: 13px; right: 13px; font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); font-weight: 750; }

/* ── Кнопки ──────────────────────────────────────────────────────── */

.btn {
  position: relative; overflow: hidden;
  border: 0; font: inherit; font-weight: 680; font-size: 15.5px; color: var(--text);
  letter-spacing: -.02em;
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  border-radius: var(--r-md); padding: 15px 20px; width: 100%; cursor: pointer;
  box-shadow: 0 8px 20px -10px var(--shadow-dark), inset 0 0 0 1px var(--edge),
              inset 0 1px 0 var(--edge-hi);
  transition: transform .32s var(--ease-spring), box-shadow .22s ease, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(.968);
  box-shadow: 0 2px 8px -4px var(--shadow-dark), inset 0 0 0 1px var(--edge); }
.btn:disabled { opacity: .38; cursor: default; }

.btn.primary {
  color: #17130a;
  background: linear-gradient(165deg, var(--gold-lit) 0%, var(--gold) 52%, var(--gold-deep) 100%);
  box-shadow: 0 12px 28px -12px rgba(232, 182, 76, .75),
              0 3px 8px -3px var(--shadow-dark),
              inset 0 1px 0 rgba(255, 255, 255, .62),
              inset 0 -2px 5px rgba(120, 78, 10, .3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}
/* Блик по золоту при нажатии — «дорогая» тактильность */
.btn.primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.45) 50%, transparent 65%);
  transform: translateX(-120%); transition: transform .6s var(--ease-out);
}
.btn.primary:active::after { transform: translateX(120%); }

.btn.green {
  color: #06170e;
  background: linear-gradient(165deg, #7bf3ae, var(--green) 55%, #1f9c5c);
  box-shadow: 0 12px 26px -12px rgba(61, 220, 132, .7),
              inset 0 1px 0 rgba(255,255,255,.5);
}
.btn.ghost {
  background: transparent; font-weight: 640; color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--edge-hi);
}
.btn.mini { padding: 10px 14px; width: auto; font-size: 14px; border-radius: var(--r-sm); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ── Ставка ──────────────────────────────────────────────────────── */

.bet-box { padding: 15px; border-radius: var(--r-md); margin: 18px 0 14px;
  background: var(--bg-deep);
  box-shadow: inset 0 2px 10px var(--shadow-dark), 0 1px 0 var(--edge); }
.bet-box label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-mute); font-weight: 700; }
.bet-input { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.bet-input input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 27px; font-weight: 740; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield;
}
.bet-input input::-webkit-outer-spin-button,
.bet-input input::-webkit-inner-spin-button { -webkit-appearance: none; }
.step { width: 40px; height: 40px; flex: none; border-radius: 13px; border: 0;
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  color: var(--text); font-size: 19px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px -6px var(--shadow-dark), inset 0 0 0 1px var(--edge); }
.step:active { transform: scale(.92); }
.quick { display: flex; gap: 7px; margin-top: 13px; }
.quick button { flex: 1; padding: 9px 0; font-size: 12.5px; font-weight: 660; border: 0;
  border-radius: 12px; background: transparent; color: var(--text-dim); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--edge-hi); transition: all .25s ease; }
.quick button:active { color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }

/* ── Слоты (три барабана) ────────────────────────────────────────── */

.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px;
  border-radius: var(--r-lg); background: var(--bg-deep);
  box-shadow: inset 0 3px 14px var(--shadow-dark), 0 1px 0 var(--edge); }
.reel { position: relative; height: 108px; overflow: hidden; border-radius: var(--r-sm);
  background: linear-gradient(180deg, #05070a, #0d1117);
  box-shadow: inset 0 0 0 1px var(--edge); }
.reel .strip { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.reel .cell { height: 108px; display: grid; place-items: center; font-size: 46px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.5)); }
.reel::after { content:""; position:absolute; inset:0; pointer-events:none; border-radius: inherit;
  background: linear-gradient(180deg, rgba(0,0,0,.55), transparent 28%, transparent 72%, rgba(0,0,0,.55)); }
.reel.win { box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 26px -4px var(--glow); }

.result-line { text-align: center; min-height: 30px; margin-top: 16px; font-weight: 720;
  font-size: 19px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.result-line.win { color: var(--green); animation: pop .5s var(--ease-spring); }
.result-line.lose { color: var(--text-mute); }
@keyframes pop { 0%{transform:scale(.62);opacity:0} 100%{transform:scale(1);opacity:1} }

/* ── Кости ───────────────────────────────────────────────────────── */

.dice-face { text-align: center; padding: 24px 16px; border-radius: var(--r-lg);
  background: var(--bg-deep);
  box-shadow: inset 0 3px 14px var(--shadow-dark), 0 1px 0 var(--edge); }
.dice-face .val { font-size: 56px; font-weight: 780; font-variant-numeric: tabular-nums;
  letter-spacing: -.04em; transition: color .3s; }
.dice-track { position: relative; height: 12px; border-radius: 999px; margin: 22px 0 6px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.45); }
.dice-track .marker { position: absolute; top: 50%; width: 22px; height: 22px; margin-left: -11px;
  border-radius: 50%; background: linear-gradient(160deg, #fff, #ccd4e0);
  transform: translateY(-50%);
  box-shadow: 0 4px 10px rgba(0,0,0,.5), inset 0 1px 0 #fff;
  transition: left .6s var(--ease-spring); }
input[type=range] { width: 100%; -webkit-appearance: none; background: transparent; margin: 15px 0 4px; }
input[type=range]::-webkit-slider-runnable-track { height: 9px; border-radius: 999px;
  background: var(--bg-deep); box-shadow: inset 0 2px 6px var(--shadow-dark); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 27px; height: 27px;
  border-radius: 50%; margin-top: -9px;
  background: linear-gradient(160deg, var(--gold-lit), var(--gold));
  box-shadow: 0 5px 14px -4px rgba(232,182,76,.8), inset 0 1px 0 rgba(255,255,255,.6);
  cursor: pointer; }

.stat-row { display: flex; gap: 9px; margin-top: 14px; }
.stat { flex: 1; text-align: center; padding: 13px 6px; border-radius: var(--r-sm);
  background: var(--bg-deep); box-shadow: inset 0 2px 8px var(--shadow-dark); }
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; }
.stat span { font-size: 10.5px; color: var(--text-mute); text-transform: uppercase;
  letter-spacing: .06em; }

.seg { display: flex; padding: 4px; border-radius: 15px; gap: 4px; background: var(--bg-deep);
  box-shadow: inset 0 2px 8px var(--shadow-dark); }
.seg button { flex: 1; border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-weight: 660; font-size: 13.5px; padding: 10px 0; border-radius: 11px;
  cursor: pointer; transition: all .32s var(--ease-spring); }
.seg button.on { color: var(--text);
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  box-shadow: 0 4px 12px -5px var(--shadow-dark), inset 0 0 0 1px var(--edge); }

/* ── Монетка ─────────────────────────────────────────────────────── */

.coin-stage { height: 195px; display: grid; place-items: center; perspective: 1000px; }
.coin3d { width: 128px; height: 128px; position: relative; transform-style: preserve-3d;
  transition: transform 1.9s cubic-bezier(.25,.6,.2,1); }
.coin3d .side { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 54px; backface-visibility: hidden;
  background: radial-gradient(circle at 32% 28%, var(--gold-lit), var(--gold) 52%, var(--gold-deep));
  box-shadow: 0 18px 34px -12px rgba(0,0,0,.65), inset 0 3px 0 rgba(255,255,255,.55),
              inset 0 -6px 12px rgba(120,78,10,.45); }
.coin3d .back { transform: rotateY(180deg);
  background: radial-gradient(circle at 32% 28%, #f4f7fb, #b6c0cf 52%, #78839a); }

/* ── Списки ──────────────────────────────────────────────────────── */

.list { padding: 5px; border-radius: var(--r-lg); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border-radius: var(--r-md); }
.item + .item { box-shadow: inset 0 1px 0 var(--edge); }
.item .place { width: 26px; text-align: center; font-weight: 740; color: var(--text-mute);
  font-variant-numeric: tabular-nums; font-size: 14px; }
.item .grow { flex: 1; min-width: 0; }
.item .grow b { display: block; font-size: 14.5px; font-weight: 640; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .grow span { font-size: 11.5px; color: var(--text-mute); }
.item .amount { font-variant-numeric: tabular-nums; font-weight: 720; font-size: 14.5px;
  letter-spacing: -.02em; }
.item.me { background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge-hi); }
.amount.plus { color: var(--green); }
.amount.minus { color: var(--red); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 2px; font-size: 14px; }
.kv + .kv { box-shadow: inset 0 1px 0 var(--edge); }
.kv span { color: var(--text-dim); }
.kv b { font-variant-numeric: tabular-nums; font-weight: 660; letter-spacing: -.015em; }

.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  word-break: break-all; color: var(--text-mute); user-select: all; line-height: 1.5; }

.card { padding: 18px; margin-bottom: 12px; }
.note { font-size: 13px; color: var(--text-dim); line-height: 1.55; }

input.field {
  width: 100%; border: 0; outline: none; font: inherit; font-size: 15px; color: var(--text);
  background: var(--bg-deep); border-radius: var(--r-sm); padding: 13px 15px; margin-top: 9px;
  box-shadow: inset 0 2px 8px var(--shadow-dark), inset 0 0 0 1px transparent;
  transition: box-shadow .25s ease;
}
input.field:focus { box-shadow: inset 0 2px 8px var(--shadow-dark), inset 0 0 0 1px var(--gold); }

/* ── Таб-бар ─────────────────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 528px;
  display: flex; padding: 6px; gap: 3px; border-radius: 24px; z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  box-shadow: 0 18px 40px -16px var(--shadow-dark), 0 2px 8px -2px var(--shadow-dark),
              inset 0 0 0 1px var(--edge), inset 0 1px 0 var(--edge-hi);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--text-mute);
  font: inherit; font-size: 10px; font-weight: 640; letter-spacing: -.005em;
  padding: 9px 0 7px; border-radius: 18px; cursor: pointer;
  display: grid; gap: 4px; justify-items: center;
  transition: all .38s var(--ease-spring);
}
.tabbar button i { font-style: normal; font-size: 19px; line-height: 1;
  transition: transform .38s var(--ease-spring); }
.tabbar button.on { color: var(--text); background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--edge-hi); }
.tabbar button.on i { transform: translateY(-1px) scale(1.08);
  filter: drop-shadow(0 3px 8px var(--glow)); }

/* ── Шторка ──────────────────────────────────────────────────────── */

.sheet {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  padding: 12px 16px calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(100%); transition: transform .48s var(--ease-lux);
  max-width: 560px; margin: 0 auto;
}
.sheet::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(80% 40% at 50% -6%, var(--glow), transparent 62%);
}
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px;
  position: relative; }
.sheet-head .back { width: 40px; height: 40px; flex: none; border: 0; border-radius: 14px;
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  color: var(--text); font-size: 17px; cursor: pointer;
  box-shadow: 0 6px 16px -8px var(--shadow-dark), inset 0 0 0 1px var(--edge); }
.sheet-head .back:active { transform: scale(.92); }
.sheet-head h1 { font-size: 19.5px; margin: 0; flex: 1; font-weight: 730; letter-spacing: -.03em; }

/* ── Тосты ───────────────────────────────────────────────────────── */

#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top));
  z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { padding: 12px 19px; border-radius: 18px; font-size: 14px; font-weight: 630;
  max-width: 88%; text-align: center; letter-spacing: -.015em;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  color: var(--text);
  box-shadow: 0 14px 34px -12px var(--shadow-dark), inset 0 0 0 1px var(--edge-hi);
  animation: toastIn .42s var(--ease-spring); }
.toast.err { color: var(--red); }
.toast.ok { color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.92) } to { opacity: 1; transform: none } }

/* ── Повышение уровня ────────────────────────────────────────────── */

#levelup { position: fixed; inset: 0; z-index: 120; display: none; place-items: center;
  background: rgba(4, 7, 11, .62); backdrop-filter: blur(18px); }
#levelup.show { display: grid; animation: fade .34s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
#levelup .box { text-align: center; padding: 36px 30px 28px; border-radius: var(--r-xl);
  background: linear-gradient(168deg, var(--surface-hi), var(--surface));
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.8), inset 0 0 0 1px var(--edge-hi),
              0 0 60px -20px var(--glow);
  animation: pop .58s var(--ease-spring); max-width: 300px; }
#levelup .em { font-size: 68px; filter: drop-shadow(0 8px 20px rgba(0,0,0,.55)); }
#levelup h3 { margin: 14px 0 5px; font-size: 23px; font-weight: 740; letter-spacing: -.03em; }
#levelup p { margin: 0 0 22px; color: var(--text-dim); font-size: 13.5px; }

/* ── Заставка при запуске ────────────────────────────────────────── */

#splash {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: var(--bg); transition: opacity .5s var(--ease-out), visibility .5s;
}
#splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
#splash .mark { display: grid; justify-items: center; gap: 16px; animation: rise .7s var(--ease-out); }
#splash .chip {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  font-size: 34px;
  background: radial-gradient(circle at 34% 28%, var(--gold-lit), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 20px 44px -14px rgba(232,182,76,.6), inset 0 2px 0 rgba(255,255,255,.55),
              inset 0 -5px 12px rgba(120,78,10,.4);
  animation: chipSpin 2.4s var(--ease-lux) infinite;
}
#splash .name { font-size: 13px; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: var(--text-mute); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) } }
@keyframes chipSpin { 0%, 100% { transform: rotateY(0) } 50% { transform: rotateY(180deg) } }

.spin-anim { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }

.hidden { display: none !important; }

/* ── Чат ─────────────────────────────────────────────────────────── */

.chat-box {
  height: 58vh; min-height: 260px; overflow-y: auto; padding: 13px;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.msg { max-width: 82%; padding: 9px 14px; border-radius: 18px; font-size: 14.5px;
  line-height: 1.38; word-break: break-word; align-self: flex-start;
  letter-spacing: -.012em;
  background: var(--bg-lift);
  box-shadow: 0 4px 12px -6px var(--shadow-dark), inset 0 0 0 1px var(--edge); }
.msg .who { font-size: 11px; color: var(--text-mute); font-weight: 660; margin-bottom: 2px; }
.msg.mine { align-self: flex-end; color: #17130a;
  background: linear-gradient(165deg, var(--gold-lit), var(--gold));
  box-shadow: 0 8px 20px -10px rgba(232,182,76,.7); }
.msg.mine .who { color: rgba(0,0,0,.45); }
.msg.system { align-self: center; text-align: center; font-size: 12px;
  color: var(--text-mute); background: transparent; box-shadow: none; padding: 2px; }
.msg.feed { align-self: center; font-size: 12.5px; text-align: center; font-weight: 620;
  background: var(--bg-lift); color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(61, 220, 132, .25); }

.chat-input { display: flex; gap: 9px; margin-top: 12px; align-items: center; }
.chat-input input {
  flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 15px;
  color: var(--text); background: var(--bg-deep); border-radius: 999px; padding: 13px 19px;
  box-shadow: inset 0 2px 8px var(--shadow-dark);
}
.chat-input button {
  width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  font-size: 17px; color: #17130a;
  background: linear-gradient(165deg, var(--gold-lit), var(--gold));
  box-shadow: 0 10px 22px -10px rgba(232,182,76,.8), inset 0 1px 0 rgba(255,255,255,.5);
}
.chat-input button:active { transform: scale(.9); }

/* ── Узкие экраны ────────────────────────────────────────────────── */

@media (max-width: 380px) {
  #app, .sheet { padding-left: 12px; padding-right: 12px; }
  .grid { gap: 10px; }
  .tile { padding: 15px 12px 14px; }
  .tile .t { font-size: 15.5px; }
  .tile .s { font-size: 11.5px; }
  .balance { padding: 9px 13px; font-size: 15px; }
  .avatar { width: 42px; height: 42px; }
  h2.section { margin: 22px 2px 9px; }
}

/* Ничто не должно выпирать за край экрана по горизонтали. */
#app, .sheet { overflow-x: hidden; }

/* ═══════════════════════════════════════════════════════════════════
   Удержание текста

   Правила ниже не украшают, а чинят. Русский текст длиннее английского,
   а во флексах у детей по умолчанию min-width:auto — они отказываются
   сжиматься уже своего содержимого и выталкивают соседей за экран.
   Это и есть «текст съезжает». Лечится один раз и глобально.
   ═══════════════════════════════════════════════════════════════════ */

/* Ни один элемент не имеет права быть шире экрана. */
html, body { max-width: 100%; overflow-x: hidden; }

/* Дети флексов и гридов должны уметь сжиматься. */
.topbar > *, .who > *, .item > *, .kv > *, .level-head > *,
.bar-legend > *, .stat-row > *, .row > *, .seg > *,
.chat-input > *, .quick > *, .pk-table-card > *, .cr-player > * {
  min-width: 0;
}

/* Длинные слова, ссылки и ники переносятся, а не рвут макет. */
.note, .msg, .item .grow b, .item .grow span, .kv span, .kv b,
.tile .t, .tile .s, .who .name, .ad-player b, .ad-player span {
  overflow-wrap: anywhere;
}

/* Пара «подпись — значение». Раньше длинная подпись выдавливала число;
   теперь она переносится, а число всегда остаётся целым и справа. */
.kv {
  align-items: baseline;
  flex-wrap: wrap;
  row-gap: 2px;
}
.kv span { flex: 1 1 auto; }
.kv b { flex: 0 0 auto; text-align: right; white-space: nowrap; }

/* Строка списка: слева гибкий текст, справа неразрывная сумма. */
.item .grow { min-width: 0; }
.item .amount { flex: 0 0 auto; white-space: nowrap; }
.item .place { flex: 0 0 auto; }

/* Заголовки разделов: капс с разрядкой по-русски широкий, даём перенос. */
h2.section { overflow-wrap: anywhere; letter-spacing: .08em; }

/* Переключатели: три подписи на узком экране не должны наезжать. */
.seg button {
  padding-left: 4px; padding-right: 4px;
  font-size: clamp(12px, 3.4vw, 13.5px);
  white-space: nowrap;
}

/* Кнопки: длинная подпись сжимается шрифтом, а не вылезает. */
.btn { font-size: clamp(14px, 4vw, 15.5px); }
.btn.mini { font-size: clamp(12.5px, 3.4vw, 14px); }

/* Ставка: крупное число не должно упираться в кнопки. */
.bet-input input { font-size: clamp(21px, 6.5vw, 27px); }
.quick button { font-size: clamp(11px, 3.2vw, 12.5px); padding-left: 2px; padding-right: 2px; }

/* Длинные хеши переносим по символам — иначе распирают карточку. */
.mono { overflow-wrap: anywhere; word-break: break-all; }

/* Поля ввода не вылезают за карточку. */
input.field, .chat-input input { max-width: 100%; }

/* Плитки игр: подпись в две строки максимум, дальше многоточие. */
.tile .s {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Админка ─────────────────────────────────────────────────────── */

.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }
.ad-metric {
  padding: 12px 10px; border-radius: var(--r-sm); text-align: center;
  background: var(--bg-deep); box-shadow: inset 0 2px 8px var(--shadow-dark);
  min-width: 0;
}
.ad-metric b {
  display: block; font-size: clamp(15px, 4.6vw, 19px); font-weight: 740;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ad-metric span { font-size: 10.5px; color: var(--text-mute); }

.ad-player {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px;
  border-radius: var(--r-md); cursor: pointer;
}
.ad-player + .ad-player { box-shadow: inset 0 1px 0 var(--edge); }
.ad-player:active { background: var(--glass); }
.ad-player .grow { flex: 1; min-width: 0; }
.ad-player b { display: block; font-size: 14px; font-weight: 640;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-player span { font-size: 11.5px; color: var(--text-mute);
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-player .ad-bal { flex: 0 0 auto; font-variant-numeric: tabular-nums;
  font-weight: 720; font-size: 14px; color: var(--gold); white-space: nowrap; }
.ad-player.banned { opacity: .5; }

.ad-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--gold);
  background: var(--bg-deep); box-shadow: inset 0 0 0 1px var(--edge-hi);
}

/* ── Кошелёк ─────────────────────────────────────────────────────── */

.wl-preview {
  margin-top: 12px; padding: 11px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--text-dim); min-height: 20px;
  background: var(--bg-deep); box-shadow: inset 0 2px 8px var(--shadow-dark);
  overflow-wrap: anywhere;
}
.wl-preview b { color: var(--gold); font-variant-numeric: tabular-nums; }
.wl-preview:empty { display: none; }

.item.wl-overdue { box-shadow: inset 0 0 0 1px rgba(255, 90, 78, .45); }

/* Сообщение казино в общем чате — отличается от игроков. */
.msg.house {
  align-self: center; text-align: center; max-width: 92%;
  color: var(--gold); font-weight: 620;
  background: var(--bg-deep);
  box-shadow: inset 0 0 0 1px rgba(232, 182, 76, .35);
}
.msg.house .who { color: var(--gold); opacity: .8; }

/* Экран «не загрузилось». Показывается вместо пустоты, когда пропала связь
   или сервер перезапускается: игрок видит причину и кнопку повтора. */
.boot-error {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: 28px; background: var(--bg);
}
.boot-error-inner { max-width: 320px; text-align: center; }
.boot-error-icon { font-size: 54px; margin-bottom: 14px; }
.boot-error-inner h2 { font-size: 21px; margin: 0 0 8px; letter-spacing: -.02em; }
.boot-error-inner p {
  color: var(--text-dim); font-size: 14.5px; line-height: 1.5;
  margin: 0 0 22px; overflow-wrap: anywhere;
}
