:root {
  --sand: #ece2c4;
  --ink: #2b2620;
  --ink-soft: #5a5142;
  --red: #a8341f;
  --gold: #b8902e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sand);
  font-family: 'Noto Serif KR', 'Nanum Myeongjo', Georgia, serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }
.red { color: var(--red); font-weight: 600; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 18px;
  /* 내용이 화면보다 길면(작은 폰) 세로 스크롤을 허용해 버튼이 잘리지 않게 한다 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(43, 38, 32, 0.45);
  backdrop-filter: blur(2px);
}

/* 타이틀 뒤로 갈릴리의 새벽이 비쳐 보이는 반투명 양피지 스크림 */
#intro {
  background: linear-gradient(165deg,
    rgba(236, 226, 196, 0.9),
    rgba(236, 226, 196, 0.62) 55%,
    rgba(199, 179, 138, 0.78));
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
}

.intro-inner {
  max-width: 620px;
  margin: auto; /* 스크롤 가능한 오버레이 안에서 위가 잘리지 않게 가운데 정렬 */
  text-align: center;
  padding: 30px 26px;
  animation: fadein 0.9s ease;
}

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

/* 타이틀 글줄이 위에서부터 차례로 배어 나온다 */
.intro-inner > * {
  opacity: 0;
  animation: intro-step 0.7s ease forwards;
}
.intro-inner > *:nth-child(1) { animation-delay: 0.1s; }
.intro-inner > *:nth-child(2) { animation-delay: 0.24s; }
.intro-inner > *:nth-child(3) { animation-delay: 0.38s; }
.intro-inner > *:nth-child(4) { animation-delay: 0.52s; }
.intro-inner > *:nth-child(n + 5) { animation-delay: 0.66s; }
@keyframes intro-step { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .intro-inner { animation: none; }
  .intro-inner > * { opacity: 1; animation: none; }
}

.rule-top, .rule-bottom {
  height: 10px;
  margin: 0 auto 26px;
  max-width: 420px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}
.rule-bottom { margin: 26px auto 0; border-top: 1px solid var(--ink); border-bottom: 2px solid var(--ink); }

h1 {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: clamp(30px, 6.4vw, 52px);
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: var(--ink);
}

.subtitle {
  font-style: italic;
  font-size: clamp(15px, 3vw, 19px);
  color: var(--ink-soft);
  margin-top: 8px;
}

blockquote {
  margin: 26px auto 0;
  max-width: 480px;
  font-style: italic;
  font-size: clamp(15px, 2.6vw, 18px);
  line-height: 1.5;
  color: var(--ink);
}
blockquote cite { display: block; margin-top: 8px; font-size: 0.85em; font-style: normal; color: var(--ink-soft); }

.intro-text {
  margin: 22px auto 0;
  max-width: 460px;
  font-size: clamp(15px, 2.6vw, 18px);
  line-height: 1.55;
}

.controls-hint {
  margin: 22px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  justify-content: center;
  font-size: 14px;
  color: var(--ink-soft);
}
.controls-hint b { color: var(--ink); letter-spacing: 0.08em; }

button {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.08em;
  padding: 12px 34px;
  margin-top: 26px;
  color: var(--sand);
  background: var(--red);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 3px 0 #6e2013;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e2013; }

.guide-link { margin-top: 14px; font-size: 14px; }
.guide-link a { color: var(--ink-soft); text-decoration: underline dotted; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#hud-top {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
#hud-title {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: clamp(14px, 2.4vw, 19px);
  letter-spacing: 0.2em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(236, 226, 196, 0.9);
}
#progress {
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  text-shadow: 0 1px 0 rgba(236, 226, 196, 0.9);
}
/* 다음 목적지 안내 — 컬러 표지와 짝을 이룬다 */
#next-hint {
  margin-top: 3px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--red);
  text-shadow: 0 1px 0 rgba(236, 226, 196, 0.9);
}

