:root {
  color-scheme: dark;
  --bg-a: #1436a3;
  --bg-b: #7b3ff2;
  --bg-c: #ff7ab8;
  --text: #fff9ff;
  --muted: rgba(255, 255, 255, 0.78);
  --card: rgba(255, 255, 255, 0.16);
  --card-strong: rgba(255, 255, 255, 0.24);
  --card-border: rgba(255, 255, 255, 0.28);
  --shadow: 0 22px 70px rgba(22, 18, 67, 0.32);
  --button-a: #00d4ff;
  --button-b: #ff72c7;
  --button-c: #ffd166;
  --correct: #25d889;
  --correct-soft: rgba(37, 216, 137, 0.16);
  --incorrect: #ff5c7a;
  --incorrect-soft: rgba(255, 92, 122, 0.16);
  --warning: #ffd166;
  --input: rgba(255, 255, 255, 0.14);
  --input-border: rgba(255, 255, 255, 0.32);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

body.light-mode {
  color-scheme: light;
  --bg-a: #dff7ff;
  --bg-b: #f0dbff;
  --bg-c: #ffe2ef;
  --text: #201a3d;
  --muted: rgba(32, 26, 61, 0.72);
  --card: rgba(255, 255, 255, 0.62);
  --card-strong: rgba(255, 255, 255, 0.78);
  --card-border: rgba(101, 83, 172, 0.18);
  --shadow: 0 20px 55px rgba(70, 67, 128, 0.18);
  --input: rgba(255, 255, 255, 0.72);
  --input-border: rgba(86, 70, 166, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 209, 102, 0.35), transparent 26%),
    radial-gradient(circle at 84% 16%, rgba(0, 212, 255, 0.28), transparent 28%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b) 52%, var(--bg-c));
  background-attachment: fixed;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 82%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

.background-lights {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

.blob,
.spark {
  position: absolute;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.72;
  animation: floaty 16s ease-in-out infinite;
}

.blob {
  width: 26rem;
  height: 26rem;
}

.blob-one {
  top: 8%;
  left: -7rem;
  background: rgba(0, 212, 255, 0.38);
}

.blob-two {
  right: -8rem;
  bottom: 12%;
  background: rgba(255, 114, 199, 0.42);
  animation-delay: -5s;
}

.blob-three {
  top: 48%;
  left: 42%;
  background: rgba(255, 209, 102, 0.22);
  animation-delay: -9s;
}

.spark {
  width: 8rem;
  height: 8rem;
  background: rgba(255, 255, 255, 0.3);
}

.spark-one {
  top: 24%;
  right: 22%;
}

.spark-two {
  bottom: 18%;
  left: 14%;
  animation-delay: -7s;
}

.spark-three {
  top: 68%;
  right: 10%;
  animation-delay: -11s;
}

@keyframes floaty {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(28px, -34px, 0) scale(1.07);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  backdrop-filter: blur(22px);
  background: rgba(17, 18, 57, 0.42);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

body.light-mode .topbar {
  background: rgba(255, 255, 255, 0.55);
}

.topbar__progress {
  display: grid;
  grid-template-columns: auto minmax(130px, 340px);
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

.progress-track {
  height: 0.72rem;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--button-a), var(--button-b), var(--button-c));
  box-shadow: 0 0 22px rgba(0, 212, 255, 0.55);
  transition: width 0.35s ease;
}

.topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 3rem) 0 7rem;
}

.glass-card {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, var(--card), rgba(255, 255, 255, 0.08));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
  min-height: calc(100vh - 7rem);
  padding: clamp(1.25rem, 5vw, 4rem);
  margin-bottom: 1.5rem;
}

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

.hero h1,
.hero h2,
.section-header h3,
.result-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 9ch;
  font-size: clamp(3rem, 8vw, 6.6rem);
  line-height: 0.9;
}

.hero h2 {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  line-height: 1.1;
}

.student-name {
  display: inline-flex;
  width: fit-content;
  margin: 1.2rem 0 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 850;
}

.hero__copy {
  max-width: 56ch;
  margin: 1.3rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.hero__chips span,
.tag {
  padding: 0.48rem 0.72rem;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 780;
}

.cover-card {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4.15;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.08)),
    radial-gradient(circle at 50% 18%, rgba(255, 209, 102, 0.35), transparent 40%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  transform: rotate(2deg);
  transition: transform 0.35s ease;
}

.cover-card:hover {
  transform: rotate(0deg) translateY(-4px);
}

.cover-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  display: grid;
  place-items: center;
  gap: 0.8rem;
  width: 100%;
  height: 100%;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.cover-placeholder__icon {
  font-size: 4rem;
}

.exam-container {
  display: grid;
  gap: 1.4rem;
}

.exam-section {
  padding: clamp(1rem, 3vw, 1.6rem);
  animation: sectionIn 0.55s ease both;
}

.exam-section:nth-child(2n) {
  animation-delay: 0.08s;
}

