/* Game Mode - global styles */

:root {
  /* Typography */
  --font-zh: 'Noto Serif TC', 'Source Han Serif TC', serif;
  --font-en: 'Inter', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Ink palette */
  --color-ink: #111;
  --color-ink-soft: #555;
  --color-ink-mute: #888;
  --color-bg: #fff;
  --color-bg-soft: #fafafa;
  --color-accent: #0066ff;
  --color-warning: #b33;
  --color-highlight-bg: #fff6f0;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;

  /* Geometry */
  --radius: 6px;

  /* Motion */
  --duration-fast: 180ms;
  --duration-med: 400ms;
  --duration-slow: 1000ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-zh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
}

.gm-mobile-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 5vw, 42px);
  background: #fff;
  color: var(--color-ink);
}

.gm-mobile-gate-inner {
  width: min(100%, 680px);
}

.gm-mobile-gate-label {
  margin: 0 0 28px;
  color: var(--color-ink-mute);
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.gm-mobile-gate h1 {
  margin: 0 0 18px;
  font-size: clamp(28px, 9vw, 48px);
  font-weight: 500;
  line-height: 1.15;
}

.gm-mobile-gate-copy {
  max-width: 38rem;
  margin: 0 0 12px;
  color: var(--color-ink-soft);
  font-size: 15px;
  line-height: 1.75;
}

.gm-mobile-gate-copy.en {
  color: var(--color-ink-mute);
  font-family: var(--font-en);
  font-size: 13px;
  font-style: italic;
  line-height: 1.55;
}

.gm-mobile-gate-orientation {
  margin: 22px 0 0;
  padding: 10px 0;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  color: #8a5a14;
  font-size: 14px;
  line-height: 1.45;
}

.gm-mobile-gate-actions {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.gm-mobile-gate-btn {
  min-height: 50px;
  border: 1px solid #222;
  border-radius: 0;
  background: transparent;
  color: #111;
  cursor: pointer;
  font-family: var(--font-zh);
  font-size: 15px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  text-align: left;
}

.gm-mobile-gate-btn small {
  color: #777;
  font-family: var(--font-en);
  font-size: 11px;
  text-align: right;
  text-transform: uppercase;
}

.gm-mobile-gate-btn.primary {
  background: #111;
  color: #fff;
}

.gm-mobile-gate-btn.primary small {
  color: rgba(255,255,255,.68);
}

/* ============================================================
   Entry screen (B · 画廊极简)
   ============================================================ */

.entry-screen {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--space-lg) var(--space-xl);
  background: var(--color-bg);
}

.entry-header {
  padding-top: var(--space-md);
}

.entry-label {
  font-family: var(--font-en);
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--color-ink-mute);
  font-weight: 500;
}

.entry-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-xl) 0;
}

.entry-title {
  font-family: var(--font-zh);
  font-weight: 500;
  font-size: clamp(28px, 4.5vw, 42px);
  line-height: 1.3;
  color: var(--color-ink);
  margin: 0 0 var(--space-lg) 0;
  letter-spacing: 0.02em;
}

.entry-sub {
  font-family: var(--font-zh);
  font-size: clamp(14px, 1.6vw, 16px);
  color: var(--color-ink-soft);
  line-height: 1.8;
  margin: 0 0 var(--space-md) 0;
  font-weight: 400;
}

.entry-sub-en {
  font-family: var(--font-en);
  font-size: 13px;
  color: var(--color-ink-mute);
  line-height: 1.6;
  margin: 0 0 var(--space-xl) 0;
  font-weight: 300;
}

.entry-sub-en em {
  font-style: italic;
}

.entry-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-md);
}

.entry-btn {
  font-family: var(--font-zh);
  font-size: 14px;
  padding: 10px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast),
              border-color var(--duration-fast), transform var(--duration-fast);
  letter-spacing: 0.03em;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
  min-width: 160px;
}

.entry-btn .zh {
  font-family: var(--font-zh);
  font-size: 14px;
  font-weight: 500;
}

