:root {
  --bg: #17171f;
  --bg2: #1f1f2a;
  --card: #23232f;
  --text: #f2f2f7;
  --muted: #8f8f9d;
  --accent: #7c5cff;
  --accent2: #34d399;
  --danger: #f87171;
  --radius: 18px;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: pan-y;
}

/* фоновый градиент — фиксированный слой, не режется при скролле */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #262637 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { min-height: 100dvh; position: relative; z-index: 1; }

/* скрыть полосы прокрутки, скролл остаётся */
::-webkit-scrollbar { width: 0; height: 0; display: none; }
html, .content, .result-words {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

button, input, textarea, .theme-card, .chip { touch-action: manipulation; }

#app { min-height: 100dvh; }

/* ---------- экраны ---------- */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.content { flex: 1; padding: 16px 20px 24px; overflow-y: auto; }

/* ---------- шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  position: sticky; top: 0; z-index: 5;
  background: rgba(23, 23, 31, 0.85); backdrop-filter: blur(10px);
}
.topbar h2 { margin: 0; font-size: 18px; }
.spacer { flex: 1; }
.btn-back {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
}
.round-badge { color: var(--muted); font-size: 14px; padding-right: 8px; }

/* ---------- кнопки ---------- */
.btn {
  border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 16px; font-weight: 600; padding: 14px 20px; color: var(--text);
  transition: transform 0.06s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #5b3df0); box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35); }
.btn-ghost { background: var(--card); }
.btn-danger { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.btn-xl { font-size: 19px; padding: 18px 28px; width: 100%; }
.btn-wide { width: 100%; margin-bottom: 12px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ---------- главная ---------- */
.home-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 32px; max-width: 480px; margin: 0 auto; width: 100%; }
.logo { text-align: center; margin-bottom: 28px; }
.logo-mark {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px;
  background: linear-gradient(135deg, var(--accent), #5b3df0);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 800; color: #fff;
  box-shadow: 0 14px 40px rgba(124, 92, 255, 0.45);
}
.logo h1 { margin: 0; font-size: 40px; letter-spacing: 1px; }
.subtitle { margin: 6px 0 0; color: var(--muted); }

/* ---------- настройка ---------- */
.section-title { font-size: 15px; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.section-title:first-child { margin-top: 8px; }
.hint { color: var(--accent2); font-weight: 500; }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 12px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 10px; min-height: 62px;
  transition: border-color 0.15s;
}
.theme-card .t-emoji { font-size: 24px; }
.theme-card .t-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.theme-card .t-count { font-size: 12px; color: var(--muted); font-weight: 400; }
.theme-card.selected { border-color: var(--accent); background: rgba(124, 92, 255, 0.12); }
.theme-card.custom-tag::after { content: 'своя'; font-size: 10px; color: var(--accent2); margin-left: auto; }

.chip-row { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 12px 8px; border-radius: 14px; border: 2px solid transparent;
  background: var(--card); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
}
.chip.selected { border-color: var(--accent); background: rgba(124, 92, 255, 0.12); }

.pool-info { margin-top: 18px; padding: 12px 16px; border-radius: 14px; background: var(--bg2); color: var(--muted); font-size: 14px; }
.pool-info b { color: var(--accent2); }

/* ---------- команды ---------- */
.team-card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 14px;
}
.avatar {
  width: 68px; height: 68px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: #fff; cursor: pointer; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.team-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.team-name-input {
  background: var(--bg2); border: none; border-radius: 12px; color: var(--text);
  font-size: 16px; font-weight: 600; padding: 10px 12px; width: 100%;
}
.team-score { color: var(--muted); font-size: 13px; }
.team-delete { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 6px; }

.footer { padding: 14px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }

/* ---------- интро/результаты/финал ---------- */
.center-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px; text-align: center; position: relative; max-width: 520px; margin: 0 auto; width: 100%;
}
.intro-label { color: var(--muted); margin: 0; letter-spacing: 1px; text-transform: uppercase; font-size: 13px; }
.intro-avatar {
  width: 220px; height: 220px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 105px; font-weight: 800; color: #fff; overflow: hidden;
}
.result-avatar, .winner-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; font-weight: 800; color: #fff; overflow: hidden;
}
.winner-avatar { width: 110px; height: 110px; font-size: 52px; }
.intro-avatar img, .result-avatar img, .winner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.center-wrap h1 { margin: 4px 0; font-size: 32px; }
.intro-sub { color: var(--muted); margin: 0 0 18px; }

.result-score { font-size: 56px; font-weight: 800; color: var(--accent2); }
.result-words { max-height: 34dvh; overflow-y: auto; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.word-row {
  display: flex; justify-content: space-between; padding: 8px 14px;
  border-radius: 12px; background: var(--card); font-size: 15px;
}
#result-words .word-row { cursor: pointer; }
#result-words .word-row:active { transform: scale(0.98); }
.wr-theme { color: var(--muted); font-size: 11px; font-weight: 400; }
.word-row.guessed { color: var(--accent2); }
.word-row.skipped { color: var(--muted); }

/* ---------- раунд ---------- */
.timer-track { height: 6px; background: var(--bg2); }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 1s linear; }
.timer-fill.hurry { background: var(--danger); }

.round-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px 0; font-size: 22px; font-weight: 700;
}
#round-score { color: var(--accent2); }
#round-time.hurry { color: var(--danger); }

