/* =================================================================
   На раз-два! — UI v14
   Огонь (тёплая) vs Лёд (холодная) дуэль.
   Минимум деталей, максимум контраста. Mobile-first, PC-aware.
================================================================= */

:root {
  /* База */
  --bg-0: #0a0c18;
  --bg-1: #11142a;
  --bg-2: #1a1f3d;
  --fg: #f4f6ff;
  --fg-mute: rgba(244, 246, 255, .65);
  --fg-dim: rgba(244, 246, 255, .42);
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);

  /* Акценты — огонь и лёд */
  --hot-1: #ff5b3a;
  --hot-2: #ff9a3a;
  --hot-glow: rgba(255, 91, 58, .55);

  --cold-1: #5b8bff;
  --cold-2: #45e8ff;
  --cold-glow: rgba(91, 139, 255, .55);

  /* Состояния */
  --good: #4dd49b;
  --bad:  #ff4d6d;
  --warn: #ffc555;

  /* Размеры/радиусы */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  /* Шрифты */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Безопасные зоны */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bot: env(safe-area-inset-bottom, 0px);

  /* Высоты UI */
  --topbar-h: 56px;
  --nav-h: 64px;
}

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

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--bg-0);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
body { background: transparent; }
html { background: var(--bg-0); }

body {
  display: flex; flex-direction: column;
  padding-top: calc(var(--topbar-h) + var(--sa-top));
  padding-bottom: calc(var(--nav-h) + var(--sa-bot));
}

button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; }
img, svg { display: block; }

/* =====================================================
   ФОН — два слоя градиента + лёгкая сетка
===================================================== */
.bg {
  position: fixed; inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-hot, .bg-cold {
  position: absolute;
  width: 75vw;
  height: 75vh;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .7;
  transition: opacity .6s ease;
  pointer-events: none;
}
.bg-hot {
  top: -15vh;
  left: -25vw;
  background: radial-gradient(circle, var(--hot-1) 0%, rgba(255,91,58,.55) 35%, transparent 65%);
}
.bg-cold {
  bottom: -15vh;
  right: -25vw;
  background: radial-gradient(circle, var(--cold-1) 0%, rgba(91,139,255,.55) 35%, transparent 65%);
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* Состояния фона: победа/поражение */
body.fx-good .bg-hot { opacity: .15; }
body.fx-good .bg-cold {
  opacity: .85;
  width: 100vw; height: 100vh;
  top: 0; bottom: auto; right: 0;
  background: radial-gradient(circle at center, var(--good) 0%, rgba(77,212,155,.4) 35%, transparent 70%);
}
body.fx-bad .bg-cold { opacity: .15; }
body.fx-bad .bg-hot {
  opacity: .85;
  width: 100vw; height: 100vh;
  top: 0; bottom: auto; left: 0;
  background: radial-gradient(circle at center, var(--bad) 0%, rgba(255,77,109,.4) 35%, transparent 70%);
}

/* =====================================================
   ЗАГРУЗЧИК
===================================================== */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg-1), var(--bg-0));
  transition: opacity .4s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.splash-logo {
  font-size: 42px; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(95deg, var(--hot-2), var(--hot-1) 35%, var(--cold-1) 65%, var(--cold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.splash-spinner {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.08);
  border-top-color: var(--hot-1);
  border-right-color: var(--cold-1);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   ШАПКА
===================================================== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--sa-top));
  padding-top: var(--sa-top);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(to bottom, rgba(8,10,20,.98), rgba(8,10,20,.75));
  backdrop-filter: blur(24px) saturate(140%); -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-bottom: 1px solid var(--line-strong);
  z-index: 50;
}
.topbar-inner {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 920px;
  margin: 0 auto;
  padding-inline: 14px;
}
.btn-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  color: var(--fg);
  background: rgba(255,255,255,.05);
  transition: background .15s, transform .1s;
}
.btn-icon:hover { background: rgba(255,255,255,.1); }
.btn-icon:active { transform: scale(.92); }
.topbar-title {
  flex: 1; font-weight: 700; font-size: 16px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-stats { display: flex; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 10px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--fg);
}
.chip svg { color: var(--fg-mute); flex-shrink: 0; }
.chip-sparks { color: var(--hot-2); }
.chip-sparks svg { color: var(--hot-2); }
.chip.bump {
  animation: chipBump .5s ease;
}
@keyframes chipBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); background: rgba(255,154,58,.25); }
  100% { transform: scale(1); }
}

/* =====================================================
   НИЖНЕЕ МЕНЮ
===================================================== */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--sa-bot));
  padding-bottom: var(--sa-bot);
  display: flex;
  background: linear-gradient(to top, rgba(8,10,20,.98), rgba(8,10,20,.85));
  backdrop-filter: blur(24px) saturate(140%); -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-top: 1px solid var(--line-strong);
  z-index: 50;
}
.nav-inner {
  display: flex;
  width: 100%; max-width: 920px;
  margin: 0 auto;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  font-size: 11px; font-weight: 600;
  color: var(--fg-dim);
  transition: color .15s;
  position: relative;
}
.nav-btn svg { color: var(--fg-dim); transition: color .15s, transform .15s; }
.nav-btn:hover { color: var(--fg-mute); }
.nav-btn:hover svg { color: var(--fg-mute); }
.nav-btn.active { color: var(--fg); }
.nav-btn.active svg { color: var(--fg); transform: scale(1.05); }
.nav-btn.active::before {
  content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: linear-gradient(135deg, var(--hot-1), var(--cold-1));
}