.entry-btn .en {
  font-family: var(--font-en);
  font-size: 10px;
  font-weight: 300;
  opacity: 0.7;
  letter-spacing: 0.05em;
}

.entry-btn-ghost {
  background: transparent;
  color: var(--color-ink);
  border: 1px solid #ccc;
}

.entry-btn-ghost:hover {
  border-color: var(--color-ink);
  background: var(--color-bg-soft);
}

.entry-btn-solid {
  background: var(--color-ink);
  color: var(--color-bg);
  border: 1px solid var(--color-ink);
}

.entry-btn-solid:hover {
  transform: translateY(-1px);
  background: #000;
}

.entry-btn:active {
  transform: translateY(1px);
}

.entry-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Returning-visitor shortcuts (entry hub) — quieter than the two main
   choices so the first-visit ritual keeps its weight. */
.entry-actions-secondary {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

.entry-actions-secondary[hidden] {
  display: none;
}

/* .entry-btn's display:inline-flex would defeat the [hidden] attribute
   (author styles beat the UA's hidden→display:none). */
.entry-btn[hidden] {
  display: none;
}

.entry-btn-quiet {
  background: transparent;
  color: #888;
  border: 1px dashed #ccc;
  font-size: 12px;
  padding: 7px 16px;
}

.entry-btn-quiet .zh {
  font-size: 12px;
  font-weight: 400;
}

.entry-btn-quiet .en {
  font-size: 9px;
}

.entry-btn-quiet:hover {
  color: var(--color-ink);
  border-color: #888;
  background: var(--color-bg-soft);
}

.entry-footer {
  padding-bottom: var(--space-md);
}

.entry-fine {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--color-ink-mute);
  opacity: 0.6;
}

/* Narrow screens */
@media (max-width: 520px) {
  .entry-screen { padding: var(--space-md); }
  .entry-actions { flex-direction: column; }
  .entry-btn { width: 100%; }
}

/* ============================================================
   Gender layer (性别层 · 假选择)
   ============================================================ */

.gender-layer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
}

.gender-inner {
  max-width: 860px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
}

.gender-prompt {
  text-align: center;
  margin: 0;
  font-family: var(--font-zh);
  font-weight: 400;
}
.gender-prompt .zh {
  display: block;
  font-size: clamp(20px, 2.4vw, 26px);
  color: var(--color-ink);
  margin-bottom: var(--space-sm);
}
.gender-prompt .en {
  display: block;
  font-family: var(--font-en);
  font-size: 13px;
  color: var(--color-ink-mute);
  font-weight: 300;
}
.gender-prompt .en em { font-style: italic; }

.gender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-sm);
  width: 100%;
  transition: opacity var(--duration-med);
}

.gender-grid.fading-out { opacity: 0.25; }
.gender-grid.hidden     { display: none; }

.gender-option {
  font-family: var(--font-zh);
  background: var(--color-bg);
  color: var(--color-ink);
  border: 1px solid #ddd;
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast),
              background var(--duration-fast),
              transform var(--duration-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 54px;
}

.gender-option:hover:not(:disabled) {
  border-color: var(--color-ink);
  background: var(--color-bg-soft);
}

.gender-option.selected {
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-bg);
}

.gender-option:disabled {
  cursor: default;
  opacity: 0.6;
}

.gender-option .opt-zh {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
}
.gender-option .opt-en {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 0.04em;
  opacity: 0.65;
  line-height: 1.2;
  font-weight: 300;
}

.gender-option:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.gender-break,
.gender-transition {
  text-align: center;
  opacity: 0;
  transition: opacity var(--duration-med);
  max-width: 680px;
}
.gender-break.fading-in,
.gender-transition.fading-in   { opacity: 1; }
.gender-break.fading-out       { opacity: 0; }

.break-line, .break-zh {
  font-family: var(--font-zh);
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.5;
  color: var(--color-ink);
  margin: 0 0 8px 0;
  white-space: pre-line;
  font-weight: 500;
}

