/* ===== Tokens ===== */
:root {
  --bg: #F7F7FB;
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --border: #E1E1EE;
  --ink: #1E2340;
  --ink-soft: #5B5F7A;
  --accent: #B5792A;
  --accent-soft: #F3E3CC;
  --gold-glow: rgba(255, 215, 0, 0.6);
  --good: #3E8E5B;
  --good-soft: #DFF0E4;
  --bad: #C64B4B;
  --bad-soft: #F8E2E2;
  --white: #FFFFFF;
  --on-accent: #1A1200;
  --bad-hover: #B33E3E;
  --badge-pass: #5CB85C;
  --badge-pass-light: #4CAF50;
  --badge-pass-dark: #2E8B57;
  --badge-pass-darker: #1E5E3A;
  --badge-fail: #E67C7C;
  --badge-fail-dark: #C64B4B;
  --badge-fail-darker: #A33A3A;
  --badge-fail-mid: #FFB366;
  --badge-fail-mid-mid: #FF8C42;
  --badge-fail-mid-dark: #E67A2D;
  --badge-fail-high: #FFE066;
  --badge-fail-high-mid: #FFCC33;
  --badge-fail-high-dark: #E6B800;
  --black-20: rgba(0, 0, 0, 0.2);
  --black-25: rgba(0, 0, 0, 0.25);
  --black-15: rgba(0, 0, 0, 0.15);
  --black-05: rgba(0, 0, 0, 0.05);
  --black-30: rgba(0, 0, 0, 0.3);
  --black-50: rgba(0, 0, 0, 0.5);
  --black-80: rgba(0, 0, 0, 0.8);
  --black-35: rgba(0, 0, 0, 0.35);
  --white-40: rgba(255, 255, 255, 0.4);
  --white-15: rgba(255, 255, 255, 0.15);
  --white-10: rgba(255, 255, 255, 0.1);
  --white-50: rgba(255, 255, 255, 0.5);
  --white-95: rgba(255, 255, 255, 0.95);
  --gold-glow: rgba(255, 215, 0, 0.8);
  --good-glow-50: rgba(62, 142, 91, 0.5);
  --good-glow-30: rgba(62, 142, 91, 0.3);
  --good-glow-80: rgba(62, 142, 91, 0.8);
  --bad-glow-40: rgba(198, 75, 75, 0.4);
  --mid-glow-40: rgba(255, 140, 66, 0.4);
  --high-glow-40: rgba(255, 204, 51, 0.4);
  --overlay: rgba(18, 20, 43, 0.5);
  --shadow: 0 1px 2px rgba(30, 35, 64, 0.04), 0 8px 24px rgba(30, 35, 64, 0.06);
  --shadow-sm: 0 2px 6px var(--black-20);
  --shadow-md: 0 3px 10px var(--black-30);
  --shadow-inset-light: inset 0 2px 4px var(--black-15), 0 1px 2px var(--black-05);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --radius-pill: 999px;
  --transition-fast: all 0.15s ease;
  --transition-fast-colors: border-color 0.15s ease, background 0.15s ease;
  --transition-fast-transform: transform 0.15s ease, border-color 0.15s ease;
  --transition-medium: background 0.2s ease, color 0.2s ease;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

html[data-theme="dark"] {
  --bg: #12142B;
  --surface: #191C3A;
  --surface-raised: #202449;
  --border: #2E3260;
  --ink: #EDEEF7;
  --ink-soft: #A7ABCB;
  --accent: #E3A860;
  --accent-soft: #3A3220;
  --gold-glow: rgba(255, 215, 0, 0.35);
  --good: #6FCB93;
  --good-soft: #1E3327;
  --bad: #E67C7C;
  --bad-soft: #3A2020;
  --bad-hover-dark: #F08A8A;
  --shadow: 0 1px 2px var(--black-20), 0 12px 32px var(--black-35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  width: 100%;
  flex: 1;
}

/* ===== Header ===== */
.header {
  margin-bottom: 2rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--surface);
  color: var(--gold-glow);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  /*background: var(--surface);*/
}

.icon-btn i {
  color: var(--accent);
}

.menu-icon {
  /*text-shadow: 0 0 6px var(--gold-glow), 0 0 12px var(--gold-glow);*/
}

html[data-theme="light"] .icon-btn:hover {
  background: var(--black-15);
}

html[data-theme="dark"] .icon-btn:hover {
  background: var(--white-15);
}


h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2rem;
  margin: 0.1rem 0 0;
  letter-spacing: -0.01em;
}

