:root {
  --ink: #1d2636;
  --muted: #59647a;
  --paper: #fffaf0;
  --surface: #ffffff;
  --sun: #ffd166;
  --leaf: #43aa8b;
  --sky: #4d96ff;
  --berry: #ef476f;
  --grape: #7b61ff;
  --correct: #1f9d55;
  --wrong: #d64545;
  font-family: Inter, ui-rounded, "Avenir Next", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 209, 102, 0.4), transparent 30%),
    linear-gradient(135deg, #e8f7ff 0%, #fff7df 42%, #f2fff5 100%);
}

button {
  font: inherit;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--berry);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

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

.score-pill {
  display: grid;
  min-width: 112px;
  min-height: 72px;
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 24px;
  background: var(--sun);
  box-shadow: 0 8px 0 rgba(29, 38, 54, 0.18);
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 950;
}

.grade-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.grade-card {
  display: grid;
  min-height: 300px;
  align-content: center;
  gap: 16px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 12px 0 rgba(29, 38, 54, 0.16);
  color: var(--ink);
  cursor: pointer;
  padding: 28px;
  text-align: center;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.grade-card:nth-child(1) {
  background: #fff0f6;
}

.grade-card:nth-child(2) {
  background: #effff9;
}

.grade-card:nth-child(3) {
  background: #eff6ff;
}

.grade-card:hover,
.grade-card:focus-visible {
  box-shadow: 0 6px 0 rgba(29, 38, 54, 0.18);
  outline: 0;
  transform: translateY(6px);
}

.grade-icon {
  font-size: clamp(4rem, 10vw, 7rem);
  line-height: 1;
}

.grade-title {
  font-size: clamp(2rem, 6vw, 3.8rem);
  font-weight: 950;
}

.grade-subtitle {
  color: var(--muted);
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  font-weight: 800;
}

.quiz-panel,
.result-panel {
  display: grid;
  gap: 20px;
}

.quiz-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
}

.small-button,
.next-button {
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 6px 0 rgba(29, 38, 54, 0.16);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 900;
  padding: 14px 18px;
}

.small-button:hover,
.small-button:focus-visible,
.next-button:hover,
.next-button:focus-visible {
  outline: 0;
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(29, 38, 54, 0.18);
}

.progress-track {
  height: 22px;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--leaf), var(--sky));
  transition: width 220ms ease;
}

.question-card {
  display: grid;
  min-height: 390px;
  align-content: center;
  gap: 18px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 12px 0 rgba(29, 38, 54, 0.16);
  padding: clamp(18px, 4vw, 34px);
  text-align: center;
}

.question-count {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
}

.question-card h2 {
  font-size: clamp(1.7rem, 4.5vw, 3.8rem);
  line-height: 1.05;
}

.visual-stage {
  display: grid;
  min-height: 180px;
  place-items: center;
}

.visual {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
  width: 100%;
}

.big-token,
.operator-token,
.shape-token {
  display: inline-grid;
  min-width: clamp(58px, 10vw, 104px);
  min-height: clamp(58px, 10vw, 104px);
  place-items: center;
  border: 4px solid var(--ink);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 7px 0 rgba(29, 38, 54, 0.14);
  font-size: clamp(2.6rem, 8vw, 5.8rem);
  font-weight: 950;
  line-height: 1;
}

.operator-token {
  min-width: 72px;
  background: #dff7ff;
}

.question-token {
  background: #fff0f6;
  color: var(--berry);
}

.crossed {
  position: relative;
  opacity: 0.52;
}

.crossed::after {
  position: absolute;
  inset: 46% 10%;
  height: 8px;
  border-radius: 999px;
  background: var(--wrong);
  content: "";
  transform: rotate(-18deg);
}

.visual-compare {
  align-items: stretch;
}

.side-group {
  display: grid;
  min-width: min(330px, 100%);
  align-content: center;
  gap: 14px;
  border: 4px dashed rgba(29, 38, 54, 0.5);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.6);
  padding: 18px;
}

.side-group strong {
  font-size: clamp(1.4rem, 3vw, 2.2rem);
}

.side-items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.target-box {
  display: flex;
  gap: 14px;
  border: 5px solid var(--sky);
  border-radius: 28px;
  background: #ffffff;
  padding: 22px;
}

.visual-towers {
  min-height: 170px;
  align-items: flex-end;
}

.tower {
  width: clamp(52px, 9vw, 92px);
  border: 4px solid var(--ink);
  border-radius: 18px 18px 8px 8px;
  background: linear-gradient(180deg, var(--sun), #ff8a5c);
  box-shadow: 0 7px 0 rgba(29, 38, 54, 0.14);
}

.sum-group,
.half-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 520px;
}

.half-group {
  border: 4px dashed var(--leaf);
  border-radius: 24px;
  padding: 16px;
}

