:root {
  color-scheme: light;
  --bg-top: #f7fafc;
  --bg-bottom: #eef2f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --text: #13202f;
  --muted: #58677a;
  --line: rgba(19, 32, 47, 0.12);
  --line-soft: rgba(19, 32, 47, 0.08);
  --brand: #1f6feb;
  --brand-soft: rgba(31, 111, 235, 0.14);
  --ok: #16794b;
  --ok-soft: rgba(22, 121, 75, 0.15);
  --bad: #c73a3a;
  --bad-soft: rgba(199, 58, 58, 0.14);
  --warn: #b15f07;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-lg: 0 24px 56px rgba(14, 27, 43, 0.14);
  --shadow-sm: 0 6px 18px rgba(14, 27, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.45;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Georgia", serif;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg::before,
.bg::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(46px);
  opacity: 0.6;
  animation: drift 16s ease-in-out infinite alternate;
}

.bg::before {
  width: 420px;
  height: 420px;
  left: -120px;
  top: -80px;
  background: rgba(31, 111, 235, 0.16);
}

.bg::after {
  width: 460px;
  height: 460px;
  right: -130px;
  bottom: -120px;
  animation-delay: 2s;
  background: rgba(22, 121, 75, 0.12);
}

@keyframes drift {
  from {
    transform: translateY(-8px) scale(1);
  }
  to {
    transform: translateY(12px) scale(1.08);
  }
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 20px 72px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
  animation: fade-up 0.45s ease both;
}

.hero h1 {
  font-size: clamp(30px, 4vw, 44px);
}

.subtitle {
  max-width: 700px;
  color: var(--muted);
  font-size: 17px;
}

.badge {
  align-self: flex-start;
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--brand-soft);
  color: #0f4bb0;
  border: 1px solid rgba(31, 111, 235, 0.22);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge.alt {
  background: rgba(22, 121, 75, 0.12);
  color: #0f5b39;
  border-color: rgba(22, 121, 75, 0.22);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  backdrop-filter: blur(7px);
  animation: fade-up 0.45s ease both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none;
}

.join-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

input[type="text"] {
  flex: 1 1 260px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 11px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus {
  border-color: rgba(31, 111, 235, 0.42);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.14);
}

button {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary {
  color: #fff;
  background: linear-gradient(130deg, #1f6feb, #3e89f1);
}

.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--line);
}

.danger {
  color: #fff;
  background: linear-gradient(130deg, #a92929, #d74444);
}

.error {
  margin-top: 8px;
  color: var(--bad);
  font-size: 14px;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  padding: 6px 10px;
}

.question-title {
  font-size: clamp(24px, 2.8vw, 32px);
  margin-bottom: 12px;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.options button {
  text-align: left;
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.options button.selected {
  background: var(--brand-soft);
  border-color: rgba(31, 111, 235, 0.28);
}

.options button.answer-correct {
  background: var(--ok-soft);
  border-color: rgba(22, 121, 75, 0.35);
  color: #124e33;
}

.options button.answer-wrong {
  background: var(--bad-soft);
  border-color: rgba(199, 58, 58, 0.3);
  color: #822727;
}

.answer-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.answer-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.answer-item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  padding: 12px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
}

.answer-item.correct {
  border-color: rgba(22, 121, 75, 0.35);
  background: linear-gradient(135deg, rgba(22, 121, 75, 0.16), rgba(255, 255, 255, 0.9));
}

.answer-item.wrong {
  border-color: rgba(199, 58, 58, 0.3);
  background: linear-gradient(135deg, rgba(199, 58, 58, 0.14), rgba(255, 255, 255, 0.9));
}

.answer-mark {
  font-weight: 700;
  color: var(--muted);
}

.answer-chip {
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid transparent;
}

.answer-chip.mine {
  color: #0f4bb0;
  border-color: rgba(31, 111, 235, 0.35);
  background: rgba(31, 111, 235, 0.1);
}

.answer-chip.correct {
  color: #0f5b39;
  border-color: rgba(22, 121, 75, 0.35);
  background: rgba(22, 121, 75, 0.1);
}

.answer-chip.wrong {
  color: #822727;
  border-color: rgba(199, 58, 58, 0.32);
  background: rgba(199, 58, 58, 0.09);
}

.leaderboard {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.leaderboard .row {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  animation: fade-up 0.35s ease both;
}

.leaderboard .score {
  font-weight: 800;
}

.admin {
  max-width: 1120px;
}

.admin .subtitle {
  max-width: 860px;
}

.admin-controls {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 8px;
}

.admin-controls button {
  width: 100%;
  min-height: 42px;
}

.admin .leaderboard .row {
  grid-template-columns: 1fr auto auto auto;
}

.admin-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.admin-state-card {
  display: grid;
  gap: 14px;
}

.admin-state-question {
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.correct-text {
  color: var(--ok);
  font-weight: 700;
}

.screen-body {
  overflow: hidden;
}

.screen {
  min-height: 100vh;
  padding: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide {
  width: min(1240px, 100%);
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 36px;
  display: grid;
  gap: 24px;
  animation: fade-up 0.45s ease both;
}

.slide-header h1 {
  margin-top: 10px;
  font-size: clamp(36px, 4vw, 58px);
}

.slide-header p {
  margin-top: 10px;
  font-size: clamp(16px, 2vw, 24px);
  color: var(--muted);
}

.qr-block {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
}

.qr-block img {
  width: 260px;
  height: 260px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.qr-url {
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 700;
  word-break: break-word;
}

.options-big {
  display: grid;
  gap: 12px;
}

.option-row {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.84);
  padding: 14px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  font-size: clamp(18px, 2vw, 30px);
}

.option-row.correct {
  background: linear-gradient(135deg, rgba(22, 121, 75, 0.2), rgba(255, 255, 255, 0.92));
  border-color: rgba(22, 121, 75, 0.42);
}

.option-row.wrong {
  background: linear-gradient(135deg, rgba(199, 58, 58, 0.17), rgba(255, 255, 255, 0.92));
  border-color: rgba(199, 58, 58, 0.34);
}

.option-letter {
  border-radius: 10px;
  text-align: center;
  font-weight: 800;
  padding: 4px 0;
  background: rgba(19, 32, 47, 0.08);
}

@media (max-width: 1024px) {
  .admin-controls {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 820px) {
  .app {
    padding: 26px 14px 48px;
  }
  .card {
    padding: 16px;
    border-radius: 18px;
  }
  .leaderboard .row {
    grid-template-columns: 1fr auto;
  }
  .admin .leaderboard .row {
    grid-template-columns: 1fr auto;
  }
  .screen {
    padding: 14px;
  }
  .slide {
    padding: 18px;
    border-radius: 20px;
  }
  .qr-block {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .qr-block img {
    width: 220px;
    height: 220px;
  }
  .admin-controls {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
