@font-face {
  font-family: "Cormorant Unicase";
  src: url("../assets/fonts/cormorant-unicase-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Cormorant Unicase";
  src: url("../assets/fonts/cormorant-unicase-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("../assets/fonts/geist-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("../assets/fonts/geist-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("../assets/fonts/geist-latin-300-normal.woff2") format("woff2");
  font-weight: 300; font-style: normal; font-display: swap;
}

:root {
  --bg: #0f0b08;
  --ivory: #fbf8ee;
  --gold: #c9a86a;
  --bronze: #7b5b3f;
  --brown: #564435;
  --pad: 28px;
  --serif-vn: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-width: thin; scrollbar-color: var(--bronze) var(--bg); }
html, body { background: var(--bg); }
body {
  font-family: "Geist", system-ui, sans-serif;
  color: var(--ivory);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }

#track { height: 1200vh; width: 1px; }

#hall {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  display: block; z-index: 1; cursor: crosshair;
}

#hero-fallback {
  position: fixed; inset: 0; z-index: 1; overflow: hidden; opacity: 0;
  background: #0f0b08; pointer-events: none;
}
#hero-fallback img { width: 100%; height: 100%; object-fit: cover; display: block; }
#hero-fallback::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(15,11,8,.72) 100%);
}

/* ---- film layer ---- */
#film {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  opacity: 0; background: #000;
}
.chapter { position: absolute; inset: 0; opacity: 0; overflow: hidden; }
.chapter img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  will-change: transform; transform-origin: 50% 50%;
}
.chapter-text {
  position: absolute; left: var(--pad); bottom: calc(var(--pad) + 10px);
  max-width: min(620px, 82vw); text-shadow: 0 1px 18px rgba(0,0,0,.65), 0 0 3px rgba(0,0,0,.5);
}
.numeral {
  font-family: "Cormorant Unicase", serif; font-weight: 500;
  font-size: 15px; letter-spacing: .35em; color: var(--gold); margin-bottom: 10px;
}
.chapter-text h2 {
  font-family: "Cormorant Unicase", serif; font-weight: 500;
  font-size: clamp(38px, 6vw, 84px); line-height: .95; letter-spacing: .02em;
  color: var(--ivory);
}
.chapter-text .vn {
  font-family: var(--serif-vn); font-style: italic;
  font-size: clamp(15px, 1.6vw, 19px); color: #e8dcc3; margin-top: 8px;
}
.chapter-text .body {
  font-family: "Geist", sans-serif; font-weight: 300;
  font-size: clamp(14px, 1.4vw, 17px); line-height: 1.65; color: #f2ede0;
  margin-top: 12px; max-width: 520px;
}
#grain {
  position: absolute; inset: -100px; pointer-events: none; opacity: .08; z-index: 5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-30px, 20px); }
  50% { transform: translate(20px, -25px); } 75% { transform: translate(-15px, -10px); }
  100% { transform: translate(0, 0); }
}
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0,0,0,.42) 100%);
}

/* ---- hall chrome ---- */
#masthead {
  position: fixed; top: var(--pad); left: 0; right: 0; z-index: 3;
  text-align: center; pointer-events: none;
  transition: opacity .6s ease;
}
#masthead .title {
  font-family: "Cormorant Unicase", serif; font-weight: 500;
  font-size: clamp(17px, 2.2vw, 26px); letter-spacing: .32em; color: var(--ivory);
  text-shadow: 0 1px 12px rgba(0,0,0,.7);
}
#masthead .sub {
  font-size: 11px; letter-spacing: .42em; color: var(--gold); margin-top: 7px;
  text-shadow: 0 1px 10px rgba(0,0,0,.7);
}
#hint {
  position: fixed; right: var(--pad); bottom: var(--pad); z-index: 3;
  font-size: 11px; letter-spacing: .34em; color: var(--ivory);
  text-shadow: 0 1px 10px rgba(0,0,0,.8); pointer-events: none;
  animation: hint-bob 2.6s ease-in-out infinite;
}
@keyframes hint-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

#card {
  position: fixed; left: var(--pad); bottom: var(--pad); z-index: 3;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  background: rgba(15,11,8,.55); border: 1px solid rgba(201,168,106,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 12px 16px; cursor: pointer; text-align: left; color: var(--ivory);
  transition: border-color .25s ease, background .25s ease, opacity .4s ease;
}
#card:hover { border-color: var(--gold); background: rgba(15,11,8,.75); }
#card .card-num { font-family: "Cormorant Unicase", serif; font-size: 13px; letter-spacing: .3em; color: var(--gold); }
#card .card-name { font-family: "Cormorant Unicase", serif; font-size: 19px; letter-spacing: .06em; }
#card .card-meta { font-size: 11px; letter-spacing: .18em; color: #cfc4ab; }

#rail {
  position: fixed; right: var(--pad); top: 50%; transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; gap: 12px;
}
#rail button {
  display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer;
  opacity: .45; transition: opacity .25s ease; padding: 0; color: var(--ivory);
}
#rail button:hover, #rail button.active { opacity: 1; }
#rail img { width: 44px; height: 30px; object-fit: cover; border: 1px solid rgba(201,168,106,.7); display: block; }
#rail span { font-family: "Cormorant Unicase", serif; font-size: 14px; letter-spacing: .2em; }

#sound {
  position: fixed; left: var(--pad); top: var(--pad); z-index: 3;
  background: none; border: 0; cursor: pointer; color: var(--ivory);
  font-family: "Geist", sans-serif; font-size: 11px; letter-spacing: .3em;
  text-shadow: 0 1px 10px rgba(0,0,0,.8); padding: 4px 0;
}
#sound:hover { color: var(--gold); }

