:root {
  color-scheme: light;
  --ink: #17233e;
  --muted: #505f79;
  --line: #e2e4e7;
  --surface: #f6f7f8;
  --white: #fff;
  --blue: #195ec6;
  --logo-blue: #4285f4;
  --logo-red: #ea4335;
  --logo-yellow: #fbbc05;
  --logo-green: #34a853;
  --shadow: 0 2px 8px #20212409;
  --page: min(100% - 40px, 920px);
  font-family: system-ui, "Leelawadee UI", sans-serif;
  background: var(--white);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  background: white;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--logo-blue);
  outline-offset: 3px;
}
h1:focus, h2:focus, h3:focus, .finale:focus { outline: none; }
button, a.button { -webkit-tap-highlight-color: transparent; }

.wordmark {
  margin: 0;
  font: normal 800 clamp(3.5rem, 11vw, 6rem)/1.12 system-ui, sans-serif;
  letter-spacing: -.085em;
  white-space: nowrap;
}
.wordmark span:nth-child(4n + 1) { color: var(--logo-blue); }
.wordmark span:nth-child(4n + 2) { color: var(--logo-red); }
.wordmark span:nth-child(4n + 3) { color: var(--logo-yellow); }
.wordmark span:nth-child(4n) { color: var(--logo-green); }
.lookup {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100svh;
  overflow: hidden;
  background: white;
}
.lookup-content {
  position: relative;
  z-index: 0;
  width: min(100% - 32px, 630px);
  margin: auto;
  padding-bottom: clamp(34px, 10svh, 96px);
  text-align: center;
}
.lookup .wordmark { margin-bottom: clamp(24px, 5vw, 34px); }
.lookup-query, .masthead-query {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: white;
}
.lookup-query {
  min-height: 62px;
  padding: 6px 7px 6px clamp(12px, 4vw, 21px);
  box-shadow: 0 2px 8px #20212412;
}
.lookup-query:focus-within { border-color: #668ee7; }
.lookup-query svg, .masthead-query svg {
  flex: 0 0 21px;
  width: 21px;
  fill: none;
  stroke: #456097;
  stroke-width: 2.15;
  stroke-linecap: round;
}
.lookup-query input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  padding: 8px 0;
  background: transparent;
  text-overflow: ellipsis;
}
.lookup-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 13px clamp(16px, 4vw, 44px);
  border-top: 1px solid #dce6f680;
  background: #ffffff75;
  color: var(--muted);
  font-size: .84rem;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  text-decoration: none;
  transition: background .17s, border-color .17s, transform .17s, box-shadow .17s;
}
.button:hover { border-color: #adbfec; background: #eaf1fd; }
.button:active { transform: scale(.97); }
.primary { background: var(--blue); border-color: var(--blue); color: white; }
.primary:hover { background: #183a94; border-color: #183a94; box-shadow: 0 4px 13px #244bb02a; }
.quiet { background: transparent; border-color: transparent; color: var(--blue); }

.masthead { border-bottom: 1px solid var(--line); background: #ffffffd9; }
.masthead-inner {
  display: flex;
  align-items: center;
  gap: clamp(12px, 3vw, 28px);
  width: var(--page);
  margin: auto;
  padding-block: clamp(12px, 2.4vw, 19px);
}
.compact { flex: none; background: none; border: 0; padding: 4px 3px 5px 0; font-size: clamp(1.35rem, 4vw, 2.2rem); }
.masthead-query { width: min(100%, 530px); min-height: 44px; padding-inline: 14px; background: #f6f7f8; }
.masthead-query span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .92rem; }
.scene:not(.lookup) { width: var(--page); margin: 0 auto 32px; animation: arrive .34s ease-out both; }
@keyframes arrive { from { opacity: 0; transform: translateY(7px); } }

.loading {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: min(48svh, 360px);
  gap: 11px;
}
.spinner {
  width: 30px;
  aspect-ratio: 1;
  border: 3px solid #dbe8ff;
  border-top-color: var(--logo-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.loading h2 { margin: 0; color: var(--muted); font-size: .93rem; font-weight: 590; }
.result-card, .reveal-card { border: 1px solid var(--line); border-radius: clamp(20px, 4vw, 32px); box-shadow: var(--shadow); background: white; }

.results-nav { display: flex; gap: 8px; align-items: center; margin-block: 15px; color: var(--muted); font-size: .88rem; }
.results-nav span { padding: 6px 12px; }
.results-nav .nav-current { color: var(--blue); border-radius: 99px; background: #e9efff; font-weight: 740; }
.result-card { padding: clamp(19px, 5vw, 42px); }
.result-story {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(7px, 4vw, 30px);
  align-items: center;
}
.news-art { display: block; width: 100%; }
.result-source { display: flex; align-items: center; gap: 10px; font-size: .93rem; line-height: 1.35; }
.source-icon { display: grid; place-items: center; background: #eaf1ff; color: var(--blue); width: 34px; height: 34px; border-radius: 50%; font-weight: 800; flex: none; }
.result-source div span { color: var(--muted); font-size: .8rem; }
.breaking { margin-left: auto; white-space: nowrap; padding: 4px 9px; background: #fff1ef; color: #a92619; border-radius: 99px; font-size: .79rem; font-weight: 760; }
.result-card h2 { margin: 13px 0 5px; color: var(--blue); font-size: clamp(1.5rem, 4vw, 2.5rem); line-height: 1.24; }
.result-card p { margin: 0; color: var(--muted); line-height: 1.63; }
.result-footer { margin-top: 15px; }


.reveal-card { overflow: hidden; }
.reveal-copy { position: relative; }
.transform-status {
  position: absolute;
  top: 50%;
  left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: clamp(.98rem, 3.4vw, 1.35rem);
  font-weight: 760;
  animation: transform-status .76s ease both;
}
.transform-spark { color: #ad5f00; animation: turn .76s ease-in-out both; }
@keyframes turn { to { transform: rotate(1turn); } }
@keyframes transform-status {
  0% { transform: translateY(-25%); opacity: 0; }
  24%, 71% { transform: translateY(-50%); opacity: 1; }
  100% { transform: translateY(-70%); opacity: 0; }
}
.correction, .reveal-copy h2, .graduate, .crew, .next-stage,
.finale .envelope-area, .finale .final-actions {
  animation: reveal-step .46s var(--reveal-delay) cubic-bezier(.22,.7,.31,1) both;
}
.correction { --reveal-delay: .66s; }
.reveal-copy h2 { --reveal-delay: .82s; }
.graduate { --reveal-delay: .98s; }
.crew { --reveal-delay: 1.08s; }
.next-stage { --reveal-delay: 1.26s; }
.finale .envelope-area, .finale .final-actions { --reveal-delay: 1.48s; }
@keyframes reveal-step {
  0% { visibility: hidden; opacity: 0; transform: translateY(13px); }
  1% { visibility: visible; }
  100% { visibility: visible; opacity: 1; transform: translateY(0); }
}
.reveal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, .53fr);
  align-items: center;
  min-height: clamp(305px, 50svh, 385px);
  gap: clamp(10px, 4vw, 36px);
  padding: clamp(20px, 6vw, 55px);
  border-bottom: 1px solid var(--line);
  background: white;
}
.correction {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e1f4e9;
  color: #176539;
  font-size: .87rem;
  font-weight: 740;
}
.reveal-copy h2 { margin: 0; font: 800 clamp(2.8rem, 8vw, 5.65rem)/1.04 system-ui, sans-serif; color: #25282b; letter-spacing: -.065em; }
.reveal-copy h2 span { color: #ad5f00; }
.graduate { margin: 5px 0 0; font-size: clamp(1.5rem, 5vw, 2.8rem); font-weight: 840; line-height: 1.2; overflow-wrap: anywhere; }
.graduate > span:last-child { color: var(--blue); font-size: .49em; vertical-align: middle; }
.crew { color: var(--muted); font-weight: 650; margin: 4px 0 0; }
.next-stage {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .15em .45em;
  margin: 10px 0 0;
  padding: 4px 9px;
  border-radius: 8px;
  background: #e4efff;
  color: #20467e;
  font-size: .86rem;
}
.sticker { display: grid; place-items: center; perspective: 420px; }
.sticker svg { display: block; grid-area: 1 / 1; width: 100%; max-height: 220px;  }
.student-sticker { animation: student-flip .72s ease-in-out both; }
.graduate-sticker { animation: graduate-flip .62s .61s cubic-bezier(.18,.75,.25,1.24) both; }
@keyframes student-flip {
  0% { transform: scale(.8) rotateY(0deg); opacity: 0; }
  30%, 48% { transform: scale(1) rotateY(0deg); opacity: 1; }
  100% { transform: scale(.84) rotateY(90deg); opacity: 0; }
}
@keyframes graduate-flip {
  0% { transform: rotateY(-90deg) scale(.84); opacity: 0; }
  52% { opacity: 1; }
  100% { transform: rotateY(0deg) rotate(7deg) scale(1); opacity: 1; }
}
.mail-card { width: min(100%, 680px); margin-inline: auto; }
.mail-header { text-align: center; padding: 22px 16px 0; animation: arrive .36s ease-out both; }
.mail-header h2 { margin: 0; color: var(--blue); font-size: clamp(1.6rem, 5vw, 2.5rem); }
.mail-header p { margin: 3px 0 0; color: var(--muted); font-weight: 650; overflow-wrap: anywhere; }
.envelope-area { padding: 12px clamp(14px, 4vw, 28px) 0; }
.mail .envelope-area { animation: reveal-step .48s .12s cubic-bezier(.22,.7,.31,1) both; }
.envelope {
  display: grid;
  justify-items: center;
  width: 100%;
  padding: 6px 10px 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--blue);
  background: #fffdf6;
  font-weight: 740;
  transition: border-color .22s, background .22s;
  touch-action: manipulation;
}
.envelope:hover { border-color: #a3bff0; }
.envelope-art { display: block; width: min(100%, 340px); height: auto; overflow: visible; transition: transform .22s ease; }
.envelope:not([aria-expanded="true"]):hover .envelope-art { transform: translateY(-4px); }
.envelope-label {
  padding: 7px 15px;
  border: 1px solid var(--blue);
  border-radius: 99px;
  color: white;
  background: var(--blue);
}
.envelope[aria-expanded="true"] .envelope-label { border-color: transparent; background: transparent; color: var(--blue); }
.mail-flap { transform-origin: 160px 83px; }
.mail-flap-open { transform: scaleY(0); opacity: 0; }
.envelope[aria-expanded="true"] .mail-seal { animation: unseal .28s ease-in both; transform-origin: 160px 139px; }
.envelope[aria-expanded="true"] .mail-flap-closed { animation: fold-back .22s .16s ease-in both; }
.envelope[aria-expanded="true"] .mail-flap-open { animation: fold-open .26s .32s ease-out both; }
.envelope[aria-expanded="true"] .mail-paper { animation: mail-pop .48s .42s cubic-bezier(.22,.77,.35,1) both; }
.envelope[aria-expanded="true"] .mail-sparkles { animation: sparkle .54s .49s ease-out both; transform-origin: center; }
@keyframes unseal { to { transform: translateY(-20px) rotate(-24deg) scale(.55); opacity: 0; } }
@keyframes fold-back { to { transform: scaleY(0); opacity: 0; } }
@keyframes fold-open { to { transform: scaleY(-1); opacity: 1; } }
@keyframes mail-pop {
  64% { transform: translateY(-65px) rotate(-2deg); }
  100% { transform: translateY(-47px); }
}
@keyframes sparkle {
  35% { transform: scale(1.12); opacity: .45; }
  to { transform: scale(1); opacity: 1; }
}
.letter {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 24px);
  margin-top: 10px;
  border-radius: 14px;
  overflow-wrap: anywhere;
  animation: letter-rise .5s .67s cubic-bezier(.16,.84,.32,1.14) both;
}
@keyframes letter-rise {
  from { transform: translateY(-76px) scale(.72); opacity: 0; }
  58% { opacity: 1; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.letter h3 { margin: 0; font-size: 1.25rem; color: var(--blue); }
.letter p { white-space: pre-wrap; line-height: 1.75; max-width: 64ch; }
.letter .signature { margin-bottom: 0; }
.letter .signature strong { color: var(--blue); }
.final-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; padding: 14px clamp(14px, 4vw, 29px); }

.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.confetti b {
  position: absolute; top: -20px; left: var(--x);
  width: var(--size); height: calc(var(--size) * 1.6);
  background: var(--color); border-radius: var(--round);
  animation: fall var(--duration) var(--delay) ease-in both;
}
@keyframes fall { to { transform: translate(var(--drift), 109vh) rotate(var(--spin)); opacity: .55; } }
dialog { width: min(100% - 36px, 520px); border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: var(--shadow); padding: 20px; }
dialog::backdrop { background: #1f263080; }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.editor-head h2 { margin: 0; }
.editor-head button { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 1.35rem; line-height: 1; padding: .18em .35em; }
dialog label { display: block; margin: 14px 0 5px; font-weight: 750; }
dialog input, dialog textarea { width: 100%; background: white; border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
dialog textarea { resize: vertical; }
dialog .primary { margin-top: 12px; }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.no-js { margin: 12px 18px; padding: 12px; border: 1px solid var(--line); background: var(--surface); }

@media (max-width: 530px) {
  :root { --page: calc(100% - 28px); }
  .lookup-query { gap: 7px; min-height: 55px; }
  .lookup-query svg, .masthead-query svg { flex-basis: 17px; width: 17px; }
  .lookup-query input { font-size: .92rem; }
  .lookup-query .button { padding-inline: 12px; min-height: 40px; }
  .masthead-query { min-width: 0; padding-inline: 10px; gap: 6px; }
  .masthead-query span { font-size: .81rem; }
  .result-story { position: relative; display: block; }
  .news-art { width: 75px; margin: -44px 0 0 auto; pointer-events: none; }

  .reveal-grid {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
    padding: 22px 18px 25px;
    gap: 11px;
  }
  .reveal-copy { grid-row: 2; }
  .sticker { grid-row: 1; }
  .sticker svg { max-height: 122px; }
  .transform-status { justify-content: center; width: 100%; top: 24%; }
  .final-actions { justify-content: center; }
}
@media (max-width: 350px) {
  .result-footer { padding-inline-end: 0; }
  .news-art { display: none; }
}
.scene.mini {
  max-width: 560px;
  padding: clamp(36px, 10vh, 86px) 0 24px;
  text-align: center;
}
.mini h2 { margin: 0 0 22px; font-size: clamp(1.65rem, 5vw, 2.55rem); line-height: 1.25; overflow-wrap: anywhere; }
.answers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(6px, 2vw, 12px); }
.answers button {
  display: grid; justify-items: center; gap: 6px; padding: 16px 4px;
  border: 1px solid #dadce0; border-radius: 16px; background: white; font-weight: 700;
}
.answers [aria-hidden="true"], .student-token { font-size: clamp(2rem, 7vw, 3.1rem); }
.answers button:hover { background: #f8f9fa; }
.answers .miss { animation: wiggle .33s ease both; }
.answers .hit { border-color: #34a853; background: #eef8f0; animation: hop .4s ease; }
.answers button:disabled:not(.hit) { opacity: .45; }
.feedback { margin: 16px 0; min-height: 1.5em; color: var(--muted); }
.student-token { display: inline-grid; place-items: center; border-radius: 50%; background: #fff6df; width: 90px; height: 90px; margin-bottom: 15px; animation: hop .45s ease; }
@keyframes wiggle { 25%, 70% { transform: translateX(-5px) rotate(-3deg); } 45% { transform: translateX(5px) rotate(3deg); } }
@keyframes hop { 50% { transform: translateY(-7px) scale(1.05); } }
.answers strong { max-width: 100%; overflow-wrap: anywhere; font-weight: inherit; }
@media (max-width: 530px) {
  .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
#quiz[data-beat] { overflow: clip; }
#quiz[data-beat] .feedback {
  margin: 20px 0 12px;
  font-weight: 950;
  font-size: clamp(2rem, 8vw, 3.8rem);
  letter-spacing: -.035em;
  line-height: 1.3;
}
#quiz[data-beat="correct"] .feedback { color: #167444; animation: stamp .5s cubic-bezier(.2,.8,.4,1.2) both; }
#quiz[data-beat="joke"] .feedback { color: #b4314d; animation: prank .55s cubic-bezier(.2,.8,.4,1.2) both; }
#quiz[data-beat="joke"] .answers { position: relative; }
#quiz[data-beat="joke"] .answers button:not(.hit) { animation: swipe .46s ease-in both; }
#quiz[data-beat="joke"] .answers button:nth-child(3) { animation-delay: .08s; }
#quiz[data-beat="joke"] .answers button:nth-child(4) { animation-delay: .16s; }
#quiz[data-beat="joke"] .hit { position: absolute; inset: 0; width: min(100%, 150px); height: fit-content; margin: auto; animation: dog-pop .55s ease-out both; }
#quiz[data-beat="joke"] #truth { animation: arrive .35s .35s both; }
@keyframes stamp { from { opacity: 0; transform: scale(1.5) rotate(-8deg); } 65% { transform: scale(.94) rotate(2deg); } }
@keyframes prank { from { opacity: 0; transform: translateY(22px) rotate(6deg); } 65% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes swipe { to { transform: translateX(120%) rotate(15deg); opacity: 0; visibility: hidden; } }
@keyframes dog-pop { from { opacity: 0; transform: scale(.6); } 72% { transform: scale(1.1) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
}