/* ===== Overall Progress ===== */
.overall-progress {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slideDown 0.5s ease;
}

.overall-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.overall-progress-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.overall-progress-score {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.overall-progress-bar {
  height: 14px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  box-shadow: inset 0 2px 4px var(--black-15), 0 1px 2px var(--black-05);
  position: relative;
}

.overall-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.overall-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-45deg,
      transparent,
      transparent 6px,
      var(--white-15) 6px,
      var(--white-15) 12px);
  animation: stripeMove 1.5s linear infinite;
}

@keyframes stripeMove {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 24px 0;
  }
}

.overall-progress-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0;
  font-style: italic;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes badgePop {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }

  60% {
    transform: scale(1.2) rotate(10deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-3px);
  }

  75% {
    transform: translateX(3px);
  }
}

@keyframes badge3D {
  0% {
    transform: rotateY(0deg) rotateX(0deg) scale(0);
    opacity: 0;
  }

  30% {
    transform: rotateY(180deg) rotateX(45deg) scale(1.3);
    opacity: 1;
  }

  60% {
    transform: rotateY(360deg) rotateX(0deg) scale(0.95);
  }

  80% {
    transform: rotateY(400deg) rotateX(-10deg) scale(1.05);
  }

  100% {
    transform: rotateY(360deg) rotateX(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes badgeGlow {

  0%,
  100% {
    box-shadow: 0 0 5px var(--good-glow-50), 0 0 10px var(--good-glow-30);
  }

  50% {
    box-shadow: 0 0 20px var(--good-glow-80), 0 0 30px var(--good-glow-50), 0 0 40px var(--good-glow-30);
  }
}

@keyframes badgeShine {
  0% {
    background-position: -200% center;
  }

  100% {
    background-position: 200% center;
  }
}

@keyframes starPulse {

  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.2);
  }
}

.completion-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  animation: badgePop 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) backwards;
  flex-shrink: 0;
  animation-delay: 0.8s;
}

.completion-badge.passed {
  background: radial-gradient(circle at 35% 35%, var(--badge-pass) 0%, var(--badge-pass-light) 30%, var(--badge-pass-dark) 70%, var(--badge-pass-darker) 100%);
  color: var(--white);
  border: 3.5px solid var(--white-50);
  box-shadow:
    inset -0.6rem -0.6rem 0 var(--black-25),
    inset 0.3rem 0.3rem 0 var(--white-15),
    0 8px 24px var(--good-glow-50),
    0 2px 8px var(--black-20);
  animation: badgeUnlock 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, badgeFloat 3s ease-in-out infinite, badgeGlow 2.5s ease-in-out infinite;
  animation-delay: 0.6s, 1.5s, 2s;
}

.completion-badge.passed .badge-star {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  animation: starShine 2s ease-in-out infinite;
  text-shadow:
    0 0 12px var(--white-95),
    0 0 24px var(--gold-glow),
    0 2px 4px var(--black-30);
  z-index: 2;
  line-height: 1;
}

.completion-badge.passed svg {
  width: 80px;
  height: 80px;
  opacity: 1;
  animation: none;
  filter: drop-shadow(0 2px 3px var(--black-20));
}

.completion-badge.passed .progress-circle {
  stroke: var(--white);
  opacity: 0.9;
}

.completion-badge.failed {
  background: radial-gradient(circle at 35% 35%, var(--badge-fail) 0%, var(--badge-fail-dark) 50%, var(--badge-fail-darker) 100%);
  color: var(--white);
  border: 3px solid var(--white-40);
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-20),
    inset 0.2rem 0.2rem 0 var(--white-10),
    0 6px 20px var(--bad-glow-40),
    0 2px 6px var(--black-15);
  animation: badgeUnlock 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.6s;
}

