:root {
  --bg-body: #050505;
  --bg-gradient-top: #141414;
  --bg-card: rgba(0, 0, 0, 0.8);
  --border-card: rgba(255, 255, 255, 0.07);
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.7);
  --text-main: #f5f5f5;
  --text-muted: rgba(245, 245, 245, 0.75);
  --text-soft: rgba(245, 245, 245, 0.9);
  --accent: #ffd400;
  --accent-text: #111111;
  --btn-secondary-bg: #333333;
  --btn-secondary-text: #f5f5f5;
  --btn-ghost-border: #444444;
  --btn-danger-bg: #b3261e;
  --answer-card-bg: linear-gradient(135deg, #ffd400, #ffae00);
  --answer-card-hidden-bg: repeating-linear-gradient(
    90deg,
    #f5c400 0,
    #f5c400 10px,
    #ffdf6a 10px,
    #ffdf6a 20px
  );
  --team-card-bg: linear-gradient(135deg, #1d1d1d, #000000);
  --team-card-border: rgba(255, 255, 255, 0.08);
  --input-bg: #111111;
  --input-border: #444444;
  --header-border: transparent;
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Светлая тема */
:root[data-theme="light"] {
  --bg-body: #f3f4f6;
  --bg-gradient-top: #ffffff;
  --bg-card: #ffffff;
  --border-card: rgba(15, 23, 42, 0.08);
  --shadow-card: 0 12px 30px rgba(15, 23, 42, 0.08);
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-soft: #374151;
  --accent: #f59e0b;
  --accent-text: #111827;
  --btn-secondary-bg: #e5e7eb;
  --btn-secondary-text: #111827;
  --btn-ghost-border: #d1d5db;
  --btn-danger-bg: #b91c1c;
  --answer-card-bg: linear-gradient(135deg, #fbbf24, #f59e0b);
  --answer-card-hidden-bg: repeating-linear-gradient(
    90deg,
    #fee9a3 0,
    #fee9a3 10px,
    #fde68a 10px,
    #fde68a 20px
  );
  --team-card-bg: linear-gradient(135deg, #f9fafb, #e5e7eb);
  --team-card-border: rgba(15, 23, 42, 0.08);
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --header-border: rgba(15, 23, 42, 0.06);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(circle at top, var(--bg-gradient-top) 0, var(--bg-body) 60%);
  color: var(--text-main);
}

header {
  width: 100%;
  max-width: 960px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--header-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

header .back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

header .back-link:hover {
  filter: brightness(1.1);
}

header .title {
  font-size: 20px;
  font-weight: 600;
}

main {
  width: 100%;
  max-width: 960px;
  padding: 16px;
  flex: 1;
}

h1 {
  font-size: 26px;
  margin: 0 0 8px 0;
}

p.note {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px 0;
}

.card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--btn-ghost-border);
  color: var(--text-soft);
}

.btn-danger {
  background: var(--btn-danger-bg);
  color: #ffffff;
}

.btn + .btn {
  margin-left: 8px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.theme-toggle-label {
  font-size: 13px;
  color: var(--text-muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.team-card {
  min-width: 200px;
  padding: 10px;
  border-radius: 10px;
  background: var(--team-card-bg);
  border: 1px solid var(--team-card-border);
}

.team-name-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 4px 8px;
  margin-bottom: 4px;
}

.team-name-display {
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 4px;
}

.team-score {
  font-size: 28px;
  font-weight: 800;
}

.round-info {
  min-width: 160px;
  text-align: right;
}

.round-info .round-number {
  font-size: 22px;
  font-weight: 700;
}

.round-info .round-points {
  font-size: 16px;
  margin-top: 4px;
}

.question-text {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-top: 4px;
}

.question-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 6px 8px;
  box-sizing: border-box;
  resize: vertical;
}

/* ТВ-табло на экране игроков */

.player-board-wrapper {
  display: flex;
  justify-content: center;
}

.player-board {
  width: 100%;
  max-width: 720px;
  padding: 12px;
  border-radius: 16px;
  background: radial-gradient(circle at top, #1f2933 0, #020617 70%);
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.player-board-header {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--accent);
}

.player-board-center {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.player-board-side {
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.player-board-side-score {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  background: #c1121f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: #ffe8e8;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6);
}

.player-board-side-crosses {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.player-board-cross {
  width: 60px;
  height: 26px;
  border-radius: 8px;
  background: #ffe4b5;
  position: relative;
  overflow: hidden;
}

.player-board-cross::before,
.player-board-cross::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 4px;
  background: #d41919;
}

.player-board-cross::before {
  top: 8px;
  transform: rotate(38deg);
}

.player-board-cross::after {
  bottom: 8px;
  transform: rotate(-38deg);
}

/* центр – 6 полос как на табло */

.player-board-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-answer-row {
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.8);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.7);
  display: flex;
}

.player-answer-row-inner {
  flex: 1;
  display: flex;
  align-items: stretch;
}

.player-answer-number {
  width: 56px;
  background: #b91c1c;
  color: #ffe8e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
}

.player-answer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--answer-card-hidden-bg);
  color: var(--accent-text);
}

.player-answer-body.revealed {
  background: var(--answer-card-bg);
}

.player-answer-text {
  font-size: 18px;
  font-weight: 700;
}

.player-answer-score {
  font-size: 20px;
  font-weight: 800;
}

/* старые общие стили для таблиц и форм (host/decks) */

.answers-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 14px;
}

.answers-table th,
.answers-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  text-align: left;
}

.answers-table th {
  font-weight: 500;
  color: var(--text-soft);
}

.answers-table tr:last-child td {
  border-bottom: none;
}

.answer-text-input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 4px 6px;
}

