/* ------------------------------------------------------------------
   Fonts — self-hosted faces (all OFL); DM Sans / Noto from Google Fonts.
------------------------------------------------------------------- */
@font-face { font-family: "Open Sans"; src: url("./fonts/OpenSans-Variable-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Open Sans"; src: url("./fonts/OpenSans-VariableItalic-latin.woff2") format("woff2"); font-weight: 300 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("./fonts/SourceSerif4-Light-latin.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("./fonts/SourceSerif4-LightItalic-latin.woff2") format("woff2"); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("./fonts/IBMPlexMono-Regular-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* ------------------------------------------------------------------
   Tokens. --t runs 0 → 1 as the names are collected: 0 is Wendy's site,
   1 is cjinn.org. app.js blends the colours; these are the t = 0 values.
------------------------------------------------------------------- */
:root {
  --t: 0;
  --bg: #F6F8FA;
  --surface: #FFFFFF;
  --ink: #1B2D42;
  --muted: #5B6B7B;
  --rule: #DCE4EA;
  --accent: #1D5C82;
  --accent-soft: #7397AB;
  --accent-tint: #E6EEF3;
  --stage-bg: #1B2D42;

  /* fixed identities, whatever t is */
  --her: #1D5C82;
  --her-soft: #A8C3BC;
  --his: #B75C45;
  --his-light: #F0A48F;
  --paper: #F6F3EC;
  --his-ink: #202322;

  --font-her: "Source Serif 4", "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-her-sans: "Open Sans", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  --font-her-mono: "IBM Plex Mono", "PingFang SC", "Noto Sans SC", ui-monospace, monospace;
  --font-his: "DM Sans", "Noto Sans SC", sans-serif;
  --font-his-serif: Georgia, "Noto Serif SC", "Noto Serif KR", "Songti SC", serif;

  --radius: calc(14px - 12px * var(--t));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-her-sans);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font-family: var(--font-her-mono);
  font-size: 0.85em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 0.35em;
  background: var(--surface);
}

/* The paper texture surfaces as the journey goes on */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: calc(0.2 * var(--t));
  background-image: radial-gradient(#8a8579 0.5px, transparent 0.7px);
  background-size: 7px 7px;
  z-index: 0;
}

.site {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------
   Header: a collab logotype and the journey meter
------------------------------------------------------------------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 20px clamp(16px, 5vw, 64px);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) calc(var(--t) * 100%), transparent);
}
.logo {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
/* Wendy's WF monogram (as on her site): letters stacked vertically, the rest of
   WENYU FAN unfolds on hover with a small stagger. */
.logo { align-items: center; }
.logo-her {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 20px;
  height: 40px; /* W + F; the unfolded name floats over the page instead of pushing it */
  position: relative;
  z-index: 20;
  font-family: var(--font-her);
  font-weight: 300;
  font-synthesis: none;
  font-size: 16px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--her);
}
.logo-her > span {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  opacity: 0;
  overflow: hidden;
  transition: height 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.25s ease-out;
}
.logo-her > span.keep { height: 20px; opacity: 1; }
.logo:hover .logo-her > span { height: 20px; opacity: 1; }
.logo:hover .logo-her > span.gap { height: 10px; }
.logo-her > span:nth-child(2) { transition-delay: 0.04s; }
.logo-her > span:nth-child(3) { transition-delay: 0.08s; }
.logo-her > span:nth-child(4) { transition-delay: 0.12s; }
.logo-her > span:nth-child(5) { transition-delay: 0.16s; }
.logo-her > span:nth-child(8) { transition-delay: 0.28s; }
.logo-her > span:nth-child(9) { transition-delay: 0.32s; }
.logo-x { font-family: var(--font-her-mono); font-size: 13px; color: var(--muted); }
.logo-his { font-family: var(--font-his); font-weight: 700; font-size: 26px; letter-spacing: -0.07em; color: var(--his-ink); }
.logo-his b { color: var(--his); font-weight: inherit; }

.journey {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.journey-end.her { color: var(--her); }
.journey-end.his { color: var(--his); }
.journey-bar {
  position: relative;
  width: clamp(70px, 12vw, 150px);
  height: 4px;
  border-radius: 4px;
  background: var(--rule);
  overflow: hidden;
}
.journey-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--t) * 100%);
  background: linear-gradient(90deg, var(--her), var(--his));
  border-radius: inherit;
}
.journey-count { min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; }
.restart {
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  line-height: 1;
}
.restart:hover { border-color: var(--accent); }

