:root {
  color-scheme: light;
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ink: #0f172a;
  --muted: #475569;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --surface: #f6f7fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --success: #0f9d58;
  --danger: #ef4444;
  --shadow-lg: 0 12px 34px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 18px rgba(15, 23, 42, 0.07);
  --radius-card: 14px;
  --radius-soft: 10px;
  --max-width: 1080px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
}

* {
  box-sizing: border-box;
  font-family: var(--font-sans);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--ink);
  font-size: clamp(15px, 0.9vw + 12px, 17px);
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: var(--radius-soft);
  color: var(--accent-strong);
  font-weight: 800;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  left: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

h1,
h2,
h3,
h4 {
  margin: 0 0 10px;
  font-weight: 800;
  line-height: 1.2;
}

p {
  margin: 0 0 10px;
}

.app-shell {
  position: relative;
  max-width: var(--max-width);
  margin: clamp(14px, 3vw, 32px) auto 40px;
  padding: 0 clamp(14px, 2vw, 28px) 28px;
}

#main-content {
  scroll-margin-top: var(--space-5);
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr minmax(340px, 0.9fr);
  gap: clamp(14px, 2vw, 24px);
  align-items: stretch;
  margin-bottom: clamp(16px, 2vw, 24px);
}

.hero__text,
.hero__panel .panel,
.card,
.scores,
.install-card {
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: clamp(16px, 2.4vw, 22px);
}

.hero__text {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 12px;
}

.hero__panel .panel {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.eyebrow {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.lede {
  font-size: 1.04rem;
  color: var(--muted);
  max-width: 680px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12);
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meta-row,
.callouts,
.download-grid {
  display: grid;
  gap: 12px;
}

.meta-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}

.meta-card,
.download-card,
.status-panel,
.table-wrapper {
  border-radius: var(--radius-soft);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.meta-card,
.download-card {
  padding: 14px 16px;
}

.meta-card .label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.meta-card .value {
  font-weight: 800;
  font-size: 1.05rem;
}

.cta-banner {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: center;
  background: linear-gradient(120deg, #1d4ed8, #2563eb 40%, #1e3a8a);
  color: #f8fafc;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 48px rgba(37, 99, 235, 0.35);
}

.cta-banner .helper-text {
  color: rgba(248, 250, 252, 0.88);
  margin: 0;
}

.cta-banner__actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.cta-banner__secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.install-banner {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 16px;
  align-items: center;
  margin: 16px 0 18px;
  padding: 18px 20px;
  border-radius: 16px;
  background: linear-gradient(110deg, #0f172a, #1d4ed8);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 52px rgba(15, 23, 42, 0.32);
}

.install-banner__actions {
  display: grid;
  gap: 10px;
  justify-items: end;
  align-content: start;
}

.start-cta {
  margin: 12px 0 16px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.start-cta .helper-text {
  margin: 0;
  max-width: 520px;
}

.platform-downloads {
  margin: 18px 0 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0));
  box-shadow: var(--shadow-md);
}

.download-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.download-card {
  display: grid;
  align-content: start;
  gap: 8px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.download-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.15);
}

.download-card.is-disabled {
  opacity: 0.65;
  border-style: dashed;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.download-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1d4ed8;
  font-weight: 700;
  width: fit-content;
}

.start-button {
  min-width: 210px;
  font-size: 1.05rem;
}

.selector-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 6px;
  flex-wrap: wrap;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selector-label {
  font-weight: 700;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-soft);
  border: 1px dashed var(--border);
  background: #f8fafc;
  font-weight: 700;
  color: var(--muted);
}

#question-set,
#question-filter,
#grade-filter,
input[type="text"] {
  padding: 10px 12px;
  border-radius: var(--radius-soft);
  border: 1px solid var(--border);
  font-weight: 600;
  background: var(--surface);
  width: 100%;
}

.selector-meta {
  margin: 2px 0 10px;
  font-style: italic;
  color: var(--muted);
}

.helper-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.helper-text.error {
  color: var(--danger);
}

.button-row,
.hero__actions,
.status-row,
.score-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-soft);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.18);
}

button:hover,
.btn:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:focus-visible,
.btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
}

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

.ghost-button {
  background: transparent;
  color: var(--accent-strong);
  border-color: var(--accent);
  box-shadow: none;
}

.ghost-button:hover {
  background: #eef2ff;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1d4ed8;
  font-weight: 700;
  border: 1px solid #c7d2fe;
}