#touch-tip {
  position: fixed; z-index: 6; pointer-events: none; display: none;
  font-size: 11px; letter-spacing: .3em; color: var(--ivory);
  background: rgba(15,11,8,.72); border: 1px solid rgba(201,168,106,.6);
  padding: 7px 12px; white-space: nowrap; transform: translate(14px, 14px);
}

/* ---- finale ---- */
#finale {
  position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 14px;
  pointer-events: none; opacity: 0; padding: 0 20px;
  background: radial-gradient(ellipse at center, rgba(15,11,8,.12) 0%, rgba(15,11,8,.55) 100%);
}
.finale-line {
  font-family: "Cormorant Unicase", serif; font-weight: 500;
  font-size: clamp(26px, 4.6vw, 58px); line-height: 1.05; letter-spacing: .04em;
  color: var(--ivory); text-shadow: 0 2px 26px rgba(0,0,0,.8); max-width: 900px;
}
.finale-vn { font-family: var(--serif-vn); font-style: italic; font-size: clamp(15px, 1.8vw, 20px); color: #e8dcc3; }
.finale-sub { font-size: 11px; letter-spacing: .42em; color: var(--gold); margin-top: 6px; }
#watch-again {
  margin-top: 22px; pointer-events: auto; cursor: pointer;
  font-family: "Cormorant Unicase", serif; font-size: 16px; letter-spacing: .32em;
  color: var(--ivory); background: transparent;
  border: 1px solid var(--gold); padding: 14px 30px 12px;
  transition: background .25s ease, color .25s ease;
}
#watch-again:hover { background: var(--gold); color: var(--bg); }

/* ---- overlay ---- */
#overlay {
  position: fixed; inset: 0; z-index: 8; display: none;
  background: rgba(8,6,4,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  align-items: center; justify-content: center; gap: 36px; padding: 40px;
}
#overlay.open { display: flex; }
#overlay img { max-width: min(58vw, 760px); max-height: 78vh; object-fit: contain; border: 1px solid rgba(201,168,106,.5); }
.overlay-text { max-width: 420px; }
.overlay-text h3 { font-family: "Cormorant Unicase", serif; font-weight: 500; font-size: 34px; letter-spacing: .04em; }
.overlay-meta { font-size: 11px; letter-spacing: .3em; color: var(--gold); margin: 10px 0 16px; }
.overlay-text p:last-child { font-weight: 300; font-size: 15px; line-height: 1.8; color: #efe9d8; }
#overlay-close {
  position: absolute; top: 22px; right: 26px; background: none; border: 0; cursor: pointer;
  color: var(--ivory); font-size: 22px; padding: 8px;
}
#overlay-close:hover { color: var(--gold); }

/* ---- preloader ---- */
#preloader {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  transition: opacity .8s ease;
}
#preloader.done { opacity: 0; pointer-events: none; }
.pre-frame { position: absolute; inset: 26px; pointer-events: none; }
.pre-frame i { position: absolute; background: var(--gold); opacity: 0; transition: opacity 1.2s ease; }
.pre-frame i:nth-child(1) { top: 0; left: 0; right: 0; height: 1px; }
.pre-frame i:nth-child(2) { bottom: 0; left: 0; right: 0; height: 1px; }
.pre-frame i:nth-child(3) { left: 0; top: 0; bottom: 0; width: 1px; }
.pre-frame i:nth-child(4) { right: 0; top: 0; bottom: 0; width: 1px; }
#preloader.lit .pre-frame i { opacity: .85; }
.pre-title {
  font-family: "Cormorant Unicase", serif; font-weight: 500; text-align: center;
  font-size: clamp(30px, 5vw, 54px); line-height: 1.08; letter-spacing: .1em; color: var(--ivory);
}
.pre-count { display: flex; align-items: baseline; gap: 16px; }
#pre-num { font-family: "Cormorant Unicase", serif; font-size: 30px; letter-spacing: .12em; color: var(--gold); min-width: 74px; text-align: right; }
#pre-word { font-size: 11px; letter-spacing: .42em; color: #cfc4ab; }
#enter {
  font-family: "Cormorant Unicase", serif; font-size: 17px; letter-spacing: .4em;
  color: var(--bg); background: var(--gold); border: 0; cursor: pointer;
  padding: 15px 34px 13px 38px; transition: background .25s ease, transform .25s ease;
}
#enter:hover { background: var(--ivory); transform: translateY(-1px); }
.pre-note { font-size: 10px; letter-spacing: .34em; color: #8f8271; text-align: center; padding: 0 20px; }

#nogl {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 30;
  background: rgba(8,6,4,.85); border: 1px solid rgba(201,168,106,.5);
  padding: 8px 14px; max-width: 92vw; text-align: center;
}
#nogl p { font-family: "Geist", sans-serif; font-size: 11px; letter-spacing: .14em; color: #cfc4ab; }
#nogl-err { font-size: 10px !important; color: #8f8271 !important; margin-top: 3px; word-break: break-word; }

@media (max-width: 768px) {
  :root { --pad: 16px; }
  #masthead .title { letter-spacing: .22em; }
  #rail img { width: 34px; height: 23px; }
  #rail span { display: none; }
  #card { padding: 9px 12px; }
  #card .card-name { font-size: 15px; }
  #card .card-meta { display: none; }
  #hint { display: none; }
  #overlay { flex-direction: column; gap: 20px; padding: 60px 20px 30px; overflow-y: auto; }
  #overlay img { max-width: 92vw; max-height: 52vh; }
  .chapter-text { bottom: calc(var(--pad) + 64px); }
}
