:root {
  color-scheme: light;
  --paper: #FBF4E6;
  --panel: #FFFDF6;
  --ink: #3A2A20;
  --ink-soft: #6E5647;
  --honey-soft: #FCEBC6;
  --rose: #D9486F;
  --rose-text: #B23358;
  --moss: #6B7F4F;
  --terra: #B36A4C;
  --line: #E4D3B0;
  --serif: "Songti TC", "Noto Serif TC", serif;
  --sans: "PingFang TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  min-width: 20rem;
  overflow: hidden;
}

body {
  margin: 0;
  background: radial-gradient(75rem 44rem at 20% -10%, #FFF7E6 0, transparent 60%), var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.65;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 12;
  background-image: radial-gradient(rgba(120, 90, 60, .06) 1px, transparent 1px);
  background-size: 4px 4px;
  content: "";
  opacity: .3;
  pointer-events: none;
}

button,
input,
textarea { font: inherit; }

button { white-space: nowrap; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--moss);
  outline-offset: 3px;
}

button:disabled { cursor: not-allowed; opacity: .55; }

h1,
h2,
h3,
h4,
p { margin-block-start: 0; }

h1,
h2,
h3,
h4,
.brand,
.chip,
.primary-button,
.secondary-button,
.choice-button {
  font-family: var(--serif);
}

h1,
h2,
h3,
h4 { line-height: 1.35; text-wrap: balance; }

p,
li { text-wrap: pretty; }

h1 { margin-bottom: .55rem; font-size: clamp(1.75rem, 2.2vw, 2rem); }
h2 { margin-bottom: .5rem; font-size: clamp(1.25rem, 1.8vw, 1.55rem); }
h3 { margin-bottom: .25rem; font-size: .95rem; }
h4 { margin-bottom: .25rem; font-size: .9rem; }

img { display: block; max-width: 100%; }

.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 40;
  transform: translateY(-160%);
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: .6rem 1rem;
}

.skip-link:focus { transform: none; }

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 26px;
  pointer-events: none;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
  pointer-events: auto;
}

.brandmark {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 2px 2px 0 var(--ink);
  color: #fff;
  font-family: var(--serif);
  font-size: 22px;
}

.brand { font-size: 22px; }
.brand small { color: var(--ink-soft); font-family: var(--sans); font-size: 11px; letter-spacing: 2px; }

body[data-tone="scenic"] .brand {
  color: #FFF8EA;
  text-shadow: 0 1px 3px rgba(58, 42, 32, .55);
}

body[data-tone="scenic"] .brand small { color: inherit; opacity: .9; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  border-radius: 999px;
  background: rgba(255, 253, 246, .88);
  padding: 2px 6px;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.nav-button {
  border: 0;
  background: transparent;
  color: var(--rose-text);
  cursor: pointer;
  padding: 6px 8px;
  font-family: var(--serif);
  font-size: 13px;
}

body[data-screen="guest"] .main-nav { display: none; }

.audio-controls {
  position: relative;
  display: flex;
  align-items: center;
  pointer-events: auto;
}

body[data-screen="guest"] .audio-controls { margin-left: auto; }

.audio-toggle {
  border: 1px solid rgba(58, 42, 32, .28);
  border-radius: 999px;
  background: rgba(255, 253, 246, .9);
  color: var(--rose-text);
  cursor: pointer;
  padding: 6px 10px;
  font-family: var(--serif);
  font-size: 12px;
  box-shadow: 1px 1px 0 rgba(58, 42, 32, .18);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.audio-toggle[aria-pressed="true"] { background: var(--moss); color: #fff; }

.audio-mix {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(20rem, calc(100vw - 2rem));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 253, 246, .97);
  box-shadow: 3px 3px 0 rgba(58, 42, 32, .18);
  padding: 12px;
}

.audio-mix label { display: grid; gap: 2px; color: var(--ink-soft); font-size: 11px; }
.audio-mix input { min-height: 20px; padding: 0; accent-color: var(--rose); }
.audio-status { position: fixed; right: 1rem; bottom: 1rem; z-index: 35; max-width: min(24rem, calc(100% - 2rem)); margin: 0; border-radius: 999px; background: rgba(255, 253, 246, .9); color: var(--ink-soft); padding: 5px 12px; font-size: 11px; line-height: 1.45; pointer-events: none; }

#game {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  outline: none;
}

.screen {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 13px;
  overflow: hidden;
  padding: 78px 26px 24px;
  animation: page-arrive .32s ease-out both;
}

.screen::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(75rem 44rem at 20% -10%, #FFF7E6 0, transparent 60%), var(--paper);
  content: "";
}

.scene-backed { padding: 0; }

.scene-backed > img,
.scene-backed > .image-fallback:first-child {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.scene-backed > .image-fallback:first-child { display: grid; place-items: center; }

.scene-vignette,
.paper-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.scene-vignette {
  background: linear-gradient(90deg, rgba(58, 42, 32, .43) 0, rgba(58, 42, 32, .16) 40%, transparent 64%), linear-gradient(180deg, rgba(58, 42, 32, .14), transparent 25%, transparent 68%, rgba(58, 42, 32, .36));
}

.paper-vignette { background: linear-gradient(rgba(251, 244, 230, .75), rgba(251, 244, 230, .92)); }

.eyebrow {
  margin-bottom: .35rem;
  color: var(--rose-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
}

.lede { margin-bottom: 0; color: var(--ink-soft); font-size: .95rem; line-height: 1.8; }
.lede.compact { max-width: 56ch; font-size: .8rem; }
.muted { color: var(--ink-soft); }

.chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--honey-soft);
  color: var(--ink-soft);
  padding: 4px 13px;
  font-size: 12px;
  line-height: 1.35;
}

.card,
.floating-panel {
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 3px 3px 0 rgba(58, 42, 32, .18);
  padding: 14px 16px;
}

.primary-button,
.secondary-button,
.choice-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 2px 2px 0 rgba(58, 42, 32, .2);
  cursor: pointer;
  padding: 10px 16px;
  transition: transform .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}

