:root {
  color-scheme: light;
  --paper: #f2eedf;
  --ink: #272522;
  --muted: rgba(39, 37, 34, 0.58);
  --line: rgba(39, 37, 34, 0.2);
  --panel: rgba(245, 241, 228, 0.78);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
}

body {
  color: var(--ink);
  font-family: var(--sans);
}

button,
a,
input {
  font: inherit;
}

button,
a {
  color: inherit;
}

button {
  border: 0;
}

#watercolor {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  mix-blend-mode: multiply;
  background-image:
    repeating-radial-gradient(circle at 17% 23%, rgba(63, 55, 41, 0.12) 0 0.4px, transparent 0.6px 3px),
    repeating-radial-gradient(circle at 73% 64%, rgba(255, 255, 255, 0.34) 0 0.5px, transparent 0.7px 4px);
  background-size: 10px 11px, 13px 15px;
}

.site-header,
.site-footer,
.hero,
.settings-panel {
  position: fixed;
  z-index: 2;
}

.site-header {
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 1.55rem clamp(1.1rem, 2.7vw, 2.7rem);
  font: 560 0.68rem/1 var(--sans);
  letter-spacing: 0.08em;
}

.site-header > :last-child {
  justify-self: end;
}

.language-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.72rem;
  padding: 0;
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
}

.language-menu::before {
  content: "（";
}

.language-menu::after {
  content: "）";
}

.language-menu button {
  position: relative;
  min-height: 0;
  padding: 0;
  color: rgba(39, 37, 34, 0.55);
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color 180ms ease, transform 180ms ease;
}

.language-menu button:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.language-menu button.is-active {
  color: var(--ink);
}

.language-menu button.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -0.35rem;
  left: 0;
  height: 1px;
  background: currentColor;
}

.text-button,
.quiet-link {
  width: fit-content;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  letter-spacing: inherit;
}

.text-button::after,
.quiet-link::after {
  content: "";
  display: block;
  width: 0;
  height: 1px;
  margin-top: 0.2rem;
  background: currentColor;
  transition: width 220ms ease;
}

.text-button:hover::after,
.quiet-link:hover::after {
  width: 100%;
}

#books-label {
  text-decoration: none;
}

#books-label::after {
  content: none;
}

.gear {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1rem;
}

.hero {
  top: 50%;
  left: 50%;
  width: min(760px, calc(100vw - 2rem));
  text-align: center;
  transform: translate(-50%, -47%);
  pointer-events: none;
}