.completion-badge.failed-low {
  background: radial-gradient(circle at 35% 35%, var(--badge-fail) 0%, var(--badge-fail-dark) 50%, var(--badge-fail-darker) 100%);
  color: var(--white);
  border: 3px solid var(--white-40);
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-20),
    inset 0.2rem 0.2rem 0 var(--white-10),
    0 6px 20px var(--bad-glow-40),
    0 2px 6px var(--black-15);
  animation: badgeUnlock 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.6s;
}

.completion-badge.failed-mid {
  background: radial-gradient(circle at 35% 35%, var(--badge-fail-mid) 0%, var(--badge-fail-mid-mid) 50%, var(--badge-fail-mid-dark) 100%);
  color: var(--white);
  border: 3px solid var(--white-40);
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-20),
    inset 0.2rem 0.2rem 0 var(--white-10),
    0 6px 20px var(--bad-glow-40),
    0 2px 6px var(--black-15);
  animation: badgeUnlock 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.6s;
}

.completion-badge.failed-high {
  background: radial-gradient(circle at 35% 35%, var(--badge-fail-high) 0%, var(--badge-fail-high-mid) 50%, var(--badge-fail-high-dark) 100%);
  color: var(--white);
  border: 3px solid var(--white-40);
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-15),
    inset 0.2rem 0.2rem 0 var(--white-15),
    0 6px 20px var(--high-glow-40),
    0 2px 6px var(--black-15);
  animation: badgeUnlock 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: 0.6s;
}

.completion-badge.failed-high .progress-circle {
  stroke: var(--white);
  animation: none;
}

.completion-badge.failed-high svg text {
  fill: var(--white);
  font-weight: 800;
  text-shadow: 0 1px 2px var(--black-30);
}

.completion-badge.failed-high svg {
  width: 80px;
  height: 80px;
  opacity: 1;
  animation: none;
  filter: drop-shadow(0 2px 3px var(--black-25));
}

.section-card {
  position: relative;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 1rem;
}

.timer-display {
  margin-top: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.7rem;
}

.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.timer {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.timer.low {
  color: var(--bad);
}

/* ===== Tutorial ===== */
.tutorial-kicker {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.tutorial-title {
  margin: 0 0 0.35rem;
}

.tutorial-lede {
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.tutorial-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-step h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.3rem;
}

.tutorial-step p {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

.tutorial-step strong {
  color: var(--ink);
}

.tutorial-actions {
  display: flex;
  justify-content: center;
}

/* ===== Visual (canvas) questions ===== */
.visual-sequence {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.shape-box {
  width: 84px;
  height: 84px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.shape-box.placeholder {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--ink-soft);
}

.shape-canvas {
  display: block;
}

.visual-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.shape-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  cursor: pointer;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.shape-option:hover {
  border-color: var(--accent);
}

.shape-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.shape-option-letter {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  align-self: flex-start;
}

.review-thumbs {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.review-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.review-thumb .shape-canvas {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}



.level-group-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 1.5rem 0 0.75rem;
}

/* ===== Section cards ===== */
.section-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}

.section-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 5rem 1.25rem 1.1rem;
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.section-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.learn-badge {
  display: none;
  align-items: center;
  width: fit-content;
  min-width: 50%;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  margin-bottom: 0.25rem;
}

.learn-badge.in-progress {
  display: inline-flex;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.learn-badge.done {
  display: inline-flex;
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid var(--good);
}

.section-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.section-card>p {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}



/* ===== Learn screen ===== */
.learn-header {
  margin-bottom: 1.5rem;
}

.learn-header h2 {
  margin: 0 0 0.35rem;
}

.learn-progress {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0;
}

.learn-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.learn-content h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.learn-content p {
  margin: 0 0 1.25rem;
  line-height: 1.6;
  color: var(--ink);
}

.learn-output {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--good);
  background: var(--good-soft);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin: 0.5rem 0 0;
}

/* ===== Exercises ===== */
.exercise-container {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow);
}

.exercise-prompt {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 1rem;
  color: var(--ink);
}

.exercise-option {
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.exercise-option:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.exercise-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.exercise-option.correct {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good);
}

.exercise-option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.exercise-feedback {
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  text-align: center;
  animation: feedbackPulse 0.4s ease;
}

.exercise-feedback.correct {
  color: var(--good);
  background: var(--good-soft);
  border: 2px solid var(--good);
}

.exercise-feedback.wrong {
  color: var(--bad);
  background: var(--bad-soft);
  border: 2px solid var(--bad);
}

.exercise-check-btn {
  margin-top: 0.75rem;
}

.exercise-code-line {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.exercise-blank {
  display: inline-block;
  min-width: 80px;
  min-height: 1.5em;
  border: 2px dashed var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  margin: 0 0.2rem;
  vertical-align: middle;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.exercise-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.exercise-editor {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

.exercise-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 2.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  white-space: pre-wrap;
}

@keyframes feedbackPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.02);
  }

  100% {
    transform: scale(1);
  }
}

.learn-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0 0 0.75rem;
  overflow-x: auto;
}