.topline {
  display: flex;
  justify-content: space-between;
  padding: 11px clamp(16px, 5vw, 64px);
  font: 10px Georgia, serif;
  letter-spacing: 0.2em;
  color: #77796f;
  border-bottom: 1px solid var(--rule);
  opacity: var(--t);
}
.topline i { font-style: normal; color: #b2a89a; }

/* ------------------------------------------------------------------
   Hero: her line, then his
------------------------------------------------------------------- */
main { flex: 1; }
.hero {
  padding: clamp(24px, 5vh, 56px) clamp(16px, 5vw, 64px) 20px;
  max-width: 1400px;
  margin: 0 auto;
}
.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-her-sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
h1 { margin: 0 0 16px; display: flex; flex-direction: column; gap: 2px; }

/* ------------------------------------------------------------------
   Desktop: everything from the header to the passport fits one screen
   (app.js sizes the stage to the height that's left).
------------------------------------------------------------------- */
@media (min-width: 901px) {
  .screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  .screen main { flex: 1; }
  .screen .masthead { padding-top: 14px; padding-bottom: 14px; }
  .screen .hero { padding-top: clamp(14px, 3vh, 36px); padding-bottom: clamp(8px, 1.6vh, 18px); }
  .screen .eyebrow { margin-bottom: 6px; }
  .screen h1 { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 0.45em; margin: 0; }
  .screen .h-his { font-size: clamp(44px, min(6.4vw, 10vh), 104px); }
  .screen .h-her { font-size: clamp(26px, min(3.4vw, 5.4vh), 54px); }
  .screen .workspace { padding-bottom: clamp(12px, 2.5vh, 32px); }
  .screen .stage-col { justify-self: start; width: 100%; }
  .screen .lang-row { padding-top: 10px; }
  .screen .passport { margin-top: clamp(10px, 1.8vh, 20px); }
  .screen .passport .cell-slot { max-width: clamp(44px, 8vh, 72px); }
  /* compact finger board so it also fits */
  .screen .board { gap: clamp(8px, 1.4vh, 16px); }
  .screen .hand ol { gap: clamp(3px, 0.6vh, 6px); }
  .screen .hand-title { margin-bottom: 5px; }
  .screen .slot { padding: clamp(5px, 0.9vh, 10px) 12px; }
  .screen .slot-name { font-size: clamp(15px, 2.1vh, 19px); line-height: 1.25; }
  .screen .slot-greet { font-size: clamp(12px, 1.6vh, 14px); line-height: 1.3; }
}

/* Finger board hidden (header switch or the S key): the stage takes the room. */
.board-hidden .board { display: none; }
.board-hidden .workspace { grid-template-columns: minmax(0, 1fr); }
.board-hidden .screen .stage-col { justify-self: center; }
/* With the list hidden, the page is one centred column: title, stage, languages, passport. */
.board-hidden .screen .hero { text-align: center; }
.board-hidden .screen h1 { justify-content: center; }
.board-hidden .screen .lang-row { justify-content: center; }
#toggle-board[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#toggle-board { display: inline-grid; place-items: center; }
.h-her {
  font-family: var(--font-her);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(30px, 4.4vw, 56px);
  line-height: 1.15;
  color: var(--her);
}
.h-his {
  font-family: var(--font-his);
  font-weight: 500;
  font-size: clamp(44px, 7.6vw, 108px);
  letter-spacing: -0.055em;
  line-height: 1;
  color: var(--his-ink);
}
.h-his b { color: var(--his); font-weight: inherit; }
.intro {
  margin: 0;
  max-width: 60ch;
  text-wrap: pretty;
  color: var(--muted);
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.75;
}

/* ------------------------------------------------------------------
   Workspace
------------------------------------------------------------------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: clamp(16px, 2.5vw, 36px);
  padding: 8px clamp(16px, 5vw, 64px) 48px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  align-items: start;
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--stage-bg);
  border: 1px solid var(--rule);
  box-shadow: 0 18px 50px rgba(27, 45, 66, calc(0.14 * (1 - var(--t))));
  isolation: isolate;
}
@media (max-width: 600px) {
  .stage { aspect-ratio: 3 / 4; }
}
.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Camera-off card: the night-blue gradient fades into paper */
.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background: var(--paper);
  color: #fff;
  z-index: 3;
}
.placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  /* Stays night-blue until 40%, then turns to paper by 60% (no muddy grey). */
  opacity: clamp(0, (0.6 - var(--t)) * 5, 1);
  background:
    radial-gradient(circle at 30% 20%, rgba(168, 195, 188, 0.35), transparent 55%),
    radial-gradient(circle at 75% 80%, rgba(115, 151, 171, 0.45), transparent 60%),
    #1B2D42;
}
[data-phase="his"] .placeholder { color: var(--his-ink); }
.placeholder > * { transition: opacity 0.25s ease; }
.stage.has-caption .placeholder > * { opacity: 0; pointer-events: none; }
.placeholder-art { width: clamp(84px, 13vw, 124px); }
.placeholder-art svg { width: 100%; height: auto; display: block; overflow: visible; }