.primary-button { background: var(--rose); color: #fff; }
.secondary-button,
.choice-button { background: var(--paper); color: var(--rose-text); }

.primary-button:hover,
.secondary-button:hover,
.choice-button:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 rgba(58, 42, 32, .22); }
.primary-button:active,
.secondary-button:active,
.choice-button:active { transform: translate(1px, 1px); box-shadow: none; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.image-fallback {
  display: grid;
  min-height: 9rem;
  place-items: center;
  background: var(--honey-soft);
  color: var(--ink-soft);
  padding: 1.5rem;
  text-align: center;
}

/* G14 landing */
.landing-screen { padding: 0; }
.landing-screen > img { object-position: center 30%; }

.landing-hero {
  position: absolute;
  top: clamp(9.5rem, 22dvh, 12.5rem);
  left: clamp(1.5rem, 4vw, 4rem);
  z-index: 2;
  width: min(35rem, calc(100% - 3rem));
}

.landing-hero h1 {
  margin-bottom: 16px;
  color: #FFF8EA;
  font-size: clamp(2.6rem, 3.25vw, 3.25rem);
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(58, 42, 32, .6);
}

.landing-subtitle {
  color: #FFF3E0;
  font-family: var(--serif);
  font-size: clamp(1rem, 1.25vw, 1.25rem);
  line-height: 1.8;
  text-shadow: 0 1px 4px rgba(58, 42, 32, .6);
  white-space: pre-line;
}

.landing-actions { display: flex; gap: 14px; margin-top: 34px; }
.landing-actions button { min-height: 52px; padding: 12px 24px; font-size: 18px; }
.landing-resume-actions { margin-top: 12px; }
.landing-resume-button {
  min-height: 38px;
  border-color: rgba(255, 243, 224, .72);
  background: rgba(58, 42, 32, .48);
  box-shadow: none;
  color: #FFF3E0;
  padding: 8px 15px;
  font-size: 14px;
}
.landing-note,
.scene-footnote,
.visitor-banner {
  width: fit-content;
  border-radius: 999px;
  background: rgba(58, 42, 32, .5);
  color: #FFF3E0;
  padding: 5px 14px;
  font-size: 12px;
}

.landing-note { margin-top: 22px; font-family: var(--sans); font-size: 13px; }
.scene-footnote { position: absolute; bottom: 34px; left: clamp(1.5rem, 4vw, 4rem); z-index: 3; margin: 0; }
.scene-footnote.centered { right: 1rem; left: 1rem; margin-inline: auto; text-align: center; }

/* G1 routes */
.routes-screen > img { object-position: center 30%; }
.routes-content {
  z-index: 2;
  display: flex;
  width: min(60rem, calc(100% - 3rem));
  height: 100%;
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  margin: auto;
  padding-top: 3rem;
}
.routes-intro { text-align: center; }
.routes-intro h1 { font-size: clamp(1.8rem, 2.3vw, 2.15rem); letter-spacing: 2px; }
.route-families { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 24px; }
.route-family { border-radius: 22px; padding: 20px 24px 18px; text-align: center; }
.route-family-icon { display: grid; width: 56px; height: 56px; margin: 0 auto; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--terra); box-shadow: 2px 2px 0 rgba(58, 42, 32, .25); color: #fff; font-family: var(--serif); font-size: 21px; }
.route-family:nth-child(2) .route-family-icon { background: var(--moss); }
.route-family h2 { margin: 6px 0 2px; }
.route-family > p { margin-bottom: 0; font-size: 13px; }
.route-list { display: grid; gap: 10px; margin-top: 14px; }
.route-option { width: 100%; border: 1.5px solid var(--ink); border-radius: 13px; background: var(--paper); box-shadow: 2px 2px 0 rgba(58, 42, 32, .16); color: var(--ink); cursor: pointer; padding: 11px 14px; text-align: left; white-space: normal; }
.route-option h3 { color: var(--rose-text); font-size: 16px; }
.route-option p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.route-option.dim { border-style: dashed; box-shadow: none; opacity: .62; }
.route-option:disabled { cursor: default; }
.route-availability-copy { margin-top: 6px !important; color: var(--rose-text) !important; font-weight: 700; }
.routes-footnote { margin: 18px auto 0; max-width: 56rem; color: var(--ink-soft); font-size: 12px; line-height: 1.7; text-align: center; }

/* G15 application and shared floating panels */
.application-screen > img,
.interview-screen > img,
.portraits-screen > img,
.handbook-screen > img { object-position: left 32%; }
.application-screen .scene-vignette,
.interview-screen .scene-vignette,
.portraits-screen .scene-vignette,
.handbook-screen .scene-vignette { background: linear-gradient(90deg, transparent 0, transparent 36%, rgba(58, 42, 32, .32) 100%); }
.floating-panel { z-index: 3; }
.application-card,
.status-screen .floating-panel,
.leave-screen .floating-panel {
  position: absolute;
  top: 50%;
  right: clamp(1.5rem, 4.5vw, 4.5rem);
  width: min(32.5rem, calc(100% - 3rem));
  max-height: calc(100dvh - 7rem);
  overflow: auto;
  transform: translateY(-50%);
  border-radius: 18px;
  padding: 24px 28px;
}
.application-card h1,
.handbook-panel h1,
.leave-screen h1 { font-size: 22px; }
.field { display: grid; gap: 5px; margin-top: 13px; }
.field label { font-family: var(--serif); font-size: 14px; }
.field small { color: var(--ink-soft); font-size: 11px; }
input,
textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); padding: 10px 13px; }
textarea { min-height: 7rem; resize: vertical; }
.consent-note { margin: 15px 0 0; border: 1.5px dashed var(--line); border-radius: 12px; background: rgba(252, 245, 228, .6); color: var(--ink-soft); padding: 10px 13px; font-size: 12px; line-height: 1.7; }
.keep-note { margin: 12px 0 0; color: var(--ink-soft); font-size: 11px; }