#chart-key {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 236px;
  pointer-events: auto;
  background: rgba(236, 226, 196, 0.93);
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(43, 38, 32, 0.25);
  padding: 10px 14px;
  font-size: 14px;
}
#chart-key summary {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
}
#chart-key summary::-webkit-details-marker { display: none; }
#chart-key summary::after { content: ' ▾'; font-size: 11px; }
#chart-key:not([open]) summary::after { content: ' ▸'; }
#key-list { margin: 8px 0 2px; padding-left: 0; list-style: none; max-height: 46vh; overflow-y: auto; }
#key-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  line-height: 1.25;
  color: var(--ink-soft);
}
#key-list li .knum {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #8b8478; /* 기본은 무채색 — 다음 목적지만 붉다 */
  color: var(--sand);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(2px);
}
.key-note {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--ink-soft);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-soft);
}
#key-list li.done { color: var(--ink); }
#key-list li.done .knum { background: var(--ink); }
#key-list li.done::after { content: '✓'; margin-left: auto; color: var(--red); font-weight: 600; }
/* 다음 목적지: 범례에서도 붉게 살아 있다 */
#key-list li.next { color: var(--ink); font-weight: 600; }
#key-list li.next .knum { background: var(--red); }
#key-list li.next::after { content: '←'; margin-left: auto; color: var(--red); font-weight: 600; }

#compass {
  position: absolute;
  bottom: 18px;
  right: 18px;
  width: 56px;
  height: 56px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: rgba(236, 226, 196, 0.9);
  box-shadow: 2px 2px 0 rgba(43, 38, 32, 0.25);
  pointer-events: auto; /* the HUD ignores the pointer, but the compass has a tooltip */
}
#compass-arrow {
  position: absolute;
  inset: 0;
}
#compass-arrow::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 17px solid var(--red);
}

#view-btn {
  position: absolute;
  bottom: 18px;
  left: 18px;
  pointer-events: auto;
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  color: var(--ink);
  background: rgba(236, 226, 196, 0.92);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  box-shadow: 2px 2px 0 rgba(43, 38, 32, 0.25);
}
#view-btn:hover { transform: none; background: var(--sand); }
#view-btn:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(43, 38, 32, 0.25); }

#mute-btn {
  position: absolute;
  bottom: 64px;
  left: 18px;
  pointer-events: auto;
  margin: 0;
  width: 38px;
  font-size: 16px;
  padding: 6px 0;
  color: var(--ink);
  background: rgba(236, 226, 196, 0.92);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  box-shadow: 2px 2px 0 rgba(43, 38, 32, 0.25);
}
#mute-btn:hover { transform: none; background: var(--sand); }
#mute-btn.muted { opacity: 0.55; text-decoration: line-through; }

#pause-btn {
  position: absolute;
  bottom: 110px;
  left: 18px;
  pointer-events: auto;
  margin: 0;
  width: 38px;
  font-size: 16px;
  padding: 6px 0;
  color: var(--ink);
  background: rgba(236, 226, 196, 0.92);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  box-shadow: 2px 2px 0 rgba(43, 38, 32, 0.25);
}
#pause-btn:hover { transform: none; background: var(--sand); }

/* 유물 보따리 — 찾은 곳마다 아이콘이 채워지는 14칸 선반 */
#satchel {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 92vw;
  padding: 5px 9px;
  background: rgba(236, 226, 196, 0.72);
  border: 1px solid rgba(90, 81, 66, 0.35);
  border-radius: 18px;
  box-shadow: 1px 1px 0 rgba(43, 38, 32, 0.18);
  pointer-events: none;
}
.relic-slot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  background: rgba(43, 38, 32, 0.08);
  border: 1px solid rgba(90, 81, 66, 0.28);
  filter: grayscale(1);
  opacity: 0.4;
  transition: opacity 0.4s ease, filter 0.4s ease, transform 0.3s ease;
}
.relic-slot.filled {
  filter: none;
  opacity: 1;
  background: rgba(184, 144, 46, 0.18);
  border-color: var(--gold);
}
.relic-slot.pop { animation: relic-pop 0.6s cubic-bezier(0.25, 1.6, 0.5, 1); }