.pill--status {
  background: #ecfeff;
  color: #0f172a;
  border-color: #bae6fd;
}

.pill--status.is-offline {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.pill--status.error {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.status-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
}

.timer {
  background: #eef2ff;
  color: #0f172a;
  padding: 12px 14px;
  border-radius: var(--radius-soft);
  font-weight: 700;
  border: 1px solid #c7d2fe;
  box-shadow: var(--shadow-md);
}

.progress-track {
  position: relative;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f8fafc, #e2e8f0);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.progress-bar {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 160ms ease;
}

.panel__header,
.card__header,
.score-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.callouts {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.callout {
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, #f8fafc, #fff);
  border-radius: var(--radius-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  box-shadow: var(--shadow-md);
}

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

.options {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 10px;
}

.options button {
  justify-content: flex-start;
  text-align: left;
  border-color: var(--border);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-soft);
  padding: 14px 16px;
  font-weight: 700;
  width: 100%;
  word-break: break-word;
}

.options button:hover {
  border-color: #c7d2fe;
  background: linear-gradient(120deg, #f8fff3, #f4f9ff);
  box-shadow: 0 18px 36px rgba(46, 91, 4, 0.12);
}

.chip-group {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.chip,
.chip-success,
.chip-info,
.chip-subject {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid #e0e7ff;
  background: #eef2ff;
  color: #1d4ed8;
}

.chip-success {
  background: #ecfdf3;
  color: #0f9d58;
  border-color: #bbf7d0;
}

.chip-info {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

.label {
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}

.card h2,
.card h3 {
  margin: 0 0 6px;
}

.card .helper-text {
  margin-top: 4px;
}

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

.input-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.input-hint--error {
  color: var(--danger);
  font-weight: 700;
}

.input-hint--success {
  color: var(--success);
  font-weight: 700;
}

.feedback {
  font-size: 1rem;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-soft);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
}

.feedback.success {
  border-color: #b3e6c5;
  background: #f1fff5;
  color: var(--success);
}

.feedback.error {
  border-color: #ffd9d5;
  background: #fff5f4;
  color: var(--danger);
}

.review-card {
  margin-top: 16px;
}

.table-wrapper {
  overflow: auto;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
}

.review-table th,
.review-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.review-table th {
  background: #f8fafc;
  font-weight: 800;
  color: var(--muted);
}

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

.review-empty {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.answer-correct {
  color: var(--success);
  font-weight: 700;
}

.answer-wrong {
  color: var(--danger);
  font-weight: 700;
}

.scores {
  margin: 32px auto 0;
  max-width: 820px;
}

.score-header {
  align-items: center;
}

ol {
  padding-left: 18px;
  max-height: 460px;
  overflow: auto;
  margin: 14px 0 18px;
}

#highscores {
  list-style: none;
  padding-left: 0;
}

li {
  padding: 10px 12px;
  list-style: decimal inside none;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.install-card {
  margin-top: 16px;
}

.install-card__meta {
  display: grid;
  gap: 6px;
}

.hide {
  display: none;
}

.feedback-area {
  margin-top: 10px;
}

/* Responsive tweaks */
@media screen and (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .cta-banner,
  .install-banner {
    grid-template-columns: 1fr;
  }

  .cta-banner__actions,
  .install-banner__actions {
    justify-items: start;
  }
}

@media screen and (max-width: 800px) {
  h1 {
    font-size: clamp(26px, 6vw, 32px);
  }

  h2 {
    font-size: clamp(22px, 5vw, 28px);
  }

  .hero__text .lede {
    font-size: 1rem;
  }

  .start-cta,
  .start-cta .helper-text {
    flex-direction: column;
    align-items: flex-start;
  }

  .start-cta {
    gap: 12px;
  }
}

@media screen and (max-width: 640px) {
  .selector-row,
  .panel__header,
  .card__header,
  .score-header,
  .hero__actions {
    flex-direction: column;
    align-items: flex-start;
  }

  button,
  .btn,
  .ghost-button,
  #question-set,
  input[type="text"] {
    width: 100%;
  }

  .chip-group {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
}

@media screen and (max-width: 520px) {
  .app-shell {
    margin-inline: clamp(8px, 3vw, 16px);
    padding-inline: clamp(10px, 3vw, 16px);
  }

  .options {
    grid-template-columns: 1fr;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .orb-a,
  .orb-b {
    width: 220px;
    height: 220px;
    filter: blur(60px);
  }

  .orb-b {
    top: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .progress-bar {
    transition: none;
  }
}