/* ===== Quiz ===== */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.question-prompt {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 1.35rem;
  line-height: 1.4;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover {
  border-color: var(--accent);
}

.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-marker {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.option.selected .option-marker {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--white);
}

.option-text {
  font-size: 0.95rem;
}

.multi-hint {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.6rem;
  background: var(--accent-soft);
  border-radius: 6px;
  display: inline-block;
}

.navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 0.75rem;
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.4rem;
  border-radius: 10px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

html[data-theme="dark"] .btn {
  background: var(--accent);
  color: var(--on-accent);
}

#nextBtn {
  background: var(--accent);
  color: var(--surface);
}


html[data-theme="dark"] #nextBtn {
  background: var(--accent);
  color: var(--surface);
}

.btn-secondary {
  background: var(--ink-soft);
  color: var(--surface);
  border: 1px solid var(--border);
}

html[data-theme="dark"] .btn-secondary {
  background: var(--ink);
  color: var(--surface);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--bad);
  color: var(--white);
  border: 1px solid var(--bad);
}

.btn-danger:hover {
  background: var(--bad-hover);
  border-color: var(--bad-hover);
}

html[data-theme="dark"] .btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--on-accent);
}

html[data-theme="dark"] .btn-danger:hover {
  background: var(--bad-hover-dark);
  border-color: var(--bad-hover-dark);
}

.learn-btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

.quiz-btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: var(--surface);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 50;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem 0.75rem;
  flex-shrink: 0;
}

.modal-head h2 {
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--ink-soft);
}

.modal-body {
  overflow-y: auto;
  padding: 0 1.5rem;
  flex: 1;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ===== Accessibility Modal ===== */
.a11y-modal-content {
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.a11y-subtitle {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0 0 1rem;
  padding: 0 0.25rem;
}

.a11y-section-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 1rem 0 0.4rem;
  padding: 0 0.25rem;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.a11y-row:last-child { border-bottom: none; }

.a11y-row-info {
  flex: 1;
  min-width: 0;
}

.a11y-row-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.1rem;
}

.a11y-icon {
  font-size: 1.05rem;
  color: var(--accent);
  width: 1.1rem;
  text-align: center;
}

.a11y-row-desc {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.toggle-btn {
  width: 44px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-btn::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  transition: transform 0.2s ease;
}

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

.toggle-btn.active::before {
  transform: translateX(20px);
}

.toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Accessibility body classes ===== */
body.high-contrast {
  --bg: #0F1117;
  --surface: #1A1D29;
  --surface-raised: #222639;
  --border: #2E3260;
  --ink: #FFFFFF;
  --ink-soft: #C7CCD9;
  --accent: #FFD166;
  --accent-soft: #FFE9B8;
  --good: #6BCB77;
  --good-soft: #DCF4E1;
  --bad: #FF7878;
  --bad-soft: #FFD6D6;
}

body.high-contrast .learn-content pre,
body.high-contrast .exercise-code-line {
  background: var(--bg);
}

body.high-contrast .completion-badge.passed {
  box-shadow:
    inset -0.6rem -0.6rem 0 var(--black-25),
    inset 0.3rem 0.3rem 0 var(--white-15),
    0 8px 24px var(--good-glow-50),
    0 2px 8px var(--black-20);
}

body.high-contrast .completion-badge.failed,
body.high-contrast .completion-badge.failed-low {
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-20),
    inset 0.2rem 0.2rem 0 var(--white-10),
     0 6px 20px var(--bad-glow-40),
     0 2px 6px var(--black-15);
}

body.high-contrast .completion-badge.failed-mid {
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-20),
    inset 0.2rem 0.2rem 0 var(--white-10),
     0 6px 20px var(--mid-glow-40),
     0 2px 6px var(--black-15);
}

