@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Nunito:wght@500;600;700;800;900&display=swap");

:root {
  color-scheme: light;
  font-family: "DM Sans", sans-serif;
  color: #26324a;
  background: #fff8ed;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  --ink: #26324a;
  --muted: #788196;
  --purple: #7657df;
  --purple-dark: #6142c5;
  --coral: #ff8a72;
  --mint: #e7f8ef;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 9% 25%, rgba(255, 207, 165, 0.3), transparent 25rem),
    radial-gradient(ellipse at 93% 61%, rgba(206, 195, 255, 0.27), transparent 27rem),
    #fff8ed;
}

button,
input {
  font: inherit;
}

.site-header {
  width: min(100% - 48px, 1080px);
  min-height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Nunito", sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--purple);
  font-size: 1.2rem;
}

.brand-grade {
  margin-left: 3px;
  padding: 3px 8px;
  border-radius: 8px;
  color: #9c5c37;
  background: #ffe4cf;
  font-size: 0.8rem;
}

.header-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

main {
  width: min(100% - 40px, 680px);
  margin: 48px auto 54px;
}

.intro {
  margin-bottom: 30px;
  text-align: center;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid #eee8ff;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.04em;
  text-transform: none;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Nunito", sans-serif;
}

h1 {
  margin-bottom: 7px;
  color: var(--ink);
  font-size: clamp(2.5rem, 8vw, 3.65rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.intro-copy {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.lesson-picker {
  margin: 0 auto 20px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  border: 1px solid rgba(225, 219, 244, 0.8);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.lesson-button {
  min-height: 42px;
  padding: 9px 15px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 800;
  transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.lesson-button:hover {
  color: var(--purple-dark);
}

.lesson-button.is-active {
  color: #fff;
  background: var(--purple);
  box-shadow: 0 4px 10px rgba(118, 87, 223, 0.18);
}

.lesson-button:focus-visible {
  outline: 3px solid #ad9af1;
  outline-offset: 3px;
}

.lesson-button,
.comparison-button {
  white-space: nowrap;
}

.game-card {
  padding: 30px 38px 34px;
  border: 1px solid rgba(225, 219, 244, 0.8);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 55px rgba(76, 57, 134, 0.1), 0 3px 10px rgba(76, 57, 134, 0.04);
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game-top h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
  font-weight: 900;
}

.section-label {
  font-size: 0.7rem;
}

.score-pill {
  min-width: 66px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 14px;
  color: #986118;
  background: #fff4d8;
  font-weight: 800;
}

.progress-area {
  margin-top: 26px;
}

.progress-label {
  margin-bottom: 9px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #f0edf7;
}

.progress-fill {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #9d7cf2, #7657df);
  transition: width 250ms ease;
}

.exercise {
  padding-top: 32px;
  text-align: center;
}

.sum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 20px);
  color: var(--ink);
  font-family: "Nunito", sans-serif;
  font-size: clamp(2.35rem, 8vw, 3.3rem);
  font-weight: 900;
}

.operator {
  color: var(--coral);
}

.equals {
  color: #a4a9b5;
}

.answer-input {
  width: clamp(66px, 17vw, 82px);
  height: clamp(66px, 17vw, 82px);
  padding: 4px;
  border: 2px dashed #c9c0e8;
  border-radius: 20px;
  outline: none;
  color: var(--purple-dark);
  background: #faf8ff;
  font-family: "Nunito", sans-serif;
  font-size: clamp(2rem, 7vw, 2.7rem);
  font-weight: 900;
  text-align: center;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
  appearance: textfield;
}

.answer-input::-webkit-inner-spin-button,
.answer-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.answer-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(118, 87, 223, 0.13);
}

.answer-input:disabled {
  opacity: 0.75;
}

.comparison-options {
  display: flex;
  align-items: center;
  gap: clamp(5px, 2vw, 12px);
}

.comparison-button {
  width: clamp(52px, 13vw, 68px);
  height: clamp(58px, 15vw, 72px);
  padding: 4px;
  border: 2px solid #e8e2f5;
  border-radius: 17px;
  color: var(--purple-dark);
  background: #faf8ff;
  cursor: pointer;
  font-family: "Nunito", sans-serif;
  font-size: clamp(2rem, 7vw, 2.7rem);
  font-weight: 900;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}

.comparison-button:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #b7a9e5;
}

.comparison-button.is-selected {
  border-color: var(--purple);
  color: #fff;
  background: var(--purple);
  box-shadow: 0 5px 12px rgba(118, 87, 223, 0.2);
}

.comparison-button:disabled:not(.is-selected) {
  opacity: 0.55;
}

.comparison-button:focus-visible {
  outline: 3px solid #ad9af1;
  outline-offset: 3px;
}

.feedback {
  min-height: 25px;
  margin: 17px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.feedback.is-correct {
  color: #218255;
}

.feedback.is-wrong {
  color: #cb604d;
}

.button {
  min-height: 50px;
  padding: 12px 23px;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button:focus-visible,
.brand:focus-visible {
  outline: 3px solid #ad9af1;
  outline-offset: 3px;
}

.button:active {
  transform: translateY(0);
}

.button-primary {
  color: #fff;
  background: var(--purple);
  box-shadow: 0 7px 15px rgba(118, 87, 223, 0.2);
}

.button-primary:hover {
  background: var(--purple-dark);
}

.result-panel {
  padding: 34px 0 6px;
  text-align: center;
}

.result-emoji {
  margin-bottom: 8px;
  font-size: 3rem;
}

.result-panel h2 {
  margin-bottom: 8px;
  font-size: 2rem;
}

.result-panel p {
  margin-bottom: 22px;
  color: var(--muted);
}

.tip-card {
  margin-top: 20px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid #f6e8cd;
  border-radius: 18px;
  background: rgba(255, 250, 237, 0.8);
}

.tip-icon {
  flex: 0 0 auto;
  font-size: 1.35rem;
}

.tip-card p {
  margin: 0;
  color: #756d60;
  font-size: 0.9rem;
  line-height: 1.5;
}

.tip-card strong {
  color: #4a443b;
}

.site-footer {
  margin-top: auto;
  padding: 0 20px 24px;
  color: #9893a3;
  font-size: 0.8rem;
  text-align: center;
}

.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  position: absolute;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .site-header {
    width: calc(100% - 32px);
    min-height: 68px;
  }

  .header-note {
    max-width: 120px;
    font-size: 0.75rem;
    text-align: right;
  }

  main {
    width: calc(100% - 28px);
    margin-top: 35px;
  }

  .game-card {
    padding: 24px 18px 27px;
    border-radius: 22px;
  }

  .game-top h2 {
    font-size: 1.2rem;
  }

  .tip-card {
    padding: 14px 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
