:root {
  color-scheme: dark;
  --bg: #06070b;
  --bg-elevated: rgba(14, 18, 30, 0.9);
  --bg-soft: rgba(19, 25, 41, 0.86);
  --border: rgba(184, 31, 48, 0.34);
  --border-strong: rgba(229, 60, 78, 0.72);
  --text: #f4ead8;
  --muted: #b6a996;
  --accent: #d83a49;
  --accent-strong: #f15656;
  --good: #6bd59a;
  --bad: #ff7b7b;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.08), transparent 24%),
    linear-gradient(180deg, #090b11 0%, #05060a 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top, rgba(213, 49, 62, 0.11), transparent 28%),
    repeating-linear-gradient(
      180deg,
      transparent,
      transparent 38px,
      rgba(255, 255, 255, 0.015) 39px,
      transparent 40px
    );
  opacity: 0.85;
}

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

button,
input,
select {
  font: inherit;
}

#app {
  position: relative;
  z-index: 1;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.lesson-shell {
  width: min(1220px, calc(100vw - 32px));
}

.gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 24px;
  min-height: 220px;
  background:
    linear-gradient(135deg, rgba(35, 14, 21, 0.92), rgba(9, 12, 21, 0.9)),
    linear-gradient(0deg, rgba(145, 22, 35, 0.16), rgba(145, 22, 35, 0.16));
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.035) 49%, transparent 100%),
    linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.02) 100%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.hero-copy {
  max-width: 700px;
}

.hero h1,
.panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
}

.panel h2,
.activity-card h3 {
  margin: 0;
  line-height: 1.15;
}

.eyebrow,
.activity-type,
.summary-label,
.lesson-number,
.availability {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0;
}

.eyebrow,
.activity-type,
.lesson-number {
  color: var(--accent-strong);
}

.muted {
  color: var(--muted);
}

.panel,
.lesson-card,
.activity-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.gate-panel {
  width: min(460px, 100%);
}

.gate-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.gate-error {
  margin: 0;
  color: var(--bad);
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.level-stack {
  display: grid;
  gap: 28px;
}

.level-section {
  display: grid;
  gap: 18px;
}

.level-section-heading {
  align-items: end;
}

.level-section-copy {
  max-width: 720px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lesson-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  min-height: 220px;
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.06), transparent 34%),
    var(--bg-soft);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.lesson-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.12), transparent 42%),
    var(--bg-soft);
}

.lesson-card.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.lesson-card-top,
.lesson-meta,
.section-heading,
.activity-header,
.submit-row,
.result-summary {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.lesson-meta,
.submit-row,
.result-summary {
  flex-wrap: wrap;
}

.teacher-lesson-card {
  gap: 18px;
}

.teacher-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.teacher-section-panel {
  margin-top: 20px;
}

.teacher-answer-list,
.attempt-stack {
  margin-top: 18px;
}

.teacher-answer-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.teacher-answer-text,
.teacher-note {
  margin: 0;
}

.attempt-stack {
  display: grid;
  gap: 12px;
}

.attempt-card {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.attempt-card summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  font-weight: 700;
}

.attempt-card summary::-webkit-details-marker {
  display: none;
}

.attempt-card-body {
  padding: 0 16px 16px;
}

.lesson-card h2 {
  font-size: 1.45rem;
}

.availability,
.points-pill,
.result-badge,
.lesson-stat strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.lesson-stat {
  min-width: 110px;
  text-align: right;
}

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  color: var(--muted);
}

.back-link:hover {
  color: var(--text);
}

.form-panel,
.result-panel,
.leaderboard-panel,
.warning-panel,
.course-summary-panel {
  margin-top: 20px;
}

.student-name-field,
.question-row {
  display: grid;
  gap: 8px;
}

.student-name-field {
  margin-bottom: 20px;
}

.student-name-field span,
.question-label {
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(4, 6, 10, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(241, 86, 86, 0.24);
}

.activity-stack {
  display: grid;
  gap: 18px;
}

.activity-card {
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.05), transparent 22%),
    rgba(8, 11, 19, 0.96);
}

