:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #5f6c7c;
  --line: #dbe3ee;
  --paper: #ffffff;
  --soft: #f4f7fb;
  --aqua: #18a6a6;
  --aqua-dark: #087b82;
  --coral: #f05f57;
  --gold: #f5b642;
  --green: #2f9e62;
  --red: #cf3c3c;
  --shadow: 0 18px 45px rgba(31, 45, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(24, 166, 166, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(245, 182, 66, 0.16), transparent 35%),
    #eef4f8;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr);
  gap: 32px;
  align-items: center;
  min-height: 280px;
}

.hero-art {
  position: relative;
  min-height: 240px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(8, 123, 130, 0.96), rgba(24, 166, 166, 0.85)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(255, 255, 255, 0.15) 24px);
  box-shadow: var(--shadow);
}

.math-tile {
  position: absolute;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(4px);
}

.tile-a {
  top: 28px;
  left: 30px;
  font-size: 42px;
}

.tile-b {
  right: 34px;
  top: 48px;
  color: #1b2633;
  background: var(--gold);
}

.tile-c {
  left: 48%;
  bottom: 34px;
  width: 112px;
  font-size: 28px;
  background: var(--coral);
}

.number-line {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 34px;
  height: 4px;
  background: rgba(255, 255, 255, 0.85);
}

.number-line span {
  position: absolute;
  top: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
}

.number-line span:nth-child(1) { left: 0; }
.number-line span:nth-child(2) { left: 32%; }
.number-line span:nth-child(3) { left: 64%; }
.number-line span:nth-child(4) { right: 0; }

.hero-copy h1,
.summary h2 {
  margin: 4px 0 12px;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0;
  color: var(--aqua-dark);
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.setup-panel,
.practice,
.summary {
  margin-top: 24px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.setup-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 20px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cbd6e2;
  border-radius: 6px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(24, 166, 166, 0.25);
  outline-offset: 2px;
}

.setup-actions,
.summary-actions,
.nav-actions,
.answer-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  color: white;
  background: var(--aqua-dark);
}

.primary-btn:hover {
  background: #05646b;
}

.ghost-btn {
  color: var(--aqua-dark);
  background: #e8f6f6;
}

.ghost-btn:hover {
  background: #d4eeee;
}

.practice {
  padding: 20px;
}

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

.practice-top h2 {
  margin: 4px 0 0;
  font-size: 1.8rem;
}

.progress-box {
  min-width: 220px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce5ee;
}

#progressFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--aqua), var(--gold));
  transition: width 240ms ease;
}

.question-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
  align-items: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.question-visual {
  min-height: 150px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: white;
  border: 1px dashed #b8c7d8;
  color: var(--aqua-dark);
  font-size: 1.6rem;
  font-weight: 900;
  text-align: center;
  padding: 16px;
}

.question-text {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.55;
  font-weight: 700;
}

.answer-row {
  grid-column: 2;
}

.answer-row input {
  max-width: 340px;
  font-size: 1.2rem;
}

.hint-text {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
}

.solution-panel {
  margin-top: 16px;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.solution-panel h3 {
  margin: 0 0 12px;
}

.step-list {
  margin: 0 0 16px;
  padding-left: 20px;
  line-height: 1.65;
}

.correct {
  color: var(--green);
}

.wrong {
  color: var(--red);
}

.summary {
  padding: 22px;
}

.summary h2 {
  font-size: 2.2rem;
}

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

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--soft);
}

.review-item strong {
  display: block;
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(80px);
  opacity: 0;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 6px;
  color: white;
  background: #1d2938;
  transition: 180ms ease;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 780px) {
  .hero,
  .setup-panel,
  .question-card {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 18px;
  }

  .hero-art {
    min-height: 210px;
  }

  .setup-actions,
  .answer-row,
  .summary-actions,
  .nav-actions,
  .practice-top {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-box {
    width: 100%;
    min-width: 0;
  }

  .answer-row,
  .hint-text {
    grid-column: 1;
  }

  .answer-row input {
    max-width: none;
  }
}

@media print {
  body {
    background: white;
  }

  .hero,
  .setup-panel,
  .practice,
  .summary-actions,
  .toast {
    display: none !important;
  }

  .summary {
    display: block !important;
    box-shadow: none;
    border: 0;
  }
}