.hero h1 {
  display: flex;
  justify-content: center;
  gap: 0.05em;
  margin: 0;
  font: 400 clamp(4.8rem, 11.5vw, 9.7rem) / 0.82 var(--serif);
  letter-spacing: -0.12em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.hero h1 span {
  display: inline-block;
  transition: transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-language="en"] .hero h1,
body[data-language="tok"] .hero h1 {
  gap: 0.2em;
  font-size: clamp(4.6rem, 10vw, 8.5rem);
  letter-spacing: -0.075em;
}

body.is-painting .hero h1 span:nth-child(1) {
  transform: translate(-0.04em, -0.04em) rotate(-2deg);
}

body.is-painting .hero h1 span:nth-child(2) {
  transform: translateY(0.025em) rotate(1deg);
}

body.is-painting .hero h1 span:nth-child(3) {
  transform: translate(0.04em, -0.02em) rotate(2deg);
}

body.is-painting .hero h1 span:nth-child(4n) {
  transform: translate(0.025em, 0.035em) rotate(-1deg);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.9rem 2rem;
  margin-top: 1.65rem;
  pointer-events: auto;
}

.quiet-link {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
}

.paint-hint {
  margin: 3.2rem 0 0;
  color: var(--muted);
  font: 500 0.66rem/1 var(--sans);
  letter-spacing: 0.13em;
  animation: breathe 3.2s ease-in-out infinite;
}

.site-footer {
  right: clamp(1.1rem, 2.7vw, 2.7rem);
  bottom: 1.55rem;
  left: clamp(1.1rem, 2.7vw, 2.7rem);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  font-size: 0.62rem;
  line-height: 1.25;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.site-footer p {
  margin: 0;
}

.site-footer > :last-child {
  justify-self: end;
}

.built-by {
  text-align: center;
}

.settings-panel {
  top: 4.8rem;
  left: 0.55rem;
  width: 205px;
  border: 1px solid rgba(65, 57, 44, 0.08);
  padding: 0.85rem 0.9rem 1rem;
  background: var(--panel);
  box-shadow: 0 18px 46px rgba(80, 67, 42, 0.1);
  backdrop-filter: blur(14px) saturate(0.7);
  transform: translateX(calc(-100% - 1rem));
  opacity: 0;
  transition: transform 280ms ease, opacity 220ms ease;
}

.settings-panel.is-open {
  transform: translateX(0);
  opacity: 1;
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.settings-actions button {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 0.66rem;
  cursor: pointer;
}

.control {
  display: block;
  margin-top: 0.62rem;
  font-size: 0.61rem;
}

.control > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.control output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.control input[type="range"] {
  width: 100%;
  height: 1px;
  margin: 0.25rem 0;
  appearance: none;
  background: rgba(39, 37, 34, 0.34);
}

.control input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  appearance: none;
  border: 1px solid rgba(39, 37, 34, 0.7);
  border-radius: 50%;
  background: #faf7ec;
  cursor: grab;
}

.color-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.color-control > span {
  margin: 0;
}

.color-control input {
  width: 25px;
  height: 15px;
  border: 0;
  padding: 0;
  background: transparent;
}

.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-control > span {
  margin: 0;
}

.toggle-control input {
  width: 26px;
  height: 14px;
  appearance: none;
  border-radius: 99px;
  background: rgba(39, 37, 34, 0.17);
  transition: background 180ms ease;
}

.toggle-control input::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 2px;
  border-radius: 50%;
  background: #fffdf5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 180ms ease;
}

.toggle-control input:checked {
  background: #292622;
}

.toggle-control input:checked::after {
  transform: translateX(12px);
}

.content-panel {
  width: min(680px, calc(100vw - 2rem));
  max-height: min(720px, calc(100vh - 2rem));
  border: 1px solid rgba(55, 49, 40, 0.18);
  padding: clamp(1.4rem, 4vw, 3.4rem);
  color: var(--ink);
  background: rgba(247, 243, 231, 0.91);
  box-shadow: 0 35px 110px rgba(74, 62, 44, 0.22);
  backdrop-filter: blur(26px) saturate(0.72);
}

.content-panel::backdrop {
  background: rgba(239, 233, 215, 0.16);
  backdrop-filter: blur(6px);
}

.close-button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
}

.panel-kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
}

.content-panel h2 {
  margin: 0.8rem 0 2.2rem;
  font: 400 clamp(3.2rem, 8vw, 6rem) / 1 var(--serif);
}

.quiz-shell {
  position: relative;
  min-height: 470px;
}

.quiz-shell::before,
.quiz-shell::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(28px);
  opacity: 0.32;
  pointer-events: none;
}

.quiz-shell::before {
  top: 8%;
  right: -6%;
  width: 13rem;
  height: 8rem;
  background: rgba(196, 156, 226, 0.38);
  transform: rotate(-18deg);
}

.quiz-shell::after {
  bottom: 2%;
  left: -8%;
  width: 15rem;
  height: 9rem;
  background: rgba(130, 211, 205, 0.28);
  transform: rotate(16deg);
}

.quiz-progress {
  width: 100%;
  height: 1px;
  margin-bottom: 2rem;
  overflow: hidden;
  background: rgba(39, 37, 34, 0.12);
}