/* 잃은 양 카운터 — 첫 마리를 찾으면 나타난다 */
#sheep-chip {
  position: absolute;
  bottom: 76px;
  left: 14px;
  padding: 5px 11px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(236, 226, 196, 0.85);
  border: 1px solid rgba(90, 81, 66, 0.4);
  border-radius: 15px;
  box-shadow: 1px 1px 0 rgba(43, 38, 32, 0.2);
  pointer-events: auto;
}
#sheep-chip.gold {
  border-color: var(--gold);
  background: rgba(184, 144, 46, 0.2);
  box-shadow: 0 0 10px 2px rgba(184, 144, 46, 0.35);
}
@keyframes relic-pop {
  0% { transform: scale(2.4); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* 기념 카드 (완주 시) — 에필로그의 #souvenir-wrap과 일시정지의 #record-wrap이 함께 쓴다 */
#souvenir-wrap, #record-wrap { margin-top: 18px; }
.souvenir-name-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: stretch;
  margin-bottom: 12px;
}
.souvenir-name {
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 16px;
  padding: 9px 14px;
  width: 180px;
  color: var(--ink);
  background: rgba(255, 252, 240, 0.9);
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  text-align: center;
}
.souvenir-name:focus { outline: 2px solid var(--gold); }
.souvenir-name-btn {
  margin: 0;
  font-size: 15px;
  padding: 9px 16px;
}
.souvenir-img {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 12px;
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(43, 38, 32, 0.25);
}
.souvenir-btn {
  margin-top: 0;
  font-size: 15px;
  padding: 9px 22px;
}

/* all fourteen remembered: the needle turns gold and idles */
#compass.compass-done #compass-arrow { animation: compass-idle 16s linear infinite; opacity: 0.85; }
#compass.compass-done #compass-arrow::before { border-bottom-color: var(--gold); }
@keyframes compass-idle { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ---------- visit button / toast ---------- */
#visit-btn {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  margin: 0;
  font-size: 17px;
  padding: 11px 26px;
  animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }

#toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(43, 38, 32, 0.88);
  color: var(--sand);
  font-style: italic;
  font-size: 15px;
  padding: 9px 20px;
  border-radius: 3px;
  max-width: 86vw;
  text-align: center;
  transition: opacity 0.5s ease;
}

/* ---------- site card ---------- */
.card-inner {
  position: relative;
  max-width: 560px;
  max-height: 86vh;
  margin: auto;
  overflow-y: auto;
  background: var(--sand);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(43, 38, 32, 0.4);
  padding: 20px 32px 28px;
  text-align: center;
  animation: fadein 0.35s ease;
}

.card-seal {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--red);
  border: 3px solid var(--sand);
  box-shadow: 0 0 0 1.5px var(--ink);
  color: var(--sand);
  font-size: 21px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-inner h2 {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: clamp(20px, 4.2vw, 27px);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.dates { font-style: italic; color: var(--ink-soft); margin-top: 4px; font-size: 16px; }

/* 핵심 구절 인용 박스 — 급한 독자는 이 한 줄만 읽어도 이야기가 이어진다 */
.verse {
  margin: 16px auto 0;
  max-width: 460px;
  padding: 12px 18px;
  border-left: 3px solid var(--red);
  background: rgba(168, 52, 31, 0.06);
  font-size: clamp(15px, 2.6vw, 18px);
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
}

/* 함께 나눠요 — 고등부 나눔 질문 (접힘) */
.discuss {
  margin-top: 18px;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  background: rgba(184, 144, 46, 0.07);
  text-align: left;
}
.discuss summary {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: clamp(17px, 3vw, 19px);
  color: #8a6a1e;
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
}
.discuss summary::-webkit-details-marker { display: none; }
.discuss summary::before { content: '🕊  '; }
.discuss summary::after { content: '  ▾'; font-size: 13px; }
.discuss:not([open]) summary::after { content: '  펼치기 ▸'; font-size: 13px; color: var(--ink-soft); }
.discuss #card-question {
  padding: 0 18px 16px;
  font-size: clamp(16px, 2.8vw, 18px);
  line-height: 1.7;
  color: var(--ink);
}

.card-figure {
  margin: 16px auto 0;
  max-width: 420px;
}
.card-figure img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(43, 38, 32, 0.25);
  background: #fff;
}
.card-figure figcaption {
  margin-top: 7px;
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}

#card-body, #epilogue-body {
  margin-top: 16px;
  text-align: left;
  font-size: clamp(15px, 2.4vw, 17.5px);
  line-height: 1.58;
}
#card-body p + p, #epilogue-body p + p { margin-top: 10px; }
#card-body em, #epilogue-body em { color: var(--red); font-style: italic; }

