:root {
  --paper: #fffdf7;
  --ink: #263241;
  --muted: #5d6b78;
  --line: #d8e1ea;
  --blue: #2777d9;
  --teal: #00a7a5;
  --green: #4da947;
  --yellow: #f4b62a;
  --orange: #f47a2a;
  --pink: #e84c73;
  --shadow: 0 16px 30px rgba(38, 50, 65, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 20px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  line-height: 1.4;
  background-color: #f2fbff;
  background-image:
    linear-gradient(120deg, rgba(255, 244, 179, 0.65), transparent 32%),
    linear-gradient(240deg, rgba(170, 232, 216, 0.65), transparent 38%),
    linear-gradient(180deg, #f8fcff 0%, #fef6df 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px;
  border: 3px solid rgba(39, 119, 217, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.92);
  box-shadow: 0 10px 20px rgba(38, 50, 65, 0.08);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.35rem;
  line-height: 1.08;
}

h2 {
  margin-bottom: 12px;
  font-size: 3rem;
  line-height: 1.08;
}

h3 {
  margin-bottom: 22px;
  font-size: 2.15rem;
  line-height: 1.25;
}

.eyebrow,
.badge,
.question-type {
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #fff4c7;
  color: #79520a;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.start-screen {
  min-height: calc(100vh - 152px);
  display: none;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  gap: 28px;
  align-items: center;
}

.start-screen.is-active {
  display: grid;
}

.start-copy {
  padding: 44px;
  border: 3px solid rgba(244, 122, 42, 0.24);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.start-copy p:not(.badge) {
  max-width: 48ch;
  color: #425162;
  font-size: 1.22rem;
  line-height: 1.5;
}

.hero-icons {
  overflow: hidden;
  border: 3px solid rgba(0, 167, 165, 0.24);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.hero-icons img {
  display: block;
  width: 100%;
  height: auto;
}

.primary-button,
.ghost-button,
.sound-button,
.answer-button,
.submit-answer {
  min-height: 64px;
  padding: 16px 24px;
  border: 3px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.15;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-button {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 0 #155caa;
}

.ghost-button,
.sound-button {
  color: #1f5f84;
  border-color: #b8dff0;
  background: #f4fbff;
}

.primary-button:hover,
.ghost-button:hover,
.sound-button:hover,
.answer-button:hover,
.submit-answer:hover,
.subject-card:hover {
  transform: translateY(-2px);
}

.primary-button:active,
.ghost-button:active,
.sound-button:active,
.answer-button:active,
.submit-answer:active,
.subject-card:active {
  transform: translateY(1px);
}

.section-heading {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
  margin: 14px 0 24px;
}

.section-heading p:last-child {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.subject-card {
  position: relative;
  display: grid;
  grid-template-columns: 142px 1fr;
  gap: 16px;
  min-height: 214px;
  padding: 18px;
  border: 3px solid rgba(38, 50, 65, 0.1);
  border-left: 12px solid var(--card-color, var(--blue));
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: var(--paper);
  box-shadow: 0 10px 18px rgba(38, 50, 65, 0.09);
}

.sprite-icon {
  width: 142px;
  aspect-ratio: 1.125 / 1;
  align-self: start;
  border: 3px solid rgba(38, 50, 65, 0.08);
  border-radius: 8px;
  background-image: url("assets/icons.png");
  background-size: 400% 300%;
  background-position:
    calc(var(--icon-col, 0) * 33.333333%)
    calc(var(--icon-row, 0) * 50%);
  background-repeat: no-repeat;
  background-color: #fff;
}

.subject-card h3 {
  margin-bottom: 8px;
  font-size: 1.34rem;
  line-height: 1.18;
}

.subject-card p {
  margin-bottom: 14px;
  color: #546171;
  font-size: 1rem;
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #314053;
  background: #eef5f8;
  font-size: 0.9rem;
  font-weight: 800;
}

.mini-badge.done {
  color: #1f5b25;
  background: #dff5da;
}

.quiz-card,
.result-card {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px;
  border: 3px solid rgba(39, 119, 217, 0.18);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: var(--shadow);
}

.quiz-top {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
}

.score-pill {
  min-width: 170px;
  padding: 14px 16px;
  border: 3px solid #bce4da;
  border-radius: 8px;
  color: #096764;
  background: #eafffa;
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
}

.score-pill.pop {
  animation: pop 0.34s ease;
}

.progress-track {
  overflow: hidden;
  height: 22px;
  margin: 12px 0 24px;
  border-radius: 8px;
  background: #dfeaf2;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--orange));
  transition: width 0.28s ease;
}

.question-panel {
  padding: 34px;
  border: 3px solid #e4ecf2;
  border-radius: 8px;
  background: #fff;
}

.subject-tag {
  display: inline-flex;
  margin: -6px 0 18px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #614709;
  background: #fff2bd;
  font-weight: 800;
}

.answers {
  display: grid;
  gap: 16px;
}

.answer-button,
.submit-answer {
  width: 100%;
  border-color: #d7e3ec;
  color: var(--ink);
  background: #f9fcff;
  font-size: 1.08rem;
  text-align: left;
}

.answer-button.correct,
.match-row.correct select {
  border-color: #55ad50;
  color: #1d5924;
  background: #e4f8de;
  animation: correctPulse 0.45s ease;
}

.answer-button.wrong,
.match-row.wrong select {
  border-color: #e25d5d;
  color: #812626;
  background: #fff0f0;
}

.short-answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}

.short-answer-form input,
.match-row select {
  min-height: 70px;
  width: 100%;
  padding: 14px 16px;
  border: 3px solid #cbd9e4;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.match-list {
  display: grid;
  gap: 14px;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.match-left {
  padding: 16px;
  border-radius: 8px;
  background: #f1f6fb;
  font-weight: 800;
}

.feedback {
  display: none;
  margin-top: 20px;
  padding: 18px;
  border-radius: 8px;
  line-height: 1.45;
  font-size: 1.08rem;
  font-weight: 700;
}

.feedback.is-visible {
  display: block;
}

.feedback.good {
  color: #1d5924;
  background: #e4f8de;
}

.feedback.needs-work {
  color: #7a2e25;
  background: #fff0df;
}

.quiz-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  margin-top: 24px;
}

.result-card {
  text-align: center;
}

.reward-star {
  width: 160px;
  height: 160px;
  margin: 12px auto 16px;
  border-radius: 50%;
  color: #815405;
  background: #ffe08a;
  font-size: 6.2rem;
  line-height: 160px;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.65);
  transform-origin: center;
}

.reward-star.bronze {
  background: #d99b61;
}

.reward-star.silver {
  background: #dfe6ee;
}

.reward-star.gold {
  background: #ffd54a;
  animation: starWin 0.7s ease;
}

.result-score {
  margin-bottom: 14px;
  color: #096764;
  font-size: 1.75rem;
  font-weight: 900;
}

.result-message {
  max-width: 58ch;
  margin: 0 auto;
  color: #425162;
  font-size: 1.24rem;
  line-height: 1.5;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

@keyframes starWin {
  0% { transform: scale(0.8) rotate(-8deg); }
  55% { transform: scale(1.16) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}

@media (max-width: 780px) {
  html {
    font-size: 18px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 2.3rem;
  }

  h3 {
    font-size: 1.7rem;
  }

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

  .topbar .ghost-button,
  .topbar .sound-button {
    width: 100%;
  }

  .start-screen,
  .start-screen.is-active {
    grid-template-columns: 1fr;
  }

  .start-copy,
  .quiz-card,
  .result-card,
  .question-panel {
    padding: 24px;
  }

  .section-heading,
  .quiz-top {
    align-items: stretch;
    flex-direction: column;
  }

  .subject-card {
    grid-template-columns: 110px 1fr;
    min-height: 180px;
  }

  .sprite-icon {
    width: 110px;
  }

  .short-answer-form,
  .match-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  h1 {
    font-size: 1.55rem;
  }

  h2 {
    font-size: 2rem;
  }

  h3 {
    font-size: 1.45rem;
  }

  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .start-copy,
  .quiz-card,
  .result-card,
  .question-panel {
    padding: 16px;
  }

  .subject-card {
    grid-template-columns: 1fr;
  }

  .sprite-icon {
    width: min(180px, 100%);
  }

  .quiz-actions,
  .result-actions {
    flex-direction: column;
  }

  .primary-button,
  .ghost-button,
  .sound-button {
    width: 100%;
  }
}