.equation {
  display: inline-grid;
  min-height: 160px;
  place-items: center;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 9px 0 rgba(29, 38, 54, 0.14);
  font-size: clamp(4rem, 15vw, 9rem);
  font-weight: 950;
  padding: 8px 36px;
}

.ten-rod {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: clamp(120px, 23vw, 210px);
  border: 4px solid var(--ink);
  border-radius: 18px;
  background: #ffffff;
  padding: 8px;
}

.ten-rod span {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--sky);
}

.clock {
  position: relative;
  width: clamp(180px, 38vw, 300px);
  aspect-ratio: 1;
  border: 8px solid var(--ink);
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--ink) 0 7px, transparent 8px),
    #ffffff;
  box-shadow: 0 9px 0 rgba(29, 38, 54, 0.14);
}

.clock::before {
  position: absolute;
  inset: 16px;
  border: 3px dashed rgba(29, 38, 54, 0.2);
  border-radius: 50%;
  content: "";
}

.clock-hand {
  position: absolute;
  bottom: 50%;
  left: calc(50% - 5px);
  width: 10px;
  border-radius: 999px;
  background: var(--ink);
  transform-origin: bottom center;
}

.hour-hand {
  height: 28%;
}

.minute-hand {
  height: 38%;
  background: var(--berry);
}

.coin {
  display: grid;
  width: clamp(84px, 16vw, 140px);
  aspect-ratio: 1;
  place-items: center;
  border: 5px solid #9c6b1d;
  border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 8px 0 rgba(29, 38, 54, 0.14);
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 950;
}

.visual-lengths {
  display: grid;
  justify-items: start;
  max-width: 620px;
  margin: 0 auto;
}

