:root {
  --bg: #0f1117;
  --panel: #181b24;
  --panel-2: #20242f;
  --border: #2b3040;
  --text: #e8eaf0;
  --muted: #8a90a2;
  --accent: #f5b400;
  --accent-text: #1a1400;
  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

h2 { font-size: 18px; margin: 28px 0 12px; }

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

.brand { font-weight: 800; font-size: 20px; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.brand-lg { font-size: 28px; }

/* ─── Buttons & inputs ─────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 14px; }

input, select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ─── Login ────────────────────────────────────────────────────────── */

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  display: grid; gap: 14px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-card p { margin: 0; }

/* ─── Lobby ────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 12px 24px;
  background: rgba(15, 17, 23, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.wallet { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.balance-box { display: grid; line-height: 1.15; margin-right: 6px; }
.balance-box span { font-size: 12px; }
.balance-box strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.deposit-form { display: flex; gap: 6px; }
.deposit-form input { width: 110px; padding: 6px 10px; }
.user { display: flex; align-items: center; gap: 10px; }
.user select { padding: 6px 8px; }
.nickname { font-weight: 600; }

.content { max-width: 1200px; margin: 0 auto; padding: 8px 24px 48px; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.game {
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.game-cover {
  aspect-ratio: 16 / 8;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; letter-spacing: .5px;
  text-align: center; padding: 12px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.game-body { padding: 14px 16px 4px; }
.game-body h3 { margin: 0 0 4px; font-size: 17px; }
.game-body p { margin: 0; font-size: 13px; }
.game-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.game-actions select { padding: 6px 8px; }
.game-actions .btn { margin-left: auto; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.tx { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tx th, .tx td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tx th { color: var(--muted); font-weight: 600; background: var(--panel); }
.tx tr:last-child td { border-bottom: 0; }
.plus { color: var(--ok); }
.minus { color: var(--bad); }
.status-FAILED { color: var(--bad); }

/* ─── Game player ──────────────────────────────────────────────────── */

.player {
  position: fixed; inset: 0; z-index: 20;
  display: grid; grid-template-rows: auto 1fr;
  background: #000;
}
.player-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.player-bar .spacer { flex: 1; }
.player iframe { width: 100%; height: 100%; border: 0; background: #000; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30;
  transform: translateX(-50%);
  max-width: min(640px, calc(100% - 32px));
  padding: 12px 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.error { border-color: var(--bad); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .content { padding: 8px 16px 40px; }
  .wallet { margin-left: 0; }
  .player-bar { gap: 8px; padding: 8px; }
  .player-bar .muted { display: none; }
}

/* Живые баннеры 19flip: плашка тянется на любую ширину от 280px.
   Пустой слот (тиража нет) выводим из потока, но не display:none —
   iframe должен оставаться в layout, чтобы измерить плашку. */
.live-banners { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.live-banners:has([data-19flip-visible]) { margin-bottom: 24px; }
/* Размер задаёт только контейнер: iframe занимает 100% его ширины, высоту
   подгоняет embed.js. Здесь — шире и по центру; на всю ширину — убрать
   max-width. */
.live-banner { width: 100%; max-width: 720px; min-width: 280px; }
.live-banner:not([data-19flip-visible]) { position: absolute; width: 360px; visibility: hidden; pointer-events: none; }
