:root {
  --ink: #1a1d2a;
  --soft-ink: #3b4254;
  --cream: #f6f3ed;
  --card: #ffffff;
  --accent: #2457d6;
  --accent-dark: #1f45aa;
  --shadow: 0 18px 40px rgba(26, 29, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Avenir", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #f4f5f8 0%, #eef3ff 55%, #f7f1ea 100%);
}

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

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(0px);
  opacity: 0.35;
  animation: float 8s ease-in-out infinite;
}

.blob-a {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 30% 30%, #d9e2ff, #b8c8f6);
  top: -80px;
  left: -60px;
}

.blob-b {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle at 70% 40%, #d4efe9, #a8d6cd);
  bottom: -120px;
  right: 10%;
  animation-delay: 1s;
}

.blob-c {
  width: 190px;
  height: 190px;
  background: radial-gradient(circle at 40% 40%, #e7dfd2, #c9b79f);
  top: 30%;
  right: -60px;
  animation-delay: 2s;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(18px);
  }
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  align-items: center;
  margin-bottom: 32px;
}

.hero-text h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 3vw + 1rem, 3rem);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--soft-ink);
  margin-bottom: 10px;
}

.subhead {
  font-size: 1.05rem;
  color: var(--soft-ink);
  line-height: 1.5;
  margin-bottom: 20px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.module-switch {
  display: flex;
  gap: 8px;
}

.module-btn {
  border: 2px solid #c8d2e7;
  background: transparent;
  color: var(--soft-ink);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.module-btn.active {
  background: #e9efff;
  border-color: #9eb4ef;
  color: #1b3f9b;
  font-weight: 700;
}

.level-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--soft-ink);
}

.level-jump select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid #d1d9eb;
  background: #fff;
  font-size: 0.95rem;
  color: var(--ink);
}

.level-up-example {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: var(--soft-ink);
}

.level-up-example code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.hero-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.score {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}

.score .label {
  font-size: 0.8rem;
  margin: 0;
  color: var(--soft-ink);
}

.score .value {
  margin: 4px 0 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.tip {
  margin-top: 20px;
  background: var(--cream);
  border-radius: 14px;
  padding: 14px 16px;
}

.tip-title {
  margin: 0 0 6px;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.uitleg .bullets {
  padding-left: 20px;
  color: var(--soft-ink);
  margin: 0 0 16px;
}

.uitleg .bullets li {
  margin-bottom: 6px;
}

.stepper {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.step {
  background: #f7f9ff;
  border: 2px solid #e3e8f4;
  border-radius: 14px;
  padding: 14px;
}

.step.locked {
  display: none;
}

.step-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.mini-test {
  margin-top: 12px;
}

.mini-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.mini-btn {
  border: 2px solid #c8d2e7;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.mini-feedback {
  min-height: 20px;
  font-size: 0.9rem;
  color: var(--soft-ink);
}

.mini-feedback.good {
  color: #1b4a9e;
}

.mini-feedback.bad {
  color: #b32727;
}

#step1Svg .step1-rect {
  fill: #d8e4ff;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#step1Svg .step1-para {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
  opacity: 1;
  transition: opacity 0.6s ease;
}

#step1Svg .step1-height {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 6 6;
  opacity: 0.6;
  transition: opacity 0.6s ease;
}

#step1Svg.play .step1-rect {
  opacity: 0.75;
}

#step1Svg.play .step1-para {
  opacity: 0.25;
}

#step1Svg.play .step1-height {
  opacity: 1;
}

#step2Svg .step2-para {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
}

#step2Svg .step2-height {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.2;
  transition: opacity 0.6s ease;
}

#step2Svg.play .step2-height {
  opacity: 1;
}

#step3Svg .step3-para {
  fill: #d8e4ff;
  stroke: #1e3f8a;
  stroke-width: 2;
}

#step3Svg .step3-diag {
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

#step3Svg .step3-tri {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
  transition: opacity 0.6s ease;
}

#step3Svg .step3-tri.right {
  fill: #c6d6ff;
}

#step3Svg .step3-label {
  font-size: 12px;
  fill: #1b3f9b;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#step3Svg.play .step3-tri.right {
  opacity: 0.2;
}

#step3Svg.play .step3-label {
  opacity: 1;
}

.step4-tri {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
}

.step4-base {
  stroke: #1e3f8a;
  stroke-width: 2;
}

.step4-extend,
.step4-height {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.2;
  transition: opacity 0.6s ease;
}

#step4Svg.play .step4-extend,
#step4Svg.play .step4-height {
  opacity: 1;
}