/* 03A / 03B */
.floating-layout { position: absolute; right: 3rem; bottom: 3rem; z-index: 3; display: grid; width: min(58rem, calc(100% - 6rem)); grid-template-columns: minmax(0, 1fr) 14rem; gap: 14px; }
.hearth-question { max-height: calc(100dvh - 9rem); overflow: auto; padding: 20px 22px; }
.hearth-question h1 { font-size: 22px; }
.hearth-question h2 { font-size: 19px; }
.action-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.portrait-side { text-align: center; }
.villager-portrait { width: 7rem; aspect-ratio: 1; margin: 0 auto 8px; overflow: hidden; border: 2px solid var(--ink); border-radius: 50%; background: var(--honey-soft); }
.villager-portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-panel { position: absolute; inset: 78px 26px 24px; z-index: 3; display: flex; min-height: 0; flex-direction: column; overflow: auto; border: 2px solid var(--ink); border-radius: 18px; background: rgba(255, 253, 246, .96); box-shadow: 4px 4px 0 rgba(58, 42, 32, .22); padding: 16px 20px; }
.portrait-head { text-align: center; }
.portrait-head h1 { font-size: 24px; }
.portrait-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.portrait-choice { text-align: center; }
.candidate-portrait { width: min(10rem, 70%); aspect-ratio: 1; margin: 6px auto 8px; overflow: hidden; border: 2px solid var(--ink); border-radius: 14px; background: var(--honey-soft); }
.candidate-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.portrait-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.portrait-tool { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.portrait-tool h3,
.portrait-tool .muted { grid-column: 1 / -1; }

/* G4 */
.trial-screen > img { object-position: center 40%; }
.trial-screen .scene-vignette { background: rgba(251, 244, 230, .88); }
.trial-layout { position: absolute; inset: 82px 4vw 28px; z-index: 3; display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) 16rem; align-items: center; gap: 14px; }
.certificate-card { position: relative; overflow: hidden; border: 2.5px solid var(--ink); border-radius: 24px; background: #FCF5E4; box-shadow: 8px 8px 0 rgba(58, 42, 32, .18); padding: 24px 28px; }
.certificate-card::before { position: absolute; inset: 10px; border: 1.5px dashed var(--line); border-radius: 16px; content: ""; pointer-events: none; }
.certificate-head { position: relative; display: flex; align-items: center; }
.certificate-head h2 { margin: 0; letter-spacing: 3px; }
.certificate-head p { margin: 0; font-size: 12px; }
.certificate-stamp { display: grid; width: 64px; height: 64px; margin-left: auto; place-items: center; border: 2.5px solid var(--rose); border-radius: 50%; color: var(--rose); font-family: var(--serif); font-size: 13px; line-height: 1.3; text-align: center; white-space: pre-line; transform: rotate(-12deg); }
.certificate-body { position: relative; display: grid; grid-template-columns: minmax(9rem, 15rem) minmax(15rem, 1fr) minmax(14rem, 19rem); gap: 22px; margin-top: 16px; }
.certificate-portrait { overflow: hidden; border: 2px solid var(--ink); border-radius: 16px; background: var(--honey-soft); box-shadow: 3px 3px 0 rgba(58, 42, 32, .15); }
.certificate-portrait img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: center top; }
.certificate-key { margin: 8px 0 0; color: var(--rose-text); font-size: 11px; font-weight: 700; letter-spacing: 2.5px; }
.certificate-details h1 { margin: 0; font-size: 2rem; }
.certificate-details p:not(.certificate-key) { margin-bottom: 5px; font-family: var(--serif); }
.certificate-rights { align-self: start; font-size: 12px; }
.trial-task { align-self: center; }