/* Скрываем nav в режиме игры/результата */
body.in-game .nav, body.in-result .nav { display: none; }
body.in-game, body.in-result { padding-bottom: var(--sa-bot); }

/* =====================================================
   ЭКРАНЫ — общий контейнер
===================================================== */
.screen {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; animation: screenIn .35s ease; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-header { margin-bottom: 14px; }
.screen-header h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.screen-header p { margin: 0; font-size: 14px; color: var(--fg-mute); }

/* =====================================================
   HOME
===================================================== */
.screen-home {
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}
.home-hero { text-align: center; padding: 0; }
.home-kicker {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-mute);
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  margin-bottom: 14px;
}
.home-title {
  margin: 0 0 6px;
  font-size: clamp(40px, 9vw, 64px);
  font-weight: 900; letter-spacing: -.03em; line-height: 1;
  background: linear-gradient(95deg, var(--hot-2) 5%, var(--hot-1) 35%, #fff 50%, var(--cold-1) 65%, var(--cold-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-lead { margin: 0; font-size: 16px; color: var(--fg-mute); }

.home-cta { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) {
  .home-cta { grid-template-columns: 1fr 1fr; gap: 12px; }
}
.home-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}

.home-foot {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
  font-size: 12px; color: var(--fg-mute);
}
.foot-divider { color: var(--fg-dim); }
.foot-text { color: var(--fg-mute); }

/* =====================================================
   КНОПКИ CTA / TILE / GHOST
===================================================== */
.cta {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 15px;
  text-align: left;
  transition: transform .12s, background .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.cta:hover { background: rgba(255,255,255,.09); }
.cta:active { transform: scale(.98); }
.cta-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 22px;
  background: rgba(255,255,255,.06);
  flex-shrink: 0;
}
.cta-label { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cta-label strong { font-size: 15px; font-weight: 700; }
.cta-label small { font-size: 12px; color: var(--fg-mute); }
.cta-arrow {
  font-size: 22px; color: var(--fg-mute);
  transition: transform .15s;
}
.cta:hover .cta-arrow { transform: translateX(3px); color: var(--fg); }
.cta-full { width: 100%; justify-content: center; }
.cta-full .cta-label { flex: 0; }

.cta-primary {
  background: linear-gradient(135deg, var(--hot-1), var(--hot-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 30px -12px var(--hot-glow);
}
.cta-primary:hover { background: linear-gradient(135deg, #ff6b48, #ffa84a); }
.cta-primary .cta-icon { background: rgba(255,255,255,.18); }
.cta-primary .cta-label small { color: rgba(255,255,255,.78); }
.cta-primary .cta-arrow { color: rgba(255,255,255,.85); }

.cta-secondary {
  background: linear-gradient(135deg, rgba(91,139,255,.18), rgba(69,232,255,.12));
  border-color: rgba(91,139,255,.35);
}
.cta-secondary:hover { background: linear-gradient(135deg, rgba(91,139,255,.28), rgba(69,232,255,.2)); }

.tile {
  display: flex; align-items: center; gap: 10px;
  padding: 14px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  text-align: left;
  transition: transform .1s, background .15s;
  color: var(--fg);
}
.tile:hover { background: rgba(255,255,255,.07); }
.tile:active { transform: scale(.98); }
.tile-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  font-size: 18px;
  flex-shrink: 0;
}
.tile-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tile-text strong { font-size: 14px; font-weight: 700; }
.tile-text small { font-size: 11px; color: var(--fg-mute); }

.ghost-btn {
  height: 32px; padding: 0 12px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: var(--fg-mute);
  background: transparent;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .12s, background .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--fg); background: rgba(255,255,255,.05); border-color: var(--line-strong); }
.ghost-btn.danger { color: var(--bad); border-color: rgba(255,77,109,.3); }
.ghost-btn.danger:hover { background: rgba(255,77,109,.1); }

/* =====================================================
   GAME — главное место
===================================================== */
.screen-game {
  padding: 12px;
  gap: 10px;
}

.game-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  gap: 10px;
}
.game-prompt {
  font-size: 16px; font-weight: 700;
  letter-spacing: -.01em;
  flex: 1; min-width: 0;
}

.round-timer {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.round-timer-text {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #07101c;
  background: linear-gradient(135deg, var(--hot-2), var(--cold-2));
  box-shadow: 0 0 18px rgba(255,154,58,.28);
}
.round-timer-track {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  min-width: 42px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.08);
}
.round-timer-track i {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(1);
  background: linear-gradient(90deg, var(--hot-2), var(--hot-1), var(--cold-1));
  transition: transform .12s linear, background .18s ease;
}
.round-timer.is-low .round-timer-text {
  background: linear-gradient(135deg, #ff4d6d, #ffc555);
  color: #fff;
  animation: timerPulse .5s ease-in-out infinite alternate;
}
.round-timer.is-low .round-timer-track i {
  background: linear-gradient(90deg, #ff4d6d, #ffc555);
}
@keyframes timerPulse {
  from { transform: scale(1); box-shadow: 0 0 12px rgba(255,77,109,.28); }
  to { transform: scale(1.08); box-shadow: 0 0 24px rgba(255,77,109,.55); }
}
.game-meta { display: flex; gap: 8px; flex-shrink: 0; }
.meta-item {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 11px;
}
.meta-label { color: var(--fg-mute); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.meta-value { font-size: 18px; font-weight: 800; line-height: 1; }
.meta-streak .meta-value { color: var(--hot-2); }

/* Дуэль */
.duel {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  gap: 10px;
  min-height: 0;
  position: relative;
}
@media (min-width: 760px) and (orientation: landscape), (min-width: 900px) {
  .duel {
    grid-template-rows: 1fr;
    grid-template-columns: 1fr auto 1fr;
  }
}

.card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 16px 14px;
  border-radius: var(--r-lg);
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--line-strong);
  color: var(--fg);
  text-align: center;
  cursor: pointer;
  transition: transform .12s, border-color .2s, background .2s;
  overflow: hidden;
  min-height: 0;
}
.card-glow {
  position: absolute; inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
  background: radial-gradient(ellipse at center, var(--card-glow, var(--hot-glow)) 0%, transparent 70%);
}
.card-left { --card-glow: var(--hot-glow); }
.card-right { --card-glow: var(--cold-glow); }
.card-left:hover { border-color: rgba(255,91,58,.45); }
.card-right:hover { border-color: rgba(91,139,255,.45); }
.card:hover .card-glow { opacity: .6; }
.card:active { transform: scale(.98); }

.card-letter {
  position: absolute; top: 12px; left: 14px;
  font-size: 12px; font-weight: 800;
  letter-spacing: .1em;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--fg-mute);
}
.card-left .card-letter { background: linear-gradient(135deg, var(--hot-1), var(--hot-2)); color: #fff; }
.card-right .card-letter { background: linear-gradient(135deg, var(--cold-1), var(--cold-2)); color: #fff; }

.card-emoji {
  font-size: clamp(56px, 14vw, 88px);
  line-height: 1;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.35));
}
.card-title {
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.15;
  max-width: 90%;
}
.card-sub {
  font-size: 12px;
  color: var(--fg-mute);
  text-transform: lowercase;
}
.card-value {
  margin-top: 6px;
  font-size: 14px; font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line-strong);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .25s, transform .25s;
  min-height: 26px;
}
.card.reveal-show .card-value { opacity: 1; transform: translateY(0); }

/* состояние правильно/неправильно */
.card.is-correct {
  border-color: var(--good);
  background: linear-gradient(145deg, rgba(77,212,155,.16), rgba(77,212,155,.04));
  animation: cardCorrect .5s ease;
}
.card.is-correct .card-value { background: rgba(77,212,155,.18); border-color: rgba(77,212,155,.45); color: #b9f5d3; }
.card.is-wrong {
  border-color: var(--bad);
  background: linear-gradient(145deg, rgba(255,77,109,.14), rgba(255,77,109,.03));
  animation: cardWrong .35s ease;
}
.card.is-wrong .card-value { background: rgba(255,77,109,.14); border-color: rgba(255,77,109,.4); color: #ffc1cd; }
.card.dim { opacity: .5; }
.card.is-hint { animation: hintPulse 1.2s ease infinite; }

@keyframes cardCorrect {
  0% { transform: scale(.97); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes cardWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,197,85,.5); }
  50% { box-shadow: 0 0 0 12px rgba(255,197,85,0); }
}

/* VS */
.vs {
  display: grid; place-items: center;
  font-size: 14px; font-weight: 900; letter-spacing: .12em;
  color: var(--fg-mute);
  position: relative;
}
.vs span {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,91,58,.25), rgba(91,139,255,.25));
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
  font-size: 13px;
}

/* Foot tools */
.game-foot {
  display: flex; gap: 8px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.tool {
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, transform .1s;
}
.tool:hover { background: rgba(255,255,255,.09); }
.tool:active { transform: scale(.96); }
.tool small {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(255,154,58,.2);
  color: var(--hot-2);
}
.tool[disabled] { opacity: .45; cursor: not-allowed; }

/* Reveal */
.reveal {
  position: fixed; inset: 0;
  z-index: 60;
  display: grid; place-items: end center;
  background: rgba(8,10,20,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .25s ease;
  padding: 16px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.reveal-card {
  width: 100%; max-width: 480px;
  margin-bottom: calc(var(--sa-bot) + 16px);
  padding: 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(145deg, rgba(26,31,61,.95), rgba(17,20,42,.95));
  border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; gap: 12px;
  animation: revealUp .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes revealUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal-badge {
  display: inline-block;
  font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
  background: linear-gradient(135deg, var(--good), #6ae0b0);
  color: #082416;
  align-self: flex-start;
}
.reveal-badge.is-bad { background: linear-gradient(135deg, var(--bad), #ff7a90); color: #fff; }
.reveal-fact {
  font-size: 15px; line-height: 1.5;
  color: var(--fg);
}
.reveal-hint {
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  margin-top: -4px;
}

/* =====================================================
   RESULT
===================================================== */
.screen-result {
  justify-content: center;
  padding: 16px;
}
.result-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  padding: 24px 18px;
  background: linear-gradient(145deg, rgba(26,31,61,.85), rgba(17,20,42,.85));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  text-align: center;
  animation: resultIn .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes resultIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.result-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-mute);
}
.result-score {
  font-size: clamp(72px, 18vw, 110px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--hot-2), var(--hot-1) 40%, var(--cold-1) 80%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-label {
  font-size: 14px; color: var(--fg-mute);
  margin-bottom: 4px;
}
.result-record {
  display: inline-block;
  font-size: 14px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px;
  background: linear-gradient(135deg, var(--hot-1), var(--hot-2));
  color: #fff;
  margin-bottom: 4px;
  animation: bumpIn .6s ease;
}
@keyframes bumpIn {
  0% { transform: scale(.5); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}
.result-stats {
  display: flex; gap: 16px;
  flex-wrap: wrap; justify-content: center;
  margin: 6px 0 4px;
  font-size: 13px; color: var(--fg-mute);
}
.result-stats > div { display: flex; flex-direction: column; align-items: center; }
.result-stats > div b { color: var(--fg); font-size: 18px; font-weight: 800; }

.result-revive { width: 100%; margin-top: 6px; }

.result-actions {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%;
  margin-top: 8px;
}
@media (min-width: 480px) {
  .result-actions { flex-direction: row; flex-wrap: wrap; }
  .result-actions .cta { flex: 1 1 calc(50% - 4px); }
  .result-actions .ghost-btn { flex: 1 1 100%; justify-content: center; }
}

/* =====================================================
   TOPICS
===================================================== */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.topic-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px;
  padding: 16px 14px;
  border-radius: var(--r-md);
  background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  text-align: left;
  color: var(--fg);
  cursor: pointer;
  transition: transform .12s, background .2s, border-color .2s;
  overflow: hidden;
}
.topic-card:hover { transform: translateY(-2px); background: rgba(255,255,255,.08); border-color: var(--line-strong); }
.topic-card:active { transform: scale(.98); }
.topic-card-emoji { font-size: 32px; line-height: 1; margin-bottom: 4px; }
.topic-card-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.topic-card-meta { font-size: 11px; color: var(--fg-mute); }
.topic-card-best {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(255,154,58,.18);
  color: var(--hot-2);
  display: flex; align-items: center; gap: 3px;
}
.topic-card-best::before { content: "★"; font-size: 9px; }

/* =====================================================
   STATS
===================================================== */
.stats-block {
  margin-bottom: 14px;
  padding: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.block-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.block-head h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--fg); }
.block-head span { font-size: 14px; font-weight: 700; color: var(--fg-mute); }

.big-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 480px) { .big-stats { grid-template-columns: repeat(4, 1fr); } }
.big-stat {
  text-align: center;
  padding: 10px 6px;
  background: rgba(255,255,255,.04);
  border-radius: 12px;
}
.big-stat-value {
  font-size: 28px; font-weight: 900; line-height: 1;
  background: linear-gradient(135deg, var(--hot-2), var(--cold-1));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 4px;
}
.big-stat-label { font-size: 11px; color: var(--fg-mute); }

.bar {
  height: 8px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden;
}
.bar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--hot-1), var(--cold-1));
  width: 0%;
  transition: width .5s ease;
  border-radius: inherit;
}

.pack-stats {
  display: flex; flex-direction: column; gap: 8px;
}
.pack-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border-radius: 12px;
  font-size: 13px;
}
.pack-row-emoji { font-size: 18px; flex-shrink: 0; }
.pack-row-name { flex: 1; font-weight: 600; }
.pack-row-best {
  font-size: 12px; font-weight: 700;
  color: var(--hot-2);
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255,154,58,.15);
}
.pack-row-best.empty { color: var(--fg-dim); background: rgba(255,255,255,.04); }

