/* ═══════════════════════════════════════════════════════
   숨 쉬는 지구 갤러리 — 스타일
   팔레트: 숲 녹색 #0F2A1F · 샴페인 골드 #C9A96E · 아이보리 #F3EEE3 · 모스 #4F7A4A
   ═══════════════════════════════════════════════════════ */
:root {
  --forest: #0F2A1F;
  --forest-2: #143628;
  --ink: #07100c;
  --gold: #C9A96E;
  --gold-2: #E2CB98;
  --gold-dim: rgba(201, 169, 110, .35);
  --ivory: #F3EEE3;
  --ivory-2: rgba(243, 238, 227, .72);
  --ivory-3: rgba(243, 238, 227, .48);
  --moss: #4F7A4A;
  --leaf: #A3C46B;
  --danger: #E08A6E;
  --serif: 'MaruBuri', 'Nanum Myeongjo', serif;
  --latin: 'Cormorant Garamond', 'MaruBuri', serif;
  --sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--ivory); }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.55; letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
img { display: block; max-width: 100%; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 .35em; margin: 0 .1em; border: 1px solid var(--gold-dim);
  border-bottom-width: 2px; border-radius: 5px; font-family: var(--sans); font-size: .78em; text-align: center; color: var(--gold-2);
}
.hidden { display: none !important; }
.muted { color: var(--ivory-2); }
.hint { color: var(--ivory-3); font-size: .86rem; }
.eyebrow { margin: 0 0 .35rem; font-size: .74rem; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.title-serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 0; }
.display { font-family: var(--serif); font-weight: 300; margin: 0; font-size: clamp(2.4rem, 6.8vw, 4.9rem); line-height: 1.14; letter-spacing: -0.01em; }
.rule-gold { width: 72px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); margin: 1.4rem auto; }