.cta {
  border: 0;
  padding: 14px 26px;
  font-size: 15px;
  border-radius: calc(999px * (1 - var(--t)));
  background: #fff;
  color: var(--ink);
  transition: transform 0.15s ease;
}
[data-phase="his"] .cta { background: var(--his-ink); color: #fff; letter-spacing: 0.03em; }
.cta:hover { transform: translateY(-1px); }
.cta:disabled { opacity: 0.6; cursor: progress; }
.status {
  margin: 0;
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.75;
  max-width: 46ch;
}

/* Out of the way for screen recordings: shows only when the pointer is over the stage. */
.stage .stop { opacity: 0; transition: opacity 0.2s; }
.stage:hover .stop, .stage .stop:focus-visible { opacity: 1; }
.stop {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 6;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  backdrop-filter: blur(6px);
}

.nudge {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  margin: 0;
  padding: 7px 14px;
  font-family: var(--font-his-serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: #fff;
  background: var(--his);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: translateX(-50%) translateY(-2px); } }

.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  margin: 0;
  padding: 7px 14px;
  font-size: 13px;
  white-space: nowrap;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
}

/* fingertip markers */
.markers { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.marker {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(var(--x), var(--y));
  transition: opacity 0.15s;
  will-change: transform;
}
.marker.is-off { opacity: 0; }
.marker-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--her);
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, background 0.3s;
}
.marker.is-got .marker-dot { background: var(--his); }
.marker-label {
  position: absolute;
  left: 12px;
  top: -30px;
  white-space: nowrap;
  padding: 4px 9px;
  font-size: 12px;
  font-family: var(--font-her);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  border-radius: calc(999px * (1 - var(--t)) + 2px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.marker.is-near .marker-dot { transform: scale(1.35); }
.marker.is-hit .marker-dot { animation: hit 0.5s ease-out; }
.marker.is-hit .marker-label { background: var(--his); color: #fff; }
@keyframes hit {
  0% { box-shadow: 0 0 0 0 var(--his); }
  100% { box-shadow: 0 0 0 26px transparent; }
}

/* ------------------------------------------------------------------
   Caption: her half (the name) then his half (the world's reply)
------------------------------------------------------------------- */
.caption {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 4;
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 40px clamp(16px, 4vw, 40px) clamp(18px, 3vw, 30px);
  text-align: center;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.66), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.caption.is-on { opacity: 1; }
.stage:not(.is-live) .caption { inset: 0; align-content: center; background: none; }
.caption p { margin: 0; }

.cap-meta {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.cap-her .cap-meta {
  font-family: var(--font-her-mono);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(115, 151, 171, 0.35);
  color: #DCEAF3;
}
.cap-his .cap-meta {
  font-family: var(--font-his-serif);
  color: var(--his-light);
}
.cap-name {
  font-family: var(--font-her);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(26px, 4.6vw, 56px);
  line-height: 1.15;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.3);
}
.cap-greet {
  font-family: var(--font-his-serif);
  font-size: clamp(30px, 6.4vw, 78px);
  line-height: 1.12;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.cap-greet[lang="ko-Hani"] { font-family: "Noto Serif KR", "Noto Serif SC", serif; }
.cap-greet.is-long { font-size: clamp(26px, 5vw, 60px); }
.cap-his {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.caption.show-greet .cap-his { opacity: 1; transform: none; }

/* camera off + paper phase: dark ink on paper */
[data-phase="his"] .stage:not(.is-live) .caption { color: var(--his-ink); }
[data-phase="his"] .stage:not(.is-live) .cap-name { color: var(--her); text-shadow: none; }
[data-phase="his"] .stage:not(.is-live) .cap-greet { text-shadow: none; }
[data-phase="his"] .stage:not(.is-live) .cap-her .cap-meta { background: #E6EEF3; color: var(--her); }
[data-phase="his"] .stage:not(.is-live) .cap-his .cap-meta { color: var(--his); }

/* Wendy's pixel cat buddy */
.buddy {
  position: absolute;
  left: 14px;
  bottom: 10px;
  width: clamp(50px, 7.5vw, 80px);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
}
.stage.is-live .buddy { opacity: 1; }
.buddy svg { width: 100%; height: auto; display: block; overflow: visible; }
.buddy.is-hop { animation: hop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-18px) rotate(-4deg); }
}
.meow {
  position: absolute;
  left: 70%;
  top: -22px;
  font-family: var(--font-her-mono);
  font-size: 12px;
  background: #fff;
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

/* Language row */
.lang-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 9px;
  padding: 14px 2px 0;
  font: 13px Georgia, "Noto Serif SC", serif;
  color: #a19d93;
}
.lang-row button {
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}
.lang-row button.got { color: var(--his-ink); }
.lang-row button:hover { color: var(--his); }
.lang-row button:focus { outline: none; } /* no focus box in screen recordings; the underline shows the choice */
.lang-row button.chosen {
  color: var(--his-ink);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-color: var(--his);
}
.lang-row .sep { color: #c9c3b8; }

/* ------------------------------------------------------------------
   Passport: one postmark per finger, with Wendy's cat in the corner
------------------------------------------------------------------- */
.passport { margin-top: 22px; }
.passport-title {
  margin: 0 0 10px;
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.passport-title span { letter-spacing: 0.05em; margin-left: 4px; }
.passport-title em { font-style: normal; float: right; color: var(--accent); }
.passport ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 600px) {
  .passport ol { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.cell {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}
.cell-slot {
  position: relative;
  width: 100%;
  max-width: 76px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px dashed var(--rule);
  display: grid;
  place-items: center;
  font-family: var(--font-her-mono);
  font-size: 11px;
  color: var(--muted);
}
.cell.is-got .cell-slot { border-color: transparent; }
.cell-stamp {
  position: absolute;
  inset: 0;
  color: var(--his);
  transform: rotate(var(--rot, -10deg));
}
.cell-stamp svg { width: 100%; height: 100%; display: block; }
.cell.is-new .cell-stamp { animation: stampIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes stampIn {
  0% { opacity: 0; transform: rotate(var(--rot)) scale(1.8); }
  100% { opacity: 1; transform: rotate(var(--rot)) scale(1); }
}
.cell-cat {
  position: absolute;
  right: -6%;
  bottom: -6%;
  width: 42%;
}
.cell-cat svg { width: 100%; height: auto; display: block; }
.cell-name {
  font-size: 11px;
  font-family: var(--font-her);
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell.is-got .cell-name { color: var(--ink); }

/* ------------------------------------------------------------------
   Finger board: each slot holds her name and his language
------------------------------------------------------------------- */
.board { display: grid; gap: 18px; }
@media (max-width: 900px) and (min-width: 520px) {
  .board { grid-template-columns: 1fr 1fr; }
  .board .hint { grid-column: 1 / -1; }
}
.hand-title {
  margin: 0 0 8px;
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.hand-title span { letter-spacing: 0.05em; margin-left: 6px; }
.hand ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.slot {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  column-gap: 10px;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s, transform 0.12s;
}
.slot:hover { border-color: var(--accent-soft); }
.slot:active { transform: scale(0.99); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.slot-num {
  grid-row: span 2;
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--her);
}
.slot-name {
  font-family: var(--font-her);
  font-size: 19px;
  line-height: 1.3;
  color: var(--her);
  overflow-wrap: anywhere;
}
.slot-greet {
  grid-column: 2;
  font-family: var(--font-his-serif);
  font-size: 14px;
  line-height: 1.4;
  color: var(--his-ink);
  opacity: 0.55;
  transition: opacity 0.3s;
}
.slot-greet[lang="ko-Hani"] { font-family: "Noto Serif KR", "Noto Serif SC", serif; }
.slot-lang {
  grid-column: 3;
  grid-row: 1 / span 2;
  font-family: var(--font-his-serif);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: right;
}
.slot.is-got .slot-greet { opacity: 1; }
.slot.is-got .slot-num { color: var(--his); }
.slot.is-got .slot-num::after { content: " ✓"; }
.slot.is-hit { border-color: var(--his); background: var(--accent-tint); }
.slot.is-finale .slot-greet { font-style: italic; }

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--muted);
}

/* ------------------------------------------------------------------
   Footer + confetti
------------------------------------------------------------------- */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 22px clamp(16px, 5vw, 64px);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--font-her-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}
footer a { color: inherit; text-underline-offset: 3px; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10000;
}

/* ------------------------------------------------------------------
   Finale: dotted map, flags from everywhere fly home
------------------------------------------------------------------- */
.world {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 3vh 3vw;
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.world::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: radial-gradient(#8a8579 0.5px, transparent 0.7px);
  background-size: 7px 7px;
}
.world.is-on { opacity: 1; }
.world-inner { position: relative; width: min(94vw, calc((94vh - 120px) * 2.65), 1400px); }
.world-title {
  margin: 0 0 3vh;
  text-align: center;
  font-family: var(--font-his);
  font-weight: 500;
  font-size: clamp(34px, 5.6vw, 88px);
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--his-ink);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}
.world-title b { color: var(--his); font-weight: inherit; }
.world.is-on .world-title { opacity: 1; transform: none; }
.world-map { position: relative; width: 100%; aspect-ratio: 2.647; }
.world-map canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.3s cubic-bezier(0.65, 0, 0.35, 1);
}
.world.is-on .world-map canvas { clip-path: inset(0 0 0 0); }
.world-cat {
  position: absolute;
  left: 4%;
  bottom: 6%;
  width: clamp(40px, 5vw, 72px);
}
.world-cat svg { width: 100%; height: auto; display: block; overflow: visible; }

.flag {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: clamp(14px, 1.7vw, 24px);
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.6);
  transition:
    transform 1.25s cubic-bezier(0.2, 1.15, 0.35, 1) var(--d),
    opacity 0.35s ease var(--d);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
  will-change: transform;
}
.flag.been { font-size: clamp(18px, 2.3vw, 32px); z-index: 1; }
.world.is-flying .flag { opacity: 1; transform: translate(-50%, -50%); }

/* ------------------------------------------------------------------
   The birthday edition — modelled on cjinn.org's sheet
------------------------------------------------------------------- */
.edition {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: clamp(0px, 3vw, 36px);
  background: rgba(19, 27, 30, 0.76);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.5s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.edition-sheet {
  position: relative;
  width: min(100%, 760px);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: #292e2d;
  border: 1px solid #d9d5ca;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.55);
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.edition-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: radial-gradient(#8a8579 0.5px, transparent 0.7px);
  background-size: 7px 7px;
}
.edition-topline,
.edition-bottom {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(20px, 5vw, 52px);
  flex-shrink: 0;
}
.edition-topline { font-size: 10px; letter-spacing: 0.2em; color: #77796f; }
.edition-topline i { font-style: normal; color: #b2a89a; }
.edition-x { border: 0; background: transparent; font-size: 25px; line-height: 1; color: #67675f; }
.edition-x:focus:not(:focus-visible) { outline: none; }
.edition-sheet:focus { outline: none; }
.edition-scroll {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 clamp(22px, 9vw, 94px) 40px;
}
.edition-masthead {
  text-align: center;
  padding-bottom: 26px;
  margin-bottom: 8px;
  border-bottom: 1px solid #d2cec3;
}
.edition-logo {
  margin: 4px 0 14px;
  font-family: var(--font-his);
  font-weight: 700;
  font-size: clamp(54px, 10vw, 92px);
  letter-spacing: -0.07em;
  line-height: 1;
  color: var(--his-ink);
}
.edition-logo b, #edition-title b { color: var(--his); font-weight: inherit; }
.edition-rule {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #d2cec3;
  border-bottom: 1px solid #d2cec3;
  padding: 9px 0;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #7b7b71;
}
.edition-label { font-size: 11px; letter-spacing: 0.24em; color: #77786e; margin: 26px 0 8px; }
#edition-title {
  margin: 0;
  font-family: var(--font-his);
  font-weight: 500;
  font-size: clamp(38px, 7vw, 64px);
  letter-spacing: -0.05em;
  line-height: 1.05;
}
.edition-names {
  margin: 14px 0 0;
  font-family: var(--font-her);
  font-style: italic;
  font-size: clamp(16px, 2.2vw, 20px);
  line-height: 1.7;
  color: var(--her);
  white-space: nowrap;
  overflow: hidden;
}
.edition-list { list-style: none; margin: 0; padding: 0; }
.edition-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 92px 1fr;
  gap: 14px;
  align-items: baseline;
  padding: 15px 0;
  border: 0;
  border-bottom: 1px solid #dedbd4;
  background: transparent;
  text-align: left;
  font: inherit;
  transition: background 0.2s;
}
.edition-list button:hover { background: #efeee9; }
.edition-list .n { color: var(--his); font-size: 11px; letter-spacing: 0.12em; }
.edition-list .l { color: #8a8984; font-size: 12px; }
.edition-list .g { font-size: clamp(18px, 2.6vw, 24px); color: var(--his-ink); }
.edition-list .g[lang="ko-Hani"] { font-family: "Noto Serif KR", "Noto Serif SC", serif; }
.edition-list .who { display: block; margin-top: 3px; font-family: var(--font-her); font-style: italic; font-size: 13px; color: var(--her); }
.edition-letter {
  margin-top: 34px;
  font-size: clamp(15px, 1.7vw, 17px);
  line-height: 2.05;
  letter-spacing: 0.01em;
}
.edition-letter p { margin: 0 0 1.2em; }
.edition-signature {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 10px;
  margin-top: 26px;
  font-size: 21px;
  letter-spacing: 0.06em;
}
.edition-cat { width: 46px; }
.edition-cat svg { width: 100%; height: auto; display: block; overflow: visible; }
.edition-bottom {
  background: #f0ece3;
  border-top: 1px solid #d2cec3;
  font-size: 12px;
  color: #7e7b72;
}
.edition-bottom button { border: 0; background: transparent; color: #262d2d; font: inherit; font-size: 13px; }
.edition-bottom button span { margin-left: 6px; }

@media (max-width: 600px) {
  .edition { padding: 0; }
  .edition-sheet { height: 100dvh; max-height: 100dvh; border: 0; }
  .edition-list button { grid-template-columns: 28px 1fr; }
  .edition-list .l { grid-column: 2; }
  .edition-list .g { grid-column: 2; }
}

@media (max-width: 520px) {
  .masthead { padding: 14px 16px; }
  .journey-end { display: none; }
  .topline { font-size: 9px; letter-spacing: 0.12em; }
}

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

/* ── Finger editor ─────────────────────────────────────────────────── */
.editor {
  width: min(100% - 32px, 820px);
  max-height: 90dvh;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-her-sans);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.35);
}
.editor::backdrop { background: rgba(10, 16, 20, 0.5); }
.editor form { display: flex; flex-direction: column; max-height: 90dvh; }
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 0;
}
.editor-head h2 { margin: 0; font: 300 22px var(--font-her); }
.editor-x { border: 0; background: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.editor-note { margin: 8px 20px 12px; font-size: 13px; line-height: 1.5; color: var(--muted); word-break: break-all; }
.editor-rows {
  list-style: none;
  margin: 0;
  padding: 0 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.editor-row {
  display: grid;
  grid-template-columns: 34px 1fr 1.4fr 1fr;
  gap: 10px;
  align-items: end;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
.editor-slot { font: 12px var(--font-her-mono); color: var(--accent); padding-bottom: 9px; }
.editor-row label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.editor-row label span { font-size: 11px; color: var(--muted); }
.editor-row input,
.editor-row select {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) / 2);
  background: var(--bg);
  color: var(--ink);
  font: 15px var(--font-her-sans);
}
.editor-row input:focus,
.editor-row select:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
.editor-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--rule);
}
.editor-foot button {
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 13px var(--font-her-sans);
  cursor: pointer;
}
.editor-foot button:hover { border-color: var(--accent); }
.editor-foot .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 600px) {
  .editor-row { grid-template-columns: 1fr 1fr; }
  .editor-slot { grid-column: 1 / -1; padding: 0; }
  .editor-row label:nth-of-type(1) { grid-area: 2 / 1; }
  .editor-row label:nth-of-type(3) { grid-area: 2 / 2; }
  .editor-row label:nth-of-type(2) { grid-area: 3 / 1 / 4 / 3; }
  .editor-foot { justify-content: stretch; }
  .editor-foot button { flex: 1; }
}