/* G20 world overview */
.world-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 14px; }
.world-head .eyebrow { margin: 0; }
.world-head h1 { margin: 0; font-size: 32px; }
.world-head .chip { margin: 0; }
.world-main { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1fr) 430px; gap: 14px; }
.scene-figure { position: relative; min-height: 0; overflow: hidden; margin: 0; border: 2px solid var(--ink); border-radius: 16px; background: var(--honey-soft); box-shadow: 4px 4px 0 rgba(58, 42, 32, .18); }
.scene-figure > img { width: 100%; height: 100%; object-fit: cover; }
.scene-figure > .image-fallback { width: 100%; height: 100%; }
.scene-caption { position: absolute; bottom: 12px; left: 14px; width: fit-content; max-width: calc(100% - 28px); border: 1.5px solid var(--line); border-radius: 999px; background: rgba(255, 253, 246, .93); color: var(--ink-soft); padding: 5px 14px; font-family: var(--serif); font-size: 12px; }
.scene-caption h3:empty { display: none; }
.scene-caption h3,
.scene-caption p { margin: 0; }
.world-side { display: flex; min-height: 0; flex-direction: column; gap: 12px; overflow: auto; padding: 0 4px 4px 0; }
.world-card h3:first-child { font-size: 15px; }
.world-row { display: flex; gap: 9px; margin-top: 6px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.75; }
.world-row b { min-width: 62px; color: var(--ink); font-family: var(--serif); font-weight: 400; }
.world-event { margin-top: 8px; border: 1.5px solid var(--line); border-radius: 11px; background: rgba(252, 245, 228, .7); padding: 9px 12px; }
.world-event h3 { display: inline; font-size: 14px; }
.event-status { display: inline-flex; width: fit-content; margin: 0 0 0 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--honey-soft); padding: 1px 8px; font-size: 10.5px; }
.world-event .muted { margin: 4px 0 0; font-size: 11.5px; }
.actionbar { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); border-radius: 14px; background: var(--panel); box-shadow: 3px 3px 0 rgba(58, 42, 32, .18); padding: 11px 16px; }
.actionbar-label { margin: 0; color: var(--ink-soft); font-family: var(--serif); font-size: 14px; white-space: nowrap; }
.actionbar-buttons { display: flex; min-width: 0; flex: 1; gap: 10px; }
.actionbar-buttons > button { min-width: 0; flex: 1 1 0; padding-inline: 8px; }

/* G21 */
.quiet-screen > img { object-position: center 60%; }
.quiet-panel { position: absolute; right: 50%; bottom: 17%; z-index: 3; width: min(40rem, calc(100% - 2rem)); padding: 22px 26px; text-align: center; transform: translateX(50%); }
.quiet-panel h1 { font-size: 26px; }
.quiet-copy { color: var(--ink-soft); font-family: var(--serif); font-size: 15px; line-height: 1.9; }