/* ── 화면 전환 ── */
.screen {
  position: fixed; inset: 0; display: none; opacity: 0;
  transition: opacity .6s var(--ease);
}
.screen.active { display: block; }
.screen.visible { opacity: 1; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .7em 1.5em; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; letter-spacing: .01em; transition: transform .2s var(--ease), background .25s, border-color .25s, opacity .25s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-gold { background: linear-gradient(180deg, #d9bd86, var(--gold)); color: #1b140a; box-shadow: 0 6px 24px rgba(201, 169, 110, .25), inset 0 1px 0 rgba(255, 255, 255, .4); }
.btn-gold:not(:disabled):hover { background: linear-gradient(180deg, #e6cd99, #d2b37a); }
.btn-outline { background: rgba(15, 42, 31, .4); border-color: var(--gold-dim); color: var(--ivory); backdrop-filter: blur(6px); }
.btn-outline:hover { border-color: var(--gold); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: .45em 1.1em; font-size: .92rem; }
.btn-star { background: transparent; border: 1px solid var(--gold-dim); color: var(--gold-2); }
.btn-star.on { background: var(--gold); color: #1b140a; border-color: var(--gold); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35em; min-width: 44px; height: 44px; padding: 0 .8em;
  background: rgba(7, 16, 12, .45); border: 1px solid var(--gold-dim); border-radius: 999px; color: var(--ivory); font-size: 1.1rem;
  backdrop-filter: blur(8px);
}
.icon-btn span { font-size: .88rem; }
.icon-btn:hover { border-color: var(--gold); }
.chip { background: rgba(7, 16, 12, .55); border: 1px solid var(--gold-dim); border-radius: 999px; padding: .45em 1em; font-size: .86rem; backdrop-filter: blur(8px); }
.link-btn { background: none; border: 0; color: var(--gold-2); text-decoration: underline; text-underline-offset: 4px; }

/* ═════════════ 입구 ═════════════ */
#s-entrance { overflow-y: auto; }
.entrance-bg { position: fixed; inset: 0; z-index: 0; background: radial-gradient(120% 80% at 50% 0%, #1b3d2e 0%, var(--forest) 40%, var(--ink) 100%); }
.entrance-photo { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity 1.2s; filter: saturate(.9); }
.entrance-photo.loaded { opacity: .5; }
.entrance-earth {
  position: absolute; left: 50%; top: 50%; width: min(78vmin, 720px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 50%; opacity: .22; filter: blur(.5px);
  background: url(../assets/tex/earth_gray_1024.jpg) 0 0 / 200% 100% repeat-x;
  box-shadow: inset -40px -30px 90px rgba(0, 0, 0, .85), 0 0 120px rgba(163, 196, 107, .18);
  animation: spinEarth 90s linear infinite;
}
.entrance-photo.loaded + .entrance-earth { opacity: .0; }
@keyframes spinEarth { to { background-position: -200% 0; } }
.entrance-vignette { position: absolute; inset: 0; background: radial-gradient(70% 60% at 50% 45%, transparent 0%, rgba(7, 16, 12, .55) 60%, rgba(7, 16, 12, .92) 100%); }
.entrance-inner { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px calc(32px + var(--safe-b)); }
.entrance-inner .eyebrow { letter-spacing: .5em; }
.tagline { margin: .7rem 0 0; font-family: var(--latin); font-style: italic; font-weight: 400; color: var(--gold-2); letter-spacing: .03em; font-size: clamp(1.1rem, 2.6vw, 1.4rem); }
.facts { margin: 0 0 1.8rem; color: var(--ivory-2); font-size: .95rem; letter-spacing: .04em; }

.ticket {
  width: min(380px, 100%); text-align: left; padding: 22px 22px 18px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(20, 54, 40, .78), rgba(10, 26, 19, .85));
  border: 1px solid var(--gold-dim); box-shadow: 0 30px 80px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(243, 238, 227, .06);
  backdrop-filter: blur(10px); position: relative;
}
.ticket::before, .ticket::after { content: ''; position: absolute; top: 58px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 1px solid var(--gold-dim); }
.ticket::before { left: -10px; clip-path: inset(0 0 0 50%); }
.ticket::after { right: -10px; clip-path: inset(0 50% 0 0); }
.ticket-head { display: flex; justify-content: space-between; font-size: .72rem; letter-spacing: .3em; color: var(--gold); padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px dashed var(--gold-dim); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; color: var(--ivory-2); margin-bottom: 6px; }
.field small { color: var(--ivory-3); margin-left: .3em; }
.field input {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 12px; border: 1px solid rgba(201, 169, 110, .28);
  background: rgba(7, 16, 12, .55); color: var(--ivory); font-size: 1.15rem; letter-spacing: .04em; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 169, 110, .18); }
#in-sid { letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.form-msg { min-height: 1.4em; margin: 10px 0 0; font-size: .9rem; color: var(--danger); text-align: center; }
.form-msg.ok { color: var(--leaf); }
.entrance-foot { margin-top: 18px; display: grid; gap: 6px; justify-items: center; }
.demo-flag { color: var(--gold-2); }

/* 입장 연출 (문이 열림) */
.gate-open { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: flex; }
.gate-open i { flex: 1; background: linear-gradient(90deg, #1a120a, #3b2616 40%, #2a1a0e); border: 1px solid #000; animation: gateL 1.6s var(--ease) forwards; box-shadow: inset 0 0 0 2px rgba(201, 169, 110, .4); }
.gate-open i + i { animation-name: gateR; }
@keyframes gateL { 0% { transform: translateX(0); } 30% { transform: translateX(0); } 100% { transform: translateX(-102%); } }
@keyframes gateR { 0% { transform: translateX(0); } 30% { transform: translateX(0); } 100% { transform: translateX(102%); } }

/* ═════════════ 3D 로비 ═════════════ */
#s-lobby { background: #000; }
#lobby-canvas-wrap, #lobby-canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.lobby-crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--ivory); opacity: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; transition: opacity .2s; }
.locked .lobby-crosshair { opacity: .75; }
.lobby-prompt {
  position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); padding: .7em 1.3em; border-radius: 999px;
  background: rgba(7, 16, 12, .72); border: 1px solid var(--gold); color: var(--ivory); font-weight: 600; backdrop-filter: blur(8px);
  pointer-events: auto; cursor: pointer; white-space: nowrap; animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(201, 169, 110, .12); } }
.lobby-help { position: absolute; left: 50%; bottom: calc(94px + var(--safe-b)); transform: translateX(-50%); font-size: .86rem; color: var(--ivory-2); text-align: center; text-shadow: 0 1px 6px #000; pointer-events: none; width: max-content; max-width: 92vw; transition: opacity .6s; }
.lobby-help .help-mobile { display: none; }
.touch .lobby-help .help-pc { display: none; }
.touch .lobby-help .help-mobile { display: block; }
.touch .lobby-help { bottom: auto; top: 58px; max-width: 70vw; white-space: normal; }
.lobby-side { position: absolute; right: 16px; top: 76px; display: grid; gap: 8px; justify-items: end; }
.joystick { position: absolute; left: 28px; bottom: calc(110px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--gold-dim); background: rgba(7, 16, 12, .35); backdrop-filter: blur(4px); touch-action: none; }
.joystick-knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--gold-2), var(--gold)); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }

/* ═════════════ 2D 로비 ═════════════ */
#s-lobby2d { overflow-y: auto; background: radial-gradient(100% 60% at 50% 0%, #1b3d2e, var(--forest) 45%, var(--ink)); }
.lobby2d-wrap { max-width: 1080px; margin: 0 auto; padding: 84px 20px calc(130px + var(--safe-b)); }
.lobby2d-head { display: flex; align-items: center; gap: 22px; margin-bottom: 28px; }
.lobby2d-head h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); }
.lobby2d-earth { position: relative; flex: none; width: 104px; height: 104px; border-radius: 50%; overflow: hidden; box-shadow: inset -14px -10px 30px rgba(0, 0, 0, .8), 0 0 40px rgba(163, 196, 107, .25); }
.lobby2d-earth img { position: absolute; top: 0; left: 0; height: 100%; width: 200%; max-width: none; object-fit: cover; animation: slideEarth 40s linear infinite; }
.lobby2d-earth .earth-green { -webkit-mask-image: linear-gradient(90deg, #000 var(--p, 0%), transparent calc(var(--p, 0%) + 8%)); mask-image: linear-gradient(90deg, #000 var(--p, 0%), transparent calc(var(--p, 0%) + 8%)); }
@keyframes slideEarth { to { transform: translateX(-50%); } }
.door-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.door-card {
  position: relative; aspect-ratio: 3 / 4.2; border-radius: 120px 120px 10px 10px; overflow: hidden; text-align: left;
  border: 1px solid var(--gold-dim); background: linear-gradient(180deg, #2a1a0e, #170e07);
  padding: 0; display: flex; flex-direction: column; justify-content: flex-end; transition: transform .35s var(--ease), border-color .3s, box-shadow .3s;
}
.door-card:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.door-card .door-art { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .55; transition: opacity .4s; }
.door-card:hover .door-art { opacity: .75; }
.door-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(7, 16, 12, .1) 30%, rgba(7, 16, 12, .92)); }
.door-card .door-info { position: relative; z-index: 1; padding: 16px; }
.door-card .door-no { font-size: .7rem; letter-spacing: .3em; color: var(--gold); }
.door-card .door-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 400; margin: 2px 0; }
.door-card .door-progress { font-size: .8rem; color: var(--ivory-2); }
.door-card .door-light { position: absolute; z-index: 1; top: 14px; left: 50%; transform: translateX(-50%); width: 46px; height: 4px; border-radius: 4px; background: var(--room, var(--gold)); box-shadow: 0 0 14px var(--room, var(--gold)); }
.door-card.done .door-light { background: var(--leaf); box-shadow: 0 0 16px var(--leaf); }
.door-card.start::before { content: '여기서 시작'; position: absolute; z-index: 2; top: 28px; left: 50%; transform: translateX(-50%); font-size: .72rem; padding: .25em .8em; border-radius: 999px; background: var(--gold); color: #1b140a; font-weight: 700; white-space: nowrap; }
.lobby2d-actions { display: flex; justify-content: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

/* ═════════════ 전시실 ═════════════ */
#s-room { background: #0b1d15; }
#s-room::before { /* 벽 */
  content: ''; position: absolute; inset: 0;
  background:
    var(--wall-img, linear-gradient(transparent, transparent)),
    radial-gradient(ellipse 22% 55% at 18% 18%, rgba(255, 228, 170, .13), transparent 70%),
    radial-gradient(ellipse 22% 55% at 50% 18%, rgba(255, 228, 170, .13), transparent 70%),
    radial-gradient(ellipse 22% 55% at 82% 18%, rgba(255, 228, 170, .13), transparent 70%),
    linear-gradient(180deg, #0c2219 0%, var(--forest) 55%, #0a1a13 100%);
}
#s-room::after { /* 바닥 */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 15%;
  background: var(--floor-img, linear-gradient(180deg, #0d0b09, #050404));
  border-top: 1px solid rgba(201, 169, 110, .55); box-shadow: 0 -1px 12px rgba(201, 169, 110, .18);
}
.room-head { position: absolute; z-index: 3; left: 0; right: 0; top: 64px; display: flex; align-items: flex-start; gap: 16px; padding: 0 22px; }
.room-title { flex: 1; text-align: center; }
.room-title h2 { font-size: clamp(1.3rem, 3vw, 1.9rem); }
.docent { margin: .35rem auto 0; max-width: 560px; color: var(--ivory-2); font-family: var(--serif); font-weight: 300; font-size: .98rem; }
.room-count { min-width: 74px; text-align: right; color: var(--gold-2); font-variant-numeric: tabular-nums; padding-top: 10px; }
.wall { position: absolute; z-index: 2; left: 0; right: 0; top: 168px; bottom: 15%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.wall::-webkit-scrollbar { display: none; }
.wall-track { display: flex; align-items: center; height: 100%; padding: 0 max(8vw, calc(50vw - 560px)); gap: clamp(40px, 6vw, 96px); width: max-content; }
.artwork { position: relative; scroll-snap-align: center; flex: none; width: clamp(250px, 27vw, 380px); display: flex; flex-direction: column; align-items: center; cursor: zoom-in; }
.artwork .spot { position: absolute; left: 50%; top: -40%; width: 160%; height: 150%; transform: translateX(-50%); background: radial-gradient(ellipse 40% 50% at 50% 30%, rgba(255, 226, 168, .22), transparent 70%); pointer-events: none; opacity: .6; transition: opacity .8s; }
.artwork.seen .spot, .artwork:hover .spot { opacity: 1; }
.frame {
  position: relative; width: 100%; padding: 7%; background: linear-gradient(180deg, #f6f1e6, #ebe4d4);
  box-shadow: 0 0 0 4px #b8975b, 0 0 0 5px #8a6d3b, 0 26px 50px rgba(0, 0, 0, .55), 0 6px 14px rgba(0, 0, 0, .35);
  transition: transform .5s var(--ease);
}
.artwork:hover .frame { transform: translateY(-4px); }
.frame-inner { position: relative; aspect-ratio: 4 / 3; background: #1b1b1b; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25), inset 0 2px 6px rgba(0, 0, 0, .35); }
.artwork.portrait { width: clamp(190px, 19vw, 270px); }
.artwork.portrait .frame-inner { aspect-ratio: 3 / 4; }
.frame-inner img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .8s; }
.frame-inner img.loaded { opacity: 1; }
.artwork .star-flag { position: absolute; top: -12px; right: -12px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #1b140a; font-size: 1rem; box-shadow: 0 4px 12px rgba(0, 0, 0, .4); transform: scale(0); transition: transform .35s var(--ease); }
.artwork.starred .star-flag { transform: scale(1); }
.plaque { margin-top: 22px; width: 100%; max-width: 320px; text-align: left; padding: 10px 14px; background: rgba(243, 238, 227, .94); color: #1d1a14; border-radius: 2px; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.plaque .label-no { color: #8a6d3b; }
.plaque h3 { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; margin: 1px 0 2px; color: #14110c; }
.plaque p { margin: 0; font-size: .8rem; color: #5a5347; }
.label-no { font-size: .68rem; letter-spacing: .22em; font-weight: 700; font-variant-numeric: tabular-nums; }
.next-door { flex: none; scroll-snap-align: center; width: 260px; height: 70%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; border-radius: 130px 130px 8px 8px; border: 1px solid var(--gold-dim); background: linear-gradient(180deg, rgba(42, 26, 14, .8), rgba(23, 14, 7, .9)); text-align: center; padding: 20px; }
.next-door:hover { border-color: var(--gold); }
.next-door .title-serif { font-size: 1.15rem; }
.wall-nav { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(7.5% - 22px); display: flex; justify-content: center; align-items: center; gap: 16px; pointer-events: none; }
.wall-nav > * { pointer-events: auto; }
.wall-dots { display: flex; gap: 6px; }
.wall-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(243, 238, 227, .25); transition: background .3s, transform .3s; }
.wall-dots i.seen { background: var(--leaf); }
.wall-dots i.cur { transform: scale(1.5); background: var(--gold); }

/* ═════════════ HUD ═════════════ */
.hud { position: fixed; z-index: 20; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: linear-gradient(180deg, rgba(7, 16, 12, .85), rgba(7, 16, 12, 0)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-progress { display: flex; white-space: nowrap; align-items: center; gap: 10px; font-size: .86rem; font-variant-numeric: tabular-nums; }
.hud-bar { width: 120px; height: 6px; border-radius: 6px; background: rgba(243, 238, 227, .14); overflow: hidden; }
.hud-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--moss), var(--leaf)); border-radius: 6px; transition: width .8s var(--ease); }
.hud-stamps { display: flex; gap: 5px; }
.hud-stamps i { width: 22px; height: 22px; border-radius: 50%; border: 1px dashed var(--gold-dim); display: grid; place-items: center; font-style: normal; font-size: .66rem; color: var(--ivory-3); transition: all .4s var(--ease); }
.hud-stamps i.done { border: 1px solid var(--leaf); background: rgba(163, 196, 107, .2); color: var(--leaf); }
.hud-stamps i.done.pop { animation: stamp .6s var(--ease); }
@keyframes stamp { 0% { transform: scale(2.2) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.hud-user { margin-left: auto; font-size: .84rem; color: var(--ivory-2); white-space: nowrap; }
.hud-user .tag { margin-left: 6px; padding: .1em .6em; border-radius: 999px; border: 1px solid var(--gold-dim); color: var(--gold-2); font-size: .74rem; }

/* ═════════════ 관심 작품 바 ═════════════ */
.interest {
  position: fixed; z-index: 21; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; max-width: calc(100vw - 24px);
  border-radius: 999px; background: rgba(7, 16, 12, .82); border: 1px solid var(--gold-dim); backdrop-filter: blur(12px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
.interest-toggle { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; white-space: nowrap; }
.interest-toggle .star { color: var(--gold); font-size: 1.1rem; }
.interest-max { color: var(--ivory-3); font-size: .86rem; }
.interest-label { color: var(--ivory-2); font-size: .86rem; margin-left: 4px; }
.interest-thumbs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 52vw; }
.interest-thumbs::-webkit-scrollbar { display: none; }
.interest-thumbs button { flex: none; width: 40px; height: 40px; padding: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--gold-dim); background: #222; }
.interest-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.interest.bump { animation: bump .5s var(--ease); }
@keyframes bump { 40% { transform: translateX(-50%) scale(1.06); } }

/* ═════════════ 감상 모드 ═════════════ */
.viewer { position: fixed; z-index: 40; inset: 0; background: rgba(3, 7, 5, .96); display: flex; align-items: center; justify-content: center; animation: fadeIn .4s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
.viewer-spot { position: absolute; inset: 0; background: radial-gradient(ellipse 45% 70% at 40% 25%, rgba(255, 226, 168, .14), transparent 70%); pointer-events: none; }
.viewer-close { position: absolute; top: 16px; right: 16px; z-index: 2; }
.viewer-prev, .viewer-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; font-size: 1.6rem; }
.viewer-prev { left: 16px; } .viewer-next { right: 16px; }
.viewer-figure { position: relative; margin: 0; display: flex; align-items: center; gap: 40px; max-width: min(1280px, 92vw); max-height: 88vh; }
.viewer-frame { padding: 18px; background: linear-gradient(180deg, #f6f1e6, #ebe4d4); box-shadow: 0 0 0 4px #b8975b, 0 40px 90px rgba(0, 0, 0, .7); }
.viewer-frame img { max-width: min(64vw, 960px); max-height: 74vh; object-fit: contain; touch-action: pinch-zoom; }
.viewer-label { width: 300px; flex: none; }
.viewer-label .label-no { color: var(--gold); }
.viewer-label h3 { font-size: 1.6rem; margin: .3rem 0 .4rem; }
.label-author { margin: 0 0 1rem; color: var(--gold-2); font-size: .95rem; }
.label-desc { margin: 0 0 1.4rem; color: var(--ivory-2); font-size: .95rem; white-space: pre-line; }

/* ═════════════ 투표함 ═════════════ */
#s-ballot, #s-results, #s-exit { overflow-y: auto; background: radial-gradient(100% 60% at 50% 0%, #1b3d2e, var(--forest) 45%, var(--ink)); }
.ballot-wrap, .results-wrap { max-width: 1040px; margin: 0 auto; padding: 76px 20px calc(120px + var(--safe-b)); }
.ballot-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.ballot-head h2 { font-size: clamp(1.5rem, 3.6vw, 2.2rem); }
.ballot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.pick { position: relative; display: flex; flex-direction: column; padding: 0; border: 1px solid rgba(201, 169, 110, .2); border-radius: 12px; overflow: hidden; background: rgba(7, 16, 12, .5); text-align: left; transition: border-color .25s, transform .25s var(--ease), box-shadow .25s; }
.pick:hover { transform: translateY(-2px); }
.pick img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.pick .pick-info { display: block; padding: 10px 12px 12px; }
.pick .pick-info b { display: block; font-family: var(--serif); font-weight: 600; font-size: 1rem; }
.pick .pick-info span { font-size: .78rem; color: var(--ivory-3); }
.pick .check { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(243, 238, 227, .7); background: rgba(7, 16, 12, .5); display: grid; place-items: center; font-weight: 800; color: #1b140a; }
.pick.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 18px 40px rgba(0, 0, 0, .4); }
.pick.on .check { background: var(--gold); border-color: var(--gold); }
.pick .zoom { position: absolute; top: 10px; left: 10px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(7, 16, 12, .6); color: var(--ivory); font-size: .85rem; }
.ballot-foot { position: fixed; z-index: 22; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 18px; padding: 8px 8px 8px 22px; border-radius: 999px; background: rgba(7, 16, 12, .88); border: 1px solid var(--gold-dim); backdrop-filter: blur(12px); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
.ballot-count { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ballot-count b { color: var(--gold); font-size: 1.2rem; }
.ballot-lock { padding: 36px 24px; border-radius: 18px; border: 1px solid var(--gold-dim); background: rgba(7, 16, 12, .5); text-align: center; }
.ballot-lock h3 { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 .6rem; }
.ballot-lock p { margin: 0 0 1.2rem; color: var(--ivory-2); }
.ballot-lock .lock-icon { font-size: 2.2rem; margin-bottom: .5rem; }
.ballot-lock .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ═════════════ 출구 ═════════════ */
.exit-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; gap: 10px; }
.exit-wrap h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
.exit-count { color: var(--gold-2); font-family: var(--serif); font-weight: 300; font-size: 1.1rem; min-height: 1.5em; }
.tree { width: 220px; height: 240px; margin-bottom: 8px; overflow: visible; }
.tree .seed { animation: seed 1s var(--ease) both; }
.tree .trunk { stroke-dasharray: 120; stroke-dashoffset: 120; animation: grow 1.4s .8s var(--ease) forwards; }
.tree .branch { stroke-dasharray: 60; stroke-dashoffset: 60; animation: grow 1s 1.8s var(--ease) forwards; }
.tree .crown circle { transform-box: fill-box; transform-origin: center; transform: scale(0); animation: bloom .9s var(--ease) forwards; }
.tree .crown circle:nth-child(1) { animation-delay: 2.3s; } .tree .crown circle:nth-child(2) { animation-delay: 2.5s; }
.tree .crown circle:nth-child(3) { animation-delay: 2.6s; } .tree .crown circle:nth-child(4) { animation-delay: 2.8s; }
@keyframes seed { from { transform: translateY(-40px); opacity: 0; } }
@keyframes grow { to { stroke-dashoffset: 0; } }
@keyframes bloom { to { transform: scale(1); } }

/* ═════════════ 결과 ═════════════ */
.results-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.results-list li { display: grid; grid-template-columns: 52px 88px 1fr; gap: 14px; align-items: center; padding: 10px 14px; border-radius: 14px; background: rgba(7, 16, 12, .5); border: 1px solid rgba(201, 169, 110, .18); }
.results-list li.top1 { border-color: var(--gold); background: linear-gradient(90deg, rgba(201, 169, 110, .16), rgba(7, 16, 12, .5)); }
.results-list .rank { font-family: var(--latin); font-weight: 500; font-size: 2rem; color: var(--gold); text-align: center; }
.results-list img { width: 88px; height: 66px; object-fit: cover; border-radius: 6px; }
.results-list .r-title { font-family: var(--serif); font-weight: 600; }
.results-list .r-sub { font-size: .8rem; color: var(--ivory-3); }
.results-list .r-bar { margin-top: 6px; height: 8px; border-radius: 8px; background: rgba(243, 238, 227, .1); overflow: hidden; }
.results-list .r-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--moss), var(--leaf)); border-radius: 8px; width: 0; transition: width 1.2s var(--ease); }
.results-list .r-votes { font-size: .85rem; color: var(--gold-2); }

/* ═════════════ 모달 ═════════════ */
.modal { position: fixed; z-index: 45; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(3, 7, 5, .75); backdrop-filter: blur(6px); animation: fadeIn .3s var(--ease); }
.modal-card { width: min(560px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px; border-radius: 20px; background: linear-gradient(180deg, #143628, #0b1d15); border: 1px solid var(--gold-dim); box-shadow: 0 40px 90px rgba(0, 0, 0, .6); }
.modal-card h3 { font-size: 1.3rem; margin-bottom: .6rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.confirm-picks { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 14px 0; }
.confirm-picks figure { margin: 0; }
.confirm-picks img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; box-shadow: 0 0 0 2px var(--gold); }
.confirm-picks figcaption { font-family: var(--serif); font-size: .9rem; margin-top: 6px; }
.warn { margin: 0; padding: 10px 14px; border-radius: 10px; background: rgba(224, 138, 110, .12); border: 1px solid rgba(224, 138, 110, .45); color: #f2c2b2; font-weight: 600; font-size: .92rem; }
.map-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.map-list button { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid rgba(201, 169, 110, .22); background: rgba(7, 16, 12, .45); text-align: left; }
.map-list button:hover { border-color: var(--gold); }
.map-list .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--room, var(--gold)); box-shadow: 0 0 10px var(--room, var(--gold)); flex: none; }
.map-list .done .dot { background: var(--leaf); box-shadow: 0 0 10px var(--leaf); }
.map-list small { display: block; color: var(--ivory-3); font-size: .76rem; }
.missed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.missed-grid button { padding: 0; border: 1px solid rgba(201, 169, 110, .25); border-radius: 10px; overflow: hidden; background: #111; text-align: left; }
.missed-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.missed-grid span { display: block; padding: 6px 8px; font-size: .74rem; color: var(--ivory-2); }

/* ═════════════ 토스트·로딩 ═════════════ */
.toast { position: fixed; z-index: 60; left: 50%; top: 18px; transform: translate(-50%, -140%); max-width: calc(100vw - 32px); padding: .75em 1.3em; border-radius: 999px; background: rgba(7, 16, 12, .92); border: 1px solid var(--gold); color: var(--ivory); font-weight: 600; font-size: .92rem; transition: transform .45s var(--ease); pointer-events: none; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.loading { position: fixed; z-index: 55; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(7, 16, 12, .92); color: var(--ivory-2); }
.loading-ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(201, 169, 110, .2); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═════════════ 휴대폰 ═════════════ */
@media (max-width: 820px) {
  .door-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .lobby2d-head { gap: 14px; }
  .lobby2d-earth { width: 76px; height: 76px; }
  .hud { gap: 10px; padding: 10px 12px; }
  .hud-bar { width: 70px; }
  .hud-stamps i { width: 16px; height: 16px; font-size: 0; }
  .hud-user { display: none; }
  .room-head { top: 56px; padding: 0 12px; }
  .room-head .icon-btn span { display: none; }
  .docent { font-size: .84rem; }
  .wall { top: 150px; bottom: 13%; }
  .wall-track { padding: 0 9vw; gap: 9vw; }
  .artwork { width: 82vw; }
  .artwork.portrait { width: 58vw; }
  .plaque { max-width: 82vw; }
  .wall-nav { bottom: calc(13% + 76px + var(--safe-b)); }
  .wall-nav .icon-btn { display: none; }
  #s-room::after { height: 13%; }
  .viewer-figure { flex-direction: column; gap: 14px; max-height: none; }
  .viewer-frame { padding: 10px; }
  .viewer-frame img { max-width: 92vw; max-height: 56vh; }
  .viewer-label { width: 92vw; }
  .viewer-label h3 { font-size: 1.25rem; }
  .viewer-prev, .viewer-next { top: auto; bottom: 18px; transform: none; }
  .interest { left: 12px; right: 12px; transform: none; justify-content: space-between; }
  .interest.bump { animation: none; }
  .interest-thumbs, .interest-label { display: none; }
  .interest.open { flex-wrap: wrap; border-radius: 18px; }
  .interest.open .interest-thumbs { display: flex; order: 3; width: 100%; max-width: none; flex-wrap: wrap; }
  .ballot-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .ballot-foot { left: 12px; right: 12px; transform: none; justify-content: space-between; }
  .map-list { grid-template-columns: 1fr; }
  .lobby-side { top: 60px; right: 10px; }
  .lobby-prompt { bottom: calc(250px + var(--safe-b)); }
  .results-list li { grid-template-columns: 38px 64px 1fr; }
  .results-list img { width: 64px; height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