.answer-value-input {
  width: 70px;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-main);
  padding: 4px 6px;
}

.answers-player-grid {
  display: none; /* больше не используется напрямую – работаем через player-board */
}

.round-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.small-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

ul {
  margin-top: 8px;
  padding-left: 18px;
  color: var(--text-soft);
}

@media (max-width: 720px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .round-info {
    text-align: left;
  }

  .player-board-center {
    flex-direction: column;
    align-items: center;
  }

  .player-board-side {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
  }
}

/* --- ДОП. ПАТЧ ДЛЯ АНИМАЦИИ И КРЕСТОВ --- */

.player-board-cross {
  opacity: 0.2;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.player-board-cross.used {
  opacity: 1;
  transform: scale(1.02);
}

.player-answer-body {
  transition: background 0.25s ease-out, transform 0.25s ease-out,
    box-shadow 0.25s ease-out, opacity 0.25s ease-out;
}

.player-answer-body .player-answer-text,
.player-answer-body .player-answer-score {
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.player-answer-body.revealed .player-answer-text,
.player-answer-body.revealed .player-answer-score {
  opacity: 1;
}

.player-answer-body.revealed.just-revealed {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.6);
}

/* === ПОЛНОЭКРАННОЕ ТАБЛО ДЛЯ ЭКРАНА ИГРОКОВ === */

.player-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: radial-gradient(circle at top, var(--bg-gradient-top) 0, var(--bg-body) 60%);
  color: var(--text-main);
}

.player-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

/* Ширина/высота табло под размер окна:
   - по ширине максимум 1280px
   - по высоте стараемся вписаться, чтобы всё влезло
*/
.player-board-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-board {
  width: min(100vw - 32px, 1280px);
  padding: 16px;
}

/* Вопрос крупнее – в верхней полосе */
.player-board-header {
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
}

/* Чуть крупнее цифры и ответы, чтобы на большом экране читалось нормально */
.player-answer-number {
  font-size: clamp(22px, 2.6vw, 30px);
}

.player-answer-text {
  font-size: clamp(18px, 2.4vw, 26px);
}

.player-answer-score {
  font-size: clamp(18px, 2.4vw, 26px);
}

/* Счёт тоже подвинем чуть вверх по размеру */
.player-board-side-score {
  font-size: clamp(32px, 4vw, 44px);
}

/* === FULLSCREEN FIX: идеальное центрирование табло === */

.player-body {
  margin: 0;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;       /* по вертикали центр */
  justify-content: center;   /* по горизонтали центр */
  padding: 0;
}

.player-main {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;       /* вертикаль */
  justify-content: center;   /* горизонталь */
  padding: 0 !important;
}

