/* ── Theme variables (overridden at runtime from Telegram themeParams) ── */
:root {
  --bg: #0e1621;
  --bg-soft: #17212b;
  --card: #1d2a36;
  --text: #ffffff;
  --hint: #8aa0b2;
  --link: #4ea0ff;
  --button: #2ea6ff;
  --button-text: #ffffff;
  --accent: #ffcf33;
  --good: #36c06a;
  --bad: #ff5a5a;
  --felt: #0f6b4f;
  --felt-rail: #6e4a25;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
button { font-family: inherit; cursor: pointer; border: none; }
.hidden { display: none !important; }
.muted { color: var(--hint); font-size: 12px; }

/* ── Phaser canvas ── */
#game { position: fixed; inset: 0; z-index: 0; }
#game canvas { display: block; width: 100% !important; height: 100% !important; }

/* ── Loading ── */
.loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: radial-gradient(circle at 50% 35%, #14342a, var(--bg));
}
.loading .logo { font-size: 64px; filter: drop-shadow(0 4px 12px rgba(0,0,0,.5)); animation: float 2.4s ease-in-out infinite; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.loading-text { color: var(--hint); font-size: 14px; letter-spacing: .3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ── HUD ── */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(180deg, var(--bg-soft), rgba(23,33,43,0));
  pointer-events: none;
}
.hud-id { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; background: var(--button);
  box-shadow: var(--shadow); overflow: hidden; background-size: cover; background-position: center;
}
.hud-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.hud-sub { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: rgba(255,207,51,.18); color: var(--accent); }
.hud-chips {
  display: flex; align-items: center; gap: 6px; pointer-events: auto;
  background: var(--card); padding: 7px 12px; border-radius: 999px;
  font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: var(--shadow);
}
.chip-ico { font-size: 14px; }

/* ── Bottom nav ── */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: linear-gradient(0deg, var(--bg-soft), rgba(23,33,43,0));
}
.nav-btn {
  flex: 1; background: transparent; color: var(--hint);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 6px; border-radius: var(--radius-sm);
}
.nav-btn span { font-size: 20px; }
.nav-btn.active { color: var(--text); }
.nav-btn.active span { transform: translateY(-1px); filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }

/* ── Screens ── */
.screen {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 64px) 12px calc(var(--safe-bottom) + 76px);
  background: var(--bg); display: none;
}
.screen.active { display: block; }
.screen-transparent { background: transparent; }
.screen-transparent.active { display: block; }

/* ── Lobby ── */
.section-title { font-size: 13px; font-weight: 700; color: var(--hint); text-transform: uppercase; letter-spacing: .6px; margin: 14px 4px 8px; }
.city-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.city-card {
  background: var(--card); border-radius: var(--radius); padding: 12px;
  border: 1.5px solid transparent; transition: transform .12s, border-color .12s; position: relative;
}
.city-card:active { transform: scale(.97); }
.city-card.selected { border-color: var(--accent); }
.city-card.locked { opacity: .45; }
.city-name { font-weight: 700; font-size: 15px; }
.city-blinds { font-size: 12px; color: var(--hint); margin-top: 2px; }
.city-lock { position: absolute; top: 10px; right: 10px; font-size: 12px; color: var(--accent); font-weight: 700; }
.city-flag { font-size: 20px; }

.table-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 8px;
  transition: transform .12s;
}
.table-row:active { transform: scale(.98); }
.table-row .t-name { font-weight: 700; }
.table-row .t-meta { font-size: 12px; color: var(--hint); margin-top: 2px; }
.table-row .t-seats { font-size: 12px; color: var(--good); font-weight: 700; }
.pill-btn { background: var(--button); color: var(--button-text); font-weight: 700; padding: 9px 16px; border-radius: 999px; }
.empty-hint { color: var(--hint); text-align: center; padding: 24px; font-size: 14px; }

/* ── Table controls overlay ── */
.table-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 10px 12px calc(var(--safe-bottom) + 10px);
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.table-controls > * { pointer-events: auto; }
.tc-leave { position: fixed; top: calc(var(--safe-top) + 8px); right: 12px; z-index: 16;
  background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 12px; font-weight: 700; font-size: 12px; pointer-events: auto; }
