:root {
  color-scheme: light;
  --night: #213330;
  --night-soft: #304944;
  --paper: #fffdf7;
  --ink: #33433e;
  --muted: #74827c;
  --rule: #d8dfd7;
  --coral: #e06c65;
  --mint: #8fc9b4;
  --blue: #768fbe;
  --gold: #efc069;
  --green: #3c8b66;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--night);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--night);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(115deg, rgba(224, 108, 101, 0.1), transparent 32%),
    linear-gradient(295deg, rgba(118, 143, 190, 0.1), transparent 36%);
  pointer-events: none;
}

.page-shell {
  width: min(calc(100% - 32px), 940px);
  margin: clamp(20px, 5vw, 56px) auto 112px;
}

.canvas-stage {
  position: relative;
  width: 100%;
}

#quiz-canvas {
  display: block;
  width: 100%;
  background: var(--paper);
  border-radius: 8px;
  box-shadow:
    0 30px 80px rgba(8, 22, 18, 0.3),
    0 2px 0 rgba(255, 255, 255, 0.7) inset;
}

.interaction-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.effects-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.answer-input,
.check-button,
.check-result {
  position: absolute;
  pointer-events: auto;
  font-family: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

.answer-input {
  height: 30px;
  padding: 0 6px 1px;
  border: 0;
  border-bottom: 2px dashed #aab8b1;
  border-radius: 4px 4px 0 0;
  outline: 0;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font: 500 18px/28px "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  text-align: center;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.answer-input:hover {
  background: rgba(255, 255, 255, 0.55);
}

.answer-input:focus {
  border-bottom-color: var(--coral);
  background: rgba(224, 108, 101, 0.08);
}

.answer-input.is-correct {
  border-bottom-color: var(--green);
  background: rgba(143, 201, 180, 0.18);
  color: var(--green);
}

.answer-input.is-incorrect {
  border-bottom-color: var(--coral);
  background: rgba(224, 108, 101, 0.1);
  color: #b3514c;
}

.check-button {
  min-width: 64px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid #cbd8d0;
  border-radius: 7px;
  background: #f4faf6;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.check-button:hover {
  border-color: var(--mint);
  background: #e9f5ef;
}

.check-button:active {
  transform: translateY(1px);
}

.check-button:focus-visible,
.answer-input:focus-visible {
  outline: 3px solid rgba(224, 108, 101, 0.3);
  outline-offset: 2px;
}

.check-result {
  display: flex;
  height: 36px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.check-result.is-popping {
  animation: result-pop 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.check-result[data-state="correct"] {
  color: var(--green);
}

.check-result[data-state="incorrect"],
.check-result[data-state="empty"] {
  color: #bd5b55;
}

.page-controls {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 10;
  display: grid;
  grid-template-columns: 88px minmax(168px, 210px) 88px;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
}

#previous-question,
#next-question,
#answer-toggle {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  font: 700 15px/1 "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

#answer-toggle {
  padding: 0 22px;
  background: var(--coral);
  box-shadow: 0 12px 34px rgba(10, 18, 15, 0.32);
  color: #fffaf3;
}

.nav-button {
  padding: 0 12px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 10px 28px rgba(10, 18, 15, 0.24);
  color: var(--ink);
}

#previous-question:disabled,
#next-question:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

#answer-toggle:hover {
  background: #cf5c56;
  box-shadow: 0 15px 38px rgba(10, 18, 15, 0.48);
  transform: translateY(-1px);
}

.nav-button:hover:not(:disabled) {
  background: #f2f8f4;
  transform: translateY(-1px);
}

#answer-toggle:active {
  transform: translateY(1px);
}

.nav-button:active:not(:disabled) {
  transform: translateY(1px);
}

#previous-question:focus-visible,
#next-question:focus-visible,
#answer-toggle:focus-visible {
  outline: 3px solid #f3cf8a;
  outline-offset: 4px;
}

.noscript-message {
  margin: 24px;
  padding: 20px;
  background: var(--paper);
  border-left: 4px solid var(--coral);
}

@media (max-width: 560px) {
  .page-shell {
    width: calc(100% - 20px);
    margin-top: 10px;
    margin-bottom: 104px;
  }

  #quiz-canvas {
    border-radius: 2px;
  }

  .answer-input {
    height: 29px;
    font-size: 16px;
    line-height: 27px;
  }

  .check-button {
    min-width: 60px;
    height: 38px;
    padding: 0 13px;
  }

  .check-result {
    height: 38px;
    font-size: 12px;
  }

  .page-controls {
    grid-template-columns: 76px minmax(146px, 1fr) 76px;
    width: calc(100% - 20px);
    max-width: 480px;
    gap: 6px;
  }

  #previous-question,
  #next-question,
  #answer-toggle {
    min-height: 50px;
  }

  #answer-toggle {
    padding: 0 10px;
    font-size: 14px;
  }

  .nav-button {
    padding: 0 8px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #answer-toggle,
  .nav-button,
  .check-button {
    transition: none;
  }

  .check-result.is-popping {
    animation: none;
  }
}

@media print {
  @page {
    margin: 12mm;
    size: A4;
  }

  html,
  body {
    background: #fff;
  }

  body::before,
  .page-controls,
  .interaction-layer {
    display: none;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  #quiz-canvas {
    box-shadow: none;
    border-radius: 0;
  }

  .effects-canvas {
    display: none;
  }
}

@keyframes result-pop {
  0% {
    opacity: 0.25;
    transform: translateY(4px) scale(0.88);
  }

  70% {
    opacity: 1;
    transform: translateY(-1px) scale(1.04);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}