/* G14V */
.visitor-screen > img { object-position: center 40%; }
.visitor-screen .scene-vignette { background: linear-gradient(180deg, rgba(58, 42, 32, .2), transparent 18%, transparent 66%, rgba(58, 42, 32, .3)); }
.visitor-banner { position: absolute; top: 74px; left: 50%; z-index: 4; border: 2px solid var(--ink); background: var(--honey-soft); box-shadow: 3px 3px 0 rgba(58, 42, 32, .25); color: var(--ink); font-family: var(--serif); font-size: 15px; transform: translateX(-50%); }
.visitor-feed { position: absolute; top: 150px; left: 26px; z-index: 3; display: flex; width: min(22.5rem, calc(100% - 52px)); flex-direction: column; gap: 10px; }
.visitor-feed-card { border: 1.5px solid var(--line); border-radius: 12px; background: rgba(255, 253, 246, .93); color: var(--ink); cursor: pointer; padding: 11px 14px; text-align: left; white-space: normal; }
.visitor-feed-card h3 { font-size: 14px; }
.visitor-feed-card p { margin: 3px 0 0; color: var(--ink-soft); font-size: 11.5px; }
.readonly-chip { display: inline-block; margin-top: 6px; border: 1px dashed var(--line); border-radius: 999px; color: var(--ink-soft); padding: 1px 8px; font-size: 10.5px; }
.visitor-invite { position: absolute; right: 26px; bottom: 96px; z-index: 3; width: min(25rem, calc(100% - 52px)); border: 2px solid var(--ink); border-radius: 16px; background: rgba(255, 253, 246, .97); box-shadow: 4px 4px 0 rgba(58, 42, 32, .25); padding: 16px 18px; }
.visitor-invite h2 { font-size: 16px; line-height: 1.7; }