.break-en, .transition-en {
  font-family: var(--font-en);
  font-size: clamp(13px, 1.5vw, 16px);
  line-height: 1.6;
  color: var(--color-ink-mute);
  opacity: 0.75;
  margin: 0 0 var(--space-md) 0;
  font-style: italic;
}

.transition-line, .transition-zh {
  font-family: var(--font-zh);
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--color-ink-soft);
  margin: 0 0 8px 0;
  font-style: italic;
}

/* ============================================================
   Identity layer (身份层 · 嘲讽分支)
   ============================================================ */

.identity-layer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.identity-inner {
  max-width: 760px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xl);
}

.identity-prompt {
  text-align: center;
  margin: 0;
  font-family: var(--font-zh);
}
.identity-prompt .zh {
  display: block;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 500;
  color: var(--color-ink);
  margin-bottom: var(--space-sm);
}
.identity-prompt .en {
  display: block;
  font-family: var(--font-en);
  font-size: 13px;
  color: var(--color-ink-mute);
  font-weight: 300;
}
.identity-prompt .en em { font-style: italic; }

.identity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-sm);
  width: 100%;
}

.identity-option {
  font-family: var(--font-zh);
  background: var(--color-bg);
  color: var(--color-ink);
  border: 1px solid #ccc;
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.identity-option:hover {
  border-color: var(--color-ink);
  background: var(--color-bg-soft);
  transform: translateY(-2px);
}

.identity-option .id-zh {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.1;
}
.identity-option .id-en {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--color-ink-mute);
  font-weight: 300;
}

.identity-option:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Taunt screen (identity-layer 之后) */
.identity-taunt {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.identity-taunt-inner {
  max-width: 680px;
  text-align: center;
}

.identity-taunt-text {
  font-family: var(--font-zh);
  font-size: clamp(20px, 2.6vw, 26px);
  line-height: 1.7;
  color: var(--color-ink);
  margin: 0 0 var(--space-sm) 0;
  white-space: pre-line;
  min-height: 6em;
}

/* English second-line for any taunt (identity / generic-choice / year-grid) */
.identity-taunt-en,
.choice-taunt-en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: clamp(12px, 1.5vw, 16px);
  line-height: 1.55;
  color: var(--color-ink-mute);
  opacity: 0.75;
  margin: 0 0 var(--space-xl) 0;
  max-width: 62ch;
  text-align: center;
}

.identity-taunt-hint,
.choice-taunt-hint {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-ink-mute);
  opacity: 0.5;
  margin: 0;
}

/* Generic choice scene (selection pool) & choice taunt shared with identity */
.choice-layer, .year-grid-layer {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}
.choice-inner, .year-grid-inner {
  width: 100%;
  max-width: 1040px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}