body.high-contrast .completion-badge.failed-high {
  box-shadow:
    inset -0.5rem -0.5rem 0 var(--black-15),
    inset 0.2rem 0.2rem 0 var(--white-15),
     0 6px 20px var(--high-glow-40),
     0 2px 6px var(--black-15);
}

body.simple-mode .learn-content p,
body.simple-mode .tutorial-step p,
body.simple-mode .section-card > p,
body.simple-mode .question-prompt,
body.simple-mode .exercise-prompt {
  font-size: 1.05rem;
  line-height: 1.6;
}

body.simple-mode .a11y-row-desc,
body.simple-mode .learn-progress,
body.simple-mode .overall-progress-label,
body.simple-mode .progress-label {
  font-size: 0.85rem;
}

html.large-text {
  font-size: 120%;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

.settings-section {
  margin-bottom: 1.5rem;
}

.settings-section h3 {
  font-family: var(--font-body);
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.settings-hint {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin: 0 0 0.85rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.settings-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

#timerMinutes {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  margin: 0.5rem 0 0.75rem;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.settings-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

#timerMinutesValue {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
  display: block;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ===== Results ===== */
.results-hero {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.results-score {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0.25rem 0;
}

.results-sub {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.9rem;
}

.pass-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--good);
  color: var(--white);
  margin-bottom: 0.5rem;
  animation: feedbackPulse 0.4s ease;
}

.fail-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--bad);
  color: var(--white);
  margin-bottom: 0.5rem;
  animation: feedbackPulse 0.4s ease;
}

.trait-row {
  margin-bottom: 0.9rem;
}

.trait-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.trait-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.trait-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.75rem;
}

.review-item p {
  margin: 0.25rem 0;
  font-size: 0.88rem;
}

.review-item .review-prompt {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-right: 0.4rem;
}

.tag.good {
  background: var(--good-soft);
  color: var(--good);
}

.tag.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

footer {
  text-align: center;
  padding: 1.5rem 1rem;
}

footer p {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin: 0;
}

/* ===== Per-question timer ===== */
.timer-pq {
  margin-top: 0.5rem;
}

.timer-pq .timer-dot {
  animation-duration: 0.8s;
}

/* ===== Number pyramids ===== */
.pyramid-container {
  margin-top: 0.5rem;
}

.pyramid-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.pyramid-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
}

.pyramid-cell {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  cursor: default;
  user-select: none;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.pyramid-cell.filled {
  background: var(--bg);
  border-color: var(--border);
  color: var(--ink-soft);
  cursor: default;
}

.pyramid-cell.empty {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--bg);
  color: var(--ink-soft);
  cursor: pointer;
}

.pyramid-cell.empty:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pyramid-cell.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pyramid-cell.filled-user {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
  cursor: pointer;
}

.pyramid-cell.filled-user:hover {
  border-color: var(--bad);
}

.pyramid-cell.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.pyramid-cell.locked.empty {
  cursor: not-allowed;
  border-color: var(--border);
}

.pyramid-cell.correct {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good);
}

