:root {
  --ink: #07080c;
  --paper: #ece6d6;
  --paper-dim: rgba(236, 230, 214, 0.65);
  --gold: #e0ae4a;
  --red: #b8352b;
  --serif: "Gowun Batang", "Nanum Myeongjo", serif;
  --title: "Nanum Myeongjo", "Gowun Batang", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--paper); font-family: var(--serif); }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }

kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px;
  border: 1px solid rgba(236, 230, 214, 0.35); border-bottom-width: 2px; border-radius: 4px;
  font-family: var(--serif); font-size: 0.85em; text-align: center; background: rgba(255, 255, 255, 0.04);
}

/* ───── 타이틀: 밤 수묵화 속의 깃발 ───── */
:root { --night: #07080c; --bone: #e7dcc3; --cinnabar: #c0301f; --leaf: #d4a245; --brush: "Yuji Syuku", "Ma Shan Zheng", serif; --mincho: "Shippori Mincho B1", "Song Myung", serif; }
#title-screen { position: fixed; inset: 0; z-index: 10; overflow: hidden; background: var(--night); color: var(--bone); }
#title-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.t-logo { position: absolute; left: 0; top: 0; bottom: 0; display: flex; align-items: center; pointer-events: none; }
.t-glyph {
  font-family: var(--brush); font-size: min(86vh, 62vw); line-height: 0.8; margin-left: -0.12em;
  color: rgba(231, 220, 195, 0.1); text-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  animation: glyphIn 2.6s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes glyphIn { from { opacity: 0; filter: blur(24px); transform: scale(1.08); } to { opacity: 1; filter: blur(0); transform: none; } }
.t-word { position: absolute; left: 7vw; bottom: 11vh; display: grid; grid-template-columns: auto auto; column-gap: 18px; align-items: end; }
.t-name {
  grid-row: span 2; margin: 0; font-family: var(--mincho); font-weight: 800; font-size: clamp(64px, 11vw, 168px); line-height: 0.82;
  letter-spacing: 0.04em; color: var(--bone);
  text-shadow: 0 2px 0 #000, 0 0 40px rgba(212, 162, 69, 0.18);
  animation: nameIn 1.6s 0.5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes nameIn { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.t-han { writing-mode: vertical-rl; font-family: var(--brush); font-size: clamp(22px, 2.6vw, 34px); color: var(--leaf); letter-spacing: 0.12em; align-self: end; animation: fadeUp 1.2s 1.2s both; }
.t-ko { grid-column: 1 / -1; margin: 18px 0 0; font-family: "Song Myung", serif; font-size: 17px; letter-spacing: 0.32em; color: rgba(231, 220, 195, 0.75); animation: fadeUp 1.2s 1.5s both; }
.t-ja { grid-column: 1 / -1; margin: 6px 0 0; font-family: var(--mincho); font-size: 14px; letter-spacing: 0.18em; color: rgba(231, 220, 195, 0.45); animation: fadeUp 1.2s 1.8s both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.t-banners { position: absolute; right: 5vw; top: 0; display: flex; gap: 18px; align-items: flex-start; animation: dropIn 1.4s 0.9s cubic-bezier(.3,1.4,.5,1) both; }
@keyframes dropIn { from { transform: translateY(-110%); } to { transform: none; } }
.flag {
  position: relative; width: 92px; padding: 64px 0 52px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #16120f, #0e0b09 70%, #120d0a);
  border-left: 2px solid var(--cinnabar); border-right: 2px solid var(--cinnabar);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(0, 0, 0, 0.7);
  clip-path: polygon(0 0, 100% 0, 100% 93%, 50% 100%, 0 93%);
  transform-origin: 50% 0; transition: transform .5s cubic-bezier(.3,1.6,.5,1);
  color: var(--bone); font: inherit; cursor: default;
}
.flag-name { height: 64vh; min-height: 420px; }
.flag-act { height: 52vh; min-height: 360px; cursor: pointer; border-top: none; }
.flag-join { height: 58vh; min-height: 400px; cursor: default; }
.flag:hover, .flag:focus-within { transform: rotate(-1.6deg); }
button.flag:focus-visible { outline: 2px solid var(--leaf); outline-offset: 4px; }
.flag-rod { position: absolute; top: 34px; left: 6px; right: 6px; height: 5px; background: linear-gradient(90deg, #6a4a1a, var(--leaf), #6a4a1a); border-radius: 3px; }
.flag-han { margin: 0; writing-mode: vertical-rl; font-family: var(--brush); font-weight: 400; font-size: 46px; line-height: 1; letter-spacing: 0.1em; color: var(--bone); }
.flag-act .flag-han { color: #f1e6cc; }
.flag-label { writing-mode: vertical-rl; font-family: "Song Myung", serif; font-size: 14px; letter-spacing: 0.3em; color: rgba(231, 220, 195, 0.6); }
.flag-seal { margin-top: auto; width: 34px; height: 34px; display: grid; place-items: center; background: var(--cinnabar); color: #f4e4c8; font-family: var(--brush); font-size: 20px; border-radius: 3px; transform: rotate(-6deg); }
.flag input {
  writing-mode: vertical-rl; width: 44px; height: 9em; padding: 10px 0; text-align: center;
  font-family: var(--mincho); font-size: 18px; letter-spacing: 0.2em; color: var(--bone);
  background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(212, 162, 69, 0.35); border-radius: 2px;
}
.flag input:focus { border-color: var(--leaf); box-shadow: 0 0 0 2px rgba(212, 162, 69, 0.2); outline: none; }
.flag-join input { height: 5.6em; text-transform: uppercase; letter-spacing: 0.35em; }
.flag-go { margin-top: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--leaf); background: rgba(192, 48, 31, 0.85); color: #f4e4c8; font-family: var(--brush); font-size: 22px; cursor: pointer; }
.flag-go:hover { background: var(--cinnabar); }
.flag-go:focus-visible { outline: 2px solid var(--leaf); outline-offset: 3px; }
.souls { display: flex; flex-direction: column; gap: 9px; }
.souls button { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.6); cursor: pointer; outline: 2px solid transparent; outline-offset: 3px; }
.souls button.on { outline-color: var(--bone); }
.flag-act:disabled { opacity: 0.55; cursor: wait; }
.t-error { position: absolute; right: 5vw; top: calc(66vh + 20px); max-width: 320px; text-align: right; font-family: "Song Myung", serif; color: #ff9a86; font-size: 15px; min-height: 20px; }
.t-foot { position: absolute; left: 7vw; right: 5vw; bottom: 22px; display: flex; gap: 28px; align-items: baseline; flex-wrap: wrap; font-size: 12.5px; color: rgba(231, 220, 195, 0.4); font-family: "Song Myung", serif; }
.t-foot p { margin: 0; }
.t-credit-link { margin-left: auto; background: none; border: none; color: rgba(231, 220, 195, 0.5); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#credits { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); z-index: 3; }
.credits-card { max-width: 560px; margin: 16px; padding: 26px 30px; background: #0e0c0b; border: 1px solid rgba(212, 162, 69, 0.4); font-family: "Song Myung", serif; }
.credits-card h3 { margin: 0 0 12px; font-weight: 400; color: var(--leaf); }
.credits-card ul { margin: 0 0 16px; padding-left: 18px; line-height: 1.9; font-size: 14px; color: rgba(231, 220, 195, 0.8); }
@media (max-width: 860px) {
  .t-glyph { font-size: 120vw; }
  .t-word { left: 16px; top: 6vh; bottom: auto; }
  .t-banners { left: 50%; right: auto; transform: translateX(-50%); top: auto; bottom: 70px; animation: none; }
  .flag { height: 44vh !important; min-height: 300px; width: 80px; }
  .t-foot { left: 16px; right: 16px; }
  .t-keys { display: none; }
  .t-error { right: 16px; top: auto; bottom: 46px; }
}
@media (prefers-reduced-motion: reduce) { .t-glyph, .t-name, .t-han, .t-ko, .t-ja, .t-banners { animation: none; } .flag { transition: none; } }

/* ───── 인게임 UI ───── */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#room-box { position: absolute; top: 16px; right: 18px; text-align: right; text-shadow: 0 1px 3px #000; }
.room-label { font-size: 11px; letter-spacing: 0.3em; color: var(--paper-dim); }
#room-code { font-family: var(--title); font-size: 26px; font-weight: 800; letter-spacing: 0.25em; color: var(--paper); }
#player-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
#player-list li { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 3px 0; color: var(--paper-dim); }
#player-list i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 6px currentColor; }

#boss-bar { position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%); width: min(620px, 80vw); text-align: center; }
#boss-name { font-family: var(--title); font-weight: 700; font-size: 20px; letter-spacing: 0.3em; margin-bottom: 8px; text-shadow: 0 2px 6px #000; }
.boss-track { height: 8px; background: rgba(0, 0, 0, 0.7); border: 1px solid rgba(236, 230, 214, 0.35); border-radius: 1px; overflow: hidden; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #6b1e18, #c9493c, #e8c37a); transition: width .2s; }

.banner { position: absolute; top: 26%; left: 0; right: 0; text-align: center; opacity: 0; transition: opacity 1.2s ease; text-shadow: 0 2px 12px #000; }
.banner.show { opacity: 1; transition: opacity .8s ease; }
#banner-title { font-family: var(--title); font-weight: 800; font-size: 54px; letter-spacing: 0.35em; margin-right: -0.35em; color: #f3eee2; }
#banner-sub { font-size: 18px; letter-spacing: 0.3em; color: var(--paper-dim); margin-top: 8px; }
.banner-orn { width: 280px; height: 14px; margin: 0 auto 10px; background:
  radial-gradient(circle at 50% 50%, var(--paper) 2px, transparent 3px),
  linear-gradient(90deg, transparent, rgba(236, 230, 214, 0.7) 30%, transparent 48%, transparent 52%, rgba(236, 230, 214, 0.7) 70%, transparent) center / 100% 1px no-repeat; }
.banner.boss { top: 30%; }
.banner.boss #banner-title { color: #f0d9c8; font-size: 60px; }
.banner.item { top: 20%; }
.banner.item #banner-title { color: #ffe3a3; font-size: 40px; }
.banner.item #banner-sub { font-size: 16px; letter-spacing: 0.08em; }

#dialog { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: min(760px, 88vw); padding: 22px 30px 26px; text-align: center;
  background: linear-gradient(180deg, rgba(6, 7, 11, 0.92), rgba(10, 11, 18, 0.92)); border-top: 1px solid rgba(236, 230, 214, 0.4); border-bottom: 1px solid rgba(236, 230, 214, 0.4); }
#dialog-name { font-family: var(--title); font-weight: 700; letter-spacing: 0.3em; color: var(--gold); font-size: 15px; margin-bottom: 10px; }
#dialog-text { font-size: 19px; line-height: 1.7; min-height: 1.7em; }
#dialog-more { margin-top: 8px; font-size: 12px; color: var(--paper-dim); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#toasts { position: absolute; top: 120px; left: 22px; display: flex; flex-direction: column; gap: 6px; }
.toast { font-size: 14px; background: rgba(6, 7, 11, 0.75); border-left: 2px solid var(--gold); padding: 7px 12px; animation: tin .4s ease; transition: opacity .8s; }
.toast.out { opacity: 0; }
@keyframes tin { from { opacity: 0; transform: translateX(-10px); } }

#chat-log { position: absolute; left: 22px; bottom: 60px; width: min(420px, 60vw); font-size: 14px; display: flex; flex-direction: column; gap: 3px; text-shadow: 0 1px 3px #000; }
#chat-log div { transition: opacity 1.5s; }
#chat-log div.old { opacity: 0.25; }
#chat-input { position: absolute; left: 22px; bottom: 20px; width: min(420px, 70vw); pointer-events: auto; }
#map-hint { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: var(--paper-dim); font-size: 13px; }

/* ───── 이야기: 수묵 두루마리 ───── */
#story { position: absolute; inset: 0; background: #0a0b10; pointer-events: auto; overflow: hidden; }
#story-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#story-hanja {
  position: absolute; left: 9vw; top: 50%; transform: translateY(-54%);
  font-family: "Ma Shan Zheng", "Nanum Brush Script", serif; font-size: min(42vh, 30vw); line-height: 1;
  color: rgba(232, 224, 204, 0.9); text-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
  opacity: 0; filter: blur(14px); mix-blend-mode: screen;
}
#story-hanja.show { animation: inkIn 7.5s ease forwards; }
@keyframes inkIn {
  0% { opacity: 0; filter: blur(16px); letter-spacing: 0.3em; }
  18% { opacity: 0.92; filter: blur(0); letter-spacing: 0; }
  82% { opacity: 0.92; filter: blur(0); }
  100% { opacity: 0; filter: blur(6px); }
}
#story-seal {
  position: absolute; left: calc(9vw + min(30vh, 22vw)); top: calc(50% + min(14vh, 10vw));
  width: 2.6em; padding: 0.25em 0; writing-mode: vertical-rl; text-align: center;
  font-family: "Ma Shan Zheng", serif; font-size: max(16px, 2.4vh); letter-spacing: 0.1em;
  color: #f4dcc0; background: #b3261e; border: 2px solid #f4dcc0; outline: 3px solid #b3261e; border-radius: 3px;
  opacity: 0; transform: scale(1.8) rotate(-8deg);
}
#story-seal.show { animation: stamp 7.5s ease forwards; }
@keyframes stamp {
  0%, 22% { opacity: 0; transform: scale(1.8) rotate(-8deg); }
  26% { opacity: 1; transform: scale(0.94) rotate(-4deg); }
  30%, 82% { opacity: 0.92; transform: scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: scale(1) rotate(-4deg); }
}
#story-text {
  position: absolute; right: 12vw; top: 50%; transform: translateY(-50%);
  writing-mode: vertical-rl; max-height: 68vh; margin: 0;
  font-family: "Song Myung", "Nanum Myeongjo", serif; font-size: max(18px, 3.1vh); line-height: 2.1; letter-spacing: 0.14em;
  color: #e8e0cc; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9); opacity: 0;
}
#story-text.show { animation: textIn 7.5s ease forwards; }
@keyframes textIn {
  0%, 10% { opacity: 0; clip-path: inset(0 0 100% 0); }
  40% { opacity: 1; clip-path: inset(0 0 0 0); }
  86% { opacity: 1; }
  100% { opacity: 0; }
}
#story-dots { position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; gap: 12px; }
#story-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(232, 224, 204, 0.18); transition: background 0.6s; }
#story-dots i.on { background: #c9a24a; box-shadow: 0 0 8px rgba(201, 162, 74, 0.7); }
.story-skip { position: absolute; bottom: 28px; right: 32px; font-size: 12px; color: rgba(232, 224, 204, 0.35); }
@media (max-width: 700px) {
  #story-hanja { left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 40vw; }
  #story-seal { display: none; }
  #story-text { right: 50%; top: 66%; transform: translate(50%, -50%); max-height: 50vh; }
}
@media (prefers-reduced-motion: reduce) {
  #story-hanja.show, #story-text.show, #story-seal.show { animation-duration: 0.01s; opacity: 1; filter: none; clip-path: none; transform: none; }
}

#menu, #disconnected { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.menu-card { background: rgba(8, 9, 14, 0.95); border: 1px solid rgba(236, 230, 214, 0.25); padding: 28px 32px; display: flex; flex-direction: column; gap: 10px; min-width: 300px; max-width: 92vw; text-align: center; }
.menu-card h2 { font-family: var(--title); letter-spacing: 0.5em; margin: 0 0 8px; font-weight: 800; }
.menu-help { font-size: 13px; color: var(--paper-dim); line-height: 2; margin-top: 10px; text-align: left; }

body.map-open #banner, body.map-open #boss-bar, body.map-open #toasts, body.map-open #chat-log { display: none; }

.flag > * { flex: none; }
.flag-label { max-height: 12em; }
.flag-name { height: 82vh; min-height: 560px; }
.flag-name input { height: 6.5em; }
.flag { gap: 10px; }
.t-error { top: calc(70vh + 20px); }

/* ───── 이야기 연출 강화 ───── */
#story-zh {
  position: absolute; right: 5.5vw; top: 50%; transform: translateY(-50%); margin: 0; writing-mode: vertical-rl;
  font-family: "Yuji Syuku", "Ma Shan Zheng", serif; font-size: max(20px, 3.6vh); letter-spacing: 0.24em; color: #d4a245;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.9); opacity: 0;
}
#story-zh.show { animation: textIn 7.5s 0.2s ease forwards; }
#story-text { right: 13vw; }
#story-ja {
  position: absolute; left: 9vw; bottom: 17vh; margin: 0; font-family: "Shippori Mincho B1", serif; font-size: max(13px, 1.9vh);
  letter-spacing: 0.3em; color: rgba(232, 224, 204, 0.55); opacity: 0;
}
#story-ja.show { animation: fadeUpLong 7.5s 0.9s ease forwards; }
@keyframes fadeUpLong { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
.story-bars::before, .story-bars::after { content: ""; position: absolute; left: 0; right: 0; height: 9vh; background: #000; z-index: 4; }
.story-bars::before { top: 0; } .story-bars::after { bottom: 0; }
.story-grain { position: absolute; inset: -50%; z-index: 3; pointer-events: none; opacity: 0.08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.6s steps(4) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } }
#story-dots, .story-skip { z-index: 5; }
/* 먹 붓으로 쓸어내는 장면 전환 */
#story-wipe { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: linear-gradient(100deg, transparent 0%, #050507 18%, #050507 82%, transparent 100%); transform: translateX(-120%); }
#story-wipe.go { animation: wipe 1s cubic-bezier(.7,0,.3,1); }
@keyframes wipe { 0% { opacity: 1; transform: translateX(-120%); } 50% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(120%); } }
/* 마지막 제목 카드 */
#story-card { position: absolute; inset: 0; display: none; place-items: center; z-index: 2; }
#story.card #story-card { display: grid; }
#story.card #story-hanja, #story.card #story-seal, #story.card #story-text, #story.card #story-zh, #story.card #story-ja { display: none; }
#story-card > * { grid-area: 1 / 1; }
.card-glyph { font-family: "Yuji Syuku", serif; font-size: 70vh; line-height: 1; color: rgba(192, 48, 31, 0.35); animation: cardGlyph 7.5s ease forwards; }
.card-name { font-family: "Shippori Mincho B1", serif; font-weight: 800; font-size: clamp(70px, 13vw, 190px); letter-spacing: 0.12em; color: #efe4c8; text-shadow: 0 4px 30px #000; animation: cardName 7.5s ease forwards; }
.card-han { margin-top: 32vh; font-family: "Yuji Syuku", serif; font-size: 34px; letter-spacing: 0.5em; color: #d4a245; animation: cardSub 7.5s ease forwards; }
.card-ja { margin-top: 46vh; font-family: "Shippori Mincho B1", serif; font-size: 15px; letter-spacing: 0.3em; color: rgba(232, 224, 204, 0.6); animation: cardSub 7.5s 0.4s ease both; }
@keyframes cardGlyph { 0% { opacity: 0; transform: scale(1.3); filter: blur(20px); } 20% { opacity: 1; transform: scale(1); filter: blur(0); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cardName { 0%, 12% { opacity: 0; letter-spacing: 0.6em; } 30% { opacity: 1; letter-spacing: 0.12em; } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cardSub { 0%, 28% { opacity: 0; } 42% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ───── 임무 추적 / 동료 / 임무록 / 순간이동 ───── */
#toasts { top: auto; bottom: 120px; }
#quest-tracker { position: absolute; right: 18px; top: 150px; width: 270px; display: flex; flex-direction: column; gap: 8px; text-shadow: 0 1px 3px #000; }
.qt { display: flex; gap: 9px; align-items: flex-start; padding: 7px 10px; background: linear-gradient(90deg, rgba(8,7,6,0), rgba(8,7,6,0.72) 30%); border-right: 2px solid rgba(212,162,69,0.4); }
.qt.main { border-right-color: #c0301f; }
.qt i { font-style: normal; font-family: "Yuji Syuku", serif; font-size: 22px; line-height: 1; color: #d4a245; min-width: 24px; text-align: center; }
.qt.main i { color: #e0705c; }
.qt div { flex: 1; min-width: 0; }
.qt b { display: block; font-family: "Song Myung", serif; font-weight: 400; font-size: 14px; color: #efe6d0; }
.qt span { display: block; font-size: 12px; color: rgba(239,230,208,0.6); line-height: 1.45; margin-top: 2px; }
.qt em { display: block; height: 2px; margin-top: 5px; background: rgba(255,255,255,0.12); }
.qt u { display: block; height: 100%; background: #d4a245; text-decoration: none; transition: width .4s; }
#party { position: absolute; left: 22px; top: 150px; display: flex; flex-direction: column; gap: 6px; }
.pm { display: flex; gap: 8px; align-items: center; padding: 5px 10px 5px 6px; background: rgba(8,7,6,0.6); border-left: 2px solid rgba(212,162,69,0.5); min-width: 170px; }
.pm.down { border-left-color: #c0301f; animation: pulse 1s infinite; }
@keyframes pulse { 50% { background: rgba(120,20,15,0.5); } }
.pm i { width: 10px; height: 10px; border-radius: 50%; }
.pm div { flex: 1; }
.pm b { display: block; font-family: "Song Myung", serif; font-weight: 400; font-size: 13px; }
.pm em { display: block; height: 3px; background: rgba(255,255,255,0.15); margin: 3px 0; }
.pm u { display: block; height: 100%; background: #e0806c; text-decoration: none; }
.pm small { font-size: 11px; color: rgba(239,230,208,0.55); }
#quest-log, #travel { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.65); pointer-events: auto; }
.ql-card { width: min(760px, 92vw); max-height: 84vh; overflow: auto; padding: 22px 28px; background: #0d0b0a; border: 1px solid rgba(212,162,69,0.35); }
.ql-card header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.ql-card h2 { margin: 0; font-family: "Yuji Syuku", serif; font-weight: 400; font-size: 40px; color: #efe4c8; }
.ql-card header span { flex: 1; font-size: 13px; color: rgba(239,230,208,0.55); font-family: "Song Myung", serif; }
#quest-list h3 { margin: 18px 0 8px; font-family: "Song Myung", serif; font-weight: 400; font-size: 15px; color: #d4a245; border-bottom: 1px solid rgba(212,162,69,0.25); padding-bottom: 6px; }
.ql { display: flex; gap: 12px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.ql i { font-style: normal; font-family: "Yuji Syuku", serif; font-size: 26px; color: #d4a245; min-width: 30px; text-align: center; }
.ql div { flex: 1; }
.ql b { font-family: "Song Myung", serif; font-weight: 400; font-size: 15px; }
.ql p { margin: 3px 0 0; font-size: 13px; color: rgba(239,230,208,0.7); line-height: 1.5; }
.ql small { color: #b8a070; font-size: 12px; }
.ql > span { font-family: "Yuji Syuku", serif; font-size: 18px; color: #e0705c; min-width: 46px; text-align: right; }
.ql.done { opacity: 0.55; } .ql.done > span { color: #d4a245; }
.ql.locked { opacity: 0.3; }
.contrib { font-size: 14px; color: rgba(239,230,208,0.8); letter-spacing: 0.04em; }
.tv-card { min-width: 300px; padding: 22px 28px; background: #0d0b0a; border: 1px solid rgba(212,162,69,0.35); text-align: center; }
.tv-card h2 { margin: 0; font-family: "Yuji Syuku", serif; font-weight: 400; font-size: 44px; color: #efe4c8; }
.tv-card p { margin: 4px 0 14px; font-size: 12px; color: rgba(239,230,208,0.55); }
#travel-list { list-style: none; margin: 0; padding: 0; text-align: left; }
#travel-list li { display: flex; gap: 12px; align-items: center; padding: 8px 12px; font-family: "Song Myung", serif; color: rgba(239,230,208,0.7); }
#travel-list li i { font-style: normal; font-family: "Yuji Syuku", serif; font-size: 20px; color: #d4a245; }
#travel-list li.on { background: rgba(192,48,31,0.35); color: #fff; }
.banner.quest { top: 18%; }
.banner.quest #banner-title { font-family: "Yuji Syuku", "Nanum Myeongjo", serif; color: #f0d8a0; font-size: 46px; letter-spacing: 0.15em; }
body.map-open #quest-tracker, body.map-open #party { display: none; }
@media (max-width: 760px) { #quest-tracker { width: 200px; top: 120px; } #party { top: 120px; } }

/* 깃발은 내용에 맞춰 늘어난다 (짧은 화면에서 버튼이 잘리지 않도록) */
.flag { height: auto !important; }
.flag-name { min-height: 66vh; }
.flag-act { min-height: 48vh; }
.flag-join { min-height: 56vh; }
.flag-label { max-height: 9em; }
.flag-go, .flag-seal { margin-top: 14px; }
#quest-log, #travel { z-index: 10; }

/* ───── 장 표지 / 보스의 마지막 말 ───── */
#chapter { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0) 65%); }
#chapter.show { animation: chapterIn 5.2s ease forwards; }
#chapter .ch-no { font-family: "Shippori Mincho B1", serif; font-size: 18px; letter-spacing: 0.8em; margin-right: -0.8em; color: #d4a245; }
#chapter .ch-han { font-family: "Yuji Syuku", "Ma Shan Zheng", serif; font-size: clamp(80px, 13vw, 170px); line-height: 1.05; color: #f1e6cc; text-shadow: 0 6px 40px #000; }
#chapter .ch-title { font-family: "Song Myung", serif; font-size: 22px; letter-spacing: 0.4em; margin-right: -0.4em; color: #e8dcc0; }
#chapter .ch-line { font-family: "Yuji Syuku", serif; font-size: 16px; letter-spacing: 0.5em; margin-right: -0.5em; color: rgba(232,220,192,0.6); }
@keyframes chapterIn { 0% { opacity: 0; transform: scale(1.06); filter: blur(10px); } 14% { opacity: 1; transform: none; filter: blur(0); } 80% { opacity: 1; } 100% { opacity: 0; } }
#quote { position: absolute; left: 0; right: 0; bottom: 16%; text-align: center; pointer-events: none; opacity: 0; }
#quote.show { animation: quoteIn 5s ease forwards; }
#quote .q-name { font-family: "Yuji Syuku", serif; font-size: 26px; color: #d4a245; letter-spacing: 0.3em; }
#quote .q-text { margin-top: 6px; font-family: "Song Myung", serif; font-size: 20px; color: #f0e4cc; text-shadow: 0 2px 10px #000; }
@keyframes quoteIn { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 82% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #chapter.show, #quote.show { animation-duration: 0.01s; } }

body.chapter-on #banner { opacity: 0 !important; transition: none; }

/* ───── 오프닝 시네마틱 타이포 ───── */
#story { --dur: 8s; }
#story-hanja {
  left: 7vw; transform: translateY(-50%);
  font-family: "Long Cang", "Yuji Syuku", serif; font-size: min(48vh, 34vw); line-height: 1;
  color: #ebe0c4; mix-blend-mode: normal; text-shadow: 0 0 40px rgba(0,0,0,0.9), 0 0 120px rgba(255,200,120,0.25);
}
#story-hanja.show { animation: hanjaInk var(--dur) cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes hanjaInk {
  0% { opacity: 0; filter: blur(22px) contrast(3); transform: translateY(-50%) scale(1.25); letter-spacing: 0.4em; }
  10% { opacity: 1; filter: blur(0) contrast(1); transform: translateY(-50%) scale(1); letter-spacing: 0; }
  86% { opacity: 1; filter: blur(0) contrast(1); transform: translateY(-50%) scale(1.04); }
  100% { opacity: 0; filter: blur(8px) contrast(1); transform: translateY(-50%) scale(1.06); }
}
#story-seal { left: calc(7vw + min(34vh, 24vw)); top: calc(50% + min(16vh, 11vw)); }
#story-zh { right: 6vw; font-family: "Long Cang", "Yuji Syuku", serif; font-size: max(26px, 4.6vh); letter-spacing: 0.3em; color: #e2b55a; }
#story-zh.show { animation: textIn var(--dur) 0.3s ease forwards; }
#story-text {
  right: 15vw; writing-mode: horizontal-tb; top: auto; bottom: 15vh; transform: none; max-height: none; max-width: 44ch; text-align: right;
  font-family: "Hahmlet", "Song Myung", serif; font-weight: 300; font-size: max(17px, 2.7vh); line-height: 1.95; letter-spacing: 0.06em; color: #efe6d2; opacity: 1;
}
#story-text.show { animation: none; }
#story-text span { opacity: 0; display: inline-block; animation: charIn 0.5s ease forwards; }
@keyframes charIn { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
#story-ja { left: 9vw; bottom: 12vh; font-family: "Shippori Mincho B1", serif; font-size: max(13px, 1.9vh); letter-spacing: 0.26em; color: rgba(232,224,204,0.5); }
#story-ja.show { animation: fadeUpLong var(--dur) 1.4s ease forwards; }
.story-bars::before, .story-bars::after { height: 11vh; }
.story-grain { opacity: 0.1; }
#story-wipe { background: linear-gradient(100deg, transparent 0%, #050507 22%, #050507 78%, transparent 100%); }
#story-wipe.go { animation: wipe 0.9s cubic-bezier(.7,0,.3,1); }
#story-dots { bottom: 5.5vh; }
.story-skip { bottom: 5vh; right: 4vw; font-family: "Hahmlet", serif; color: rgba(232,224,204,0.3); }
/* 제목 카드 */
#story-card { background: radial-gradient(ellipse at 50% 60%, rgba(60,30,20,0.5), rgba(0,0,0,0) 60%); }
.card-glyph { font-family: "Long Cang", "Yuji Syuku", serif; font-size: 78vh; color: rgba(192,48,31,0.3); animation: cardGlyph var(--dur) ease forwards; }
.card-name { font-family: "Shippori Mincho B1", serif; font-weight: 800; font-size: clamp(90px, 15vw, 220px); letter-spacing: 0.1em; text-shadow: 0 4px 30px #000, 0 0 80px rgba(255,200,120,0.25); animation: cardName var(--dur) ease forwards; }
.card-han { margin-top: 34vh; font-family: "Long Cang", "Yuji Syuku", serif; font-size: clamp(30px, 4.4vw, 56px); letter-spacing: 0.6em; color: #e2b55a; animation: cardSub var(--dur) ease forwards; }
.card-ja { margin-top: 48vh; font-family: "Shippori Mincho B1", serif; font-size: 15px; letter-spacing: 0.3em; color: rgba(232,224,204,0.6); animation: cardSub var(--dur) 0.4s ease both; }
@media (max-width: 760px) {
  #story-hanja { left: 50%; top: 32%; transform: translate(-50%, -50%); font-size: 46vw; }
  #story-zh { right: 50%; top: 20%; transform: translate(50%, 0); writing-mode: horizontal-tb; font-size: 20px; }
  #story-text { right: 6vw; left: 6vw; bottom: 14vh; max-width: none; text-align: center; font-size: 15px; }
  #story-ja { display: none; }
}

#story-text { white-space: pre-wrap; text-shadow: 0 2px 14px rgba(0,0,0,0.95), 0 0 30px rgba(0,0,0,0.8); }
#story-text span { display: inline; }
#story-text::before { content: ""; position: absolute; inset: -14px -24px; background: radial-gradient(ellipse at center, rgba(5,5,8,0.55), rgba(5,5,8,0) 72%); z-index: -1; }

/* ── 시네마틱 타이포 v3: 붓글씨 중문 · 명조 일문 · 금빛 한글 ── */
#story-hanja { font-family: "Long Cang", "Yuji Syuku", serif; color: #f1e4c2;
  text-shadow: 0 0 2px rgba(255,236,190,0.6), 0 0 50px rgba(0,0,0,0.95), 0 0 140px rgba(255,190,100,0.35); }
#story-zh { font-family: "Yuji Mai", "Yuji Syuku", serif; font-size: max(30px, 5.4vh); letter-spacing: 0.22em; color: #e8b85c;
  text-shadow: 0 0 18px rgba(0,0,0,0.9), 0 0 36px rgba(232,170,80,0.35); }
#story-text { font-family: "Noto Serif KR", "Hahmlet", serif; font-weight: 600; font-size: max(18px, 2.9vh); letter-spacing: 0.04em; line-height: 1.9;
  text-shadow: none; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.95)) drop-shadow(0 0 22px rgba(0,0,0,0.75)); }
#story-text span { background: linear-gradient(180deg, #fff6df 0%, #f1dcae 55%, #c99a50 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
#story-ja { font-family: "Kaisei Tokumin", "Shippori Mincho B1", serif; font-weight: 500; font-size: max(14px, 2vh); letter-spacing: 0.3em; color: rgba(236,226,204,0.62);
  text-shadow: 0 1px 10px rgba(0,0,0,0.9); }
.card-name { font-family: "Kaisei Tokumin", "Shippori Mincho B1", serif; }
.card-han { font-family: "Yuji Mai", "Yuji Syuku", serif; }
.card-ja { font-family: "Kaisei Tokumin", serif; }

/* 이름 카드: SARU 직전, 플레이어 이름을 하늘에 새긴다 */
#story-name { position: absolute; inset: 0; display: none; z-index: 2; place-items: center; text-align: center; pointer-events: none; }
#story.namecard #story-name { display: grid; }
#story.namecard #story-hanja, #story.namecard #story-seal, #story.namecard #story-text, #story.namecard #story-zh, #story.namecard #story-ja { display: none; }
#story-name > * { grid-area: 1 / 1; }
#story-name .nm-pre { transform: translateY(-25vh); font-family: "Yuji Mai", "Yuji Syuku", serif; font-size: max(22px, 3.6vh); letter-spacing: 0.7em; color: rgba(232,184,92,0.85); opacity: 0; }
#story-name .nm-name { font-family: "Noto Serif KR", "Kaisei Tokumin", serif; font-weight: 900; font-size: clamp(64px, 17vh, 200px); letter-spacing: 0.08em; line-height: 1;
  background: linear-gradient(180deg, #fffaf0 0%, #ffe3a0 40%, #e0a040 70%, #8a5a1a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.95)) drop-shadow(0 0 60px rgba(255,180,80,0.45)); opacity: 0; transform: translateY(-4vh); }
#story-name .nm-rule { width: min(560px, 60vw); height: 1px; transform: translateY(6vh) scaleX(0); background: linear-gradient(90deg, transparent, #e8b85c, transparent); box-shadow: 0 0 14px rgba(232,184,92,0.8); }
#story-name .nm-line { text-shadow: 0 2px 10px #000, 0 0 24px rgba(0,0,0,0.8); transform: translateY(13vh); font-family: "Noto Serif KR", serif; font-weight: 600; font-size: max(19px, 3.1vh); letter-spacing: 0.06em; color: #f4e8cc; opacity: 0;
  }
#story-name .nm-zh { transform: translateY(20vh); font-family: "Yuji Mai", "Yuji Syuku", serif; font-size: max(22px, 3.4vh); letter-spacing: 0.35em; color: #e8b85c; opacity: 0; }
#story-name .nm-sig { transform: translateY(27vh); font-family: "Yuji Mai", "Yuji Syuku", serif; font-size: max(18px, 2.6vh); letter-spacing: 0.5em; color: rgba(236,226,204,0.7); opacity: 0; }
#story.namecard .nm-pre { animation: nmFade var(--dur) 0.3s ease forwards; }
#story.namecard .nm-name { animation: nmSlam var(--dur) 0.9s cubic-bezier(.2,.9,.2,1) forwards; }
#story.namecard .nm-rule { animation: nmRule var(--dur) 1.5s ease forwards; }
#story.namecard .nm-line { animation: nmFade var(--dur) 2.4s ease forwards; }
#story.namecard .nm-zh { animation: nmFade var(--dur) 3.4s ease forwards; }
#story.namecard .nm-sig { animation: nmFade var(--dur) 4.3s ease forwards; }
@keyframes nmFade { 0% { opacity: 0; filter: blur(8px); } 10% { opacity: 1; filter: blur(0px); } 88% { opacity: 1; filter: blur(0px); } 100% { opacity: 0; filter: blur(0px); } }
@keyframes nmSlam {
  0% { opacity: 0; transform: translateY(-4vh) scale(2.4); filter: blur(24px) drop-shadow(0 6px 18px rgba(0,0,0,0)) drop-shadow(0 0 0 rgba(255,200,100,0)); letter-spacing: 0.6em; }
  6% { opacity: 1; transform: translateY(-4vh) scale(0.96); filter: blur(0px) drop-shadow(0 6px 18px rgba(0,0,0,0.95)) drop-shadow(0 0 120px rgba(255,200,100,0.9)); letter-spacing: 0.08em; }
  14% { transform: translateY(-4vh) scale(1); filter: blur(0px) drop-shadow(0 6px 18px rgba(0,0,0,0.95)) drop-shadow(0 0 60px rgba(255,180,80,0.45)); }
  88% { opacity: 1; transform: translateY(-4vh) scale(1.05); filter: blur(0px) drop-shadow(0 6px 18px rgba(0,0,0,0.95)) drop-shadow(0 0 60px rgba(255,180,80,0.45)); }
  100% { opacity: 0; transform: translateY(-4vh) scale(1.08); filter: blur(6px) drop-shadow(0 6px 18px rgba(0,0,0,0)) drop-shadow(0 0 60px rgba(255,180,80,0)); }
}
@keyframes nmRule { 0% { transform: translateY(6vh) scaleX(0); } 14% { transform: translateY(6vh) scaleX(1); } 88% { opacity: 1; } 100% { transform: translateY(6vh) scaleX(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #story.namecard #story-name > * { animation-duration: 0.01s; opacity: 1; } }

#story-name::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 60% 45% at 50% 50%, rgba(4,3,6,0.62), rgba(4,3,6,0) 75%); }