.question-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

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

.matching-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
  margin-top: 18px;
}

.matching-targets {
  min-width: 0;
}

.matching-bank {
  min-width: 0;
}

.match-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.match-prompt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.match-prompt p {
  margin: 0;
  font-weight: 700;
}

.match-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(216, 58, 73, 0.18);
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
}

.drop-zone {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed rgba(241, 86, 86, 0.42);
  background: rgba(8, 10, 16, 0.78);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.drop-zone.is-filled {
  border-style: solid;
}

.drop-zone.is-drag-over,
.word-bank.is-drag-over {
  border-color: var(--border-strong);
  background: rgba(84, 15, 24, 0.34);
  box-shadow: 0 0 0 1px rgba(241, 86, 86, 0.24);
}

.drop-zone-placeholder,
.word-bank-empty {
  color: var(--muted);
  font-size: 0.95rem;
}

.word-bank {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(241, 86, 86, 0.24);
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.08), transparent 40%),
    rgba(7, 9, 15, 0.95);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
  position: sticky;
  top: 16px;
}

.word-bank-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.word-bank-header h4 {
  margin: 0;
  font-size: 1rem;
}

.word-bank-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.choice-chip {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.22), rgba(120, 22, 34, 0.72)),
    rgba(28, 9, 13, 0.96);
  border: 1px solid rgba(241, 86, 86, 0.34);
  color: var(--text);
  cursor: grab;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.reference-bank {
  margin-top: 16px;
}

.reference-chip-list {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.reference-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.choice-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(241, 86, 86, 0.6);
}

.choice-chip span {
  pointer-events: none;
  font-weight: 700;
}

.choice-chip.is-selected {
  border-color: #ffd27b;
  box-shadow: 0 0 0 1px rgba(255, 210, 123, 0.36);
}

.choice-chip.is-dragging {
  opacity: 0.72;
  cursor: grabbing;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.button.primary {
  color: #fff8f0;
  background: linear-gradient(180deg, #db4351 0%, #b12e3b 100%);
}

.button.primary:hover {
  background: linear-gradient(180deg, #e65260 0%, #bd3644 100%);
}

.button.danger {
  color: #fff8f0;
  background: linear-gradient(180deg, #7d1f2b 0%, #56131d 100%);
  border-color: rgba(255, 123, 123, 0.3);
}

.button.danger:hover {
  background: linear-gradient(180deg, #922733 0%, #651823 100%);
}

.button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.button.ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.result-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.result-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.result-row.is-correct {
  border-color: rgba(107, 213, 154, 0.3);
}

.result-row.is-wrong {
  border-color: rgba(255, 123, 123, 0.3);
}

.result-badge {
  flex-shrink: 0;
  align-self: flex-start;
}

.result-row.is-correct .result-badge {
  color: var(--good);
}

.result-row.is-wrong .result-badge {
  color: var(--bad);
}

.policy-note {
  margin: 12px 0 0;
  color: var(--text);
}

.warning-panel {
  border-color: rgba(229, 60, 78, 0.56);
  background:
    linear-gradient(180deg, rgba(216, 58, 73, 0.1), transparent 30%),
    rgba(18, 10, 14, 0.96);
}

.result-prompt,
.result-answer {
  margin: 0;
}

.result-answer {
  margin-top: 6px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.loading-panel,
.error-panel {
  margin-top: 60px;
}

@media (max-width: 720px) {
  .shell,
  .lesson-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 20px;
    padding-bottom: 36px;
  }

  .hero,
  .panel,
  .activity-card {
    padding: 18px;
  }

  .hero h1,
  .panel h1 {
    font-size: 2rem;
  }

  .section-heading,
  .activity-header,
  .result-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .matching-layout {
    grid-template-columns: 1fr;
  }

  .word-bank {
    position: static;
  }

  .lesson-card-top,
  .lesson-meta,
  .submit-row,
  .result-summary,
  .header-actions,
  .teacher-card-actions {
    align-items: flex-start;
  }

  .attempt-card summary {
    grid-template-columns: 1fr;
  }
}
