/* ============ Design tokens ============
   Временный нейтрально-премиальный тёмный UI.
   Визуальный слой заменяется целиком правкой токенов и этого файла —
   логика и разметка от него не зависят. */
:root {
  --bg: #14101c;
  --bg-card: #1e1730;
  --bg-raised: #2a2140;
  --text: #f4eefb;
  --text-dim: #a99cc2;
  --accent: #ff4d7d;          /* основной акцент */
  --accent-press: #e03b68;
  --player-a: #ff4d7d;        /* цвет хода игрока 1 */
  --player-b: #7c6cff;        /* цвет хода игрока 2 */
  --danger: #ff6b6b;
  --radius: 20px;
  --radius-sm: 12px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 20px;
  --space-4: 32px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-question: clamp(1.5rem, 4.2vh, 2.1rem);
  --fs-player: clamp(1.1rem, 2.6vh, 1.4rem);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --t-fast: 150ms;
  --t-card: 260ms;
  --ease: cubic-bezier(.2, .8, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 80% -10%, #2b1a3a 0%, transparent 60%);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + var(--space-3)) calc(env(safe-area-inset-right) + var(--space-3)) calc(env(safe-area-inset-bottom) + var(--space-3)) calc(env(safe-area-inset-left) + var(--space-3));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
/* Авторский display (flex/grid) перебивает браузерный [hidden] — возвращаем силу атрибуту. */
[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  min-height: 48px;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { background: var(--bg-raised); color: var(--text-dim); cursor: default; }
.btn-secondary { background: var(--bg-raised); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-danger-text { color: var(--danger); }
.btn-big { width: 100%; font-size: 1.15rem; min-height: 56px; }
.btn-icon {
  font: inherit; font-size: 1.2rem; color: var(--text-dim);
  background: transparent; border: 0; cursor: pointer;
  min-width: 44px; min-height: 44px; border-radius: var(--radius-sm);
}

/* ---------- Setup ---------- */
.setup-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: var(--space-3); }
.logo { font-size: 3.4rem; font-weight: 800; letter-spacing: -.03em; text-align: center; }
.logo-dot { color: var(--accent); }
.tagline { text-align: center; color: var(--text-dim); line-height: 1.5; }
#form-players { display: flex; flex-direction: column; gap: var(--space-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .85rem; color: var(--text-dim); font-weight: 600; }
.field input {
  font: inherit; font-size: 1.15rem; color: var(--text);
  background: var(--bg-card); border: 1.5px solid var(--bg-raised);
  border-radius: var(--radius-sm); padding: 14px 16px; min-height: 52px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.player-a-text { color: var(--player-a); }
.player-b-text { color: var(--player-b); }

.resume-banner {
  background: var(--bg-card); border-radius: var(--radius);
  padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2);
  box-shadow: var(--shadow);
}
.resume-banner p { text-align: center; color: var(--text-dim); }

/* ---------- Категории ---------- */
.screen-header { display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-1); }
.screen-header h2 { font-size: 1.4rem; }
.hint { color: var(--text-dim); font-size: .9rem; margin-bottom: var(--space-3); }
.category-list { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; overflow-y: auto; }
.cat {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--bg-card); border: 1.5px solid var(--bg-raised);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: border-color var(--t-fast);
  -webkit-user-select: none; user-select: none;
}
.cat input { position: absolute; opacity: 0; pointer-events: none; }
.cat.checked { border-color: var(--accent); background: var(--bg-raised); }
.cat-emoji { font-size: 1.5rem; }
.cat-body { flex: 1; min-width: 0; }
.cat-name { font-weight: 700; }
.cat-desc { font-size: .82rem; color: var(--text-dim); }
.cat-count { font-size: .82rem; color: var(--text-dim); white-space: nowrap; }
.cat-check {
  width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--text-dim); display: grid; place-items: center;
  font-size: .9rem; color: transparent; flex-shrink: 0;
}
.cat.checked .cat-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.pool-bar { padding-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.pool-count { text-align: center; color: var(--text-dim); font-size: .95rem; min-height: 1.4em; }
.pool-count.warn { color: var(--danger); }

/* ---------- Игра ---------- */
.game-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.game-progress { color: var(--text-dim); font-size: .9rem; font-weight: 600; }
.card-zone { flex: 1; display: grid; place-items: center; min-height: 0; }
.qcard {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4) var(--space-3);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  text-align: center;
  border-top: 4px solid var(--player-a);
  min-height: 46dvh;
  justify-content: center;
}
.qcard.player-b { border-top-color: var(--player-b); }
.qcard.player-b .q-player { color: var(--player-b); }
.q-player {
  font-size: var(--fs-player); font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--player-a);
  overflow-wrap: anywhere;
}
.q-text { font-size: var(--fs-question); font-weight: 700; line-height: 1.3; overflow-wrap: break-word; }
.q-category {
  font-size: .85rem; color: var(--text-dim);
  background: var(--bg-raised); border-radius: 999px; padding: 6px 14px;
}
.qcard.swap { animation: cardswap var(--t-card) var(--ease); }
@keyframes cardswap {
  0% { opacity: 0; transform: translateY(14px) scale(.98); }
  100% { opacity: 1; transform: none; }
}
.game-actions { display: flex; gap: var(--space-2); padding-top: var(--space-3); }
#btn-skip { flex: 0 0 auto; }
#btn-next { flex: 1; }

.exhausted { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; text-align: center; }
.exhausted-title { font-size: 1.3rem; font-weight: 700; margin-bottom: var(--space-2); line-height: 1.4; }

/* ---------- Диалоги ---------- */
.dlg {
  margin: auto; border: 0; border-radius: var(--radius);
  background: var(--bg-card); color: var(--text);
  padding: var(--space-3); width: min(92vw, 420px);
  box-shadow: var(--shadow);
}
.dlg::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.dlg-title { font-size: 1.2rem; font-weight: 800; margin-bottom: var(--space-2); }
.dlg-text { color: var(--text-dim); line-height: 1.5; margin-bottom: var(--space-3); }
.dlg-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.dlg-stack { display: flex; flex-direction: column; gap: var(--space-2); }
.history-list { list-style: none; max-height: 50dvh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }
.history-list li { border-left: 3px solid var(--bg-raised); padding-left: var(--space-2); }
.history-list .h-player { font-size: .8rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.history-list .h-player.pa { color: var(--player-a); }
.history-list .h-player.pb { color: var(--player-b); }
.history-list .h-skipped { opacity: .55; }
.history-empty { color: var(--text-dim); text-align: center; }

/* ---------- Доступность ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Десктоп: карточка не расползается */
@media (min-width: 700px) {
  .qcard { min-height: 380px; }
}
