:root {
  --font-nunito: "Nunito";
  --font-space: "Space Grotesk";
  --ink: #18323a;
  --paper: #fffdf6;
  --orange: #ff7a3d;
  --orange-dark: #e85c21;
  --yellow: #ffc84a;
  --mint: #4ec9a6;
  --sky: #53b9df;
  --line: #dfe9e4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f5efe2;
  color: var(--ink);
  font-family: var(--font-nunito), sans-serif;
}

button { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px),
    #f5efe2;
  background-size: 32px 32px;
}

.background-blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  opacity: .9;
}

.blob-one { width: 340px; height: 340px; background: #ffd469; top: -160px; left: -80px; }
.blob-two { width: 420px; height: 420px; background: #9de3d0; right: -160px; bottom: -230px; }

.game-card {
  width: min(920px, 100%);
  min-height: 650px;
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 28px;
  box-shadow: 10px 12px 0 var(--ink);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 30px;
  border-bottom: 2px solid var(--ink);
  background: rgba(255,255,255,.75);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--orange);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  color: white;
  font: 800 34px/1 var(--font-space), sans-serif;
}

.eyebrow {
  margin: 0 0 2px;
  font: 800 11px/1.3 var(--font-space), sans-serif;
  letter-spacing: .15em;
  color: #607a78;
}

h1, h2 { margin: 0; font-family: var(--font-space), sans-serif; letter-spacing: -.04em; }
h1 { font-size: 30px; }

.score-pill, .mini-stats span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff4c7;
  box-shadow: 3px 3px 0 var(--ink);
}

.progress-section { padding: 22px 30px 0; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.progress-track {
  height: 13px;
  background: #e5ece8;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--mint), var(--mint) 8px, #78dabe 8px, #78dabe 16px);
  border-right: 2px solid var(--ink);
  transition: width .35s ease;
}

.quiz { padding: 34px 70px 22px; text-align: center; }
.mode-badges { display: flex; justify-content: center; gap: 8px; }
.mode-badges span {
  padding: 6px 10px;
  border-radius: 8px;
  background: #e9efec;
  color: #79908c;
  font: 800 10px var(--font-space), sans-serif;
  letter-spacing: .1em;
}
.mode-badges span.active { background: var(--ink); color: white; }
.prompt { color: #6d817d; margin: 22px 0 4px; font-weight: 700; }
.equation {
  font: 700 clamp(50px, 8vw, 82px)/1.15 var(--font-space), sans-serif;
  letter-spacing: -.06em;
  margin-bottom: 28px;
  transition: transform .2s, color .2s;
}
.equation span { color: var(--orange); }
.equation.good { color: #198b6d; transform: scale(1.04); }
.equation.bad { color: #d94836; animation: shake .28s linear; }

@keyframes shake {
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.answers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.answers button {
  min-height: 76px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: white;
  color: var(--ink);
  box-shadow: 4px 5px 0 var(--ink);
  font: 800 27px var(--font-space), sans-serif;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.answers button:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 4px 8px 0 var(--ink); background: #fff6d8; }
.answers button:active:not(:disabled) { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.answers button.correct-answer { background: var(--mint); color: #092f28; }
.answers button.dimmed { opacity: .55; }
.feedback { min-height: 28px; margin-top: 22px; font-weight: 800; color: #70817e; }
.feedback.good { color: #198b6d; }
.feedback.bad { color: #cc4937; }

.footer-stats {
  display: flex;
  justify-content: center;
  gap: 34px;
  border-top: 1px dashed #aebfba;
  padding: 18px;
  color: #536d68;
}

.mini-game { padding: 28px 34px 26px; }
.mini-heading { display: flex; justify-content: space-between; align-items: end; max-width: 600px; margin: 0 auto; }
.mini-heading h2 { font-size: 36px; }
.mini-stats { display: flex; gap: 10px; }
.mini-stats span { padding: 8px 13px; background: white; font-weight: 900; }
.mini-instruction { text-align: center; color: #5b746f; margin: 10px 0 14px; }

.mini-canvas {
  display: block;
  width: min(560px, 82vw);
  aspect-ratio: 8 / 5;
  margin: 0 auto;
  background: #d7efca;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 7px 0 var(--ink);
  touch-action: none;
}

.game-controls { margin: 18px auto 0; display: flex; justify-content: center; gap: 7px; }
.game-controls button {
  display: grid;
  place-items: center;
  width: 50px; height: 42px;
  background: white;
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  font-weight: 900;
}
.game-controls button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.skip-button {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 16px auto 0;
  border: 0;
  background: transparent;
  color: #5c716d;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 650px) {
  .app-shell { padding: 12px; align-items: start; }
  .game-card { min-height: calc(100vh - 24px); border-radius: 20px; box-shadow: 5px 6px 0 var(--ink); }
  .topbar { padding: 17px; }
  .brand-mark { width: 43px; height: 43px; }
  h1 { font-size: 23px; }
  .score-pill { padding: 8px 10px; font-size: 13px; }
  .score-pill svg { display: none; }
  .progress-section { padding: 18px 18px 0; }
  .quiz { padding: 28px 18px 20px; }
  .equation { margin-bottom: 24px; }
  .answers { grid-template-columns: repeat(2, 1fr); }
  .answers button { min-height: 68px; }
  .footer-stats { flex-direction: column; gap: 5px; text-align: center; }
  .mini-game { padding: 24px 14px; }
  .mini-heading { align-items: center; }
  .mini-heading h2 { font-size: 29px; }
  .mini-stats { flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