.choice-prompt, .year-grid-prompt {
  margin: 0 0 var(--space-md) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.choice-prompt .zh, .year-grid-prompt .zh {
  font-family: var(--font-zh);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 500;
  color: var(--color-ink);
}
.choice-prompt .en, .year-grid-prompt .en {
  font-family: var(--font-en);
  font-size: clamp(13px, 1.5vw, 16px);
  color: var(--color-ink-mute);
  font-style: italic;
  opacity: 0.7;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 18px;
  max-width: 780px;
  width: 100%;
}
.choice-option {
  font-family: var(--font-zh);
  background: transparent;
  border: 1px solid var(--color-ink);
  border-radius: 4px;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--color-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: background 120ms, color 120ms, transform 120ms;
}
.choice-option:hover {
  background: var(--color-ink);
  color: var(--color-paper);
}
.choice-option .ch-zh {
  font-size: clamp(15px, 1.7vw, 18px);
  font-weight: 500;
}
.choice-option .ch-en {
  font-family: var(--font-en);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.06em;
  opacity: 0.65;
}

/* Year grid (10×10 + "more") */
.year-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}
.year-grid .year-tile {
  font-family: var(--font-en);
  font-size: 14px;
  aspect-ratio: 1;
  background: transparent;
  border: 1px solid var(--color-ink-mute);
  cursor: pointer;
  color: var(--color-ink);
  transition: background 100ms, color 100ms;
  border-radius: 3px;
}
.year-grid .year-tile:hover {
  background: var(--color-ink);
  color: var(--color-paper);
}
.year-grid .year-more {
  grid-column: span 10;
  aspect-ratio: auto;
  padding: 8px 12px;
  font-family: var(--font-zh);
  font-size: 14px;
  display: flex;
  justify-content: center;
  gap: 12px;
}
.year-grid .year-more .zh { font-weight: 500; }
.year-grid .year-more .en { font-family: var(--font-en); font-style: italic; opacity: 0.7; }
.year-grid-hint {
  min-height: 1.4em;
  font-family: var(--font-en);
  color: var(--color-ink-mute);
  font-size: 14px;
  font-style: italic;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.year-grid-hint .zh { font-family: var(--font-zh); font-size: 15px; }
.year-grid-hint .en { font-size: 12px; opacity: 0.7; }

/* Choice taunt (same layout as identity taunt) */
.choice-taunt {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}
.choice-taunt-inner {
  max-width: 780px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.choice-taunt-text {
  font-family: var(--font-zh);
  font-size: clamp(20px, 2.6vw, 26px);
  line-height: 1.7;
  color: var(--color-ink);
  margin: 0 0 var(--space-sm) 0;
  white-space: pre-line;
  min-height: 3em;
}

/* Followup (exit / continue after subtree) */
.choice-followup-inner {
  max-width: 640px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}
.choice-followup-text .zh {
  font-family: var(--font-zh);
  font-size: clamp(22px, 2.8vw, 28px);
  display: block;
  margin-bottom: 6px;
}
.choice-followup-text .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 14px;
  color: var(--color-ink-mute);
  opacity: 0.7;
}
.choice-followup-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
}
.followup-btn {
  font-family: var(--font-zh);
  padding: 12px 20px;
  border: 1px solid var(--color-ink);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 4px;
  transition: background 120ms, opacity 120ms;
}
.followup-btn[disabled] { opacity: 0.35; cursor: default; }
.followup-btn:not([disabled]):hover { background: var(--color-ink); color: var(--color-paper); }
.followup-btn .en { font-family: var(--font-en); font-size: 11px; font-style: italic; opacity: 0.7; }

/* ============================================================
   Theme layer (主题层 · 关键词云)
   ============================================================ */

.theme-layer {
  min-height: 100vh;
  width: 100%;
  position: relative;
  padding: var(--space-lg);
  overflow: hidden;
}

.theme-cloud {
  position: relative;
  width: 100%;
  height: 82vh;
  max-width: 1100px;
  margin: 0 auto;
}

.theme-hint {
  position: absolute;
  bottom: var(--space-md);
  left: 0;
  right: 0;
  text-align: center;
  margin: 0;
  opacity: 0.6;
}
.theme-hint .zh {
  display: block;
  font-family: var(--font-zh);
  font-size: 13px;
  color: var(--color-ink-mute);
}
.theme-hint .en {
  display: block;
  font-family: var(--font-en);
  font-size: 10px;
  color: var(--color-ink-mute);
  letter-spacing: 1px;
}
.theme-hint em { font-style: italic; }