.bet-row { display: flex; align-items: center; gap: 10px; }
.bet-slider { flex: 1; accent-color: var(--accent); height: 28px; }
.bet-amount { min-width: 64px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--bg-soft); border-radius: var(--radius-sm); padding: 6px; }
.quick-row { display: flex; gap: 6px; }
.quick-btn { flex: 1; background: var(--bg-soft); color: var(--text); font-size: 12px; font-weight: 700; padding: 8px; border-radius: var(--radius-sm); }
.action-row { display: flex; gap: 8px; }
.action-row button { flex: 1; padding: 15px; border-radius: var(--radius); font-weight: 800; font-size: 15px; }
.btn-fold { background: #3a2730; color: #ff9a9a; }
.btn-call { background: var(--good); color: #06281a; }
.btn-raise { background: var(--accent); color: #2a2200; }
.action-row button:disabled, .controls-disabled { opacity: .4; pointer-events: none; }
.turn-banner { text-align: center; font-weight: 700; font-size: 13px; color: var(--accent); }

/* ── Spin ── */
.spin-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 8px; }
.spin-title { font-size: 22px; font-weight: 800; }
.spin-sub { color: var(--hint); font-size: 13px; text-align: center; }
.spin-btn {
  background: linear-gradient(180deg, var(--accent), #f0a500); color: #2a2200;
  font-weight: 900; font-size: 17px; padding: 16px 40px; border-radius: 999px; box-shadow: var(--shadow);
  transition: transform .12s;
}
.spin-btn:active { transform: scale(.96); }
.spin-btn:disabled { opacity: .5; }

/* ── Store ── */
.pkg {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  border: 1.5px solid transparent; transition: transform .12s;
}
.pkg:active { transform: scale(.98); }
.pkg.best { border-color: var(--accent); }
.pkg-chips { font-weight: 800; font-size: 17px; }
.pkg-sub { font-size: 12px; color: var(--hint); margin-top: 2px; }
.pkg-buy { background: linear-gradient(180deg,#ffd84d,#f0a500); color: #2a2200; font-weight: 800; padding: 10px 16px; border-radius: 999px; display: flex; align-items: center; gap: 4px; }

/* ── Modal ── */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.modal {
  width: 100%; max-width: 480px; background: var(--bg-soft); border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(var(--safe-bottom) + 20px); box-shadow: var(--shadow); animation: slideup .25s ease;
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: var(--hint); font-size: 13px; margin-bottom: 16px; }
.modal .modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal .modal-actions button { flex: 1; padding: 14px; border-radius: var(--radius); font-weight: 800; }
.btn-primary { background: var(--button); color: var(--button-text); }
.btn-ghost { background: transparent; color: var(--hint); }
@keyframes fade { from { opacity: 0; } }
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%) translateY(20px);
  z-index: 60; background: var(--card); color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { color: var(--good); }
.toast.bad { color: var(--bad); }

/* ── Turn timer ring ── */
.turn-head { display: flex; align-items: center; justify-content: center; gap: 8px; }
.turn-ring { position: relative; width: 34px; height: 34px; }
.turn-ring svg { transform: rotate(-90deg); }
.turn-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.15); stroke-width: 4; }
.turn-ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.turn-ring .ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }

/* ── Segmented toggles (leaderboards) + settings card ── */
.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tab { flex: 1; text-align: center; padding: 9px; border-radius: 999px; background: var(--bg-soft); color: var(--hint); font-weight: 700; font-size: 13px; }
.tab.active { background: var(--button); color: var(--button-text); }
.settings-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 46px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-sw { position: absolute; inset: 0; background: #46566380; border-radius: 999px; transition: .2s; }
.slider-sw:before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider-sw { background: var(--good); }
.switch input:checked + .slider-sw:before { transform: translateX(18px); }
.footer-links { margin-top: 12px; text-align: center; font-size: 12px; }
.footer-links a { color: var(--link); text-decoration: none; }
.footer-links span { color: var(--hint); margin: 0 6px; }

/* ── Brand wordmark ─────────────────────────────────────────── */
.brand { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; position: relative; }
.brand-word {
  font-weight: 900; letter-spacing: -0.5px;
  background: linear-gradient(180deg, #ffe9a8 0%, #ffcf33 45%, #f0a500 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 10px rgba(240,165,0,.25);
  font-size: 26px;
}
.brand-smile {
  width: 58%; height: 9px; margin-top: 2px;
  border-bottom: 3px solid #ff5a7a; border-radius: 0 0 80% 80%;
  filter: drop-shadow(0 2px 4px rgba(255,90,122,.4));
}
.brand-sub { margin-top: 5px; font-size: 9px; font-weight: 800; letter-spacing: 4px; color: var(--hint); }
.brand-lg .brand-word { font-size: 46px; }
.brand-lg .brand-smile { height: 14px; border-bottom-width: 4px; }
.brand-lg .brand-sub { font-size: 11px; letter-spacing: 7px; }

/* lobby brand header */
.lobby-brand { display: flex; justify-content: center; padding: 4px 0 6px; }

/* ── Loading screen ─────────────────────────────────────────── */
.loading .loading-chips { display: flex; gap: 12px; }
.lchip { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255,255,255,.5), 0 4px 10px rgba(0,0,0,.45); animation: chipBounce 1s ease-in-out infinite; }
.lchip.c-red { background: radial-gradient(circle at 50% 35%, #ff7a7a, #c0392b); }
.lchip.c-blue { background: radial-gradient(circle at 50% 35%, #6fb0ff, #2b6fb0); animation-delay: .15s; }
.lchip.c-green { background: radial-gradient(circle at 50% 35%, #6fe0a0, #1f8a52); animation-delay: .3s; }
@keyframes chipBounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.loading-bar { width: 200px; height: 6px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; }
.loading-bar-fill { height: 100%; width: 12%; border-radius: 999px; background: linear-gradient(90deg, #ffcf33, #f0a500); transition: width .4s ease; box-shadow: 0 0 10px rgba(255,207,51,.6); }

/* ── Profile screen ─────────────────────────────────────────── */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 4px; }
.profile-avatar { width: 92px; height: 92px; border-radius: 50%; background: var(--button); background-size: cover; background-position: center; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 800; color: #fff; border: 3px solid var(--accent); position: relative; }
.profile-avatar .edit-badge { position: absolute; bottom: -2px; right: -2px; background: var(--accent); color: #2a2200; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: var(--shadow); }
.profile-name { font-size: 20px; font-weight: 800; }
.profile-meta { display: flex; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-card .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-card .k { font-size: 12px; color: var(--hint); margin-top: 2px; }
.field-label { font-size: 12px; color: var(--hint); margin: 16px 4px 6px; font-weight: 700; }
.text-input { width: 100%; padding: 13px; border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--text); border: 1px solid rgba(255,255,255,.08); font-size: 16px; }
.profile-actions { display: flex; gap: 8px; margin-top: 10px; }
.profile-actions button { flex: 1; padding: 13px; border-radius: var(--radius); font-weight: 800; }

/* ── Design system: motion + micro-interactions ─────────────────────────── */
:root { --ease: cubic-bezier(.22,.61,.36,1); --ease-bounce: cubic-bezier(.34,1.56,.64,1); }

/* consistent button press feedback everywhere */
button, .nav-btn, .tab, .city-card, .table-row, .pkg, .quick-btn, .pill-btn {
  transition: transform .12s var(--ease), opacity .15s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease);
}
button:active, .pill-btn:active, .pkg-buy:active, .quick-btn:active { transform: scale(.93); }
.spin-btn:active, .btn-primary:active, .btn-call:active, .btn-raise:active, .btn-fold:active { transform: scale(.96); }

/* smooth screen entrance */
.screen.active { animation: screenIn .32s var(--ease); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* subtle glass on key surfaces */
.hud, .nav { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hud-chips, .settings-card, .stat-card, .pkg, .table-row, .city-card {
  box-shadow: 0 6px 18px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.04);
}

/* count-up balance pop */
#hud-chips { transition: transform .2s var(--ease-bounce); }
#hud-chips.bump { transform: scale(1.18); }

/* ── Audio settings control ─────────────────────────────────────────────── */
.audio-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.audio-row .vol { flex: 1; accent-color: var(--accent); height: 26px; }
.mute-btn { background: var(--bg-soft); border-radius: 999px; width: 40px; height: 40px; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.mute-btn.muted { opacity: .55; }
