:root {
  --bg: #eaf1ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --surface-muted: #f4f7ff;
  --text: #172033;
  --muted: #63708b;
  --accent: #2f80ed;
  --accent-soft: #d8e9ff;
  --success: #1f9d55;
  --danger: #d94f4f;
  --warning: #d08b00;
  --shadow: 0 20px 60px rgba(22, 35, 58, 0.12);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family:
    "Segoe UI",
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

body[data-appearance="dark"] {
  --bg: #111927;
  --surface: rgba(19, 30, 47, 0.96);
  --surface-strong: #172234;
  --surface-muted: #1e2c44;
  --text: #f4f7ff;
  --muted: #a8b3cb;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

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

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

body {
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 55%, #ffffff) 0%, var(--bg) 100%);
  color: var(--text);
  user-select: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#app {
  min-height: 100dvh;
}

button,
a,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
}

.page-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 16px calc(92px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.headline {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
  color: var(--muted);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-chip--ready {
  color: var(--success);
  background: color-mix(in srgb, var(--surface-strong) 85%, #dbf8e7);
}

.status-chip--scaffold {
  color: var(--warning);
  background: color-mix(in srgb, var(--surface-strong) 84%, #fff0ca);
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-card,
.section-card,
.question-card,
.modal-card {
  padding: 22px;
}

.hero-card {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy {
  display: grid;
  gap: 12px;
}

.hero-title {
  margin: 0;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.hero-description {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.hero-actions,
.section-actions,
.question-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 700;
  transition:
    transform 0.16s ease,
    opacity 0.16s ease,
    background 0.16s ease;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--secondary {
  background: var(--surface-muted);
  color: var(--text);
}

.button--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
}

.button[disabled] {
  opacity: 0.55;
  cursor: default;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}

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

.section-title {
  margin: 0 0 14px;
  font-size: 18px;
}

.section-text {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 15%, transparent);
}

.progress-value {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 60%, #ffffff) 100%);
}

.question-card {
  display: grid;
  gap: 18px;
}

.question-index {
  color: var(--muted);
  font-size: 13px;
}

.question-text {
  margin: 0;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

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

.option {
  width: 100%;
  padding: 18px;
  border-radius: var(--radius-md);
  text-align: left;
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--muted) 13%, transparent);
}

.option--selected {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.option--correct {
  background: color-mix(in srgb, #dff6e7 68%, var(--surface-strong));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--success) 80%, #ffffff);
}

.option--wrong {
  background: color-mix(in srgb, #ffe2e2 72%, var(--surface-strong));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--danger) 72%, #ffffff);
}

.option--disabled {
  opacity: 0.4;
}

.answer-feedback {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  line-height: 1.45;
}

.answer-feedback strong {
  display: block;
  margin-bottom: 8px;
}

.two-column {
  display: grid;
  gap: 18px;
}

.leaderboard-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.tab--active {
  background: var(--accent);
  color: #fff;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
}

.duel-room {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.duel-code {
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0.18em;
  font-weight: 800;
}

.duel-meta {
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: grid;
  gap: 8px;
}

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

.field-input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--muted) 18%, transparent);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.leaderboard-rank {
  color: var(--muted);
  font-weight: 700;
}

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

.campaign-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 88%, #ffffff), color-mix(in srgb, var(--accent) 40%, #ffffff));
  color: #fff;
}

.campaign-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 700;
}

.campaign-title {
  margin: 12px 0 8px;
  font-size: 20px;
}

.campaign-text {
  margin: 0;
  line-height: 1.45;
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--muted);
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(20, 30, 48, 0.92);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 50;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 12, 22, 0.52);
  z-index: 40;
  overflow-y: auto;
}

.modal-backdrop--open {
  display: flex;
}

.modal-card {
  width: min(100%, 640px);
}

.onboarding-slide {
  display: grid;
  gap: 14px;
}

.onboarding-index {
  color: var(--muted);
  font-size: 13px;
}

.onboarding-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.onboarding-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.dot-row {
  display: flex;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
}

.dot--active {
  background: var(--accent);
}

.catalog-grid {
  display: grid;
  gap: 16px;
}

.catalog-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.catalog-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.catalog-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.catalog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.mini-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

@media (min-width: 720px) {
  .hero-card {
    grid-template-columns: 1.3fr 1fr;
    align-items: stretch;
  }

  .two-column {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