.kw-word {
  position: absolute;
  font-family: var(--font-zh);
  font-weight: 500;
  background: transparent;
  border: none;
  padding: 4px 10px;
  color: var(--color-ink);
  cursor: pointer;
  letter-spacing: 0.02em;
  line-height: 1.05;
  transition: opacity var(--duration-fast), color var(--duration-fast);
  /* Per-word drift: amplitude / period / phase set inline from theme.js */
  animation: kwDrift var(--kw-period, 6s) ease-in-out infinite;
  animation-delay: var(--kw-delay, 0s);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

/* Bilingual block: zh on top, en below */
.kw-word.kw-bilingual .kw-zh {
  display: block;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.05;
}
.kw-word.kw-bilingual .kw-en {
  display: block;
  font-size: 0.45em;
  color: var(--color-ink);
  opacity: 0.55;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  line-height: 1.4;
  margin-top: 2px;
  font-style: italic;
}

.kw-word:hover {
  color: var(--color-accent);
  z-index: 2;
}
.kw-word:hover .kw-en { opacity: 0.9; }

.kw-word:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.kw-word.kw-italic .kw-zh {
  font-style: italic;
}

.kw-word.kw-exhausted {
  opacity: 0.35;
}

.kw-word.kw-size-xl { font-size: clamp(36px, 5.5vw, 56px); }
.kw-word.kw-size-lg { font-size: clamp(28px, 4vw, 40px); }
.kw-word.kw-size-md { font-size: clamp(22px, 3vw, 30px); }
.kw-word.kw-size-sm { font-size: clamp(18px, 2.4vw, 24px); }

/* Each Chinese word is broken into <span class="kw-char"> for flee scatter. */
.kw-char {
  display: inline-block;
  transition: transform 240ms cubic-bezier(0.22, 0.9, 0.3, 1), opacity 220ms ease;
  will-change: transform;
}
.kw-word.kw-fleeing .kw-char {
  transform: translate(var(--fly-x, 0), var(--fly-y, 0));
  transition-duration: 220ms;
  opacity: 0.7;
}
.kw-word.kw-fleeing {
  pointer-events: none;
}

/* session 78 续⁶ · real (non-fleeing) keywords also dodge the cursor but
   softly. The whole button translates by a small offset that points away
   from the cursor; stays clickable (pointer-events not disabled), returns
   to rest when the cursor leaves SOFT_DODGE_PX. Distinct from kw-fleeing
   which scatters characters and locks the word. */
.kw-word.kw-dodging {
  transform: translate(var(--dodge-x, 0), var(--dodge-y, 0));
  transition: transform 180ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

/* Locked cloud (prompt voice still playing) — dim + disable interactions */
.theme-cloud[data-locked="1"] .kw-word {
  pointer-events: none;
  opacity: 0.85;
}
.theme-cloud[data-locked="1"] .kw-word.kw-exhausted {
  opacity: 0.3;
}

/* Per-word drift using inline --kw-drift-x/y + phase offsets.
   Three waypoints with independent x/y translations to feel more
   chaotic than the old sine bob. */
@keyframes kwDrift {
  0% {
    transform: translate(
      calc(-50% + var(--kw-drift-x, 30px) * -0.7 * cos(var(--kw-phase-x, 0deg))),
      calc(-50% + var(--kw-drift-y, 20px) * -0.5 * sin(var(--kw-phase-y, 0deg)))
    ) rotate(calc(var(--kw-rot, 0deg) * -1));
  }
  33% {
    transform: translate(
      calc(-50% + var(--kw-drift-x, 30px) * 0.9 * cos(var(--kw-phase-x, 0deg))),
      calc(-50% + var(--kw-drift-y, 20px) * -0.9 * sin(var(--kw-phase-y, 0deg)))
    ) rotate(var(--kw-rot, 0deg));
  }
  66% {
    transform: translate(
      calc(-50% + var(--kw-drift-x, 30px) * -0.6 * cos(var(--kw-phase-x, 0deg))),
      calc(-50% + var(--kw-drift-y, 20px) * 0.8 * sin(var(--kw-phase-y, 0deg)))
    ) rotate(calc(var(--kw-rot, 0deg) * 0.5));
  }
  100% {
    transform: translate(
      calc(-50% + var(--kw-drift-x, 30px) * -0.7 * cos(var(--kw-phase-x, 0deg))),
      calc(-50% + var(--kw-drift-y, 20px) * -0.5 * sin(var(--kw-phase-y, 0deg)))
    ) rotate(calc(var(--kw-rot, 0deg) * -1));
  }
}

/* Legacy keyframe preserved for any consumers outside theme.js */
@keyframes kwFloat {
  0%   { transform: translate(-50%, -50%) translateY(0); }
  50%  { transform: translate(-50%, -50%) translateY(-8px); }
  100% { transform: translate(-50%, -50%) translateY(0); }
}

/* Theme taunt (after a pick) */
.theme-taunt {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.theme-taunt-inner {
  max-width: 760px;
  text-align: left;
}

.theme-taunt-text {
  font-family: var(--font-zh);
  font-size: clamp(20px, 2.4vw, 24px);
  line-height: 1.8;
  color: var(--color-ink);
  margin: 0 0 var(--space-m) 0;
  white-space: pre-line;
  min-height: 6em;
}

/* session 78 续⁶ · English voiceover plain-text, reveal in lockstep with zh */
.theme-taunt-en {
  font-family: var(--font-en);
  font-size: clamp(13px, 1.4vw, 15px);
  line-height: 1.7;
  color: var(--color-ink-soft);
  margin: 0 0 var(--space-xl) 0;
  min-height: 3em;
}
.theme-taunt-en em {
  font-style: italic;
}

.theme-taunt-hint {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-ink-mute);
  opacity: 0.5;
  margin: 0;
  text-align: center;
}

/* ============================================================
   Intro video (强制介绍屏)
   ============================================================ */

.intro-video {
  position: fixed;
  inset: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--font-zh);
}

.intro-kenburns {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.intro-frame {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.0);
  will-change: transform;
}

.intro-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 40%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 2;
}