.word-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 24px; }
.word-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.word-theme {
  font-size: 14px; font-weight: 600; color: var(--muted);
  background: var(--card); border-radius: 999px; padding: 6px 16px;
  letter-spacing: 0.3px;
}
.word {
  font-size: clamp(34px, 9vw, 56px); font-weight: 800; text-align: center; line-height: 1.15;
  animation: pop 0.25s ease;
}
.word.flash-ok { color: var(--accent2); }
.word.flash-skip { color: var(--muted); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

.round-actions {
  display: flex; gap: 12px; padding: 20px 20px calc(28px + env(safe-area-inset-bottom));
}
.btn-guess { flex: 2.2; background: linear-gradient(135deg, var(--accent2), #10b981); font-size: 20px; padding: 22px; }
.btn-skip { flex: 1.3; background: var(--card); color: var(--muted); font-size: 17px; padding: 22px 10px; }

/* ---------- табло ---------- */
.score-row {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
}
.score-place { font-size: 20px; font-weight: 800; color: var(--muted); width: 30px; text-align: center; }
.score-row:first-child .score-place { color: #fbbf24; }
.score-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; overflow: hidden; flex-shrink: 0; }
.score-avatar img { width: 100%; height: 100%; object-fit: cover; }
.score-name { flex: 1; font-weight: 700; font-size: 16px; }
.score-points { font-size: 20px; font-weight: 800; color: var(--accent2); }

/* ---------- финал ---------- */
.winner-name { color: #fbbf24; }
#final-standings { width: 100%; margin: 8px 0 6px; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti span {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(105dvh) rotate(720deg); }
}

/* ---------- админ ---------- */
.admin-hint { color: var(--muted); font-size: 14px; }
.input {
  width: 100%; background: var(--card); border: 2px solid transparent; border-radius: 14px;
  color: var(--text); font-size: 16px; padding: 13px 14px; margin-bottom: 12px;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-emoji { width: 90px; font-size: 22px; text-align: center; }
.textarea { resize: vertical; line-height: 1.5; }
.label { display: block; color: var(--muted); font-size: 13px; margin: 10px 0 6px; }

.admin-theme-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.admin-theme-row .t-emoji { font-size: 22px; }
.admin-theme-row .t-name { flex: 1; font-weight: 600; }

/* ---------- утилиты ---------- */
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #2e2e3d; color: var(--text); padding: 12px 20px; border-radius: 14px;
  font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: fadein 0.2s ease; max-width: 85vw; text-align: center;
}