@keyframes sectionIn {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header h3 {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.section-progress {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.question-list {
  display: grid;
  gap: 1rem;
}

.question-card {
  position: relative;
  display: grid;
  gap: 0.95rem;
  padding: 1rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.11);
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.question-card:hover {
  transform: translateY(-2px);
  background: var(--card-strong);
}

.question-card.is-correct {
  border-color: rgba(37, 216, 137, 0.75);
  background: var(--correct-soft);
  animation: popCorrect 0.42s ease;
}

.question-card.is-incorrect {
  border-color: rgba(255, 92, 122, 0.8);
  background: var(--incorrect-soft);
  animation: shakeWrong 0.42s ease;
}

@keyframes popCorrect {
  50% {
    transform: scale(1.012);
  }
}

@keyframes shakeWrong {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

.question-title {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin: 0;
  color: var(--text);
  font-weight: 850;
  line-height: 1.45;
}

.question-number {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--button-a), var(--button-b));
  color: white;
  font-size: 0.82rem;
  font-weight: 950;
  box-shadow: 0 8px 24px rgba(0, 212, 255, 0.28);
}

.options-grid {
  display: grid;
  gap: 0.65rem;
}

.option-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.7rem;
  padding: 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.option-row:hover {
  transform: translateX(3px);
  border-color: rgba(255, 255, 255, 0.52);
}

.option-row.correct-answer,
.option-row.manual-accepted {
  border-color: var(--correct);
  background: rgba(37, 216, 137, 0.18);
}

.option-row.wrong-answer,
.manual-checkbox.wrong-answer {
  border-color: var(--incorrect);
  background: rgba(255, 92, 122, 0.18);
}

.option-letter {
  display: inline-grid;
  place-items: center;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.78rem;
  font-weight: 900;
}

input[type="radio"],
input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.17rem;
  accent-color: #25d889;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select {
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
}

textarea {
  min-height: 8rem;
  padding: 0.9rem;
  resize: vertical;
  line-height: 1.55;
}

select:focus,
textarea:focus {
  border-color: var(--button-a);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.16);
}

body:not(.light-mode) select option {
  color: #201a3d;
}

.paired-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(220px, 1fr);
  gap: 0.8rem;
  align-items: center;
}

.term-label {
  font-weight: 900;
}

.timeline-list {
  display: grid;
  gap: 0.75rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input);
}

.timeline-row select {
  min-height: 2.7rem;
}

.manual-tools {
  display: grid;
  gap: 0.75rem;
}

.manual-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  background: var(--input);
  color: var(--text);
  font-weight: 800;
}

.feedback {
  display: none;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
  line-height: 1.5;
}

.feedback.show {
  display: block;
}

.feedback strong {
  color: var(--text);
}

.correct-text {
  color: var(--correct);
  font-weight: 900;
}

.incorrect-text {
  color: var(--incorrect);
  font-weight: 900;
}

.result-card {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: clamp(1.2rem, 4vw, 2rem);
  transform-origin: center top;
  animation: resultIn 0.45s ease both;
}

@keyframes resultIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.result-card h3 {
  font-size: clamp(1.7rem, 4vw, 3rem);
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.result-stat {
  padding: 1rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
}

.result-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-stat strong {
  display: block;
  margin-top: 0.25rem;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
}

.result-message {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
  line-height: 1.5;
}

.final-actions {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1.4rem;
  padding: 1rem;
}

.button,
.icon-button {
  border: 0;
  color: white;
  font-weight: 900;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.button {
  min-height: 2.85rem;
  padding: 0.78rem 1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--button-a), var(--button-b));
  box-shadow: 0 12px 30px rgba(0, 212, 255, 0.2);
}

.button--small {
  min-height: 2.45rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
}

.button--large {
  min-width: min(100%, 250px);
  font-size: 1rem;
}

.button--ghost {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.button:hover,
.icon-button:hover,
.floating-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.12);
}

.button:active,
.icon-button:active,
.floating-button:active {
  transform: translateY(0) scale(0.98);
}

.floating-button {
  position: fixed;
  z-index: 18;
  display: grid;
  place-items: center;
  width: 3.35rem;
  height: 3.35rem;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--button-a), var(--button-b));
  color: white;
  font-size: 1.35rem;
  font-weight: 950;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.floating-button--shuffle {
  right: 1.1rem;
  bottom: 5.2rem;
}

.floating-button--top {
  right: 1.1rem;
  bottom: 1.2rem;
  opacity: 0;
  pointer-events: none;
}

.floating-button--top.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -1rem;
  width: 0.65rem;
  height: 1rem;
  border-radius: 0.2rem;
  animation: confettiFall 2.6s linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(105vh) rotate(720deg);
    opacity: 0;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar__progress {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .topbar__actions {
    justify-content: stretch;
  }

  .topbar__actions .button {
    flex: 1;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .cover-card {
    width: min(310px, 100%);
    justify-self: center;
  }

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

  .paired-grid,
  .timeline-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 1rem, 1180px);
    padding-bottom: 6rem;
  }

  .topbar__actions {
    flex-wrap: wrap;
  }

  .topbar__actions .icon-button {
    flex: 0 0 2.55rem;
  }

  .hero,
  .glass-card {
    border-radius: 22px;
  }

  .hero h1 {
    font-size: clamp(2.6rem, 18vw, 4.8rem);
  }

  .section-header {
    flex-direction: column;
  }

  .question-title {
    flex-direction: column;
  }

  .result-summary {
    grid-template-columns: 1fr;
  }

  .final-actions {
    flex-direction: column;
  }

  .button--large {
    width: 100%;
  }
}