.quiz-progress span {
  display: block;
  width: 25%;
  height: 100%;
  background: linear-gradient(90deg, #bd86ac, #8ccdc5, #a790d6);
  transition: width 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-count {
  margin: 0.8rem 0 1.35rem;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.11em;
}

.content-panel .quiz-question {
  max-width: 10.5em;
  min-height: 2.25em;
  margin: 0;
  font: 400 clamp(2rem, 5vw, 3.45rem) / 1.22 var(--serif);
  text-wrap: balance;
}

.quiz-intro {
  max-width: 31rem;
  margin: 1.2rem 0 1.7rem;
  color: var(--muted);
  font: 400 0.78rem/1.75 var(--serif);
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.quiz-options[hidden],
.quiz-result[hidden],
.quiz-question[hidden],
.quiz-intro[hidden],
.quiz-count[hidden] {
  display: none !important;
}

.quiz-option {
  min-height: 3.5rem;
  border: 1px solid rgba(39, 37, 34, 0.16);
  padding: 0.75rem 0.9rem;
  color: rgba(39, 37, 34, 0.8);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.58), transparent 46%),
    rgba(247, 243, 231, 0.36);
  font: 400 0.86rem/1.55 var(--serif);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.quiz-option:hover {
  border-color: rgba(126, 91, 132, 0.38);
  background:
    radial-gradient(circle at 18% 24%, rgba(204, 169, 222, 0.22), transparent 52%),
    rgba(255, 255, 255, 0.42);
  transform: translateY(-2px);
}

.quiz-result {
  padding-top: clamp(2rem, 7vh, 5rem);
  text-align: center;
}

.result-note {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font: 400 0.72rem/1.5 var(--serif);
  letter-spacing: 0.08em;
}

.content-panel .quiz-result h2 {
  margin: 0 auto 2.5rem;
  font-size: clamp(3rem, 8vw, 6rem);
  line-height: 1.08;
  text-wrap: balance;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
}

.result-actions a,
.result-actions button {
  min-height: 2.8rem;
  border: 1px solid rgba(39, 37, 34, 0.18);
  padding: 0.8rem 1.2rem;
  background: rgba(255, 255, 255, 0.34);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
}

.result-actions .read-result {
  color: #f9f6eb;
  background: rgba(43, 40, 36, 0.88);
}

.about-panel > p:not(.panel-kicker, .about-note) {
  max-width: 31rem;
  font: 400 1.08rem/2 var(--serif);
}

.about-note {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.7;
}

.cursor {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(39, 37, 34, 0.45);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: width 160ms ease, height 160ms ease, opacity 160ms ease;
}

.cursor.is-visible {
  opacity: 1;
}

.fallback-message {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 5rem;
  max-width: 30rem;
  margin: 0;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(-50%);
  font-size: 0.8rem;
  text-align: center;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(39, 37, 34, 0.55);
  outline-offset: 3px;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }
  50% {
    opacity: 0.88;
    transform: translateY(-3px);
  }
}

@media (max-width: 680px) {
  .site-header {
    padding: 1rem;
  }

  .language-menu {
    gap: 0.38rem;
  }

  .language-menu button {
    font-size: 0.56rem;
    letter-spacing: 0.02em;
  }

  .settings-toggle span:last-child {
    display: none;
  }

  .hero {
    transform: translate(-50%, -52%);
  }

  .hero h1 {
    font-size: clamp(4.7rem, 22.5vw, 7rem);
  }

  .paint-hint {
    margin-top: 2.3rem;
  }

  .site-footer {
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    grid-template-columns: 1fr 1fr;
  }

  .built-by {
    display: none;
  }

  .settings-panel {
    top: 3.7rem;
    max-height: calc(100vh - 7rem);
    overflow: auto;
  }

  .content-panel {
    padding: 2rem 1.2rem 1.4rem;
  }

  .quiz-shell {
    min-height: 560px;
  }

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

  .quiz-option {
    min-height: 3.15rem;
  }
}

@media (pointer: coarse) {
  #watercolor {
    cursor: auto;
  }

  .cursor {
    display: none;
  }
}

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