.account-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  background: rgba(255,255,255,.04);
  border-radius: 12px;
  margin-bottom: 10px;
}
.account-info { flex: 1; min-width: 0; }
.account-info strong { display: block; font-size: 14px; font-weight: 700; }
.account-info small { font-size: 12px; color: var(--fg-mute); }
.stats-actions { display: flex; flex-direction: column; gap: 8px; }
.stats-actions .ghost-btn { align-self: flex-start; }

/* =====================================================
   ДОСТИЖЕНИЯ
===================================================== */
.ach-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 480px) {
  .ach-grid { grid-template-columns: 1fr 1fr; }
}
.ach-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background .15s, border-color .15s;
}
.ach-item.open {
  background: linear-gradient(135deg, rgba(255,154,58,.12), rgba(91,139,255,.08));
  border-color: rgba(255,154,58,.35);
}
.ach-item.locked .ach-emoji { opacity: .5; }
.ach-item.locked .ach-title { color: var(--fg-mute); }
.ach-item.locked .ach-desc { color: var(--fg-dim); }
.ach-emoji {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 22px;
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  flex-shrink: 0;
}
.ach-item.open .ach-emoji {
  background: linear-gradient(135deg, var(--hot-1), var(--hot-2));
  box-shadow: 0 4px 12px -4px var(--hot-glow);
}
.ach-meta { flex: 1; min-width: 0; }
.ach-title { font-size: 13px; font-weight: 700; line-height: 1.2; }
.ach-desc { font-size: 11px; color: var(--fg-mute); line-height: 1.3; margin-top: 2px; }

