:root {
  color-scheme: light;
  --ink: #132033;
  --muted: #647084;
  --paper: #fffaf2;
  --panel: #ffffff;
  --line: #d9e0ea;
  --blue: #246bfe;
  --green: #00a676;
  --pink: #ef476f;
  --yellow: #ffd166;
  --orange: #f77f00;
  --shadow: 0 18px 44px rgba(19, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 209, 102, 0.45), transparent 22rem),
    linear-gradient(135deg, #f8fbff 0%, var(--paper) 45%, #eef8f4 100%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1rem 0.75rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.25rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.55rem, 4vw, 2.8rem);
  line-height: 1.05;
}

.eyebrow {
  color: var(--pink);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  gap: 1rem;
  align-items: stretch;
  margin: 0.5rem 0 1.2rem;
}

.hero-copy,
.quick-stats,
.practice-shell,
.exercise-card,
.stats-list,
.stat-cards article {
  background: rgba(255, 255, 255, 0.84);
  border: 2px solid rgba(19, 32, 51, 0.08);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 14rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 2rem);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(36, 107, 254, 0.12), rgba(0, 166, 118, 0.1)),
    rgba(255, 255, 255, 0.9);
}

.hero-copy p {
  color: var(--muted);
  max-width: 44rem;
  font-size: 1.05rem;
}

.quick-stats,
.section-score {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 8rem;
  border-radius: 8px;
  padding: 1rem;
}

.quick-stats span,
.section-score span,
.stat-cards span {
  font-size: clamp(2rem, 5vw, 3.6rem);
  font-weight: 950;
  line-height: 1;
}

.reward-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.reward-strip .reward-tile,
.badge-list {
  border: 2px solid rgba(19, 32, 51, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

.reward-strip .reward-tile {
  min-height: 5.4rem;
  padding: 0.8rem;
  border-color: rgba(19, 32, 51, 0.08);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.reward-strip .reward-tile:hover,
.reward-strip .reward-tile:focus-visible {
  border-color: rgba(36, 107, 254, 0.35);
  transform: translateY(-2px);
}

.reward-strip strong {
  display: block;
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  line-height: 1;
}

.reward-strip span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

small {
  color: var(--muted);
  font-weight: 750;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.section-card {
  position: relative;
  min-height: 13rem;
  padding: 1rem;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.section-card:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.text-button:focus-visible,
.danger-button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(36, 107, 254, 0.35);
  outline-offset: 3px;
}

.section-card strong {
  display: block;
  max-width: 17rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.05;
}

.section-card p {
  max-width: 25rem;
  margin-top: 0.65rem;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
}

.section-card .mini-progress {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  min-width: 9.8rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  text-align: center;
}

.section-card .level-chip {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  max-width: calc(100% - 12rem);
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 950;
}

.section-card .math-mark {
  position: absolute;
  right: 1rem;
  top: 0.25rem;
  color: rgba(255, 255, 255, 0.24);
  font-size: 7rem;
  font-weight: 950;
}

.text-button,
.ghost-button,
.danger-button,
.primary-button {
  min-height: 2.85rem;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.text-button {
  margin: 0.5rem 0 1rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
}

.ghost-button {
  padding: 0.7rem 1rem;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.danger-button {
  padding: 0.7rem 1rem;
  border: 0;
  background: #ffe7e7;
  color: #a3122a;
}

.primary-button {
  padding: 0.7rem 1rem;
  border: 0;
  background: var(--blue);
  color: #fff;
}

.primary-button.secondary {
  background: var(--green);
}

.practice-shell {
  border-radius: 8px;
  padding: 1rem;
}

.practice-head,
.stats-head {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.level-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.combo-track {
  width: min(18rem, 100%);
  height: 0.55rem;
  margin-top: 0.6rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(19, 32, 51, 0.12);
}

.combo-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), var(--pink), var(--blue));
  transition: width 260ms ease;
}

.level-badge,
.streak-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 950;
}

.level-badge {
  background: #132033;
  color: #fff;
}

.streak-badge {
  background: #fff1bd;
  color: #735000;
}

.exercise-card {
  position: relative;
  border-radius: 8px;
  padding: clamp(1rem, 4vw, 1.5rem);
}

.exercise-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-weight: 850;
}

.exercise-prompt {
  display: grid;
  place-items: center;
  min-height: 11rem;
  margin: 1rem 0;
  border-radius: 8px;
  background: #132033;
  color: #fff;
  font-size: clamp(2.4rem, 8vw, 5.2rem);
  font-weight: 950;
  text-align: center;
}

.answer-form label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-weight: 900;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
}

input {
  width: 100%;
  min-height: 3.4rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 1rem;
  background: #fff;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 850;
}

.feedback {
  min-height: 3.2rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: #f2f5fa;
  color: var(--muted);
  font-weight: 850;
}

.feedback.good {
  background: #dff8ef;
  color: #006c4d;
  animation: rewardPulse 520ms ease;
}

.feedback.bad {
  background: #ffe7ee;
  color: #a3122a;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.badge-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(7.6rem, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1rem;
}

.badge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 8.8rem;
  padding: 0.85rem 0.65rem 0.75rem;
  border: 2px solid rgba(19, 32, 51, 0.08);
  border-radius: 8px;
  background: #fff;
  background:
    radial-gradient(circle at 50% 12%, color-mix(in srgb, var(--badge-color) 20%, transparent), transparent 4.4rem),
    #fff;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease;
}