.artifact {
  position: relative;
  margin-top: 18px;
  padding: 9px 14px;
  border: 1px dashed var(--ink-soft);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
}
.artifact b { color: var(--red); font-style: normal; }

/* a wax-red stamp for a first visit */
.artifact.stamped::after {
  content: '다녀감';
  position: absolute;
  top: -16px;
  right: -8px;
  transform: rotate(-9deg);
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 700;
  font-style: normal;
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--red);
  border: 2px solid var(--red);
  border-radius: 3px;
  padding: 1px 8px;
  background: rgba(236, 226, 196, 0.85);
  animation: stamp-in 0.45s cubic-bezier(0.25, 1.6, 0.5, 1) 0.25s backwards;
}
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-9deg) scale(2.2); }
  to { opacity: 1; transform: rotate(-9deg) scale(1); }
}

#card-close, #epilogue-close, #record-close { margin-top: 20px; }

.epilogue-inner { max-width: 600px; }
.epilogue-inner h2 { margin-top: 14px; font-family: 'Nanum Myeongjo', serif; font-weight: 800; letter-spacing: 0.04em; }
.ep-quote { margin-top: 18px; }

.record-inner { max-width: 480px; }
.record-inner h2 { font-family: 'Nanum Myeongjo', serif; font-weight: 800; letter-spacing: 0.04em; }

/* ---------- 말씀 새기기 (Seal-to-Chart) ---------- */
.card-seal-box {
  margin-top: 20px;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  background: rgba(184, 144, 46, 0.04);
  padding: 16px 20px;
  text-align: left;
  animation: fadein 0.3s ease;
}
.seal-head {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  color: #8a6a1e;
  font-size: 15px;
  margin: 0 0 10px;
  text-align: center;
  letter-spacing: 0.1em;
}
.seal-head::before {
  content: '🖋️ ';
}
#seal-verse-box {
  margin: 0 0 12px;
  border-left: 3px solid var(--gold);
  background: rgba(184, 144, 46, 0.07);
  padding: 10px 14px;
  font-size: clamp(14px, 2.5vw, 16.5px);
  line-height: 1.58;
  color: var(--ink);
}
.seal-blank {
  display: inline-block;
  min-width: 60px;
  text-align: center;
  border-bottom: 2px solid var(--red);
  color: var(--red);
  font-weight: 700;
  margin: 0 4px;
  padding: 0 2px;
  transition: color 0.4s ease, border-color 0.4s ease;
}
.seal-blank.solved {
  color: var(--gold);
  border-bottom-color: var(--gold);
  font-weight: 800;
  text-shadow: 0 0 4px rgba(184, 144, 46, 0.2);
}
.seal-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
#seal-input {
  flex: 1;
  min-height: 44px;
  padding: 0 12px;
  font-family: 'Noto Serif KR', Georgia, serif;
  font-size: 15px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  box-sizing: border-box;
}
#seal-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
#seal-input:disabled {
  background: rgba(43, 38, 32, 0.06);
  color: var(--ink-soft);
  border-color: rgba(90, 81, 66, 0.3);
}
#seal-submit {
  min-height: 44px;
  margin: 0;
  font-size: 15px;
  padding: 0 18px;
  box-sizing: border-box;
}
#seal-submit:disabled {
  opacity: 0.5;
  pointer-events: none;
}
#seal-input.shake {
  animation: seal-shake 0.4s ease;
}
@keyframes seal-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.seal-msg {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--red);
  font-style: italic;
}
.seal-msg.success {
  color: #1e6b34;
}

/* ---------- joystick ---------- */
#joystick {
  position: fixed;
  z-index: 15;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 1.5px solid rgba(43, 38, 32, 0.5);
  background: rgba(236, 226, 196, 0.25);
  pointer-events: none;
}
#stick {
  position: absolute;
  width: 46px;
  height: 46px;
  left: 32px;
  top: 32px;
  border-radius: 50%;
  background: rgba(168, 52, 31, 0.75);
  border: 1.5px solid rgba(43, 38, 32, 0.6);
}
/* 링 바깥까지 밀어 달리는 중 */
#stick.sprint {
  background: rgba(184, 144, 46, 0.9);
  box-shadow: 0 0 14px 4px rgba(184, 144, 46, 0.5);
}