/* Toast достижения */
.ach-toast {
  position: fixed;
  top: calc(var(--topbar-h) + var(--sa-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-130%);
  width: calc(100% - 28px);
  max-width: 380px;
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(40,46,80,.98), rgba(26,31,61,.98));
  border: 1px solid rgba(255,154,58,.5);
  border-radius: 16px;
  box-shadow: 0 16px 40px -12px var(--hot-glow), 0 0 0 1px rgba(255,255,255,.05) inset;
  z-index: 90;
  opacity: 0;
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .25s;
  pointer-events: none;
}
.ach-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.ach-toast-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, var(--hot-1), var(--hot-2));
  border-radius: 12px;
  flex-shrink: 0;
}
.ach-toast-text { flex: 1; min-width: 0; }
.ach-toast-kicker {
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--hot-2);
}
.ach-toast-title { font-size: 14px; font-weight: 800; margin: 1px 0; }
.ach-toast-desc { font-size: 12px; color: var(--fg-mute); }

/* =====================================================
   ЛИДЕРБОРД
===================================================== */
.lb-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 20px;
  color: var(--fg-mute);
  font-size: 14px;
}
.lb-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 20px;
  text-align: center;
}
.lb-empty-icon {
  font-size: 56px;
  margin-bottom: 4px;
}
.lb-empty-title {
  font-size: 18px; font-weight: 800;
}
.lb-empty-desc {
  font-size: 14px; color: var(--fg-mute);
  max-width: 360px;
  margin-bottom: 8px;
}
.lb-list {
  display: flex; flex-direction: column; gap: 6px;
}
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background .15s;
}
.lb-row.is-me {
  background: linear-gradient(135deg, rgba(255,154,58,.18), rgba(91,139,255,.12));
  border-color: rgba(255,154,58,.5);
}
.lb-rank {
  width: 36px;
  font-size: 14px; font-weight: 800;
  color: var(--fg-mute);
  text-align: center;
  flex-shrink: 0;
}
.lb-row.is-me .lb-rank { color: var(--fg); }
.lb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  flex-shrink: 0;
  object-fit: cover;
}
.lb-avatar-stub {
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--fg-mute);
}
.lb-name {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-me-badge {
  display: inline-block;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 6px; margin-left: 6px;
  border-radius: 6px;
  background: var(--hot-1); color: #fff;
}
.lb-score {
  font-size: 18px; font-weight: 800;
  color: var(--hot-2);
  flex-shrink: 0;
}

/* =====================================================
   MODAL
===================================================== */
.modal {
  position: fixed; inset: 0;
  z-index: 70;
  background: rgba(8,10,20,.7);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center;
  padding: 16px;
  animation: fadeIn .25s ease;
}
.modal[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 460px;
  padding: 22px 18px;
  background: linear-gradient(145deg, rgba(26,31,61,.95), rgba(17,20,42,.95));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  animation: revealUp .3s cubic-bezier(.2,.8,.2,1);
  max-height: 85vh; overflow-y: auto;
}
.modal-card h2 { margin: 0 0 14px; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.modal-kicker {
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 6px;
}

.modal-steps {
  list-style: none;
  padding: 0; margin: 0 0 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal-steps li { display: flex; gap: 12px; }
.modal-steps li > span {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--hot-1), var(--cold-1));
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: #fff;
}
.modal-steps li > div { flex: 1; }
.modal-steps li strong { display: block; font-size: 14px; margin-bottom: 2px; }
.modal-steps li p { margin: 0; font-size: 13px; color: var(--fg-mute); }

/* =====================================================
   TOAST
===================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--sa-bot) + 14px);
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(40,46,80,.96), rgba(26,31,61,.96));
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 600;
  color: var(--fg);
  z-index: 80;
  animation: toastIn .3s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
  pointer-events: none;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
body.in-game .toast, body.in-result .toast {
  bottom: calc(var(--sa-bot) + 14px);
}

/* =====================================================
   Скроллбар (для PC)
===================================================== */
.screen::-webkit-scrollbar { width: 6px; }
.screen::-webkit-scrollbar-track { background: transparent; }
.screen::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.screen::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); }

