/* Qobiq: ranglar Telegram mavzusidan (var(--tg-theme-*)), tungi va kunduzgi rejim. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #2f7de1);
  --btn: var(--tg-theme-button-color, #2f7de1);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --section: var(--tg-theme-section-bg-color, var(--bg2));
  --accent: var(--tg-theme-accent-text-color, var(--btn));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --felt: color-mix(in srgb, #1f7a4d 78%, var(--bg));
  --radius: 14px;
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
}
:root[data-scheme="dark"] {
  --bg: var(--tg-theme-bg-color, #17191d);
  --bg2: var(--tg-theme-secondary-bg-color, #22252b);
  --text: var(--tg-theme-text-color, #f2f2f2);
  --felt: color-mix(in srgb, #14563a 80%, var(--bg));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
  overscroll-behavior: none;
}
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 18px 0 8px; color: var(--hint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
p { margin: 8px 0; }
button { font: inherit; color: inherit; }
.muted { color: var(--hint); }
.small { font-size: 12px; }
.big { font-size: 48px; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.center-text { text-align: center; }

.screen { padding: 14px 14px calc(110px + var(--safe-bottom)); max-width: 560px; margin: 0 auto; }
.screen.center { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.icon-btn { background: var(--bg2); border: 0; border-radius: 50%; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.icon-btn.danger { color: var(--danger); font-weight: 700; }
.section { margin-bottom: 8px; }
.row { display: flex; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer;
  background: var(--bg2); color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.ghost { background: transparent; color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }

.input {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: var(--bg); color: var(--text); font: inherit;
}
.input.num { flex: 0 0 80px; text-align: center; }
select.input { width: 100%; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--bg2); font-size: 12px; margin-right: 4px; }
.chip.accent { background: var(--btn); color: var(--btn-text); }
.chip.muted { color: var(--hint); }

.game-list { display: grid; gap: 10px; }
.game-card {
  text-align: left; border: 0; border-radius: var(--radius); padding: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--felt), color-mix(in srgb, var(--felt) 70%, #000));
  color: #fff;
}
.game-card .game-title { font-size: 20px; font-weight: 700; }
.game-card .game-desc { color: rgba(255,255,255,.8); margin: 4px 0 8px; font-size: 13px; }
.game-card .chip { background: rgba(255,255,255,.18); color: #fff; }
.room-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  border: 0; border-radius: 12px; padding: 12px; margin-bottom: 6px; background: var(--section); cursor: pointer;
}

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { border: 0; border-radius: 10px; padding: 9px 12px; background: var(--bg2); cursor: pointer; }
.seg.active { background: var(--btn); color: var(--btn-text); }
.options { display: flex; flex-direction: column; gap: 6px; }
.option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--section); border-radius: 12px; padding: 10px 12px;
}
.option.column { flex-direction: column; align-items: stretch; }
.help { font-size: 12px; }
.switch { position: relative; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: color-mix(in srgb, var(--hint) 50%, transparent); border-radius: 99px; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--btn); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  max-width: 560px; margin: 0 auto;
}

.table { width: 100%; border-collapse: collapse; background: var(--section); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 9px 10px; text-align: left; }
.table th { color: var(--hint); font-weight: 600; font-size: 13px; }
.table tr + tr td { border-top: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); }
.table td.num, .table th.num { text-align: right; }

/* Kutish xonasi */
.waiting { font-weight: 600; }
.seats { display: flex; flex-direction: column; gap: 6px; }
.team { background: var(--bg2); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.team-title { font-size: 12px; color: var(--hint); padding: 0 4px; }
.seat-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--section); }
.seat-row.empty { border: 1.5px dashed color-mix(in srgb, var(--hint) 50%, transparent); background: transparent; cursor: pointer; }
.seat-row.mine { outline: 2px solid var(--btn); }
.seat-row .name { flex: 1; font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: var(--btn); color: var(--btn-text); font-weight: 700; flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.code-box { text-align: center; margin: 18px 0; cursor: pointer; }
.code-box .code { font-size: 30px; font-weight: 700; }

/* Xona */
.room-screen { padding-bottom: 0; }
.room-header .title { font-weight: 700; font-size: 17px; }
.conn-status { text-align: center; font-size: 12px; padding: 4px; border-radius: 8px; background: #f5b301; color: #000; margin-bottom: 6px; }

/* Toast va modal */
.toast {
  position: fixed; left: 50%; bottom: calc(120px + var(--safe-bottom)); transform: translate(-50%, 10px);
  background: rgba(20,20,24,.92); color: #fff; padding: 10px 14px; border-radius: 12px; z-index: 50;
  max-width: 88vw; text-align: center; opacity: 0; transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  width: 100%; max-width: 560px; max-height: 85vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-bottom));
  animation: slide-up .22s ease;
}
.modal h2 { color: var(--text); text-transform: none; font-size: 18px; margin-top: 0; letter-spacing: 0; }
@keyframes slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
