:root {
  --ink: #18324a;
  --ink-soft: #526474;
  --paper: #fffaf0;
  --paper-deep: #f8f1df;
  --yellow: #f5c451;
  --yellow-light: #fff1ad;
  --green: #5f9f76;
  --green-light: #dcefdc;
  --orange: #ed7657;
  --orange-light: #ffe0cc;
  --blue: #355f87;
  --blue-light: #dcecf6;
  --shadow: rgba(30, 54, 70, 0.14);
  --radius: 24px 18px 26px 20px;
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 9%, rgba(245, 196, 81, 0.28) 0 80px, transparent 82px),
    radial-gradient(circle at 93% 28%, rgba(95, 159, 118, 0.18) 0 110px, transparent 112px),
    linear-gradient(165deg, #fffaf0 0%, #f8f1df 100%);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.65;
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(53, 95, 135, 0.35);
  outline-offset: 4px;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image:
    repeating-linear-gradient(7deg, transparent 0 6px, rgba(24, 50, 74, 0.025) 7px 8px),
    repeating-linear-gradient(91deg, transparent 0 11px, rgba(24, 50, 74, 0.018) 12px 13px);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(18px, env(safe-area-inset-left));
  border-bottom: 2px dashed rgba(24, 50, 74, 0.18);
  background: rgba(255, 250, 240, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
  text-decoration: none;
  letter-spacing: 0.04em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 48% 52% 45% 55%;
  background: var(--yellow);
  transform: rotate(-5deg);
}

.help-button,
.text-button {
  min-height: 44px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-underline-offset: 5px;
  cursor: pointer;
}

.help-button span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  place-items: center;
  border: 2px solid var(--blue);
  border-radius: 50%;
  text-decoration: none;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 28px, 760px);
  min-height: calc(100vh - 170px);
  margin: 0 auto;
  padding: 30px 0 48px;
}

.screen {
  animation: page-in 0.36s ease both;
}

.hero {
  position: relative;
  padding: 34px 24px 28px;
  border: 3px solid var(--ink);
  border-radius: 34px 22px 38px 28px;
  background: var(--paper);
  box-shadow: 9px 11px 0 rgba(53, 95, 135, 0.15);
  text-align: center;
}

.hero::before,
.hero::after {
  position: absolute;
  content: "";
  width: 72px;
  height: 19px;
  background: rgba(245, 196, 81, 0.72);
  transform: rotate(-8deg);
}

.hero::before {
  top: -10px;
  left: 12%;
}

.hero::after {
  right: 10%;
  bottom: -8px;
  transform: rotate(7deg);
}

.eyebrow {
  display: inline-block;
  margin: 0 0 12px;
  padding: 5px 14px;
  border: 2px solid var(--green);
  border-radius: 13px 16px 12px 18px;
  color: #315f42;
  background: var(--green-light);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: rotate(-1deg);
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 9vw, 58px);
  line-height: 1.16;
  letter-spacing: 0.03em;
}

h1 .accent {
  position: relative;
  display: inline-block;
  color: var(--orange);
}

h1 .accent::after {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  content: "";
  transform: rotate(-2deg);
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.25;
}

h3 {
  margin: 0 0 10px;
  font-size: 23px;
  line-height: 1.35;
}

.lead {
  margin: 18px auto 24px;
  color: var(--ink-soft);
  font-size: clamp(19px, 4.6vw, 23px);
  font-weight: 700;
  line-height: 1.7;
}

.doodle-orbit {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 25px;
}

.doodle {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50% 45% 52% 42%;
  background: var(--yellow-light);
  font-size: 27px;
  transform: rotate(-5deg);
}

.doodle:nth-child(2) {
  background: var(--green-light);
  transform: rotate(6deg) translateY(-6px);
}

.doodle:nth-child(3) {
  background: var(--orange-light);
  transform: rotate(-2deg);
}

