:root {
  color-scheme: light;
  --ink: #263449;
  --paper: #fff9ed;
  --paper-deep: #f5e8cd;
  --pine: #156448;
  --pine-dark: #0b4435;
  --accent: #d9485b;
  --accent-dark: #9e2737;
  --gold: #f6bf35;
  --navy: #102341;
  --shadow: 0 22px 55px rgba(5, 19, 42, .25);
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #102341;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid #102341;
  outline-offset: 3px;
}

.night {
  position: fixed;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 83% 11%, rgba(255, 245, 193, .72) 0 2px, transparent 3px),
    radial-gradient(circle at 15% 27%, rgba(255, 255, 255, .66) 0 2px, transparent 3px),
    radial-gradient(ellipse at 50% -4%, #294d74, #102341 67%);
}

.moon {
  position: absolute;
  width: min(25vw, 230px);
  aspect-ratio: 1;
  top: 5vh;
  right: max(7vw, 40px);
  border-radius: 50%;
  background: #fff8d3;
  box-shadow: 0 0 55px 20px rgba(255, 229, 145, .25);
  opacity: .92;
}

.snowfield { position: absolute; inset: 0; pointer-events: none; }
.snowflake {
  position: absolute;
  top: -20px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  opacity: var(--opacity);
  background: #fff;
  animation: falling var(--duration) linear var(--delay) infinite;
}

@keyframes falling {
  from { transform: translate3d(0, -15vh, 0); }
  to { transform: translate3d(var(--drift), 115vh, 0); }
}

.site-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 48px rgba(0,0,0,.26);
}

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 18px 23px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .11em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 29px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  color: #8b4a16;
  background: #fff1c8;
  box-shadow: inset 0 0 0 1px rgba(139,74,22,.12);
}

.admin-link {
  color: #627087;
  font-size: 12px;
  text-decoration: none;
}
.admin-link:hover { color: var(--accent-dark); text-decoration: underline; }

.view { animation: reveal .45s ease both; }
.view[hidden] { display: none; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.intro-scene {
  position: relative;
  height: 193px;
  margin-top: -42px;
  overflow: hidden;
  background: #294a71;
}

.scene-photo {
  position: absolute;
  inset: 0;
  background: url("/assets/default-background.svg") center/cover;
  transform: scale(1.03);
  filter: saturate(.9) contrast(.96);
}

.scene-photo::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, rgba(10,31,59,.2), rgba(8,31,44,.12) 58%, #fff9ed);
}

.scene-glow {
  position: absolute;
  z-index: 2;
  top: 32px;
  left: 29px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,241,177,.88), rgba(255,211,107,.12) 54%, transparent 72%);
}
.window-light { display: none; }

.letter-card {
  position: relative;
  z-index: 3;
  width: calc(100% - 38px);
  min-height: 286px;
  margin: -76px auto 0;
  padding: 99px 22px 26px;
  overflow: visible;
  text-align: center;
  border: 1px solid rgba(113, 80, 50, .14);
  border-radius: 25px 25px 31px 31px;
  background:
    radial-gradient(circle at 8% 87%, rgba(250, 201, 105, .17) 0 2px, transparent 3px),
    radial-gradient(circle at 87% 24%, rgba(239, 109, 119, .14) 0 2px, transparent 3px),
    var(--paper);
  box-shadow: 0 15px 34px rgba(8,33,51,.19);
}

.letter-card::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 23px;
  content: "";
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: linear-gradient(90deg, var(--accent), #ec6670 45%, var(--accent));
  clip-path: polygon(0 52%, 50% 100%, 100% 52%, 100% 100%, 0 100%);
}

.polaroid {
  position: absolute;
  top: -88px;
  left: 50%;
  width: 177px;
  padding: 9px 9px 27px;
  transform: translateX(-50%) rotate(-4deg);
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 9px 22px rgba(28,33,44,.26);
}

.polaroid-image {
  width: 100%;
  aspect-ratio: 1.42;
  overflow: hidden;
  background: #d5e1e3;
}
.polaroid-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.polaroid p {
  position: absolute;
  right: 10px;
  bottom: 4px;
  left: 10px;
  margin: 0;
  color: #2b3744;
  font-family: "Comic Sans MS", "KaiTi", cursive;
  font-size: 15px;
  font-weight: 700;
}

