:root {
  --bg: #0f1923;
  --card: #1a2733;
  --accent: #e8a838;
  --accent2: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #2d3d4d;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.container { max-width: 800px; width: 100%; padding: 20px; }
h1 { text-align: center; color: var(--accent); font-size: 2rem; margin: 20px 0 10px; }
h2 { color: var(--accent); margin-bottom: 15px; font-size: 1.3rem; }
.subtitle { text-align: center; color: var(--muted); margin-bottom: 30px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
}
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--accent2); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.screen { display: none; }
.screen.active { display: block; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; color: var(--muted); margin-bottom: 6px; font-size: 0.9rem; }
.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.file-drop {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  color: var(--muted);
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); color: var(--accent); }
.file-drop input { display: none; }
.loaded-info { margin-top: 10px; color: var(--green); font-weight: 600; }

.team-list { list-style: none; margin: 10px 0; }
.team-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
}
.team-list li.selected { border-color: var(--accent); background: rgba(232,168,56,0.1); }
.team-list li .team-name { font-weight: 600; }
.team-list li .team-score { color: var(--muted); font-size: 0.85rem; }

.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.quiz-progress { color: var(--muted); font-size: 0.9rem; }
.timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: right;
}
.timer.warning { color: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { opacity: 0.5; } }
.timer-bar { height: 4px; background: var(--border); border-radius: 2px; margin-bottom: 20px; overflow: hidden; }
.timer-bar-fill { height: 100%; background: var(--accent); transition: width 1s linear; border-radius: 2px; }
.timer-bar-fill.warning { background: var(--red); }

.question-text { font-size: 1.15rem; line-height: 1.5; margin-bottom: 20px; }
.question-media { margin-bottom: 15px; border-radius: 8px; overflow: hidden; max-height: 300px; }
.question-media img, .question-media video {
  max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px;
}
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  padding: 14px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  text-align: left;
  color: var(--text);
}
.option:hover:not(.disabled) { border-color: var(--accent); background: rgba(232,168,56,0.05); }
.option.selected { border-color: var(--accent2); background: rgba(59,130,246,0.1); }
.option.correct { border-color: var(--green); background: rgba(34,197,94,0.15); }
.option.wrong { border-color: var(--red); background: rgba(239,68,68,0.15); }
.option.disabled { cursor: default; opacity: 0.7; }
.option.disabled.correct { opacity: 1; }

.explanation {
  margin-top: 15px;
  padding: 14px;
  background: rgba(59,130,246,0.08);
  border-left: 3px solid var(--accent2);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.quiz-nav { display: flex; justify-content: flex-end; margin-top: 20px; }

.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px; }
.stat-card { background: var(--bg); border-radius: 10px; padding: 18px; text-align: center; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.results-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.results-table th {
  background: var(--bg); padding: 10px 8px; text-align: left;
  color: var(--muted); font-weight: 600; position: sticky; top: 0; z-index: 1;
}
.results-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.results-table tr:hover td { background: rgba(255,255,255,0.02); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 0.8rem; }
.badge-correct { background: rgba(34,197,94,0.2); color: var(--green); }
.badge-wrong { background: rgba(239,68,68,0.2); color: var(--red); }
.badge-timeout { background: rgba(234,179,8,0.2); color: #eab308; }
.table-wrap { max-height: 500px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--border); }
.results-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.hidden { display: none !important; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }

@media (max-width: 600px) {
  .stats-summary { grid-template-columns: 1fr; }
  .results-table { font-size: 0.75rem; }
  .results-table th, .results-table td { padding: 6px 4px; }
  h1 { font-size: 1.5rem; }
}
/* Компактная строка настроек на главной */
.setup-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
}
.setup-row .form-group { margin-bottom: 0; }
#teamSelect {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
#teamSelect:focus { outline: none; border-color: var(--accent); }

@media (max-width: 600px) {
  .setup-row { grid-template-columns: 1fr; }
}