:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", "Apple SD Gothic Neo", "Malgun Gothic", "Leelawadee UI", sans-serif;
  --ink: #3c2f2a; --muted: #8a7a72; --cream: #fff8ef; --card: rgba(255, 250, 243, .9);
  --peach: #f6b8a2; --rose: #e98a8a; --mint: #8fc4a8; --lav: #b9a7ea; --gold: #f2c14e; --red: #d9604f;
  --shadow: 0 10px 30px rgba(60, 40, 50, .18);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3e4da; color: var(--ink); font-family: var(--font); }
body { overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.btn { border-radius: 18px; padding: 12px 18px; font-weight: 700; background: #fff; box-shadow: 0 3px 0 rgba(60, 40, 50, .12); }
.btn.primary { background: linear-gradient(180deg, #ff9f8a, #ec7b6b); color: #fff; box-shadow: 0 5px 0 #c85e52, var(--shadow); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #c85e52; }
.btn.big { width: 100%; font-size: 22px; padding: 16px; border-radius: 22px; letter-spacing: .3px; }
.btn.ghost { background: rgba(255, 255, 255, .6); }
.btn:disabled { opacity: .5; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; display: grid; place-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 99px; background: var(--card); font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(60, 40, 50, .1); }
.chip.soft { background: rgba(255, 250, 243, .78); }
.muted { color: var(--muted); margin: 0; } .small { font-size: 14px; } .tiny { font-size: 11.5px; line-height: 1.4; }

/* ── entry ── */
#entry { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: calc(var(--sat) + 28px) 16px calc(var(--sab) + 22px);
  background: linear-gradient(180deg, rgba(255, 214, 196, .92) 0%, rgba(250, 226, 214, .55) 45%, rgba(236, 240, 246, .1) 100%); z-index: 20; }
#entry.ready { background: linear-gradient(180deg, rgba(255, 214, 196, .7) 0%, rgba(250, 226, 214, .15) 40%, rgba(236, 240, 246, 0) 100%); }
#entry.ready .entry-bg { opacity: 0; }
.entry-bg { position: absolute; inset: auto 0 0 0; height: 46%; transition: opacity 1.2s; pointer-events: none; }
.entry-bg svg { width: 100%; height: 100%; }
.lang { position: absolute; top: calc(var(--sat) + 14px); right: 14px; z-index: 2; }
.entry-top { text-align: center; position: relative; }
.logo { width: 64px; height: 64px; border-radius: 16px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .15)); }
h1 { margin: 2px 0 0; font-size: 38px; letter-spacing: -.5px; color: #5a3d4a; }
.sub { margin: 2px 0 0; font-weight: 700; color: #a0606a; font-size: 17px; }
.entry-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 28px; padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; text-align: center; position: relative; backdrop-filter: blur(6px); }
.name-row { display: flex; gap: 8px; }
.name-row input { flex: 1; min-width: 0; text-align: center; font-size: 24px; font-weight: 800; color: #5a3d4a; padding: 10px; border-radius: 16px;
  border: 2px dashed #e6c7b6; background: #fffdf9; }
.name-row .icon-btn { width: 56px; height: auto; box-shadow: none; background: #fbe9dc; font-size: 24px; }
.invite { margin: 0; background: #fff1c9; border-radius: 12px; padding: 8px; font-weight: 700; }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
.hud-top { position: absolute; top: calc(var(--sat) + 10px); left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; }
.alt-chip { background: var(--card); border-radius: 18px; padding: 8px 14px; box-shadow: var(--shadow); max-width: 66%; min-width: 0; }
.alt-chip b { margin-right: 3px; }
.alt-chip b { font-size: 26px; } .alt-chip span { font-weight: 700; color: var(--muted); }
.alt-chip small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-right { display: flex; gap: 8px; }
.hud-row { position: absolute; top: calc(var(--sat) + 80px); left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.status { position: fixed; z-index: 16; left: 12px; right: 12px; top: calc(var(--sat) + 172px); margin: auto; max-width: 420px; background: var(--card); border-radius: 18px;
  padding: 10px 12px; box-shadow: var(--shadow); pointer-events: auto; display: flex; flex-direction: column; gap: 8px; text-align: center; font-weight: 700; }
.status .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.status .btn { padding: 9px 14px; font-size: 14px; }
.status canvas { width: 100%; height: 140px; border-radius: 14px; }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 14px); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.breath { width: min(280px, 70vw); height: 8px; border-radius: 9px; background: rgba(255, 255, 255, .55); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08); }
.breath i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #8fd1b0, #9cc8ee); border-radius: 9px; transition: width .1s linear, background .3s; }
.breath i.low { background: linear-gradient(90deg, #f2a07b, #f2c14e); }
.controls { display: flex; align-items: center; gap: 18px; }
.climb { position: relative; width: 124px; height: 124px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffb3a0, #ec7b6b 70%);
  color: #fff; box-shadow: 0 7px 0 #c85e52, var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
.climb b { font-size: 26px; letter-spacing: 1px; } .climb small { font-size: 9.5px; opacity: .9; max-width: 96px; line-height: 1.2; }
.climb.pressed { transform: translateY(4px) scale(.97); box-shadow: 0 3px 0 #c85e52; }
.climb.disabled { filter: grayscale(.6) brightness(1.05); }
.ring { position: absolute; inset: -4px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .95); pointer-events: none; transform: scale(1.5); opacity: 0; }
.side-btn { width: 72px; height: 72px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.side-btn span { font-size: 26px; } .side-btn small { font-size: 11px; font-weight: 700; }
.side-btn.on { background: #ffe9a8; }
.greet-fan { position: absolute; right: 16px; bottom: 96px; display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.greet-fan button { width: 56px; height: 56px; border-radius: 50%; background: var(--card); font-size: 26px; box-shadow: var(--shadow); }
.rest { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(240, 232, 250, .25); }
.rest p { font-weight: 800; font-size: 20px; color: #5a3d4a; background: var(--card); padding: 8px 16px; border-radius: 99px; margin: 0; }
.breath-circle { width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .95), rgba(185, 167, 234, .6)); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.7); } 50% { transform: scale(1.15); } }

/* floating feedback */
.pop { position: fixed; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 6px rgba(120, 60, 60, .45);
  pointer-events: none; animation: popup .9s ease-out forwards; z-index: 30; white-space: nowrap; }
@keyframes popup { from { opacity: 1; transform: translate(-50%, 0) scale(.9); } 30% { transform: translate(-50%, -18px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
body.has-status #toasts { top: calc(var(--sat) + 270px); }
#toasts { position: fixed; top: calc(var(--sat) + 176px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 40; pointer-events: none; }
.toast { background: rgba(60, 47, 52, .86); color: #fff; padding: 10px 16px; border-radius: 16px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow);
  animation: tin .35s ease-out; max-width: 92vw; text-align: center; pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast button { background: #fff; color: var(--ink); border-radius: 12px; padding: 6px 10px; font-weight: 800; }
@keyframes tin { from { transform: translateY(-14px); opacity: 0; } }
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; border-radius: 14px; padding: 3px 8px; font-size: 18px; box-shadow: var(--shadow); white-space: nowrap; }
.bubble small { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 4px; }

/* ── stop sheet ── */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--cream); border-radius: 28px 28px 0 0; box-shadow: 0 -10px 30px rgba(60, 40, 50, .2);
  padding: 16px 16px calc(var(--sab) + 16px); max-height: 66%; overflow-y: auto; animation: sheetIn .35s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet h2 { margin: 0; font-size: 22px; } .sheet .meta { color: var(--muted); font-weight: 700; font-size: 13px; margin: 2px 0 6px; }
.sheet p.desc { margin: 0 0 10px; font-size: 14.5px; line-height: 1.45; }
.sheet .row { display: flex; gap: 8px; margin: 8px 0; }
.sheet .row .btn { flex: 1; font-size: 15px; padding: 12px 8px; }
.rituals { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 8px 0; }
.rit { background: #fff; border-radius: 16px; padding: 10px 4px; box-shadow: 0 3px 0 rgba(60, 40, 50, .1); display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; font-size: 13px; }
.rit span { font-size: 26px; } .rit.done { background: #eaf6ee; } .rit.done::after { content: '✓'; color: #4f9a7c; font-size: 12px; }
.rit-stage { width: 100%; height: 170px; border-radius: 18px; display: block; margin: 6px 0; }
.result { background: #fff; border-radius: 16px; padding: 12px 14px; font-size: 16px; font-weight: 700; line-height: 1.45; margin: 6px 0; animation: tin .3s; }
.result small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 6px; }
.practice-btn { width: 100%; font-size: 20px; padding: 14px; }
.drink-menu { margin: 0; }
.profile { width: 100%; height: 56px; display: block; margin: 2px 0 8px; background: #fff; border-radius: 12px; }
.seat-line { font-size: 13px; color: var(--muted); font-weight: 600; text-align: center; margin: 2px 0 6px; }

/* ── modal ── */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(40, 30, 40, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: 100%; max-width: 520px; max-height: 92%; overflow-y: auto; background: var(--cream); border-radius: 28px 28px 0 0; padding: 18px 16px calc(var(--sab) + 18px); animation: sheetIn .3s; }
.modal-card h2 { margin: 0 0 8px; font-size: 22px; display: flex; justify-content: space-between; align-items: center; }
.modal-card h2 button { background: none; font-size: 22px; }
@media (min-width: 700px) { .modal { align-items: center; } .modal-card { border-radius: 28px; } .sheet { left: 50%; transform: translateX(-50%); width: 520px; } }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list button { text-align: left; background: #fff; border-radius: 16px; padding: 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.menu-list button:disabled { opacity: .55; }
.toggles { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.toggle { border-radius: 99px; padding: 8px 14px; background: #fff; font-weight: 700; font-size: 14px; }
.toggle.on { background: #ffe1d6; color: #b34f45; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.tabs button { flex: none; border-radius: 99px; padding: 8px 12px; background: #fff; font-weight: 700; font-size: 13px; }
.tabs button.on { background: #5a3d4a; color: #fff; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item { background: #fff; border-radius: 16px; padding: 10px 6px; text-align: center; font-size: 12.5px; font-weight: 700; min-height: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px solid transparent; }
.item .ic { font-size: 28px; } .item.on { border-color: #ec7b6b; } .item.locked { opacity: .45; }
.item .r { font-size: 10px; color: var(--muted); }
.swatches { display: flex; gap: 10px; margin: 8px 0; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.swatches button.on { border-color: #5a3d4a; }
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb li { background: #fff; border-radius: 14px; padding: 10px 12px; display: flex; justify-content: space-between; font-weight: 700; }
.lb li.you { background: #fff1c9; } .lb .tag { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 600; }
.map { position: relative; width: 100%; aspect-ratio: 2 / 1; border-radius: 20px; overflow: hidden; margin-bottom: 10px;
  background: radial-gradient(circle at 30% 30%, #d8ecf6, #bcd9ee); }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin { position: absolute; transform: translate(-50%, -100%); font-size: 18px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.pin.on { font-size: 26px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -112%); } }
.mt { background: #fff; border-radius: 16px; padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.mt b { display: block; } .mt small { color: var(--muted); font-size: 12px; }
.mt .badge { flex: none; border-radius: 99px; padding: 6px 10px; font-size: 12px; font-weight: 800; background: #eee; color: #888; }
.mt .badge.play { background: #ec7b6b; color: #fff; }
.photo-view img { width: 100%; border-radius: 18px; display: block; box-shadow: var(--shadow); }
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.album button { padding: 0; border-radius: 12px; overflow: hidden; background: #fff; aspect-ratio: 9 / 16; position: relative; }
.album img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album .empty { display: grid; place-items: center; height: 100%; font-size: 12px; color: var(--muted); padding: 6px; text-align: center; }
/* mystery box */
.box-stage { height: 260px; display: grid; place-items: center; position: relative; }
.mbox { width: 130px; height: 120px; position: relative; cursor: pointer; animation: wobble 1.2s ease-in-out infinite; }
.mbox .body { position: absolute; bottom: 0; width: 100%; height: 86px; border-radius: 16px; background: linear-gradient(180deg, #c9b3f5, #a58ee8); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .1); }
.mbox .lid { position: absolute; top: 6px; left: -8px; right: -8px; height: 34px; border-radius: 12px; background: linear-gradient(180deg, #f7a8c8, #ec8ab0); transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.mbox .ribbon { position: absolute; left: 50%; top: 6px; bottom: 0; width: 22px; transform: translateX(-50%); background: #ffe07a; }
.mbox.open { animation: none; } .mbox.open .lid { transform: translateY(-80px) rotate(-25deg); }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-6deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-3deg); } }
.rays { position: absolute; width: 300px; height: 300px; border-radius: 50%; background: repeating-conic-gradient(rgba(255, 224, 122, .55) 0 12deg, transparent 12deg 30deg); animation: spin 6s linear infinite; opacity: 0; transition: opacity .4s; }
.rays.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal { text-align: center; font-weight: 800; font-size: 20px; animation: tin .4s; }
.reveal .ic { font-size: 54px; display: block; } .reveal .r { font-size: 13px; color: var(--muted); }
#loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 60; background: rgba(255, 245, 238, .4); }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid #fff; border-top-color: #ec7b6b; animation: spin 1s linear infinite; }
.modal-card.half { max-height: 56%; }
.modal:has(.modal-card.half) { background: rgba(40, 30, 40, .12); }

/* ── v3: Tibet trek, pilgrim mode, world card, ceremony ── */
.chip.pilgrim { border: 0; font: inherit; font-size: 13px; font-weight: 700; pointer-events: auto; }
.chip.pilgrim.on { background: #ffe1a6; color: #7a4a1a; }
.climb.glow { box-shadow: 0 7px 0 #c85e52, 0 0 0 6px rgba(255, 216, 120, .55), 0 0 38px rgba(255, 200, 90, .9); }
.climb.bowdue { background: radial-gradient(circle at 35% 30%, #ffd98a, #e9a84a 70%); box-shadow: 0 7px 0 #b9802f, var(--shadow); }
.climb.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.cer-banner { position: absolute; top: calc(var(--sat) + 160px); left: 12px; right: 12px; margin: auto; max-width: 420px; pointer-events: auto;
  background: linear-gradient(90deg, #ffd27a, #f7a86b); color: #5a2f1a; border-radius: 16px; padding: 8px 10px 8px 14px; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; box-shadow: var(--shadow); }
.cer-banner button { background: #fff; border-radius: 12px; padding: 7px 12px; font-weight: 800; }
.world-card { width: 100%; max-width: 400px; background: rgba(255, 250, 243, .82); border-radius: 22px; padding: 10px 12px; box-shadow: var(--shadow); position: relative; text-align: center; backdrop-filter: blur(6px); }
.mini-map { width: 100%; aspect-ratio: 100 / 46; }
.mini-map svg { width: 100%; height: 100%; display: block; }
.world-line { margin: 4px 0 0; font-weight: 800; font-size: 15px; color: #4a3a52; }
.world-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.world-cer { margin: 4px 0 0; font-size: 13px; font-weight: 800; color: #b0603a; }
.pulse { animation: pdot 1.8s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pdot { 50% { opacity: .45; transform: scale(1.8); } }
.lamp-card { display: flex; flex-direction: column; gap: 8px; }
.lamp-card canvas { width: 100%; height: 170px; border-radius: 16px; }
.lamp-card p { margin: 0; font-weight: 800; font-size: 17px; color: #5a3d4a; }
@media (max-height: 760px) { .entry-top h1 { font-size: 30px; } .logo { width: 48px; height: 48px; } .world-card { padding: 8px 10px; } }