.primary-button,
.secondary-button,
.option-button {
  width: 100%;
  min-height: 58px;
  border: 3px solid var(--ink);
  border-radius: 18px 15px 20px 16px;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.primary-button {
  padding: 15px 22px;
  color: #142c3e;
  background: var(--yellow);
  box-shadow: 5px 6px 0 var(--ink);
}

.secondary-button {
  padding: 14px 20px;
  background: var(--paper);
  box-shadow: 4px 5px 0 rgba(24, 50, 74, 0.85);
}

.primary-button:hover,
.secondary-button:hover,
.option-button:hover:not(:disabled) {
  transform: translateY(-2px) rotate(-0.3deg);
}

.primary-button:active,
.secondary-button:active,
.option-button:active:not(:disabled) {
  box-shadow: 1px 2px 0 var(--ink);
  transform: translate(3px, 3px);
}

.button-row {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.quick-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 28px 0 0;
}

.fact {
  padding: 13px 8px;
  border: 2px dashed rgba(24, 50, 74, 0.45);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.privacy-note,
.stage-card,
.question-card,
.result-card {
  margin-top: 28px;
  padding: 24px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 7px 8px 0 var(--shadow);
}

.privacy-note {
  border-color: var(--green);
  background: var(--green-light);
  text-align: left;
}

.privacy-note p:last-child {
  margin-bottom: 0;
}

.stage-heading {
  margin-bottom: 22px;
}

.stage-kicker {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.progress-wrap {
  margin-bottom: 22px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 900;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(-45deg, var(--green) 0 10px, #76b88b 10px 20px);
  transition: width 0.35s ease;
}

.tutorial-visual {
  display: grid;
  width: 112px;
  height: 112px;
  margin: 0 auto 22px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 46% 54% 50% 44%;
  background: var(--yellow-light);
  box-shadow: 5px 7px 0 rgba(24, 50, 74, 0.15);
  font-size: 54px;
  transform: rotate(-3deg);
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.tutorial-dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
}

.tutorial-dot.active {
  background: var(--orange);
}

.question-number {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 16px;
  font-weight: 900;
}

.question-text {
  margin: 0 0 22px;
  font-size: clamp(22px, 5.8vw, 29px);
  font-weight: 900;
  line-height: 1.5;
}

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

.option-button {
  position: relative;
  padding: 15px 18px 15px 54px;
  text-align: left;
  background: white;
  box-shadow: 4px 5px 0 rgba(24, 50, 74, 0.18);
}

.option-letter {
  position: absolute;
  top: 50%;
  left: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-deep);
  font-size: 16px;
  transform: translateY(-50%);
}

.option-button.selected {
  background: var(--yellow-light);
}

.option-button.correct {
  border-color: #326b48;
  background: var(--green-light);
}

.option-button.not-best {
  opacity: 0.64;
}

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

.feedback {
  margin-top: 22px;
  padding: 19px;
  border: 2px dashed var(--blue);
  border-radius: 18px 14px 20px 16px;
  background: var(--blue-light);
}

.feedback strong {
  display: block;
  margin-bottom: 6px;
  font-size: 21px;
}

.feedback p {
  margin: 0;
}

.energy-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow-light);
  font-size: 16px;
  font-weight: 900;
}

.exchange-card {
  position: relative;
  overflow: hidden;
  padding: 30px 24px;
  border: 3px solid var(--ink);
  border-radius: 28px 20px 32px 22px;
  background: var(--orange-light);
  box-shadow: 8px 9px 0 rgba(237, 118, 87, 0.22);
  text-align: center;
}

.exchange-card::after {
  position: absolute;
  right: -32px;
  bottom: -45px;
  width: 130px;
  height: 130px;
  border: 4px dashed rgba(24, 50, 74, 0.16);
  border-radius: 50%;
  content: "";
}

.exchange-icon {
  margin-bottom: 12px;
  font-size: 56px;
}

.exchange-prompt {
  margin: 18px 0;
  font-size: clamp(24px, 6.2vw, 32px);
  font-weight: 900;
  line-height: 1.5;
}

.starter-line {
  padding: 14px 16px;
  border: 2px dashed rgba(24, 50, 74, 0.45);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
  font-weight: 700;
}

.reflection-grid {
  display: grid;
  gap: 14px;
}

.reflection-button {
  min-height: 72px;
  padding: 14px 18px;
  border: 3px solid var(--ink);
  border-radius: 19px 15px 22px 17px;
  background: white;
  font-size: 19px;
  font-weight: 900;
  text-align: left;
  box-shadow: 4px 5px 0 rgba(24, 50, 74, 0.16);
  cursor: pointer;
}

.reflection-button:hover {
  background: var(--yellow-light);
}

.result-card {
  position: relative;
  overflow: hidden;
  border-radius: 30px 22px 34px 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.8), transparent 55%),
    var(--yellow-light);
  text-align: center;
}