.pyramid-cell.incorrect {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.pyramid-tiles-wrap {
  margin-top: 1rem;
}

.pyramid-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.pyramid-tile {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  cursor: grab;
  transition: var(--transition-fast);
  user-select: none;
  box-shadow: var(--shadow);
}

.pyramid-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.pyramid-tile:active {
  transform: translateY(0);
}

.pyramid-tile.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.pyramid-tile.used {
  opacity: 0.4;
  cursor: not-allowed;
}

.pyramid-tile.dragging {
  opacity: 0.5;
}

.pyramid-tile.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.pyramid-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.pyramid-check-btn {
  margin: 0.5rem auto 0;
  display: block;
}

.pyramid-msg {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.5rem auto 0;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  max-width: 400px;
}

.correct-msg {
  color: var(--good);
  background: var(--good-soft);
}

.wrong-msg {
  color: var(--bad);
  background: var(--bad-soft);
}

/* ===== Review (results) pyramids ===== */
.review-pyramid-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.review-pyramid-cell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  user-select: none;
}

.review-pyramid-cell.filled {
  background: var(--bg);
  border-color: var(--border);
  color: var(--ink-soft);
}

.review-pyramid-cell.filled-user {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
}

.review-pyramid-cell.correct {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good);
}

.review-pyramid-cell.incorrect {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

.review-pyramid-cell.skipped {
  border-color: var(--border);
  background: var(--bg);
  color: var(--ink-soft);
}

/* ===== Cluster missing-number ===== */
.cluster-missing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.cluster-instr {
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}

.cluster-row {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cluster-top {
  width: 56px;
  height: 56px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--surface);
  color: var(--ink);
}

.cluster-missing-top {
  border-style: dashed;
  color: var(--ink-soft);
}

.cluster-bottom {
  display: flex;
  gap: 0.3rem;
}

.cluster-bottom-num {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--ink);
}

.cluster-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 300px;
}

.cluster-opt {
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 1.2rem;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cluster-opt:hover {
  border-color: var(--accent);
}

.cluster-opt.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ===== Matrix 3x3 ===== */
.matrix-3x3 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.matrix-instr {
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}

.matrix-grid {
  display: flex;
  flex-direction: column;
}

.matrix-cell {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.matrix-cell canvas {
  display: block;
}

.matrix-empty {
  border-style: dashed;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.matrix-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.matrix-opt {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease;
}

.matrix-opt:hover {
  border-color: var(--accent);
}

.matrix-opt.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.matrix-opt canvas {
  display: block;
}

/* ===== Matrix review ===== */
.matrix-review {
  margin-top: 0.5rem;
}

.matrix-cell-correct {
  border: 2px solid var(--good);
}

.matrix-cell-incorrect {
  border: 2px solid var(--bad);
}

/* ===== Typing questions ===== */
.typing-input {
  width: 100%;
  max-width: 320px;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.typing-template {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

/* ===== Insert questions ===== */
.insert-template {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}

.insert-slot {
  display: inline-block;
  min-width: 80px;
  min-height: 1.5em;
  border: 2px dashed var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  margin: 0 0.2rem;
  vertical-align: middle;
  background: var(--surface);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.insert-slot:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.insert-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dragorder-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.dragorder-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dragorder-item:active {
  cursor: grabbing;
}

/* ===== Code runner questions ===== */
.coderunner-editor {
  width: 100%;
  min-height: 160px;
  padding: 0.75rem;
  border: none;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  tab-size: 4;
}

.coderunner-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  min-height: 3rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* ===== Execution Player ===== */
.execution-player {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.75rem;
}

.execution-line {
  transition: background 0.2s ease;
}

.execution-line.active {
  background: var(--accent-soft);
  font-weight: 600;
}

.execution-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.variable-viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.variable-content {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.execution-description {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* ===== Flow Diagram ===== */
.flow-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 0.75rem;
  overflow-x: auto;
}

.flow-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.flow-node {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  min-width: 120px;
  transition: transform 0.15s ease;
}

.flow-node:hover {
  transform: scale(1.03);
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.6rem;
  }

  .results-score {
    font-size: 2.4rem;
  }
}