/* first-time touch guidance, ghosted over the scene */
#touch-hint {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: flex;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
}
.hint-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-bottom: 18vh;
  text-align: center;
  font-style: italic;
  font-size: 15px;
  color: var(--sand);
  text-shadow: 0 1px 3px rgba(43, 38, 32, 0.8);
}
.hint-ring {
  width: 84px;
  height: 84px;
  border: 2.5px dashed rgba(236, 226, 196, 0.85);
  border-radius: 50%;
  animation: hint-breathe 1.8s ease-in-out infinite;
}
.hint-swipe {
  font-size: 44px;
  line-height: 84px;
  color: rgba(236, 226, 196, 0.9);
  animation: hint-sway 1.8s ease-in-out infinite;
}
@keyframes hint-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes hint-sway { 0%, 100% { transform: translateX(-12px); } 50% { transform: translateX(12px); } }

/* the visit button asks for attention the first time it ever appears */
#visit-btn.pulse { animation: bob 1.4s ease-in-out infinite, visit-glow 1.4s ease-in-out 3; }
@keyframes visit-glow {
  0%, 100% { box-shadow: 0 3px 0 #6e2013; }
  50% { box-shadow: 0 3px 0 #6e2013, 0 0 22px 6px rgba(184, 144, 46, 0.55); }
}

.save-note {
  margin-top: 12px;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
}
.reset-link {
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-style: italic;
  letter-spacing: normal;
  text-transform: none;
  color: var(--red);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--red);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}
.reset-link:hover { transform: none; color: var(--ink); border-color: var(--ink); }
.reset-link:active { transform: none; box-shadow: none; }

/* 십자가의 어둠 — 온 땅을 덮는 암전 */
#eclipse {
  position: fixed;
  inset: 0;
  z-index: 17;
  background: #05060c;
  opacity: 0;
  pointer-events: none;
}

/* 십자가의 어둠 절정 — 성전 휘장이 위에서 아래까지 찢어짐 (그림자 실루엣) */
#veil-tear {
  position: fixed;
  inset: 0;
  z-index: 19;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#veil-tear.torn { opacity: 1; }
.veil-shred {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 51%;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0) 0 6px, rgba(0, 0, 0, 0.3) 6px 8px),
    linear-gradient(180deg, #1a1015 0%, #0a0709 55%, #05060c 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  transition: clip-path 1.8s cubic-bezier(0.5, 0, 0.25, 1), transform 1.8s cubic-bezier(0.5, 0, 0.25, 1);
}
.veil-shred-l { left: 0; }
.veil-shred-r { right: 0; }
#veil-tear.torn .veil-shred-l {
  clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%);
  transform: translateX(-42%);
}
#veil-tear.torn .veil-shred-r {
  clip-path: polygon(22% 0, 100% 0, 100% 100%, 0 100%);
  transform: translateX(42%);
}

/* 겟세마네: 감기는 눈꺼풀 — 위아래에서 닫혀 온다 */
#lid-top, #lid-bottom {
  position: fixed;
  left: 0;
  right: 0;
  height: 0;
  z-index: 18;
  background: #05060c;
  pointer-events: none;
}
#lid-top { top: 0; border-bottom: 3px solid rgba(236, 226, 196, 0.12); }
#lid-bottom { bottom: 0; border-top: 3px solid rgba(236, 226, 196, 0.12); }

/* 장면 대화: 고백(4) · 부인(6) · 회복(11) */
.dialog-inner {
  max-width: 460px;
  margin: auto;
  background: var(--sand);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(43, 38, 32, 0.4);
  padding: 26px 28px 28px;
  text-align: center;
  animation: fadein 0.3s ease;
}
#dialog-speaker { font-style: italic; color: var(--ink-soft); font-size: 15px; }
#dialog-line {
  margin-top: 10px;
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: clamp(19px, 3.4vw, 24px);
  line-height: 1.5;
}
#dialog-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
#dialog-actions button {
  margin: 0;
  width: 100%;
  max-width: 380px;
  font-size: 16px;
  line-height: 1.45;
  padding: 12px 18px;
  position: relative;
  overflow: hidden;
  touch-action: none;
}
#dialog-actions button .hold-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: rgba(236, 226, 196, 0.3);
  pointer-events: none;
}
/* 부인 장면: 옳은 대답이 손끝에서 도망간다 */
#dialog-actions button.ghost-btn {
  background: #8b8478;
  box-shadow: 0 3px 0 #6b665c;
  transition: transform 0.12s ease, opacity 0.4s ease;
}
/* 세 번째 대답: 근심으로 떨리는 손 */
#dialog-actions button.tremble { animation: tremble 0.45s infinite; }
@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2.5px); }
  75% { transform: translateX(2.5px); }
}