.intro-subtitle-wrap {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 960px;
  padding: var(--space-xl);
  margin-bottom: 80px;
  text-align: center;
}

.intro-subtitle {
  font-family: var(--font-zh);
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.65;
  color: #fff;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  min-height: 2em;
  font-weight: 400;
  letter-spacing: 0.02em;
  animation: subtitleFade 400ms ease;
}

/* session 78 续⁶ · English subtitle revealed in lockstep with zh. Smaller
   than the Chinese so the eye falls to it naturally after reading above. */
.intro-subtitle-en {
  font-family: var(--font-en);
  font-size: clamp(14px, 1.4vw, 17px);
  line-height: 1.55;
  color: rgba(255,255,255,0.82);
  margin: 12px 0 0 0;
  text-shadow: 0 2px 6px rgba(0,0,0,0.75);
  min-height: 3em;
  letter-spacing: 0.01em;
}
.intro-subtitle-en em {
  font-style: italic;
}

@keyframes subtitleFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.intro-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 4;
}

.intro-progress-bar {
  width: 0%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
}

.intro-meta {
  position: absolute;
  top: var(--space-md);
  right: var(--space-lg);
  z-index: 4;
}

.intro-label {
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

/* ============================================================
   Alexandra level (横版平台关卡)
   ============================================================ */

.alex-level-host {
  position: relative;
  min-height: 100vh;
  background: #f0f0f0;
}

.alex-level {
  position: absolute;
  inset: 0;
  background: #fafafa;
  overflow: hidden;
}

.alex-level canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.alex-hud-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 10;
}

.alex-hud {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid #ddd;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-en);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #111;
}

.alex-hud-item strong {
  font-weight: 500;
  color: #111;
  margin-left: 4px;
}

.alex-hud-sep {
  color: #ccc;
}

.alex-hud-coins.alex-hud-warn strong {
  color: var(--color-warning);
}

.alex-hud-refusal strong {
  color: #0a6;
}