.formula-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.formula-card {
  border: 2px solid #e3e8f4;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.formula-card p {
  margin: 0 0 8px;
  font-weight: 700;
}

.formula-card.active {
  border-color: #9eb4ef;
  background: #f2f5ff;
}

.formula {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
}

.formula .symbol {
  color: var(--accent);
}

.theory-box {
  background: #f1f3f7;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  color: var(--soft-ink);
}

.anim-block h3 {
  margin: 0 0 6px;
}

.anim-block p {
  margin: 0 0 12px;
  color: var(--soft-ink);
}

.anim-wrap {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  border: 2px dashed #c8d2e7;
  margin-bottom: 10px;
}

.anim-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.tb-rect {
  fill: #e9efff;
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.tb-tri1,
.tb-tri2 {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-linejoin: bevel;
}

.tb-tri2 {
  fill: #c6d6ff;
}

.tb-para-outline {
  fill: none;
  stroke: #1e3f8a;
  stroke-width: 2;
}

.tb-cut {
  fill: #f4c7a0;
  stroke: #c26b2c;
  stroke-width: 2;
  stroke-linejoin: bevel;
  stroke-linecap: butt;
}

.tb-label {
  font-size: 12px;
  fill: #1b3f9b;
  font-weight: 700;
}

#triBoxSvg {
  --tbDur: 16s;
}

#tbTri2,
#tbCut {
  transform-box: fill-box;
  transform-origin: center;
}

#triBoxSvg.play #tbTri1 {
  animation: tbTri1Opacity var(--tbDur) linear infinite;
}

#triBoxSvg.play #tbTri2 {
  animation:
    tbTri2Opacity var(--tbDur) linear infinite,
    tbTri2Move var(--tbDur) ease-in-out infinite;
}

#triBoxSvg.play #tbParaOutline {
  animation: tbParaOpacity var(--tbDur) linear infinite;
}

#triBoxSvg.play #tbRect {
  animation: tbRectOpacity var(--tbDur) linear infinite;
}

#triBoxSvg.play #tbCut {
  animation:
    tbCutOpacity var(--tbDur) linear infinite,
    tbCutMove var(--tbDur) ease-in-out infinite;
}

#triBoxSvg.play #tbLabel1 {
  animation: tbLabel1Opacity var(--tbDur) linear infinite;
}

#triBoxSvg.play #tbLabel2 {
  animation: tbLabel2Opacity var(--tbDur) linear infinite;
}

#triBoxSvg.play #tbLabel3 {
  animation: tbLabel3Opacity var(--tbDur) linear infinite;
}

@keyframes tbTri1Opacity {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  65% {
    opacity: 0;
  }
  70%,
  100% {
    opacity: 1;
  }
}

@keyframes tbTri2Opacity {
  0%,
  12% {
    opacity: 0;
  }
  20%,
  45% {
    opacity: 1;
  }
  50%,
  65% {
    opacity: 0;
  }
  70%,
  85% {
    opacity: 1;
  }
  92%,
  100% {
    opacity: 0;
  }
}

@keyframes tbTri2Move {
  0%,
  12% {
    transform: translateX(-24px);
  }
  20%,
  85% {
    transform: translateX(0px);
  }
  92%,
  100% {
    transform: translateX(-24px);
  }
}

@keyframes tbParaOpacity {
  0%,
  12% {
    opacity: 0;
  }
  20%,
  45% {
    opacity: 1;
  }
  50%,
  65% {
    opacity: 0;
  }
  70%,
  85% {
    opacity: 1;
  }
  92%,
  100% {
    opacity: 0;
  }
}

@keyframes tbRectOpacity {
  0%,
  45% {
    opacity: 0;
  }
  50%,
  65% {
    opacity: 1;
  }
  70%,
  100% {
    opacity: 0;
  }
}

@keyframes tbCutOpacity {
  0%,
  44% {
    opacity: 0;
  }
  46%,
  70% {
    opacity: 1;
  }
  75%,
  100% {
    opacity: 0;
  }
}

@keyframes tbCutMove {
  0%,
  45% {
    transform: translateX(0px);
  }
  50%,
  65% {
    transform: translateX(140px);
  }
  70%,
  100% {
    transform: translateX(0px);
  }
}

@keyframes tbLabel1Opacity {
  0%,
  12% {
    opacity: 1;
  }
  20%,
  85% {
    opacity: 0;
  }
  92%,
  100% {
    opacity: 1;
  }
}

