:root {
  --cream: #f1ebdf;
  --paper: #f8f4ec;
  --ink: #2f2a22;
  --ink-soft: #6b6153;
  --forest: #3f5a3b;
  --purple: #7a6a98;
  --wood: #9b7652;
  --line: rgba(47, 42, 34, .12);
  --top-h: 56px;
  --season-h: 64px;
  --panel-w: 380px;
  --font: 'Gowun Batang', 'AppleMyungjo', 'Nanum Myeongjo', serif;
  --hand: 'Nanum Pen Script', 'Gowun Batang', cursive;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button { font-family: inherit; color: inherit; }
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ── top bar ── */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(241, 235, 223, .88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.back { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); display: grid; place-items: center; cursor: pointer; }
.back[hidden] { display: none; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-en { font-size: 10px; letter-spacing: .22em; color: var(--forest); }
.brand-ko { font-size: 18px; font-weight: 700; }
.place-sub { margin-left: auto; font-size: 13px; color: var(--ink-soft); }

/* ── layout ── */
.layout { flex: 1; display: flex; flex-direction: column; }
.stage-wrap { display: flex; justify-content: center; }
.stage {
  position: relative; width: 100vw; aspect-ratio: 1 / 1; overflow: hidden; background: #d9d0bf;
  touch-action: manipulation;
}
.breath { position: absolute; inset: 0; animation: breath 26s ease-in-out infinite alternate; transform-origin: 50% 55%; }
@keyframes breath { from { transform: scale(1); } to { transform: scale(1.025); } }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 1.1s ease; user-select: none; -webkit-user-drag: none; }
#imgB { opacity: 0; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }

/* ── signs (HTML text on blank boards) ── */
.signs { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.sign {
  position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap;
  font-family: var(--hand); color: #3b2c1c; line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 240, 210, .35);
  opacity: .92;
}

.sign .main, .sign .sub, .sign.stack span { display: block; }
.sign.serif { font-family: var(--font); color: #2a241c; text-shadow: none; opacity: .9; }
.sign.serif .main { font-weight: 700; letter-spacing: .04em; }
.sign .sub { font-size: .3em; margin-top: .45em; letter-spacing: .02em; font-weight: 400; }
.sign.stack { line-height: 1; letter-spacing: .14em; color: #4a4034; }
.sign.stack span { margin: 0 0 1.25em; }
.sign.stack span.first { font-size: .78em; padding-bottom: .8em; border-bottom: 1px solid currentColor; margin-bottom: 1.6em; }

/* ── menu modal ── */
body.noscroll { overflow: hidden; }
.menu-modal { position: fixed; inset: 0; z-index: 60; background: rgba(28, 24, 18, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); animation: fadeUp .35s ease; }
.menu-modal[hidden] { display: none; }
.mm-head, .mm-tabs, .mm-foot { width: min(100%, 760px); }
.mm-head { display: flex; justify-content: space-between; align-items: center; color: #f8f4ec; padding: 4px 4px 10px; }
.mm-en { margin: 0; font-size: 10px; letter-spacing: .22em; opacity: .75; }
.mm-title { margin: 2px 0 0; font-size: 18px; font-weight: 700; }
.mm-close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; font-size: 16px; cursor: pointer; }
.mm-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 10px; scrollbar-width: none; }
.mm-tabs::-webkit-scrollbar { display: none; }
.mm-tabs button { flex: 0 0 auto; border: 1px solid rgba(255,255,255,.28); background: transparent; color: #efe8da; border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.mm-tabs button.on { background: #f8f4ec; color: var(--ink); border-color: #f8f4ec; }
.mm-body { flex: 1; min-height: 0; width: min(100%, 860px); display: flex; align-items: center; justify-content: center; gap: 10px; }
.mm-page { height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y pinch-zoom; }
.mm-page img { max-height: 100%; max-width: 100%; border-radius: 6px; box-shadow: 0 18px 50px rgba(0,0,0,.45); background: #fff; }
.mm-nav { flex: 0 0 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.mm-foot { display: flex; justify-content: space-between; align-items: center; color: #efe8da; font-size: 13px; padding: 10px 4px 0; }
.mm-zoom { color: #efe8da; }
@media (max-width: 600px) {
  .mm-nav { position: absolute; top: 50%; z-index: 2; background: rgba(28,24,18,.45); }
  .mm-nav.prev { left: 6px; } .mm-nav.next { right: 6px; }
  .mm-body { position: relative; }
}

/* ── spotlight: "불이 켜지는" 효과 ── */
.spot {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  transition: opacity .7s ease;
  background: radial-gradient(circle at var(--sx, 50%) var(--sy, 50%), rgba(255, 214, 140, .28) 0, rgba(255, 214, 140, .10) calc(var(--sr, 15%) * .7), rgba(26, 22, 16, .58) calc(var(--sr, 15%) * 1.6), rgba(26, 22, 16, .66) 100%);
  mix-blend-mode: normal;
}
.spot.on { opacity: 1; }

/* ── hotspots ── */
.hotspots { position: absolute; inset: 0; z-index: 4; }
.hs {
  position: absolute; transform: translate(-50%, -50%); border: 0; background: none; padding: 0; cursor: pointer;
  width: 64px; height: 64px; display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.hs .dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 249, 236, .95); box-shadow: 0 0 0 2px rgba(63, 90, 59, .55), 0 2px 8px rgba(0, 0, 0, .25); position: relative; }
.hs .dot::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 1.5px solid rgba(255, 249, 236, .85); animation: ping 2.6s ease-out infinite; }
.hs.primary .dot { background: #fff4dc; box-shadow: 0 0 0 2px rgba(155, 118, 82, .8), 0 0 18px rgba(255, 220, 150, .9); }
.hs.locked .dot { background: rgba(255, 255, 255, .6); box-shadow: 0 0 0 1.5px rgba(47, 42, 34, .35); }
.hs.locked .dot::after { display: none; }
@keyframes ping { 0% { transform: scale(.6); opacity: .9; } 80%, 100% { transform: scale(1.6); opacity: 0; } }
.hs .lbl {
  position: absolute; top: calc(50% + 14px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 12px; padding: 4px 9px; border-radius: 999px; background: rgba(248, 244, 236, .92); color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15); pointer-events: none; transition: opacity .3s;
}
.hs.up .lbl { top: auto; bottom: calc(50% + 14px); }
.hs.locked .lbl { color: var(--ink-soft); background: rgba(248, 244, 236, .75); }
.hs.active .dot { background: #ffd98a; }
.hotspots.dim .hs:not(.active) { opacity: .25; }
.hs:focus-visible { outline: 2px solid var(--forest); outline-offset: -8px; border-radius: 50%; }

/* ── toast ── */
.toast {
  position: absolute; left: 50%; bottom: 16px; transform: translate(-50%, 20px); z-index: 8; opacity: 0;
  width: min(86%, 420px); padding: 12px 16px; border-radius: 14px; background: rgba(47, 42, 34, .86); color: #f8f4ec;
  font-size: 14px; line-height: 1.55; text-align: center; transition: all .4s ease; pointer-events: none; word-break: keep-all;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── panel ── */
.panel { background: var(--paper); border-top: 1px solid var(--line); padding-bottom: calc(var(--season-h) + var(--safe-b) + 12px); }
.panel-inner { padding: 20px 20px 8px; max-width: 640px; margin: 0 auto; animation: fadeUp .5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.eyebrow { font-size: 11px; letter-spacing: .2em; color: var(--forest); margin: 0 0 6px; }
.p-title { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
.p-role { font-size: 13px; color: var(--ink-soft); margin: 0 0 14px; }
.p-text { font-size: 16px; line-height: 1.85; margin: 0 0 14px; word-break: keep-all; min-height: 3.7em; }
.p-text .caret { display: inline-block; width: 1px; height: 1em; background: var(--ink); margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.p-hint { font-size: 13px; color: var(--ink-soft); margin: 0 0 14px; }
.philo { margin: 0 0 14px; padding: 14px 16px; border-left: 3px solid var(--purple); background: rgba(122, 106, 152, .07); border-radius: 0 10px 10px 0; }
.philo small { display: block; font-size: 11px; letter-spacing: .14em; color: var(--purple); margin-bottom: 4px; }
.philo p { margin: 0; font-size: 15px; line-height: 1.7; word-break: keep-all; }
.note { font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; margin: 0 0 14px; word-break: keep-all; }
.note b { color: var(--forest); font-weight: 700; display: block; font-size: 11px; letter-spacing: .14em; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 13.5px; cursor: pointer; }
.chip.primary { background: var(--forest); color: #f8f4ec; border-color: var(--forest); }
.chip.locked { color: var(--ink-soft); background: transparent; }
.chip:hover { border-color: var(--forest); }
.close-row { display: flex; gap: 8px; margin-top: 4px; }
.cta { border: 0; background: #b5452f; color: #fff8ef; border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px rgba(181, 69, 47, .25); }
.cta:hover { background: #9e3a27; }
.sign.banner { color: #3f5a3b; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--ink-soft); }

/* ── season bar ── */
.seasons {
  position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  display: flex; gap: 4px; padding: 5px; border-radius: 999px; width: max-content; max-width: calc(100vw - 16px);
  background: rgba(248, 244, 236, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(47, 42, 34, .18); border: 1px solid var(--line);
}
.seasons button { border: 0; background: transparent; border-radius: 999px; padding: 10px 16px; font-size: 15px; cursor: pointer; display: flex; align-items: center; gap: 7px; color: var(--ink-soft); white-space: nowrap; }
.seasons button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.seasons button[data-s=spring] i { background: #e7a9b8; }
.seasons button[data-s=summer] i { background: #6f9b5c; }
.seasons button[data-s=autumn] i { background: #c9783e; }
.seasons button[data-s=winter] i { background: #a9bfd3; }
.seasons button.on { background: var(--ink); color: #f8f4ec; }

/* ── gate (마을 입성) ── */
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(241, 235, 223, .0); animation: gateIn 2.6s ease forwards; pointer-events: none; }
.gate[hidden] { display: none; }
.gate-inner { text-align: center; opacity: 0; animation: gateTxt 2.6s ease forwards; padding: 24px; }
.gate-en { font-size: 11px; letter-spacing: .3em; color: var(--forest); margin: 0 0 10px; }
.gate h2 { font-size: 30px; margin: 0 0 14px; }
.gate-txt { font-size: 15px; line-height: 1.8; color: var(--ink-soft); margin: 0; }
@keyframes gateIn { 0% { background: rgba(241, 235, 223, 0); } 25%, 70% { background: rgba(241, 235, 223, 1); } 100% { background: rgba(241, 235, 223, 0); } }
@keyframes gateTxt { 0%, 15% { opacity: 0; transform: translateY(6px); } 30%, 70% { opacity: 1; transform: none; } 95%, 100% { opacity: 0; } }

/* ── desktop / landscape ── */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  #app { height: 100vh; overflow: hidden; }
  .layout { flex-direction: row; justify-content: center; align-items: center; gap: 28px; padding: 16px 24px calc(var(--season-h) + 24px); min-height: 0; }
  .stage-wrap { flex: 0 0 auto; }
  .stage {
    width: min(calc(100vh - var(--top-h) - var(--season-h) - 56px), calc(100vw - var(--panel-w) - 80px));
    border-radius: 18px; box-shadow: 0 18px 50px rgba(47, 42, 34, .22), 0 0 0 1px var(--line);
  }
  .panel { flex: 0 0 var(--panel-w); align-self: center; border: 1px solid var(--line); border-radius: 18px; padding-bottom: 8px; max-height: calc(100vh - var(--top-h) - var(--season-h) - 56px); overflow: auto; box-shadow: 0 10px 30px rgba(47, 42, 34, .08); }
  .panel-inner { padding: 24px 24px 12px; }
  .hs .lbl { font-size: 13px; }
  .top { padding: 0 28px; }
}

/* small phones */
@media (max-width: 380px) {
  .seasons button { padding: 9px 12px; font-size: 14px; }
  .hs .lbl { font-size: 11px; padding: 3px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .breath, .hs .dot::after { animation: none; }
}