.player-board-wrapper {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-board {
  transform-origin: center center;
}

/* делаем табло пропорциональным (как ТВ-картинка) */
.player-board {
  aspect-ratio: 16 / 9;
  height: min(90vh, 90vw * 9 / 16);
  width: auto;
  max-width: 90vw;
}

/* Убираем тень/паддинги если мешают */
.player-board {
  margin: 0 !important;
}


/* === ТЮНИНГ ТАБЛО ИГРОКОВ (v2) ===========================
   - уменьшаем пустое чёрное поле внизу
   - делаем строки выше и жирнее
   - увеличиваем крестики
   - вопрос чуть крупнее и компактнее по вертикали
   Всё это идёт в конце файла и перекрывает прошлые правила.
   ========================================================= */

.player-main {
  padding: 0;
}

/* Табло без жёсткого 16:9: высота = контент + отступы,
   центрирование остаётся за счёт flex в .player-body/.player-main */
.player-board {
  aspect-ratio: auto !important;
  height: auto !important;
  max-width: min(1280px, 96vw);
  width: 100%;
  padding: 18px 26px;
}

/* Вопрос: крупнее, но без огромного отступа снизу */
.player-board-header {
  font-size: clamp(24px, 3.4vw, 36px);
  margin-bottom: 10px;
}

/* Чуть плотнее блок центра */
.player-board-center {
  margin-top: 2px;
}

/* Линии ближе друг к другу и выше */
.player-board-lines {
  gap: 10px;
}

/* Строки ответов повыше, чтобы заполняли таблицу,
   и немного крупнее визуально */
.player-answer-row {
  height: clamp(64px, 9vh, 88px);
}

/* Номер и текст/очки чуть жирнее на большем табло */
.player-answer-number {
  font-size: clamp(24px, 2.7vw, 32px);
}

.player-answer-text {
  font-size: clamp(19px, 2.5vw, 28px);
}

.player-answer-score {
  font-size: clamp(19px, 2.5vw, 28px);
}

/* Крестики: побольше и ярче */
.player-board-side-crosses {
  gap: 6px;
}

.player-board-cross {
  width: 76px;
  height: 32px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* Активный крест – поярче */
.player-board-cross.used {
  opacity: 1;
  transform: scale(1.03);
}

/* Чуть подтягиваем нижнюю «ямку» – внутри табло почти нет пустоты */
.player-board-wrapper {
  align-items: flex-start;
}

/* На совсем маленьких экранах немного снижаем высоту строк,
   чтобы всё влезло по высоте */
@media (max-height: 650px) {
  .player-answer-row {
    height: clamp(54px, 8vh, 72px);
  }
}

/* === ТВ-ГЛОУ И ДОП. ПОЛИРОВКА ТАБЛО ===================== */

/* Табло как “панель” над полом: лёгкий блик-отражение снизу */
.player-board-wrapper {
  position: relative;
}

/* сама панель */
.player-board {
  position: relative;
  border-radius: 24px;
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.04);
}

/* псевдо-отражение под табло */
.player-board-wrapper::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -6%;
  height: 26%;
  background: radial-gradient(
    ellipse at top,
    rgba(0, 0, 0, 0.6) 0,
    transparent 55%
  );
  filter: blur(8px);
  opacity: 0.9;
  pointer-events: none;
}

/* Вопрос – “дышащий” заголовок, но очень мягко, чтобы не бесило */
@keyframes questionPulse {
  0% {
    text-shadow: 0 0 10px rgba(255, 212, 0, 0.3);
    transform: translateY(0);
  }
  50% {
    text-shadow: 0 0 18px rgba(255, 212, 0, 0.7);
    transform: translateY(-1px);
  }
  100% {
    text-shadow: 0 0 10px rgba(255, 212, 0, 0.3);
    transform: translateY(0);
  }
}

.player-board-header {
  letter-spacing: 0.5px;
  animation: questionPulse 3.4s ease-in-out infinite;
}

/* Счётчики по бокам – крупнее и объёмнее */
.player-board-side-score {
  font-size: clamp(34px, 4.4vw, 48px);
  border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, #ff4b4b 0, #c1121f 45%, #7f1010 100%);
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.7),
    0 0 0 2px rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.4);
}

/* активные кресты – немного ярче и “глянцевее” */
.player-board-cross {
  background: linear-gradient(to bottom, #ffe6b5 0, #f8c88b 100%);
}

.player-board-cross::before,
.player-board-cross::after {
  background: #d41919;
}

.player-board-cross.used {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.75);
}

/* немного больше контраста у жёлтых полос, чтобы не сливались с фоном */
.player-answer-body {
  border-top: 1px solid rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(0, 0, 0, 0.4);
}

.player-answer-body.revealed {
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}

/* На очень маленьких высотах слегка ослабляем анимацию заголовка,
   чтобы не прыгало сильно */
@media (max-height: 650px) {
  .player-board-header {
    animation-duration: 4.2s;
  }
}