.length-row {
  display: grid;
  grid-template-columns: auto minmax(58px, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
}

.length-row span {
  display: block;
  height: 26px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  background: var(--leaf);
}

.length-row strong {
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.cup {
  position: relative;
  width: clamp(78px, 15vw, 130px);
  height: clamp(110px, 20vw, 180px);
  overflow: hidden;
  border: 5px solid var(--ink);
  border-top-width: 2px;
  border-radius: 10px 10px 28px 28px;
  background: #ffffff;
  box-shadow: 0 8px 0 rgba(29, 38, 54, 0.14);
}

.cup-fill {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  background: #4d96ff;
}

.cup-empty {
  height: 0;
}

.cup-low {
  height: 22%;
}

.cup-half {
  height: 52%;
}

.cup-full {
  height: 92%;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.choice-button {
  display: grid;
  min-height: 180px;
  place-items: center;
  gap: 8px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 10px 0 rgba(29, 38, 54, 0.15);
  color: var(--ink);
  cursor: pointer;
  padding: 16px 10px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.choice-button:hover,
.choice-button:focus-visible {
  outline: 0;
  transform: translateY(5px);
  box-shadow: 0 5px 0 rgba(29, 38, 54, 0.17);
}

.choice-button:disabled {
  cursor: default;
}

.choice-graphic {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  min-height: 84px;
  gap: 4px;
  place-items: center;
  color: var(--grape);
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 950;
  line-height: 1;
}

.choice-label {
  max-width: 100%;
  font-size: clamp(1.05rem, 2.3vw, 1.8rem);
  font-weight: 950;
  overflow-wrap: anywhere;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.choice-button.is-correct {
  background: #dff8e9;
  border-color: var(--correct);
}

.choice-button.is-wrong {
  background: #ffe5e5;
  border-color: var(--wrong);
}

.feedback {
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 7px 0 rgba(29, 38, 54, 0.14);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 950;
  padding: 18px 20px;
  text-align: center;
}

.feedback-good {
  background: #dff8e9;
}

.feedback-warm {
  background: #fff0d0;
}

.next-button {
  justify-self: center;
  min-width: min(360px, 100%);
  background: var(--sun);
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  padding: 18px 32px;
}

.result-panel {
  justify-items: center;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 12px 0 rgba(29, 38, 54, 0.16);
  padding: clamp(28px, 6vw, 60px);
  text-align: center;
}

.result-visual {
  font-size: clamp(5rem, 18vw, 10rem);
}

.result-panel h2 {
  font-size: clamp(2.2rem, 8vw, 5.4rem);
}

.result-panel p {
  color: var(--muted);
  font-size: clamp(1.3rem, 4vw, 2.4rem);
  font-weight: 900;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.is-hidden {
  display: none;
}

@media (max-width: 850px) {
  .top-bar {
    align-items: flex-start;
  }

  .grade-panel {
    grid-template-columns: 1fr;
  }

  .grade-card {
    min-height: 190px;
  }

  .quiz-meta {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 700px) and (max-width: 950px),
  (min-width: 900px) and (max-width: 1400px) and (max-height: 950px) {
  .app-shell {
    width: min(100% - 28px, 1180px);
    padding: 16px 0 18px;
  }

  .top-bar {
    margin-bottom: 14px;
  }

  h1 {
    font-size: clamp(2rem, 5vw, 3.25rem);
  }

  .score-pill {
    min-height: 58px;
    min-width: 96px;
    border-radius: 18px;
    font-size: 1.45rem;
  }

  .quiz-panel {
    gap: 12px;
  }

  .quiz-meta {
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .small-button {
    border-width: 3px;
    border-radius: 16px;
    box-shadow: 0 4px 0 rgba(29, 38, 54, 0.16);
    font-size: 0.95rem;
    padding: 10px 14px;
  }

  .progress-track {
    height: 18px;
    border-width: 3px;
  }

  .question-card {
    min-height: 280px;
    gap: 10px;
    border-width: 4px;
    border-radius: 22px;
    box-shadow: 0 7px 0 rgba(29, 38, 54, 0.16);
    padding: 16px;
  }

  .question-card h2 {
    font-size: clamp(1.45rem, 3.6vw, 2.35rem);
  }

  .visual-stage {
    min-height: 122px;
  }

  .visual {
    gap: 10px;
  }

  .big-token,
  .operator-token,
  .shape-token {
    min-width: clamp(48px, 8vw, 72px);
    min-height: clamp(48px, 8vw, 72px);
    border-width: 3px;
    border-radius: 16px;
    box-shadow: 0 4px 0 rgba(29, 38, 54, 0.14);
    font-size: clamp(2rem, 5.5vw, 4rem);
  }

  .operator-token {
    min-width: 56px;
  }

  .side-group {
    min-width: min(260px, 48%);
    gap: 8px;
    border-width: 3px;
    border-radius: 18px;
    padding: 10px;
  }

  .target-box,
  .half-group {
    border-width: 3px;
    border-radius: 18px;
    padding: 10px;
  }

  .visual-towers {
    min-height: 122px;
  }

  .tower {
    width: clamp(42px, 7vw, 64px);
    border-width: 3px;
  }

  .equation {
    min-height: 112px;
    border-width: 4px;
    border-radius: 22px;
    box-shadow: 0 5px 0 rgba(29, 38, 54, 0.14);
    font-size: clamp(3rem, 10vw, 5rem);
    padding: 4px 24px;
  }

  .clock {
    width: clamp(132px, 24vw, 190px);
    border-width: 6px;
  }

  .cup {
    width: clamp(58px, 10vw, 92px);
    height: clamp(82px, 14vw, 126px);
    border-width: 4px;
  }

  .coin {
    width: clamp(64px, 11vw, 98px);
    border-width: 4px;
    font-size: clamp(1.25rem, 3vw, 2rem);
  }

  .choices-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .choice-button {
    min-height: 112px;
    gap: 4px;
    border-width: 4px;
    border-radius: 20px;
    box-shadow: 0 6px 0 rgba(29, 38, 54, 0.15);
    padding: 8px;
  }

  .choice-graphic {
    min-width: 54px;
    min-height: 54px;
    font-size: clamp(2rem, 4.5vw, 3.2rem);
  }

  .choice-label {
    font-size: clamp(0.95rem, 2.1vw, 1.3rem);
  }

  .feedback {
    border-width: 3px;
    border-radius: 18px;
    box-shadow: 0 4px 0 rgba(29, 38, 54, 0.14);
    font-size: clamp(1rem, 2.4vw, 1.45rem);
    padding: 10px 14px;
  }

  .next-button {
    min-width: min(300px, 100%);
    border-width: 4px;
    border-radius: 18px;
    box-shadow: 0 5px 0 rgba(29, 38, 54, 0.16);
    font-size: clamp(1.05rem, 2.4vw, 1.45rem);
    padding: 12px 26px;
  }
}

@media (min-width: 900px) and (max-width: 1400px) and (max-height: 950px) and (orientation: landscape) {
  .app-shell {
    padding: 12px 0 14px;
  }

  .top-bar {
    margin-bottom: 10px;
  }

  h1 {
    font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  }

  .score-pill {
    min-height: 54px;
  }

  .quiz-panel {
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    grid-template-areas:
      "meta meta"
      "question choices"
      "question feedback"
      "question next";
    align-items: stretch;
    gap: 10px 14px;
  }

  .quiz-meta {
    grid-area: meta;
  }

  .question-card {
    grid-area: question;
    min-height: 0;
  }

  .choices-grid {
    grid-area: choices;
    align-self: start;
  }

  .feedback {
    grid-area: feedback;
    align-self: start;
  }

  .next-button {
    grid-area: next;
    align-self: start;
    justify-self: stretch;
  }

  .visual-stage {
    min-height: 160px;
  }

  .choice-button {
    min-height: 118px;
  }

  .feedback.is-hidden,
  .next-button.is-hidden {
    display: none;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .top-bar {
    display: grid;
  }

  .score-pill {
    min-height: 58px;
    justify-self: start;
  }

  .question-card {
    min-height: 330px;
  }

  .choices-grid {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: 190px;
  }

  .big-token,
  .shape-token {
    border-width: 3px;
    border-radius: 18px;
  }
}