.result-card::before,
.result-card::after {
  position: absolute;
  color: rgba(53, 95, 135, 0.18);
  font-size: 90px;
  content: "✦";
}

.result-card::before {
  top: -36px;
  left: -12px;
}

.result-card::after {
  right: -10px;
  bottom: -52px;
}

.badge-medallion {
  display: grid;
  width: 126px;
  height: 126px;
  margin: 4px auto 18px;
  place-items: center;
  border: 4px double var(--ink);
  border-radius: 48% 52% 45% 55%;
  background: var(--orange-light);
  box-shadow: 6px 7px 0 rgba(24, 50, 74, 0.16);
  font-size: 58px;
  transform: rotate(-3deg);
}

.result-title {
  margin: 8px 0 6px;
  color: var(--orange);
  font-size: clamp(31px, 8vw, 45px);
  font-weight: 900;
  line-height: 1.25;
}

.score-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.score-cell {
  padding: 15px 10px;
  border: 2px dashed var(--ink);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.score-number {
  display: block;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
}

.score-label {
  font-size: 15px;
  font-weight: 800;
}

.reflection-stamp {
  display: inline-block;
  margin: 4px 0 18px;
  padding: 8px 14px;
  border: 3px solid var(--green);
  border-radius: 10px;
  color: #315f42;
  background: var(--green-light);
  font-weight: 900;
  transform: rotate(-1deg);
}

.tiny-note {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}

.site-footer {
  position: relative;
  z-index: 1;
  padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  color: var(--ink-soft);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.info-dialog {
  width: min(90vw, 620px);
  max-height: 86vh;
  padding: 26px;
  overflow-y: auto;
  border: 3px solid var(--ink);
  border-radius: 26px 19px 30px 21px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 10px 12px 0 rgba(24, 50, 74, 0.24);
}

.info-dialog::backdrop {
  background: rgba(20, 44, 62, 0.58);
  backdrop-filter: blur(3px);
}

.info-dialog h2 {
  font-size: 30px;
}

.info-dialog li {
  margin-bottom: 10px;
}

.dialog-close {
  margin-top: 18px;
}

.noscript-message {
  margin: 20px;
  padding: 20px;
  border: 3px solid var(--ink);
  background: var(--orange-light);
  font-weight: 900;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(12px) rotate(0.2deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

@media (min-width: 640px) {
  .game-shell {
    padding-top: 44px;
  }

  .hero,
  .stage-card,
  .question-card,
  .result-card {
    padding: 36px;
  }

  .button-row.two-columns {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 420px) {
  .game-shell {
    width: min(100% - 22px, 760px);
  }

  .hero,
  .stage-card,
  .question-card,
  .result-card {
    padding-right: 19px;
    padding-left: 19px;
  }

  .quick-facts {
    grid-template-columns: 1fr;
  }

  .fact {
    padding: 10px 12px;
  }

  .topbar {
    padding-right: 13px;
    padding-left: 13px;
  }

  .brand {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .topbar,
  .site-footer,
  .button-row,
  .paper-grain {
    display: none !important;
  }

  body {
    background: white;
  }

  .game-shell {
    width: 100%;
    padding: 0;
  }

  .result-card {
    box-shadow: none;
  }
}