.spark { position: absolute; color: var(--gold); font-size: 24px; }
.spark-one { top: 30px; left: 23px; transform: rotate(12deg); }
.spark-two { top: 65px; right: 21px; color: #f28489; font-size: 17px; }
.eyebrow { margin: 0 0 9px; color: var(--accent-dark); font-size: 12px; font-weight: 900; letter-spacing: .12em; }

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 12px;
  color: #27354a;
  font-size: clamp(25px, 7.1vw, 34px);
  line-height: 1.14;
  letter-spacing: -.045em;
}
h1 span { font-size: .8em; }

.mood {
  display: inline-block;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 7px 13px;
  color: #714617;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  border: 2px solid #73502e;
  border-radius: 999px;
  background: #ffdb67;
  box-shadow: 0 3px 0 #73502e;
}

.invitation-copy {
  max-width: 330px;
  margin: 0 auto;
  color: #59606d;
  font-size: 14px;
  line-height: 1.68;
}
.data-note {
  margin: 13px auto 0;
  color: #8a7d73;
  font-size: 11px;
  line-height: 1.45;
}

.ornament-stage {
  position: relative;
  padding: 0 25px 3px;
  text-align: center;
  background: linear-gradient(var(--paper-deep), var(--paper));
}
.ornament-stage p {
  margin: 0;
  padding: 10px 0 12px;
  color: #687180;
  font-size: 14px;
}
.ribbon {
  width: 2px;
  height: 41px;
  margin: 0 auto;
  background: #c99832;
}
.hero-ornament {
  position: relative;
  width: 104px;
  aspect-ratio: 1;
  margin: -3px auto 0;
  border: 2px solid rgba(89, 35, 58, .34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,.9), rgba(255,255,255,0) 22%),
    radial-gradient(circle at 44% 69%, #f68daf, var(--accent) 64%, var(--accent-dark));
  box-shadow: inset -13px -10px 18px rgba(113,25,54,.24), 0 8px 10px rgba(45,36,38,.2);
}
.hero-ornament::before {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 27px;
  height: 14px;
  content: "";
  transform: translateX(-50%);
  border-radius: 4px 4px 1px 1px;
  background: #e1b63d;
  box-shadow: inset 0 0 0 2px rgba(108,70,14,.33);
}