/* W5 map */
.map-main { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; }
.map-canvas { position: relative; min-height: 0; overflow: hidden; border: 2px solid var(--ink); border-radius: 16px; background: var(--honey-soft); box-shadow: 4px 4px 0 rgba(58, 42, 32, .18); }
.map-canvas > img { width: 100%; height: 100%; object-fit: cover; }
.map-pin { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--ink); cursor: pointer; padding: 0; transform: translate(-50%, -100%); }
.map-pin:focus-visible { border-radius: 8px; outline: 3px solid var(--rose); outline-offset: 3px; }
.map-pin-label { border: 1.5px solid var(--ink); border-radius: 999px; background: rgba(255, 253, 246, .95); box-shadow: 1px 1px 0 rgba(58, 42, 32, .25); padding: 3px 10px; font-family: var(--serif); font-size: 12px; white-space: nowrap; }
.map-pin-dot { width: 13px; height: 13px; border: 2px solid #FFF8EA; border-radius: 50%; background: var(--rose); box-shadow: 0 1px 3px rgba(58, 42, 32, .5); }
.map-pin.event .map-pin-dot { background: var(--moss); box-shadow: 0 0 0 5px rgba(107, 127, 79, .22); }
.map-pin.quiet .map-pin-dot { background: #B9AC90; }
.map-pin.mine .map-pin-dot { background: #8A6BB0; }
.map-side { display: flex; min-height: 0; flex-direction: column; gap: 10px; overflow: auto; padding-right: 4px; }
.map-list-card { flex: 1; }
.map-list { display: grid; gap: 7px; }
.place-button { display: flex; width: 100%; min-height: 38px; align-items: center; justify-content: space-between; padding: 7px 11px; text-align: left; }
.place-button small { color: var(--ink-soft); }
.map-help { margin: 9px 0 0; font-size: 11px; }
.privacy-card { font-size: 12px; }

/* place pages and production portraits */
.place-screen > img { object-position: center 45%; }
.place-panel { position: absolute; right: 26px; bottom: 32px; z-index: 3; width: min(34rem, calc(100% - 52px)); max-height: calc(100% - 110px); overflow: auto; padding: 16px 18px; }
.portrait-strip { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.portrait-person { width: 5rem; text-align: center; }
.portrait-person .villager-portrait { width: 4rem; }
.portrait-person p { margin: 0; font-size: 12px; }
.encounter-card { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 12px; margin-top: 12px; border-color: var(--moss); background: var(--honey-soft); }
.encounter-card > .eyebrow { grid-column: 1 / -1; margin: 0; }
.encounter-card .villager-portrait { width: 5rem; margin: 0; }
.encounter-copy h3 { margin: 0 0 3px; }
.encounter-copy p { margin: 0; font-family: var(--serif); font-size: 13px; line-height: 1.75; }
.equal-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.equal-choices > button { width: 100%; min-width: 0; padding-inline: 8px; }
.place-verbs { margin-top: 12px; border-top: 1.5px solid var(--line); padding-top: 10px; }
.place-verbs h3 { font-size: 14px; }
.feedback-card { margin-top: 10px; border-style: dashed; background: rgba(107, 127, 79, .1); }

/* 02A authored dialogue */
.dialogue-screen > img { object-position: center 42%; }
.dialogue-layout { position: absolute; right: 4vw; bottom: 5vh; z-index: 3; display: grid; width: min(56rem, calc(100% - 8vw)); grid-template-columns: 14rem minmax(0, 1fr); gap: 20px; padding: 24px; }
.dialogue-person { align-self: center; text-align: center; }
.dialogue-person .villager-portrait { width: 9rem; }
.dialogue-person h2 { margin: 6px 0; }
.dialogue-person .chip { margin-inline: auto; }
.dialogue-exchange { display: flex; min-width: 0; flex-direction: column; justify-content: center; }
.dialogue-exchange h1 { font-size: 24px; }
.dialogue-line { min-height: 5rem; border-left: 3px solid var(--moss); background: rgba(252, 235, 198, .45); padding: 13px 16px; font-family: var(--serif); font-size: 16px; line-height: 1.9; }
.dialogue-leave { align-self: flex-start; margin-top: 13px; }
.dialogue-note { margin: 9px 0 0; font-size: 11px; }

/* G13M hut */
.hut-main { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; }
.hut-scene > img { object-position: center 38%; }
.hut-side { display: flex; min-height: 0; flex-direction: column; gap: 13px; }
.hut-side .card { font-family: var(--serif); font-size: 14px; line-height: 1.8; }
.hut-hint { display: grid; flex: 1; place-items: center; background: rgba(252, 245, 228, .7); color: var(--ink-soft); text-align: center; }
.hut-leave { width: 100%; }
.hut-action-panel { flex: 1; min-height: 0; overflow: auto; }
.hut-action-panel h2 { font-size: 18px; }
.memory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 10px 0; }
.memory-grid > button { min-width: 0; padding-inline: 7px; font-size: 12px; }
.hut-list,
.chronicle-list { color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.chronicle-list { padding-left: 1.25rem; }
.hut-action-icon { display: grid; width: 34px; height: 34px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; font-size: 9px; }
.hut-action-icon img { width: 100%; height: 100%; object-fit: cover; }
.hut-action-icon .image-fallback { min-height: 0; padding: 2px; }
.hut-dock { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--panel); box-shadow: 3px 3px 0 rgba(58, 42, 32, .18); padding: 11px 15px; }
.dock-button { display: grid; min-height: 78px; min-width: 0; place-items: center; gap: 2px; border-color: var(--line); padding: 7px; white-space: normal; }
.dock-button.active { border-color: var(--rose); background: var(--honey-soft); }
.dock-button img { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; object-fit: cover; }
.dock-button h3 { margin: 0; font-size: 14px; }
.dock-button p { margin: 0; font-family: var(--sans); font-size: 10px; }
.day-note { min-height: 1.4rem; margin: 0; color: var(--moss); font-size: 12px; text-align: center; }

/* G5 mailbox */
.mailbox-head { display: flex; align-items: baseline; gap: 12px; }
.mailbox-head h1 { margin: 0; }
.mailbox-layout { display: grid; min-height: 0; flex: 1; grid-template-columns: minmax(0, 1.4fr) minmax(20rem, 1fr); gap: 14px; }
.mail-list { min-height: 0; overflow: auto; }
.mail-item { display: grid; width: 100%; grid-template-columns: 44px 1fr auto; align-items: start; gap: 11px; margin-bottom: 8px; border: 1.5px solid var(--line); border-radius: 13px; background: var(--panel); color: var(--ink); cursor: pointer; padding: 10px 12px; font: inherit; text-align: left; }
.mail-item.unread { border-color: var(--ink); background: var(--honey-soft); }
.mail-item.selected { box-shadow: inset 0 0 0 1px var(--rose); }
.mail-item .villager-portrait { width: 44px; margin: 0; }
.mail-copy { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; }
.mail-copy h3 { margin: 0; }
.mail-copy p { margin: 0; font-size: 12px; }
.mail-copy p:last-child { grid-column: 1 / -1; margin-top: 2px; color: var(--ink); font-size: 13px; }
.unread-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--rose); }
.open-letter { display: flex; min-height: 0; flex-direction: column; justify-content: center; border: 2px solid var(--ink); border-radius: 16px; background: #FCF5E4; box-shadow: 4px 4px 0 rgba(58, 42, 32, .16); padding: 20px 22px; }
.letter-body { font-size: 13px; line-height: 1.9; }
.letter-signature { color: var(--ink-soft); font-family: var(--serif); font-size: 13px; text-align: right; }
.attachment-note { width: fit-content; border: 1px dashed var(--moss); border-radius: 9px; background: rgba(107, 127, 79, .1); color: var(--moss); padding: 6px 10px; font-size: 12px; }

.handbook-panel { position: absolute; top: 50%; right: 5vw; width: min(34rem, calc(100% - 3rem)); max-height: calc(100% - 8rem); overflow: auto; transform: translateY(-50%); }
.handbook-panel > .card + .card { margin-top: 12px; }
.confirmation-list { display: grid; gap: 8px; margin-top: 12px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; }
.check-row input { width: auto; margin-top: 6px; }
.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li + li { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.gentle-warning { position: absolute; top: 72px; left: 50%; z-index: 15; max-width: calc(100% - 2rem); border: 1.5px solid var(--rose); border-radius: 999px; background: var(--panel); color: var(--rose-text); padding: 6px 14px; transform: translateX(-50%); }

/* Safari/importmap/runtime fallback */
.fallback-screen { display: grid; place-items: center; background: linear-gradient(rgba(251, 244, 230, .78), rgba(251, 244, 230, .94)), url("/assets/approved/15-chronicle-hall-hearth-a.png") center 35% / cover; }
.fallback-card { width: min(36rem, calc(100% - 2rem)); border: 2px solid var(--ink); border-radius: 18px; background: rgba(255, 253, 246, .97); box-shadow: 5px 5px 0 rgba(58, 42, 32, .24); padding: clamp(1.4rem, 4vw, 2rem); }
.fallback-card h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); }
.fallback-copy { color: var(--ink-soft); line-height: 1.8; }
.error-summary { margin: 1rem 0 0; border: 1.5px dashed var(--line); border-radius: 11px; background: var(--paper); color: var(--rose-text); padding: 9px 12px; font-size: 12px; overflow-wrap: anywhere; }
.storage-notice { position: fixed; right: 1rem; bottom: 1rem; z-index: 35; max-width: calc(100% - 2rem); border: 1.5px solid var(--ink); border-radius: 999px; background: var(--honey-soft); box-shadow: 2px 2px 0 rgba(58, 42, 32, .2); padding: 6px 14px; color: var(--ink-soft); font-size: 12px; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; }
[hidden] { display: none !important; }

@keyframes page-arrive {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 899px) {
  .site-header { padding: 12px 14px; }
  .brandmark { width: 32px; height: 32px; font-size: 17px; }
  .brand { font-size: 18px; }
  .brand small { display: none; }
  .main-nav { max-width: 62vw; overflow-x: auto; }
  .nav-button { padding: 5px 7px; font-size: 12px; }
  .audio-toggle { padding: 5px 8px; font-size: 11px; }
  .audio-status { right: 10px; bottom: 10px; left: 10px; max-width: none; border-radius: 12px; text-align: center; }
  body:not([data-screen="guest"]) .audio-status { bottom: 9rem; }
  .screen { padding: 60px 14px 12px; }

  /* G14m: scene above, copy below */
  .landing-screen { overflow: hidden; background: var(--paper); }
  .landing-screen > img,
  .landing-screen > .image-fallback:first-child { bottom: auto; height: 42.5%; object-position: center 28%; }
  .landing-screen .scene-vignette { bottom: auto; height: 42.5%; background: linear-gradient(180deg, rgba(58, 42, 32, .18), transparent 30%, rgba(58, 42, 32, .4)); }
  .landing-hero { top: 42.5%; right: 0; bottom: 0; left: 0; width: auto; overflow: auto; background: var(--paper); padding: 18px; }
  .landing-hero h1 { margin: 0; color: var(--ink); font-size: clamp(1.65rem, 7.4vw, 1.9rem); text-shadow: none; }
  .landing-subtitle { margin: 8px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.8; text-shadow: none; white-space: normal; }
  .landing-actions { display: grid; gap: 0; margin-top: 8px; }
  .landing-actions button { width: 100%; min-height: 48px; margin-top: 10px; font-size: 16px; }
  .landing-resume-actions { margin-top: 10px; }
  .landing-resume-button { width: 100%; min-height: 44px; }
  .landing-note { width: 100%; margin-top: 12px; background: transparent; color: var(--ink-soft); padding: 0; font-size: 12px; line-height: 1.7; text-align: center; }
  .landing-screen > .scene-footnote { display: none; }

  .routes-screen { overflow: auto; }
  .routes-content { display: block; width: 100%; height: auto; padding: 66px 14px 18px; }
  .routes-intro h1 { font-size: 22px; }
  .route-families { grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
  .route-family { padding: 14px; }
  .route-family-icon { width: 42px; height: 42px; font-size: 16px; }

  .application-screen,
  .leave-screen { overflow: auto; background: var(--paper); }
  .application-screen .scene-vignette,
  .leave-screen .scene-vignette { background: rgba(251, 244, 230, .9); }
  .application-card,
  .status-screen .floating-panel,
  .leave-screen .floating-panel { position: relative; top: auto; right: auto; width: auto; max-height: none; margin: 60px 14px 16px; overflow: visible; transform: none; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 0; }
  .application-card h1 { font-size: 21px; }

  .floating-layout { inset: 62px 14px 14px; display: block; width: auto; }
  .hearth-question { max-height: 100%; overflow: auto; }
  .hearth-companion { display: none; }
  .action-row { grid-template-columns: 1fr; }
  .portrait-panel { inset: 60px 14px 14px; }
  .portrait-grid,
  .portrait-tools { grid-template-columns: 1fr; }
  .portrait-tools { padding-bottom: 1rem; }

  .trial-layout { inset: 62px 14px 14px; display: block; overflow: auto; }
  .certificate-card { padding: 20px; }
  .certificate-body { grid-template-columns: 7rem 1fr; gap: 14px; }
  .certificate-rights { grid-column: 1 / -1; }
  .trial-task { margin-top: 12px; }

  .resident-screen,
  .map-screen,
  .hut-screen,
  .mailbox-screen { overflow: auto; padding-bottom: 9.5rem; }
  .world-head { flex: none; gap: 5px 8px; }
  .world-head .eyebrow { display: none; }
  .world-head h1 { font-size: 21px; }
  .world-head .chip { font-size: 10.5px; padding: 3px 9px; }
  .world-main,
  .map-main,
  .hut-main,
  .mailbox-layout { display: flex; min-height: auto; flex: none; flex-direction: column; }
  .world-scene,
  .map-canvas,
  .hut-scene { height: 180px; min-height: 180px; flex: none; }
  .world-side,
  .map-side,
  .hut-side { overflow: visible; }
  .actionbar { position: absolute; right: 14px; bottom: max(10px, env(safe-area-inset-bottom)); left: 14px; z-index: 8; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; }
  .actionbar-label { display: none; }
  .actionbar-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .actionbar-buttons > button { min-height: 42px; font-size: 13px; }

  .quiet-panel { bottom: 14%; padding: 18px; }
  .quiet-panel h1 { font-size: 21px; }
  .quiet-copy { font-size: 12px; }
  .quiet-panel .actionbar-buttons { grid-template-columns: 1fr; }
  .quiet-screen > .scene-footnote { display: none; }

  .visitor-screen { overflow: auto; padding: 60px 14px 16px; }
  .visitor-banner { position: relative; top: auto; left: auto; width: 100%; margin: 0; font-size: 12px; text-align: center; transform: none; }
  .visitor-feed { position: relative; top: auto; left: auto; width: 100%; margin-top: 12px; }
  .visitor-invite { position: relative; right: auto; bottom: auto; width: 100%; margin-top: auto; }
  .visitor-screen > .scene-footnote { display: none; }

  .map-main { flex-direction: column-reverse; }
  .map-list-card { max-height: none; }
  .map-pin-label { font-size: 9px; padding: 1px 5px; }
  .privacy-card { margin-bottom: 0; }

  .place-panel { right: 14px; bottom: 18px; width: calc(100% - 28px); max-height: calc(100% - 90px); }

  .dialogue-screen { overflow: auto; background: var(--paper); }
  .dialogue-layout { position: relative; right: auto; bottom: auto; width: auto; grid-template-columns: 1fr; gap: 10px; margin: 62px 14px 14px; padding: 16px; }
  .dialogue-person { display: grid; grid-template-columns: 4rem 1fr; align-items: center; gap: 10px; text-align: left; }
  .dialogue-person .villager-portrait { grid-row: 1 / 3; width: 4rem; margin: 0; }
  .dialogue-person h2 { margin: 0; }
  .dialogue-person .chip { margin: 0; }
  .dialogue-exchange h1 { font-size: 20px; }
  .dialogue-line { min-height: 0; font-size: 14px; }
  .dialogue-choices { grid-template-columns: 1fr; }

  .hut-side .hut-hint { display: none; }
  .hut-leave { min-height: 42px; }
  .hut-dock { display: flex; flex: none; gap: 8px; overflow-x: auto; padding: 8px; }
  .dock-button { min-width: 8rem; }
  .hut-screen .day-note { position: absolute; right: 14px; bottom: 7.7rem; left: 14px; }

  .mailbox-head { flex-wrap: wrap; }
  .mailbox-head h1 { font-size: 20px; }
  .mailbox-layout { gap: 10px; }
  .mail-list { overflow: visible; }
  .open-letter { min-height: 20rem; }
  .mailbox-screen { padding-bottom: 20px; }

  .handbook-panel { top: 62px; right: 14px; bottom: 14px; width: auto; max-height: none; overflow: auto; transform: none; }
  .storage-notice { right: 10px; bottom: 10px; left: 10px; border-radius: 12px; text-align: center; }
}

@media (max-width: 430px) {
  .site-header { gap: 8px; }
  .wordmark { gap: 8px; }
  .main-nav { max-width: 55vw; }
  .route-family h2 { font-size: 19px; }
  .certificate-body { grid-template-columns: 1fr; }
  .certificate-portrait { width: 9rem; }
  .certificate-rights { grid-column: auto; }
  .visitor-invite .actions > button { width: 100%; }
}

@media (max-width: 1024px) {
  .trial-layout { display: flex; flex-direction: column; align-items: stretch; gap: 14px; overflow: auto; }
  .trial-layout > * { flex: none; }
  .trial-task { align-self: stretch; margin-top: 0; }
}

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