@keyframes tbLabel2Opacity {
  0%,
  18% {
    opacity: 0;
  }
  20%,
  45% {
    opacity: 1;
  }
  50%,
  65% {
    opacity: 0;
  }
  70%,
  85% {
    opacity: 1;
  }
  92%,
  100% {
    opacity: 0;
  }
}

@keyframes tbLabel3Opacity {
  0%,
  45% {
    opacity: 0;
  }
  50%,
  65% {
    opacity: 1;
  }
  70%,
  100% {
    opacity: 0;
  }
}


.relation-para {
  fill: #d8e4ff;
  stroke: #1e3f8a;
  stroke-width: 2;
}

.relation-diag {
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.relation-tri {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 2;
  transition: opacity 0.6s ease;
}

.relation-tri.right {
  fill: #c6d6ff;
}

.relation-label {
  font-size: 12px;
  fill: #1b3f9b;
  opacity: 0;
  transition: opacity 0.6s ease;
}

#relationSvg.play .relation-tri.right {
  opacity: 0.2;
}

#relationSvg.play .relation-label {
  opacity: 1;
}


.small {
  font-size: 0.9rem;
  color: var(--soft-ink);
}

.oefening-header h2 {
  margin: 0 0 6px;
}

.oefening-header p {
  margin: 0 0 18px;
  color: var(--soft-ink);
}

.level-notice {
  margin: -8px 0 14px;
  font-weight: 700;
  color: #1b3f9b;
  background: #e9efff;
  border-radius: 10px;
  padding: 6px 10px;
  display: inline-block;
}

.canvas {
  display: grid;
  place-items: center;
  background: var(--cream);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

svg {
  width: 100%;
  max-width: 380px;
  height: auto;
}

.grid-bg {
  display: none;
}

#diagramSvg.grid-mode .grid-bg {
  display: block;
}

#diagramSvg.grid-mode #gridLabels {
  display: block;
}

#gridLabels {
  display: none;
}

.grid-label {
  font-size: 11px;
  fill: #7a879c;
}

#diagramSvg.grid-mode #baseLine,
#diagramSvg.grid-mode #heightLine,
#diagramSvg.grid-mode #heightDash {
  display: none;
}

#paraShape {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 3;
}

#triShape {
  fill: #8db8ff;
  stroke: #1e3f8a;
  stroke-width: 3;
  display: none;
}

#pickGroup {
  display: none;
}

.pick-line {
  stroke: #1f45aa;
  stroke-width: 8;
  opacity: 0.22;
  stroke-linecap: butt;
  cursor: pointer;
}

.pick-line:hover {
  opacity: 0.35;
}

.pick-line.correct {
  stroke: #1b4a9e;
  opacity: 0.55;
}

.pick-line.wrong {
  stroke: #b32727;
  opacity: 0.55;
}

#baseLine,
#heightLine {
  stroke: var(--accent);
  stroke-width: 3;
}

#heightDash {
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

#baseExtension {
  stroke: #1e3f8a;
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.7;
  display: none;
}

text {
  font-size: 14px;
  fill: #1d1b2a;
  font-weight: 700;
}

.answer {
  display: grid;
  gap: 12px;
}

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

input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #d1d9eb;
  font-size: 1rem;
}

#unitLabel {
  font-weight: 700;
  color: var(--soft-ink);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.small {
  padding: 8px 14px;
  font-size: 0.95rem;
  min-width: 140px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(36, 87, 214, 0.25);
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(36, 87, 214, 0.3);
}

.btn.ghost {
  background: transparent;
  color: var(--soft-ink);
  border: 2px solid #c8d2e7;
}

#nextBtn {
  display: none;
}

.feedback {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #f2f4f8;
  color: var(--soft-ink);
}

.feedback.good {
  background: #e7f1ff;
  color: #1b4a9e;
}

.feedback.bad {
  background: #fff0f0;
  color: #b32727;
}

.level-up {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(18, 20, 30, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.level-up.show {
  opacity: 1;
}

.level-up-card {
  background: #ffffff;
  padding: 22px 26px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 240px;
  animation: levelPop 0.35s ease;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e9efff;
  color: #1b3f9b;
  font-weight: 700;
  margin-bottom: 10px;
}

.level-up-text {
  font-weight: 700;
  margin-bottom: 6px;
}

.level-up-note {
  color: var(--soft-ink);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.level-up-gif {
  max-width: 200px;
  border-radius: 12px;
  display: none;
  margin: 0 auto;
}

@keyframes levelPop {
  0% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 700px) {
  .score {
    grid-template-columns: repeat(3, minmax(60px, 1fr));
  }
  .hero-card {
    padding: 16px;
  }
  .card {
    padding: 18px;
  }
}