.badge-card:hover,
.badge-card:focus-visible {
  border-color: color-mix(in srgb, var(--badge-color) 42%, #ffffff);
  transform: translateY(-2px);
}

.badge-card.locked {
  filter: grayscale(0.85);
  opacity: 0.72;
}

.badge-card.locked .badge-art {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.42), transparent 45%),
    #7f8794;
}

.badge-state {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  min-width: 1.85rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #f2f5fa;
  background: color-mix(in srgb, var(--badge-color) 16%, #ffffff);
  color: var(--ink);
  font-size: 0.64rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.badge-art {
  display: grid;
  place-items: center;
  width: 3.9rem;
  height: 3.9rem;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), transparent 45%),
    var(--badge-color);
  color: #fff;
  font-size: 1.08rem;
  font-weight: 950;
  box-shadow:
    inset 0 -7px 0 rgba(0, 0, 0, 0.16),
    0 0.75rem 1.4rem rgba(19, 32, 51, 0.14);
}

.badge-card strong {
  display: block;
  width: 100%;
  min-height: 2.1rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.badge-card small {
  display: inline-grid;
  place-items: center;
  min-height: 1.55rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: rgba(19, 32, 51, 0.07);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
}

.badge-list p {
  color: var(--muted);
  font-weight: 800;
}

.reward-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  pointer-events: none;
  opacity: 0;
  background: rgba(19, 32, 51, 0.18);
  transition: opacity 180ms ease;
}

.reward-overlay.active {
  pointer-events: auto;
  opacity: 1;
}

.reward-card {
  position: relative;
  width: min(28rem, 100%);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: 1.2rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 248, 244, 0.96)),
    #fff;
  box-shadow: 0 28px 70px rgba(19, 32, 51, 0.32);
  transform: translateY(16px) scale(0.96);
}

.reward-overlay.active .reward-card {
  animation: rewardEnter 360ms cubic-bezier(0.2, 0.9, 0.2, 1.15) forwards;
}

.reward-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(19, 32, 51, 0.08);
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
}

.reward-icon {
  display: grid;
  place-items: center;
  width: 5.8rem;
  height: 5.8rem;
  margin-bottom: 0.85rem;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.5), transparent 44%),
    var(--reward-color, var(--blue));
  color: #fff;
  font-size: 1.45rem;
  font-weight: 950;
  box-shadow:
    inset 0 -0.75rem 0 rgba(0, 0, 0, 0.16),
    0 1rem 2rem rgba(19, 32, 51, 0.18);
}

.reward-card strong {
  display: block;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  line-height: 1;
}

.reward-card p:not(.eyebrow) {
  margin-top: 0.6rem;
  color: var(--muted);
  font-weight: 800;
}

.reward-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.reward-chips span {
  min-height: 2rem;
  padding: 0.42rem 0.65rem;
  border-radius: 999px;
  background: #132033;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 950;
}

.burst-piece {
  position: fixed;
  top: 52%;
  z-index: 21;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--burst-color);
  pointer-events: none;
  animation: burst 760ms ease-out forwards;
}

.xp-pop {
  position: absolute;
  right: 1.2rem;
  top: 1.1rem;
  z-index: 2;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: #132033;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 950;
  box-shadow: 0 0.8rem 1.5rem rgba(19, 32, 51, 0.18);
  pointer-events: none;
  animation: xpFloat 900ms ease-out forwards;
}

@keyframes rewardEnter {
  to {
    transform: translateY(0) scale(1);
  }
}

@keyframes rewardPulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.015);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes burst {
  to {
    opacity: 0;
    transform: translate(var(--burst-x), var(--burst-y)) rotate(220deg);
  }
}

@keyframes xpFloat {
  to {
    opacity: 0;
    transform: translateY(-2.3rem) scale(1.08);
  }
}

.stat-cards article,
.stats-list {
  border-radius: 8px;
  padding: 1rem;
}

.stats-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(8rem, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.stats-row:last-child {
  border-bottom: 0;
}

.bar {
  height: 0.8rem;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--pink));
}

.stats-row strong {
  display: block;
  margin-bottom: 0.3rem;
}

.stats-row p {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 760px) {
  .hero,
  .section-grid,
  .reward-strip,
  .stat-cards,
  .stats-row,
  .practice-head,
  .stats-head {
    grid-template-columns: 1fr;
  }

  .badge-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-grid,
  .stat-cards {
    display: grid;
  }

  .practice-head,
  .stats-head {
    display: flex;
    flex-direction: column;
  }

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

  .section-card {
    min-height: 11rem;
  }
}