.start-form {
  display: grid;
  gap: 13px;
  padding: 0 20px 39px;
  background: var(--paper);
}
.start-form input {
  width: 100%;
  min-height: 58px;
  padding: 0 17px;
  color: #2f3b4f;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid #e0d6c4;
  border-radius: 15px;
  background: #fffdf8;
  box-shadow: inset 0 2px 6px rgba(74,55,38,.07), 0 3px 0 rgba(180,148,100,.18);
}
.start-form input::placeholder { color: #a2a4a8; }

.start-form button, .share-row button {
  min-height: 56px;
  color: #612a16;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: .02em;
  border: 1px solid #d8a417;
  border-radius: 16px;
  background: linear-gradient(#ffe981, #f9be24);
  box-shadow: inset 0 2px rgba(255,255,255,.72), 0 5px 0 #bb8213, 0 8px 14px rgba(141,89,14,.17);
  transition: transform .15s ease, box-shadow .15s ease;
}
.start-form button:hover, .share-row button:hover { transform: translateY(-2px); }
.start-form button:active, .share-row button:active { transform: translateY(3px); box-shadow: inset 0 2px rgba(255,255,255,.72), 0 2px 0 #bb8213; }
.start-form button span { color: #af5429; }

.quiz { padding: 3px 19px 37px; background: linear-gradient(180deg, #f4e6cb, #fffaf0 65%); }
.quiz-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 10px;
}
.text-button {
  padding: 0;
  color: #607083;
  font-size: 12px;
  border: 0;
  background: transparent;
}
.text-button:hover { color: var(--accent-dark); }
.progress-text { color: #526276; font-size: 12px; font-weight: 800; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: #ddd5c5; }
.progress-track i { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #f28b8d); transition: width .35s ease; }

.tree-garden {
  position: relative;
  width: min(100%, 400px);
  height: 274px;
  margin: 9px auto -17px;
  overflow: hidden;
  isolation: isolate;
}
.tree-garden::before {
  position: absolute;
  z-index: -3;
  inset: 33px 20px 18px;
  content: "";
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,234,160,.65), rgba(255,234,160,0) 67%);
}
.tree-star {
  position: absolute;
  z-index: 5;
  top: 10px;
  left: 50%;
  color: #ffd661;
  font-size: 40px;
  line-height: 1;
  text-shadow: 0 0 17px rgba(255,207,75,.77);
  transform: translateX(-50%);
}
.tree-crown {
  position: absolute;
  z-index: 1;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-right: solid transparent;
  border-bottom: solid var(--pine);
  border-left: solid transparent;
  filter: drop-shadow(0 4px 2px rgba(5,61,43,.16));
}
.crown-a { top: 43px; border-width: 0 55px 95px; border-bottom-color: #218159; }
.crown-b { top: 90px; border-width: 0 89px 128px; border-bottom-color: #1b704f; }
.crown-c { top: 145px; border-width: 0 128px 142px; border-bottom-color: #145a43; }
.tree-trunk {
  position: absolute;
  z-index: -1;
  bottom: 25px;
  left: calc(50% - 23px);
  width: 46px;
  height: 61px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, #794e42, #a36d50, #623d38);
}
.tree-ground {
  position: absolute;
  z-index: -2;
  right: -42px;
  bottom: 0;
  left: -42px;
  height: 55px;
  border-radius: 50% 50% 0 0;
  background: #eff4ef;
}
.placed-ornaments { position: absolute; z-index: 4; inset: 31px 20px 30px; }
.tiny-ornament {
  position: absolute;
  width: 18px;
  aspect-ratio: 1;
  border: 1px solid rgba(83,40,40,.38);
  border-radius: 50%;
  background: var(--ornament-color);
  box-shadow: inset -3px -3px 4px rgba(82,25,35,.25), 0 0 0 2px rgba(255,240,178,.22), 0 0 12px rgba(255,216,103,.62);
  animation: pop .4s cubic-bezier(.2,.8,.2,1) both;
}
.tiny-ornament::before {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 7px;
  height: 4px;
  content: "";
  transform: translateX(-50%);
  border-radius: 2px 2px 0 0;
  background: #ebc35c;
}
.tiny-ornament[data-name]::after {
  position: absolute;
  top: 21px;
  left: 50%;
  width: 64px;
  overflow: hidden;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px #163f38;
  white-space: nowrap;
  content: attr(data-name);
  transform: translateX(-50%);
}
@keyframes pop { from { opacity: 0; transform: scale(.2); } 75% { transform: scale(1.14); } to { opacity: 1; transform: scale(1); } }

.question-card {
  position: relative;
  z-index: 6;
  min-height: 292px;
  padding: 20px 17px 17px;
  border: 1px solid #eadcc6;
  border-radius: 23px;
  background: #fffdf7;
  box-shadow: 0 12px 21px rgba(72,47,21,.12);
}
.question-number { margin-bottom: 8px; color: var(--accent-dark); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.question-card h2 { margin-bottom: 17px; color: #334052; font-size: 21px; line-height: 1.37; }
.question-image-wrap { margin: 0 0 14px; overflow: hidden; border-radius: 13px; background: #ebf0ef; }
.question-image-wrap img { display: block; width: 100%; max-height: 185px; object-fit: cover; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.answer-button {
  position: relative;
  display: grid;
  min-height: 56px;
  place-items: center;
  overflow: hidden;
  padding: 9px 8px;
  color: #425065;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  border: 1px solid #ded7c9;
  border-radius: 13px;
  background: #fff;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); background: #fff6ef; }
.answer-button:disabled { cursor: default; }
.answer-button.is-correct { color: #174d3c; border-color: #4aa978; background: #e8f8eb; }
.answer-button.is-wrong { color: #923d4d; border-color: #d87883; background: #fff0ef; }
.answer-button.has-image { min-height: 117px; align-content: stretch; padding: 0; }
.answer-button.has-image img { width: 100%; height: 84px; object-fit: cover; }
.answer-button.has-image span { padding: 8px; }
.answer-note { min-height: 22px; margin: 14px 0 0; color: #516073; font-size: 13px; font-weight: 800; text-align: center; }
.answer-note.is-correct { color: #198155; }
.answer-note.is-wrong { color: #bd4251; }

.complete { padding: 5px 20px 44px; text-align: center; background: linear-gradient(180deg, #f3e4c9, #fff9ed 55%); }
.complete-scene { position: relative; overflow: hidden; border-radius: 27px; box-shadow: 0 13px 26px rgba(13,47,63,.2); }
.complete-scene img { position: relative; z-index: 1; display: block; width: 100%; height: 252px; object-fit: cover; }
.complete-glow { position: absolute; z-index: 2; top: 11px; left: 50%; width: 190px; height: 190px; border-radius: 50%; background: radial-gradient(circle, rgba(255,246,191,.5), transparent 66%); transform: translateX(-50%); pointer-events: none; animation: glow 2.5s ease-in-out infinite alternate; }
@keyframes glow { to { transform: translateX(-50%) scale(1.13); opacity: .7; } }
.completion-card { position: relative; z-index: 2; margin: -25px 10px 0; padding: 28px 18px 20px; border: 1px solid #ecdcc4; border-radius: 22px; background: #fffdf7; box-shadow: 0 10px 20px rgba(61,39,16,.13); }
.completion-card h2 { margin-bottom: 11px; color: #334052; font-size: 25px; line-height: 1.27; }
.completion-card h2 span { color: var(--accent-dark); }
.completion-card p:not(.eyebrow):not(.copy-status) { margin-bottom: 19px; color: #657080; font-size: 14px; line-height: 1.65; }
.rank-card {
  margin: 5px 0 20px;
  overflow: hidden;
  border: 1px solid #e7d7b9;
  border-radius: 16px;
  background: #fffaf0;
}
.rank-hero {
  padding: 15px 14px 13px;
  color: #6d481f;
  background: linear-gradient(135deg, #fff0b7, #ffd968);
}
.rank-hero p { margin: 0 0 2px !important; color: #9a6630 !important; font-size: 11px !important; font-weight: 900; line-height: 1.2 !important; }
.rank-hero strong { color: #a84438; font-size: 38px; line-height: 1; letter-spacing: -.06em; }
.rank-hero > span { margin-left: 4px; color: #7c5524; font-size: 15px; font-weight: 900; }
.rank-hero small { display: block; margin-top: 4px; color: #7c6338; font-size: 11px; }
.leaderboard { padding: 12px 14px 4px; text-align: left; }
.leaderboard-heading { display: flex; justify-content: space-between; margin-bottom: 8px; color: #687486; font-size: 12px; font-weight: 900; }
.leaderboard-heading span:last-child { color: #9c8b70; font-weight: 700; }
.leaderboard ol { margin: 0; padding: 0; list-style: none; }
.leaderboard li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 31px; border-top: 1px dashed #ebdfcb; }
.leaderboard li:first-child { border-top: 0; }
.leaderboard-rank { color: #a87636; font-size: 12px; font-weight: 900; }
.leaderboard li:nth-child(1) .leaderboard-rank { color: #cb8b10; }
.leaderboard li:nth-child(2) .leaderboard-rank { color: #7d8ca1; }
.leaderboard li:nth-child(3) .leaderboard-rank { color: #b97b48; }
.leaderboard-name { overflow: hidden; color: #48576a; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { color: var(--accent-dark); font-size: 12px; font-weight: 900; }
.leaderboard-empty { display: block !important; padding: 11px 0; color: #8d958f; font-size: 12px; text-align: center; }
.share-row { display: grid; grid-template-columns: 1.2fr .8fr; gap: 10px; }
.share-row button { min-height: 48px; font-size: 13px; border-radius: 13px; }
.share-row .secondary-button { color: #536273; border-color: #dad5c8; background: #fffdf7; box-shadow: 0 3px 0 #cec8bb; }
.copy-status { min-height: 17px; margin: 12px 0 0; color: #238257; font-size: 12px; font-weight: 800; }

footer { padding: 0 20px 28px; color: #7d818a; font-size: 12px; line-height: 1.5; text-align: center; background: var(--paper); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 390px) {
  .site-header { padding-right: 18px; padding-left: 18px; }
  .letter-card { width: calc(100% - 26px); padding-right: 17px; padding-left: 17px; }
  h1 { font-size: 25px; }
  .polaroid { width: 158px; }
  .answer-grid { gap: 8px; }
  .answer-button { font-size: 13px; }
}
@media (min-width: 700px) {
  .site-shell { margin-top: 24px; margin-bottom: 24px; min-height: calc(100vh - 48px); border-radius: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