/* =====================================================
   Адаптивные мелочи
===================================================== */
@media (max-height: 700px) and (orientation: portrait) {
  .home-title { font-size: clamp(36px, 9vw, 56px); }
  .home-hero { margin-bottom: 0; }
  .screen-home { gap: 14px; padding-top: 16px; }
  .card-emoji { font-size: clamp(48px, 13vw, 76px); }
}

/* Десктоп: даём больше воздуха главному экрану */
@media (min-width: 760px) and (orientation: landscape), (min-width: 900px) {
  .duel { gap: 14px; }
  .card { padding: 24px 18px; }
  .card-emoji { font-size: clamp(64px, 8vw, 110px); }
  .card-title { font-size: clamp(20px, 2.4vw, 28px); }
  .vs span { width: 56px; height: 56px; font-size: 14px; }

  .screen-home { gap: 24px; padding-top: 32px; }
  .home-title { font-size: clamp(60px, 6vw, 84px); }
  .home-lead { font-size: 18px; }
  .home-cta .cta { padding: 20px 22px; }
  .home-cta .cta-icon { width: 48px; height: 48px; font-size: 28px; }
  .home-cta .cta-label strong { font-size: 17px; }
  .home-cta .cta-label small { font-size: 13px; }
  .home-grid .tile { padding: 18px; }
  .home-grid .tile-icon { width: 44px; height: 44px; font-size: 22px; }
  .home-grid .tile-text strong { font-size: 16px; }
  .home-grid .tile-text small { font-size: 12px; }
}