/* 물에 가라앉을 때 화면 가장자리가 어두워지는 비네트 */
#sink-veil {
  position: fixed;
  inset: 0;
  z-index: 16;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s linear;
  background: radial-gradient(ellipse at center, rgba(20,26,40,0) 34%, rgba(10,14,26,0.95) 100%);
}

/* ---------- 일시정지 — 잠시 쉬어가기 ---------- */
.pause-inner {
  position: relative;
  width: min(360px, 92vw);
  margin: auto;
  background: var(--sand);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(43, 38, 32, 0.4);
  padding: 26px 28px 22px;
  text-align: center;
  animation: fadein 0.25s ease;
}
.pause-inner h2 {
  font-family: 'Nanum Myeongjo', serif;
  font-weight: 800;
  font-size: clamp(21px, 4vw, 26px);
  letter-spacing: 0.04em;
}
.pause-inner button {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  font-size: 16px;
  letter-spacing: 0.06em;
  padding: 11px 16px;
}
#pause-resume { margin-top: 20px; }
.pause-inner .pause-opt {
  color: var(--ink);
  background: rgba(236, 226, 196, 0.92);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(43, 38, 32, 0.25);
}
.pause-inner .pause-opt:hover { transform: none; background: var(--sand); }
.pause-inner button.danger {
  color: var(--red);
  background: none;
  border: 2px solid var(--red);
  box-shadow: none;
}
.pause-inner button.danger:hover { transform: none; }
.pause-controls {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.pause-inner .guide-link { margin-top: 8px; }

/* ---------- 크레딧 롤 ---------- */
#credits {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  background: rgba(12, 12, 18, 0.94);
  opacity: 0;
  transition: opacity 1.2s ease;
}
#credits-scroll {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 0 24px;
  text-align: center;
  font-family: 'Nanum Myeongjo', serif;
  color: #efe6cf;
  will-change: transform;
}
.cr-title {
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #d8b45a; /* 어둠 위의 금박 — --gold를 밝힌 톤 */
}
.cr-sub { font-style: italic; color: #cfc4a6; }
.cr-head {
  margin-top: 54px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: #d8b45a;
}
.cr-line {
  margin-top: 10px;
  font-size: clamp(15px, 2.4vw, 18px);
  line-height: 1.7;
}
.cr-verse {
  margin-top: 54px;
  font-style: italic;
  font-size: clamp(16px, 2.8vw, 20px);
  color: #efe6cf;
}
.cr-end {
  margin-top: 16px;
  letter-spacing: 0.12em;
  color: #cfc4a6;
}
#credits-skip {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(239, 230, 207, 0.55);
}

/* ---------- voyage caption (scripted sea-crossing to Rome) ---------- */
#voyage-caption {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-style: italic;
  font-size: 16px;
  color: var(--sand);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  text-align: center;
  max-width: 80vw;
  transition: opacity 0.8s ease;
}

@media (max-width: 700px) {
  #chart-key { width: 188px; font-size: 12.5px; top: 60px; }
  #chart-key summary { font-size: 13px; }
  #hud-top { top: 8px; }
  .card-inner { padding: 30px 20px 24px; }
  #compass { bottom: auto; top: 60px; left: 14px; right: auto; width: 46px; height: 46px; }
  #compass-arrow::before { top: 7px; border-left-width: 5px; border-right-width: 5px; border-bottom-width: 14px; }
  #view-btn { bottom: 14px; right: 14px; left: auto; font-size: 13px; padding: 7px 12px; }
  #mute-btn { bottom: 58px; right: 14px; left: auto; }
  #pause-btn { bottom: 102px; right: 14px; left: auto; }
  .pause-inner { padding: 22px 20px 18px; }
}