.alex-hud-quit {
  margin-left: auto;
  font-family: var(--font-zh);
  background: transparent;
  border: 1px solid #888;
  color: #555;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}
.alex-hud-quit:hover {
  border-color: #111;
  color: #111;
}

.alex-hud-toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 20px;
  border-radius: 4px;
  font-family: var(--font-en);
  font-size: 13px;
  letter-spacing: 0.5px;
  max-width: 680px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.alex-toast-zh {
  font-family: var(--font-zh);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: #fff;
  font-weight: 500;
}
.alex-toast-en {
  font-family: var(--font-en);
  font-size: 11px;
  font-style: italic;
  color: #d0d0d0;
  opacity: 0.85;
}
.alex-hud-toast-show {
  opacity: 1;
}

/* ============================================================
   Narration subtitle · 关卡内电影字幕浮层（lib/narration-subtitle.js）
   Session 78 续⁶ · 两层礼让堆叠（primary + secondary）
     .sub-slot-primary   — current line, full opacity, bottom position
     .sub-slot-secondary — previous line, dimmed + scaled down, stacked above
   ============================================================ */

.narration-subtitle {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 820px;
  min-width: 320px;
  pointer-events: none;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.narration-subtitle .sub-slot {
  padding: 14px 28px;
  text-align: center;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 6px;
  min-width: 320px;
  max-width: 820px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 280ms ease, transform 280ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.narration-subtitle .sub-slot.sub-show {
  opacity: 1;
  transform: translateY(0);
}
/* Secondary slot: previous line, still readable but visually demoted so the
   eye tracks to the new one below. Smaller scale + lower background alpha,
   and fades out 2.2s later via SECONDARY_LINGER_MS. */
.narration-subtitle .sub-slot-secondary {
  background: rgba(0, 0, 0, 0.52);
  transform: translateY(20px) scale(0.88);
}
.narration-subtitle .sub-slot-secondary.sub-show {
  opacity: 0.72;
  transform: translateY(0) scale(0.88);
}
.narration-subtitle .sub-zh {
  font-family: var(--font-zh);
  font-size: clamp(17px, 2.1vw, 22px);
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
}
.narration-subtitle .sub-en {
  font-family: var(--font-en);
  font-size: clamp(12px, 1.3vw, 14px);
  font-style: italic;
  color: #d8d8d8;
  opacity: 0.88;
  line-height: 1.5;
}
/* Secondary slot text is slightly dimmer/smaller so the hierarchy is clear
   even with the same markup. */
.narration-subtitle .sub-slot-secondary .sub-zh {
  font-size: clamp(15px, 1.9vw, 19px);
  color: #e6e6e6;
}
.narration-subtitle .sub-slot-secondary .sub-en {
  font-size: clamp(11px, 1.2vw, 13px);
  color: #c8c8c8;
}

/* ============================================================
   Arrival overlay (终点 + 作品嵌入 + 画面缩小)
   ============================================================ */

.gm-arrival {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 700ms ease, transform 1400ms cubic-bezier(0.65, 0, 0.35, 1);
  transform-origin: right bottom;
  pointer-events: none;
}

.gm-arrival-visible {
  opacity: 1;
}

.gm-arrival-shrinking {
  transform: translate(33vw, 35vh) scale(0.12);
  opacity: 0.95;
}

.gm-arrival-inner {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: #000;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gm-arrival-inner video,
.gm-arrival-inner img {
  max-width: 80vw;
  max-height: 75vh;
  display: block;
  object-fit: contain;
}

.gm-arrival-placeholder {
  min-width: 640px;
  min-height: 360px;
  background:
    linear-gradient(135deg, #2a1a1a 0%, #4a3a3a 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 2px, transparent 2px, transparent 4px);
}

.gm-arrival-caption {
  color: #fff;
  font-family: var(--font-zh);
  font-size: 18px;
  text-align: center;
  line-height: 1.5;
}

.gm-arrival-caption em {
  font-style: italic;
  font-weight: 500;
}

.gm-arrival-note {
  display: block;
  margin-top: 6px;
  font-family: var(--font-en);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  font-style: normal;
}
/* session 78 续⁶ · bilingual stack inside the arrival note. Keep letter-spacing
   on the en line only — Chinese text with 2px letter-spacing looks broken. */
.gm-arrival-note .zh {
  display: block;
  font-family: var(--font-zh);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.55);
}
.gm-arrival-note .en {
  display: block;
  margin-top: 3px;
}
.gm-arrival-note .en em {
  font-style: italic;
}