/* Fix: на узких экранах градиенты могут давать «пятно» — поджимаем */
@media (max-width: 380px) {
  .bg-hot, .bg-cold { width: 70%; }
}

/* Скрытые элементы */
[hidden] { display: none !important; }

/* =================================================================
   v18 moderation/layout fix
   Goal: page-based UX, no category grids leaking into Home/Game,
   stable fit on desktop resize and mobile landscape.
================================================================= */

/* Screens are now viewport pages, not normal document flow blocks. */
.screen {
  position: fixed;
  top: calc(var(--topbar-h) + var(--sa-top));
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--sa-bot));
  width: 100%;
  max-width: 920px;
  height: auto;
  max-height: none;
  margin: 0 auto;
  padding: clamp(10px, 2vmin, 16px);
  overflow: hidden;
  min-height: 0;
}
.screen.active {
  display: flex;
}

/* Only secondary pages scroll. Home and Game must fit as pages. */
.screen-home,
.screen-game,
.screen-result {
  overflow: hidden;
}
.screen-topics,
.screen-stats,
.screen-leaderboard {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Game/result have no bottom nav, so use the full available height. */
body.in-game .screen-game,
body.in-result .screen-result {
  bottom: var(--sa-bot);
}

/* Home is a compact launch page. Rubrics are only in the Topics tab. */
.screen-home {
  justify-content: center;
  gap: clamp(10px, 2.2vmin, 18px);
}
.home-grid {
  display: none !important;
}
.home-hero {
  max-width: 620px;
  margin: 0 auto;
}
.home-kicker {
  margin-bottom: 8px;
  padding: 4px 10px;
  font-size: 10px;
}
.home-title {
  margin-bottom: 4px;
  font-size: clamp(38px, 9vmin, 72px);
}
.home-lead {
  font-size: clamp(13px, 2.4vmin, 17px);
}
.home-cta {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.home-foot {
  margin-top: 0;
}

/* More predictable CTA heights for small windows. */
.cta {
  min-height: 58px;
}
.home-cta .cta {
  min-height: clamp(58px, 11vmin, 76px);
}

/* Topics page is the only place with rubrics; keep it inside the page. */
.screen-topics .screen-header {
  flex: 0 0 auto;
  margin-bottom: 10px;
}
.screen-topics .screen-header h2 {
  font-size: clamp(19px, 3.5vmin, 24px);
}
.screen-topics .screen-header p {
  font-size: clamp(12px, 2vmin, 14px);
}
.topics-grid {
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.topic-card {
  min-height: 86px;
  padding: 12px;
}
.topic-card-emoji {
  font-size: 24px;
  margin-bottom: 0;
}
.topic-card-title {
  font-size: 14px;
}
.topic-card-meta {
  font-size: 10px;
}

/* Game screen: absolutely no other page content below the duel. */
.screen-game {
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex-direction: column;
  gap: clamp(6px, 1.4vmin, 10px);
  padding: clamp(8px, 1.6vmin, 12px);
}
.screen-game.active {
  display: grid;
}
.game-head {
  min-height: 42px;
  padding: 8px 12px;
}
.game-prompt {
  font-size: clamp(13px, 2.3vmin, 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta-label {
  font-size: 9px;
}
.meta-value {
  font-size: 16px;
}
.duel {
  min-height: 0;
  height: 100%;
}
.card {
  min-height: 0;
  padding: clamp(10px, 2vmin, 16px);
}
.card-emoji {
  font-size: clamp(34px, 10vmin, 76px);
}
.card-title {
  font-size: clamp(15px, 3vmin, 22px);
  line-height: 1.12;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  font-size: clamp(10px, 1.8vmin, 12px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}
.game-foot {
  flex: 0 0 auto;
  min-height: 34px;
  align-items: center;
}
.tool {
  height: 34px;
  padding: 0 12px;
}

/* Landscape phones and short desktop windows are the critical moderation case. */
@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --topbar-h: 44px;
    --nav-h: 50px;
  }
  .topbar-inner {
    padding-inline: 8px;
  }
  .topbar-title {
    font-size: 13px;
  }
  .btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .chip {
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
  }
  .nav-btn {
    font-size: 10px;
    gap: 1px;
  }
  .nav-btn svg {
    width: 18px;
    height: 18px;
  }

  .screen {
    padding: 8px 10px;
  }

  .screen-home {
    display: none;
    grid-template-columns: minmax(220px, .9fr) minmax(300px, 1.1fr);
    grid-template-rows: auto auto;
    align-content: center;
    justify-content: center;
    gap: 10px 16px;
  }
  .screen-home.active {
    display: grid;
  }
  .home-hero {
    text-align: left;
    margin: 0;
    max-width: 340px;
  }
  .home-kicker {
    margin-bottom: 6px;
    font-size: 9px;
  }
  .home-title {
    font-size: clamp(32px, 10vh, 48px);
  }
  .home-lead {
    font-size: 13px;
  }
  .home-cta {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-self: center;
  }
  .home-cta .cta {
    min-height: 72px;
    padding: 12px;
  }
  .home-cta .cta-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  .home-cta .cta-label strong {
    font-size: 14px;
  }
  .home-cta .cta-label small {
    font-size: 11px;
  }
  .home-foot {
    grid-column: 1 / -1;
  }

  .screen-game {
    padding: 6px 8px;
    gap: 6px;
  }
  .game-head {
    min-height: 34px;
    padding: 5px 10px;
    border-radius: 12px;
  }
  .game-prompt {
    font-size: 13px;
  }
  .game-meta {
    gap: 6px;
  }
  .meta-label {
    font-size: 8px;
  }
  .meta-value {
    font-size: 14px;
  }
  .duel {
    grid-template-rows: 1fr;
    grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
    gap: 8px;
  }
  .card {
    border-radius: 16px;
    padding: 8px 10px;
    gap: 2px;
  }
  .card-letter {
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    font-size: 10px;
  }
  .card-emoji {
    font-size: clamp(24px, 10vh, 42px);
  }
  .card-title {
    font-size: clamp(13px, 4.2vh, 18px);
    line-height: 1.05;
    max-width: 86%;
  }
  .card-sub {
    font-size: 10px;
  }
  .card-value {
    min-height: 22px;
    margin-top: 2px;
    padding: 3px 8px;
    font-size: 11px;
  }
  .vs span {
    width: 38px;
    height: 38px;
    font-size: 10px;
  }
  .game-foot {
    min-height: 30px;
  }
  .tool {
    height: 30px;
    font-size: 11px;
    padding: 0 10px;
  }
  .reveal {
    padding: 8px;
  }
  .reveal-card {
    max-width: 520px;
    padding: 12px;
    gap: 8px;
    margin-bottom: 8px;
  }
  .reveal-fact {
    font-size: 13px;
    line-height: 1.35;
  }

  .screen-topics .screen-header,
  .screen-stats .screen-header,
  .screen-leaderboard .screen-header {
    margin-bottom: 8px;
  }
  .topics-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 8px;
  }
  .topic-card {
    min-height: 70px;
    padding: 9px 10px;
    gap: 3px;
  }
  .topic-card-emoji {
    font-size: 20px;
  }
  .topic-card-title {
    font-size: 12px;
  }
  .topic-card-meta {
    font-size: 9px;
  }
}

/* Very small portrait devices: keep Home within one page. */
@media (max-width: 430px) and (orientation: portrait) {
  .screen-home {
    justify-content: center;
    gap: 10px;
  }
  .home-title {
    font-size: clamp(38px, 13vw, 54px);
  }
  .home-lead {
    font-size: 13px;
  }
  .home-cta {
    gap: 8px;
  }
  .home-cta .cta {
    min-height: 62px;
    padding: 12px;
  }
  .cta-icon {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }
  .cta-label strong {
    font-size: 14px;
  }
  .cta-label small {
    font-size: 11px;
  }
}

/* If the window is extremely short, hide decorative text rather than overlap. */
@media (max-height: 390px) {
  .home-kicker,
  .home-foot,
  .card-sub,
  .reveal-hint {
    display: none !important;
  }
  .screen-home {
    gap: 8px;
  }
  .home-title {
    font-size: clamp(30px, 11vh, 42px);
  }
  .home-cta .cta {
    min-height: 56px;
  }
}


/* =====================================================
   v19 moderation pass: timer + stricter page fit
===================================================== */
.game-head { flex-wrap: nowrap; }
.round-timer { max-width: 140px; }

@media (max-width: 520px) {
  .round-timer { flex-basis: 82px; gap: 5px; }
  .round-timer-text { width: 24px; height: 24px; font-size: 12px; }
  .round-timer-track { min-width: 32px; height: 5px; }
  .game-meta { gap: 5px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .round-timer { flex: 0 0 78px; gap: 5px; }
  .round-timer-text { width: 24px; height: 24px; font-size: 11px; }
  .round-timer-track { height: 5px; min-width: 28px; }
  .game-head { min-height: 32px; padding: 4px 8px; gap: 6px; }
  .game-prompt { font-size: 12px; }
  .duel { grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); }
  .vs span { width: 34px; height: 34px; font-size: 9px; }
}

@media (max-height: 360px) {
  .round-timer-track { display: none; }
  .round-timer { flex: 0 0 28px; }
  .game-foot { min-height: 28px; }
  .tool { height: 28px; font-size: 10px; }
  .card-title { -webkit-line-clamp: 1; }
}

/* Keep reveal readable in short windows after timeout/fact text. */
.reveal-card {
  max-height: calc(100vh - var(--topbar-h) - var(--sa-top) - var(--sa-bot) - 24px);
  overflow-y: auto;
}
@media (orientation: landscape) and (max-height: 560px) {
  .reveal-card {
    max-height: calc(100vh - var(--topbar-h) - 16px);
  }
}


/* =================================================================
   v20 moderation hard-fix
   - no browser scroll/swipe-to-refresh in play/result
   - compact result screen for ads/browser chrome/exit fullscreen
   - explicit auth reason and in-game reset approval
================================================================= */
html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none;
}
body {
  min-height: 100dvh;
  max-height: 100dvh;
}
.bg,
.splash,
.topbar,
.nav {
  overscroll-behavior: none !important;
}
.screen {
  max-width: min(920px, 100vw);
  overflow: hidden;
  overscroll-behavior: none !important;
}
.screen-topics,
.screen-stats,
.screen-leaderboard {
  overflow-y: auto;
  overscroll-behavior: contain !important;
  touch-action: pan-y;
  scrollbar-gutter: stable both-edges;
}
.screen-game,
.screen-result,
.screen-home {
  touch-action: none;
}
.reset-note {
  display: block;
  margin-top: 6px;
  color: var(--warn);
  font-size: 11px;
}

/* Result screen must fit even with mobile browser chrome and ad blocks. */
.screen-result {
  justify-content: center;
  align-items: center;
  padding: clamp(8px, 2vmin, 14px);
}
.result-card {
  width: min(100%, 640px);
  max-height: 100%;
  overflow: hidden;
  padding: clamp(14px, 2.4vmin, 22px);
  gap: clamp(5px, 1.1vmin, 8px);
}
.result-score {
  font-size: clamp(46px, 12vmin, 92px);
}
.result-label {
  font-size: clamp(12px, 2.1vmin, 14px);
  margin-bottom: 0;
}
.result-stats {
  margin: 2px 0;
  gap: clamp(10px, 3vmin, 18px);
}
.result-stats > div b {
  font-size: clamp(15px, 3vmin, 18px);
}
.result-revive {
  margin-top: 2px;
}
.result-revive .cta {
  min-height: clamp(48px, 9vmin, 64px);
}
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.result-actions .cta,
.result-actions .ghost-btn {
  width: 100%;
  min-height: clamp(42px, 8vmin, 56px);
  justify-content: center;
}
.result-actions .ghost-btn {
  grid-column: 1 / -1;
}

@media (max-width: 430px) and (orientation: portrait) {
  .screen-result { padding: 8px; }
  .result-card { padding: 14px 12px; border-radius: 20px; }
  .result-kicker { font-size: 10px; }
  .result-score { font-size: clamp(44px, 17vw, 72px); }
  .result-record { font-size: 12px; padding: 5px 10px; }
  .result-actions { gap: 7px; }
  .result-actions .cta-icon { width: 30px; height: 30px; font-size: 17px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  body.in-result .screen-result { bottom: var(--sa-bot); }
  .screen-result {
    padding: 6px 8px;
  }
  .result-card {
    width: min(100%, 760px);
    max-height: 100%;
    padding: 8px 10px;
    gap: 3px;
    border-radius: 16px;
  }
  .result-kicker { display: none; }
  .result-score {
    font-size: clamp(36px, 17vh, 58px);
  }
  .result-label {
    font-size: 11px;
  }
  .result-record {
    font-size: 11px;
    padding: 4px 8px;
    margin: 0;
  }
  .result-stats {
    gap: 12px;
    margin: 0;
    font-size: 11px;
  }
  .result-stats > div b {
    font-size: 14px;
  }
  .result-revive .cta {
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 14px;
  }
  .result-actions {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 2px;
  }
  .result-actions .ghost-btn {
    grid-column: auto;
  }
  .result-actions .cta,
  .result-actions .ghost-btn {
    min-height: 34px;
    padding: 5px 8px;
    border-radius: 13px;
    font-size: 12px;
  }
  .result-actions .cta-icon,
  .result-revive .cta-icon {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }
  .result-actions .cta-label small,
  .result-revive .cta-label small {
    display: none;
  }
}

@media (max-height: 420px) and (orientation: portrait) {
  .result-kicker,
  .result-record:not([hidden]) + .result-stats {
    margin-top: 0;
  }
  .result-score { font-size: 42px; }
  .result-stats { font-size: 11px; }
  .result-revive .cta { min-height: 42px; }
  .result-actions .cta,
  .result-actions .ghost-btn { min-height: 36px; }
}

#btnShare[hidden] { display: none !important; }
