/* 한 바가지의 쉼 v4 · 3D. 글자 18px 이상, 버튼 56px 이상 */
:root {
  --ink: #2b2824; --paper: #f4eee2; --gold: #d9a441; --gold2: #f3cf7d; --deep: rgba(30, 24, 18, .62); --glass: rgba(34, 28, 22, .55);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --serif: "Noto Serif KR", "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c1712; color: #fff; font-family: var(--sans); font-size: 18px; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app, #main { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* 이름표 */
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.nm { position: absolute; left: 0; top: 0; padding: 1px 9px; border-radius: 12px; font-size: 15px; line-height: 1.5; color: #fff; background: rgba(25, 20, 15, .48); white-space: nowrap; will-change: transform; transition: opacity .3s; }
.nm.me { background: rgba(200, 145, 50, .85); font-weight: 700; color: #2b1d08; }

.vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 2s; background: radial-gradient(ellipse at center, transparent 45%, rgba(8, 5, 2, .78) 100%); }
.med .vignette { opacity: 1; }
.viewing .bottom > :not(.actions), .viewing .side-tools .round:not(.gold) { opacity: .2; transition: opacity 1s; }
.viewing .vignette { opacity: .6; }
.med .dests, .med .music { opacity: .35; }

/* 로딩 */
.loading { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: radial-gradient(circle at 50% 40%, #3a2f22, #17120d 70%); transition: opacity 1s; }
.loading h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; margin: 0; letter-spacing: .08em; color: #f6e7c8; }
.loading p { margin: 0; color: #d8c9ad; }
.loading .bar { width: min(260px, 60vw); height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.loading .bar i { display: block; height: 100%; width: 0; background: var(--gold2); transition: width .3s; }
.loading.done { opacity: 0; pointer-events: none; }

/* 첫 제목 */
.title { position: absolute; top: calc(70px + var(--safe-t)); left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; transition: opacity 1.4s; text-shadow: 0 1px 3px rgba(0, 0, 0, .85), 0 2px 14px rgba(0, 0, 0, .7), 0 0 28px rgba(0, 0, 0, .45); background: radial-gradient(ellipse 60% 70% at 50% 45%, rgba(20, 14, 8, .38), rgba(20, 14, 8, 0) 75%); padding: 10px 0 14px; }
.title.on { opacity: 1; } .title.off { opacity: 0 !important; transition-duration: .8s; }
.title h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 7vw, 46px); margin: 0; letter-spacing: .06em; }
.count-line { margin: 6px 0 0; font-size: 19px; }

.place { position: absolute; top: calc(14px + var(--safe-t)); left: 14px; margin: 0; padding: 8px 16px; border-radius: 22px; background: var(--glass); backdrop-filter: blur(6px); font-family: var(--serif); font-size: 19px; }
.corner-row { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; display: flex; gap: 8px; align-items: center; }
.pill { min-width: 56px; height: 56px; border-radius: 28px; border: 0; background: var(--glass); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; }
.pill svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pill.icon { width: 56px; padding: 0; }
.people span { font-size: 20px; font-weight: 700; }
#soundBtn .mute { display: none; } #soundBtn[aria-pressed="false"] .mute { display: inline; } #soundBtn[aria-pressed="false"] .wave1, #soundBtn[aria-pressed="false"] .wave2 { display: none; }
.test-badge { position: absolute; top: calc(74px + var(--safe-t)); right: 12px; margin: 0; padding: 3px 10px; border-radius: 10px; background: #a33; font-size: 15px; }

.side-tools { position: absolute; right: 10px; top: 38%; display: flex; flex-direction: column; gap: 10px; }
.round { width: 64px; height: 64px; border-radius: 32px; border: 1px solid rgba(255, 255, 255, .25); background: var(--glass); backdrop-filter: blur(6px); font-size: 16px; line-height: 1.15; padding: 0; }
.round.gold { background: rgba(196, 140, 50, .88); color: #241707; font-weight: 700; border-color: #f3d38c; height: 72px; }

/* 알림 */
.toasts { position: absolute; top: calc(80px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(92vw, 520px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 12; }
.toast { word-break: keep-all; pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 18px; background: rgba(30, 24, 18, .8); backdrop-filter: blur(6px); font-size: 18px; line-height: 1.4; animation: tin .5s ease-out; }
.toast.big { font-size: 21px; font-family: var(--serif); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .7s; }
.toast .with { flex: none; min-height: 48px; padding: 0 16px; border-radius: 24px; border: 0; background: var(--gold2); color: #2b1d08; font-weight: 700; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* 안내 */
.guide { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(90vw, 420px); padding: 22px 22px 18px; border-radius: 22px; background: rgba(244, 238, 226, .96); color: var(--ink); text-align: center; z-index: 20; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
.guide p { margin: 0 0 10px; font-size: 19px; line-height: 1.5; word-break: keep-all; }
.guide b { color: #8a5a12; }

.stop-btn { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(250px + var(--safe-b)); min-height: 56px; padding: 0 10px 0 20px; border-radius: 28px; border: 0; background: rgba(30, 24, 18, .82); display: flex; align-items: center; gap: 12px; z-index: 6; }
.stop-btn { white-space: nowrap; }
.stop-btn b { padding: 9px 16px; border-radius: 20px; background: #fff; color: var(--ink); }

/* 아래 */
.bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px calc(10px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; background: linear-gradient(to top, rgba(20, 15, 10, .72), rgba(20, 15, 10, .35) 70%, transparent); pointer-events: none; }
.bottom > * { pointer-events: auto; }
.sound-hint { word-break: keep-all; text-align: center; margin: 0; padding: 8px 16px; border-radius: 18px; background: rgba(30, 24, 18, .7); opacity: 0; transition: opacity .8s; }
.sound-hint.on { opacity: 1; }
.choice { width: min(96vw, 520px); padding: 14px; border-radius: 20px; background: rgba(244, 238, 226, .97); color: var(--ink); text-align: center; }
.choice p { margin: 0 0 10px; font-size: 19px; }
.choice .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mala-panel { display: flex; gap: 10px; align-items: center; }
.mala-count { position: absolute; right: 14px; top: calc(80px + var(--safe-t)); margin: 0; padding: 4px 12px; border-radius: 14px; background: var(--glass); font-size: 18px; color: #f4e2bd; }

.music { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 14px; border-radius: 26px; background: rgba(30, 24, 18, .55); max-width: 96vw; }
.music .note { width: 22px; height: 22px; fill: none; stroke: #f3d38c; stroke-width: 2; }
.music .track { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.music.empty { padding-right: 14px; }
.mbtn { width: 48px; height: 48px; border-radius: 24px; border: 0; background: rgba(255, 255, 255, .14); display: flex; align-items: center; justify-content: center; }
.mbtn svg { width: 22px; height: 22px; fill: #fff; } .mbtn .pause { display: none; } .mbtn[aria-pressed="true"] .pause { display: inline; } .mbtn[aria-pressed="true"] .play { display: none; }

.dests { display: flex; gap: 6px; }
.dest { min-height: 48px; padding: 0 14px; border-radius: 24px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(30, 24, 18, .5); font-size: 17px; }
.dest.here { background: rgba(243, 207, 125, .25); border-color: var(--gold2); color: #ffe7b0; }
.actions { display: flex; gap: 8px; width: min(100%, 560px); }
.act { flex: 1 1 0; min-width: 0; min-height: 72px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(244, 238, 226, .94); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; font-size: 18px; font-weight: 600; }
.act .ic svg { width: 28px; height: 28px; fill: none; stroke: #6b4a1e; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.act .lb { white-space: nowrap; }
.act.pour { background: linear-gradient(#f6dc9a, #e3b55a); }
.act.glow { box-shadow: 0 0 0 3px rgba(255, 230, 160, .9), 0 0 24px rgba(255, 210, 120, .8); animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px rgba(255, 230, 160, .5), 0 0 10px rgba(255, 210, 120, .4); } }

.btn { min-height: 56px; padding: 0 22px; border-radius: 28px; border: 0; background: #fff; color: var(--ink); font-size: 18px; font-weight: 600; }
.btn.gold { background: linear-gradient(#f6dc9a, #e3b55a); }
.btn.ghost { background: transparent; border: 1.5px solid currentColor; }
.btn.small { min-height: 52px; padding: 0 18px; font-size: 18px; }
.btn.big { min-height: 64px; padding: 0 30px; font-size: 20px; }
.mala-panel .btn.ghost { color: #fff; }

/* 관불: 영상 */
.scene { position: absolute; inset: 0; z-index: 30; background: #000; }
.frame { position: absolute; inset: 0; outline: none; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.layer.wet, .layer.dry { opacity: 0; }
.pour-cap { position: absolute; left: 0; right: 0; bottom: calc(40px + var(--safe-b)); margin: 0; text-align: center; font-size: 19px; text-shadow: 0 2px 8px #000; }
.thanks { position: absolute; left: 0; right: 0; top: 18%; margin: 0; text-align: center; font-family: var(--serif); font-size: 30px; opacity: 0; transition: opacity 1.2s; text-shadow: 0 2px 12px rgba(0, 0, 0, .7); }
.thanks.on { opacity: 1; }
/* 눈꺼풀 */
.lid { position: absolute; left: -5%; right: -5%; height: 52%; background: #050302; z-index: 35; pointer-events: none; transition: transform var(--lid-ms, 1000ms) cubic-bezier(.45, 0, .55, 1); }
.lid.top { top: 0; transform: translateY(-102%); border-radius: 0 0 50% 50% / 0 0 30% 30%; }
.lid.bot { bottom: 0; transform: translateY(102%); border-radius: 50% 50% 0 0 / 30% 30% 0 0; }
.lids .lid.top, .lids .lid.bot { transform: translateY(0); }
.pouring .bottom, .pouring .side-tools, .pouring .place, .pouring .corner-row { visibility: hidden; }

/* 설정 */
.sheet { position: absolute; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: min(100%, 620px); max-height: 88vh; overflow: auto; background: var(--paper); color: var(--ink); border-radius: 24px 24px 0 0; padding: 18px 20px calc(24px + var(--safe-b)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { font-family: var(--serif); margin: 0; font-size: 24px; }
.sheet h3 { font-size: 19px; margin: 20px 0 6px; }
.small { font-size: 17px; line-height: 1.6; color: #4a433a; }
.mix-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.mix-row input[type=range] { flex: 1; height: 32px; }
.sw { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 18px; }
.sw input { width: 26px; height: 26px; }
.sw.line { margin: 4px 0; }
.info .btn { margin: 14px 8px 0 0; }
.credits li { margin-bottom: 6px; }
.credits a, .small a { color: #7a4a10; }

/* 갈피 */
.galpi-screen { position: absolute; inset: 0; z-index: 60; overflow: auto; background: #241d16; padding: 16px 16px calc(30px + var(--safe-b)); text-align: center; }
.galpi-x { position: absolute; right: 12px; top: 12px; min-height: 52px; padding: 0 18px; border-radius: 26px; border: 1px solid #fff5; background: transparent; }
.galpi-card { margin: 60px auto 12px; width: min(84vw, 360px); }
.galpi-card img { width: 100%; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.share-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.status { min-height: 1.5em; color: #f0e2c4; }
.exit p { color: #d8c9ad; margin: 6px 0; }
.exit .again { color: #fff; margin-top: 10px; }
.modal #main { filter: brightness(.7); }

@media (min-width: 900px) {
  .bottom { flex-direction: column; }
  .actions { width: 560px; }
  .side-tools { top: 30%; }
}
@media (max-height: 640px) { .music { display: none; } }
@media (prefers-reduced-motion: reduce) { .toast, .act.glow { animation: none; } }

/* ===== v4.1: 산사처럼 절제된 반투명 다크 UI ===== */
.place-wrap { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; z-index: 14; }
.place { position: static; display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 0 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 26px; background: rgba(22,18,14,.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-family: var(--serif); font-size: 19px; color: #f5ead6; }
.place-menu { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 20px; background: rgba(22,18,14,.78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); }
.place-menu .dest { min-height: 52px; min-width: 150px; text-align: left; padding: 0 16px; border: 0; border-radius: 14px; background: transparent; font-size: 18px; color: #f5ead6; }
.place-menu .dest:hover, .place-menu .dest:focus-visible { background: rgba(255,255,255,.1); }
.place-menu .dest.here { color: #f3cf7d; }
.pill, .pill.icon { background: rgba(22,18,14,.5); border: 1px solid rgba(255,255,255,.14); }
#musicBtn[aria-expanded="true"] { background: rgba(196,150,70,.6); }
.music { position: absolute; top: calc(74px + var(--safe-t)); right: 10px; z-index: 14; background: rgba(22,18,14,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); border-radius: 26px; }
.music .track { max-width: 46vw; }
.side-tools { top: 42%; }
.round { width: 56px; height: 56px; font-size: 24px; background: rgba(22,18,14,.5); }

/* 하단: 캡슐 한 줄 */
.bottom { background: none; padding-bottom: calc(12px + var(--safe-b)); gap: 10px; }
.actions { width: auto; max-width: calc(100vw - 20px); gap: 2px; padding: 5px; border-radius: 40px; background: rgba(22,18,14,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.act { flex: 0 1 auto; min-width: 64px; min-height: 62px; padding: 4px 10px; border: 0; border-radius: 30px; background: transparent; color: #f5ead6; font-size: 18px; font-weight: 500; gap: 1px; }
.act .ic svg { width: 26px; height: 26px; stroke: #f0d9a8; }
.act:active, .act:hover { background: rgba(255,255,255,.08); }
.act.pour { background: transparent; }
.act.glow { background: rgba(214,170,90,.32); box-shadow: none; animation: glow2 2.6s ease-in-out infinite; }
@keyframes glow2 { 50% { background: rgba(214,170,90,.14); } }
.stop-btn { bottom: calc(96px + var(--safe-b)); background: rgba(22,18,14,.7); backdrop-filter: blur(8px); min-height: 52px; }
.choice { background: rgba(22,18,14,.78); color: #f5ead6; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); }
.choice .btn.ghost { color: #f5ead6; }
.toasts { top: auto; bottom: calc(100px + var(--safe-b)); }
.toast { background: rgba(22,18,14,.68); }
.sound-hint { background: rgba(22,18,14,.55); font-size: 17px; }
.guide { top: auto; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); width: min(92vw, 380px); padding: 14px 16px 12px; background: rgba(22,18,14,.78); color: #f5ead6; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); }
.guide p { font-size: 18px; margin: 0 0 6px; }
.guide b { color: #f3cf7d; }
.guide .btn { min-height: 48px; margin-top: 4px; }
.mala-panel { margin-bottom: 2px; }
.viewing .toasts, .viewing .guide, .viewing .sound-hint, .viewing .title, .viewing .labels { opacity: 0 !important; transition: opacity .6s; pointer-events: none; }
.viewing .bottom > :not(.actions) { opacity: 1; }

/* 이름표: 머리 위 작은 반투명 캡슐 */
.nm { padding: 0 9px; font-size: 14px; line-height: 22px; border-radius: 11px; background: rgba(22,18,14,.42); color: #f5ead6; }
.nm.me { background: rgba(240,210,150,.78); color: #3a2a12; font-weight: 700; }

/* 관불 전환: 부드러운 블러 비네팅 + 흰빛/물결 디졸브 */
.veil { position: absolute; inset: 0; z-index: 35; pointer-events: none; opacity: 0; transition: opacity var(--veil-ms, 1000ms) ease-in-out, backdrop-filter var(--veil-ms, 1000ms) ease-in-out;
  backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px);
  background: radial-gradient(ellipse at center, rgba(255,250,238,0) 25%, rgba(255,246,228,.75) 80%, rgba(255,244,222,.95) 100%); }
.veil.on { opacity: 1; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.veil.white { background: radial-gradient(ellipse at center, rgba(255,252,244,.96) 0%, rgba(255,247,232,1) 100%); }
.veil i { position: absolute; left: 50%; top: 50%; width: 30vmax; height: 30vmax; margin: -15vmax 0 0 -15vmax; border-radius: 50%; border: 2px solid rgba(214,190,140,.55); opacity: 0; }
.veil.on i { animation: ripple 2.2s ease-out infinite; }
.veil.on i.w2 { animation-delay: 1.1s; }
@keyframes ripple { 0% { transform: scale(.2); opacity: .8; } 100% { transform: scale(2.4); opacity: 0; } }
.scene { transition: opacity var(--scene-ms, 900ms) ease-in-out; }
.scene.fade { opacity: 0; }

/* v4.2 첫 안내 순서표 */
.guide .guide-steps { margin: 10px 0 12px; padding-left: 22px; text-align: left; font-size: 15px; line-height: 1.55; }
.guide .guide-steps li { margin: 3px 0; }
.guide .guide-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
