:root {
  --ink: #5A3E45;
  --soft: #8A6F75;
  --pink: #F08FB0;
  --card: #FFFFFF;
  --sky1: #BFE3F7; --sky2: #FDE7EE;
  --hill: #BFE8CF; --hill2: #A6DDBC;
  --shadow: 0 8px 22px rgba(120, 70, 90, .18);
}
body[data-phase="dusk"] { --sky1: #F7A8B8; --sky2: #FFD9A8; --hill: #B5DCC4; --hill2: #9DCFB2; }
body[data-phase="night"] { --sky1: #2E2A55; --sky2: #6B5A9A; --hill: #6F8F8A; --hill2: #5E7D79; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--sky2); color: var(--ink); font-family: Nunito, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, .chip, .btn, .sheet h2 { font-family: Fredoka, Nunito, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.scene { position: fixed; inset: 0; overflow: hidden; }

/* ---------- luar ---------- */
.sky { position: absolute; inset: 0; background: linear-gradient(180deg, var(--sky1), var(--sky2) 75%); transition: background 1s; }
.sunmoon {
  position: absolute; top: 9%; right: 12%; width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #FFF6C9, #FFD97A); box-shadow: 0 0 60px 20px rgba(255, 222, 140, .55);
  animation: float 6s ease-in-out infinite;
}
body[data-phase="dusk"] .sunmoon { top: 30%; background: radial-gradient(circle at 40% 40%, #FFE2B5, #FF9F8A); box-shadow: 0 0 70px 26px rgba(255, 160, 140, .5); }
body[data-phase="night"] .sunmoon { background: radial-gradient(circle at 40% 40%, #FFFBEA, #F4E7B8); box-shadow: 0 0 50px 14px rgba(255, 245, 200, .35); }
body[data-phase="night"] .sunmoon::after { content: ""; position: absolute; inset: -6px -14px 10px 18px; border-radius: 50%; background: var(--sky1); }
.stars { position: absolute; inset: 0 0 40% 0; opacity: 0; transition: opacity 1s;
  background-image: radial-gradient(2px 2px at 12% 18%, #fff, transparent), radial-gradient(2px 2px at 30% 8%, #fff, transparent), radial-gradient(1.5px 1.5px at 48% 22%, #fff, transparent),
    radial-gradient(2px 2px at 66% 12%, #fff, transparent), radial-gradient(1.5px 1.5px at 82% 28%, #fff, transparent), radial-gradient(2px 2px at 20% 34%, #fff, transparent), radial-gradient(1.5px 1.5px at 58% 36%, #fff, transparent);
  animation: twinkle 3s ease-in-out infinite alternate; }
body[data-phase="night"] .stars { opacity: 1; }
.clouds i {
  position: absolute; display: block; width: 130px; height: 42px; border-radius: 40px; background: rgba(255, 255, 255, .92);
  filter: drop-shadow(0 6px 8px rgba(120, 90, 120, .08)); animation: drift linear infinite;
}
.clouds i::before, .clouds i::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.clouds i::before { width: 58px; height: 58px; left: 18px; top: -28px; }
.clouds i::after { width: 44px; height: 44px; left: 64px; top: -18px; }
.clouds i:nth-child(1) { top: 16%; animation-duration: 48s; animation-delay: -10s; }
.clouds i:nth-child(2) { top: 27%; transform: scale(.7); animation-duration: 64s; animation-delay: -40s; }
.clouds i:nth-child(3) { top: 8%; transform: scale(.55); animation-duration: 80s; animation-delay: -20s; }
body[data-phase="night"] .clouds i { background: rgba(255, 255, 255, .18); }

.sign { position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; padding: 0 16px; z-index: 2; }
.sign h1 { margin: 0; font-size: clamp(1.7rem, 6vw, 2.6rem); color: #fff; text-shadow: 0 3px 0 rgba(240, 143, 176, .55), 0 6px 18px rgba(120, 70, 90, .25); letter-spacing: .3px; }
.sign p { margin: 6px 0 0; color: #fff; font-weight: 800; text-shadow: 0 2px 8px rgba(90, 62, 69, .35); }

.house-wrap { position: absolute; left: 50%; bottom: 0; width: min(max(100vw, 125vw), 560px, 75vh); transform: translateX(-50%); transform-origin: 50% 78%; transition: transform 1.5s cubic-bezier(.65, 0, .25, 1), filter 1.5s; }
.house-wrap svg { display: block; width: 100%; height: auto; }
.house-wrap.zoom { transform: translateX(-50%) scale(7); }
#door { cursor: pointer; }
#door-panel { transform-box: fill-box; transform-origin: 50% 100%; }
.house-wrap.open #door-panel { opacity: 0; }
.house-wrap.knocking #door-panel { animation: rattle .18s ease-in-out 4; }
.door-persp { position: absolute; perspective: 380px; perspective-origin: 30% 50%; pointer-events: none; z-index: 2; }
.door-leaf { width: 100%; height: 100%; transform-origin: 0% 50%; transform-style: preserve-3d; transition: transform 1.05s cubic-bezier(.34, .05, .18, 1), filter 1.05s; filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
.door-leaf svg { width: 100%; height: 100%; display: block; backface-visibility: hidden; }
.door-leaf.swing { transform: rotateY(-112deg); filter: drop-shadow(-6px 0 6px rgba(90, 62, 69, .35)) brightness(.92); }
.tok { position: absolute; font: 700 15px Fredoka, sans-serif; color: #fff; text-shadow: 0 2px 6px rgba(90, 62, 69, .5); pointer-events: none; animation: tok .9s ease-out both; z-index: 3; }
#door-light { opacity: 0; transition: opacity .6s .15s; }
.house-wrap.open #door-light { opacity: 1; filter: drop-shadow(0 0 10px #FFE2A6) drop-shadow(0 0 22px #FFD08A); }
body.diving .sky, body.diving .stars, body.diving .sunmoon { transition: transform 1.5s cubic-bezier(.65, 0, .25, 1); transform: scale(1.18); }
body.diving .clouds, body.diving .sign, body.diving .hint { transition: opacity .6s, transform 1.5s cubic-bezier(.65, 0, .25, 1); opacity: 0; transform: scale(1.3); }
#portal { position: fixed; inset: 0; z-index: 21; pointer-events: none; opacity: 1; visibility: hidden;
  background: radial-gradient(circle at var(--px, 50%) var(--py, 60%), #FFFDF5 0, #FFF1D6 35%, #FFE0C2 70%, #FBD0DC 100%);
  clip-path: circle(0 at var(--px, 50%) var(--py, 60%)); transition: clip-path .85s cubic-bezier(.55, 0, .3, 1), opacity .9s ease; }
#portal.on { visibility: visible; clip-path: circle(150% at var(--px, 50%) var(--py, 60%)); }
#portal.out { opacity: 0; }
#knock-ring { transform-box: fill-box; transform-origin: center; animation: knock 2.4s ease-in-out infinite; }
.smoke circle { transform-box: fill-box; animation: smoke 4.5s ease-out infinite; opacity: 0; }
.smoke circle:nth-child(2) { animation-delay: 1.5s; } .smoke circle:nth-child(3) { animation-delay: 3s; }
.win-glow { animation: glow 4s ease-in-out infinite alternate; }
.peek { transform-box: fill-box; transform-origin: 50% 100%; animation: peek 7s ease-in-out infinite; }
.flower { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 3s ease-in-out infinite; }
.flower:nth-child(2n) { animation-delay: -1.2s; }

.hint { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; margin: 0; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(90, 62, 69, .45); animation: float 2.4s ease-in-out infinite; z-index: 2; pointer-events: none; }

/* ---------- dalam ---------- */
#dalam { background: radial-gradient(circle at 50% 35%, #FFF3F6, #F3DDE8 70%); }
body[data-phase="night"] #dalam { background: radial-gradient(circle at 50% 35%, #4A4170, #2C2748 75%); }
#room { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0; will-change: transform; pointer-events: auto; cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; padding: 6px 11px 6px 8px; border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); font-weight: 800; font-size: .84rem; color: var(--ink);
  }
.label .ic { animation: bob 2.6s ease-in-out infinite; display: inline-block; }
.label::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 2px; }
.label .ic { font-size: 1.05rem; }
.label .soon { font-size: .68rem; color: var(--soft); font-weight: 700; }
.label.live { background: var(--pink); color: #fff; }
.label.live .soon { color: #FFE3EC; }
.label.deco { background: linear-gradient(90deg, #F7A8C4, #C9B3EE); }
.hbd-photo { width: 150px; height: 150px; object-fit: cover; border-radius: 18px; border: 8px solid #F3D9A4; box-shadow: var(--shadow); transform: rotate(-3deg); margin-bottom: 8px; }
a.btn { text-align: center; text-decoration: none; }
#cat { position: absolute; left: 0; top: 0; padding: 0; border: 0; background: none; transform-origin: 50% 88%; will-change: transform; cursor: pointer; z-index: 3; }
#cat svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 6px rgba(90, 62, 69, .18)); }
#cat-name { position: absolute; left: 0; top: 0; will-change: transform; z-index: 3; pointer-events: none;
  padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .9); font: 700 .85rem Fredoka, sans-serif; color: var(--ink); box-shadow: var(--shadow); }
.hud { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; z-index: 4; pointer-events: none; }
.hud > div { background: rgba(255, 255, 255, .9); border-radius: 18px; padding: 8px 14px; box-shadow: var(--shadow); }
.hud b { font-family: Fredoka, sans-serif; display: block; }
.hud small { color: var(--soft); font-weight: 700; }
.chip { pointer-events: auto; border: 0; border-radius: 999px; padding: 9px 14px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); font-weight: 600; cursor: pointer; }
.hint.in { color: var(--ink); text-shadow: none; background: rgba(255, 255, 255, .85); width: fit-content; margin: 0 auto; padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); font-size: .82rem; animation: fadeout 1s 6s forwards; }

/* ---------- sheet / gerbang ---------- */
#fade { position: fixed; inset: 0; background: #FFF8F2; opacity: 0; pointer-events: none; transition: opacity .6s; z-index: 20; }
#fade.on { opacity: 1; }
#sheet { position: fixed; inset: 0; z-index: 15; display: flex; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(60, 40, 60, .3); }
.sheet { width: 100%; max-width: 420px; background: var(--card); border-radius: 26px; padding: 20px 18px 16px; box-shadow: var(--shadow); animation: up .35s cubic-bezier(.3, 1.4, .5, 1) both; max-height: 86dvh; overflow-y: auto; }
.sheet h2 { margin: 0 0 4px; font-size: 1.35rem; }
.sheet p { margin: 6px 0 12px; color: var(--soft); font-weight: 700; line-height: 1.45; }
.btn { display: block; width: 100%; border: 0; border-radius: 999px; padding: 13px 18px; margin: 8px 0 0; font-size: 1.05rem; font-weight: 600; background: var(--pink); color: #fff; cursor: pointer; box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px #F9C5D5; }
.btn:disabled { opacity: .5; cursor: default; }
.who { display: flex; gap: 10px; margin: 8px 0 12px; }
.who button { flex: 1; border: 0; border-radius: 18px; padding: 10px; background: #FFF3F6; font-weight: 800; cursor: pointer; }
.who button.sel { box-shadow: 0 0 0 3px var(--pink); background: #fff; }
.sheet input { width: 100%; padding: 12px 14px; border-radius: 16px; border: 2px solid #F9C5D5; font: 700 1.2rem Fredoka, sans-serif; color: var(--ink); text-align: center; }
.sheet input.pin { letter-spacing: 10px; font-size: 1.5rem; }
.err { min-height: 1.2em; color: #C2547A; font-weight: 700; font-size: .9rem; margin: 6px 0 0; }
.shake { animation: shake .4s; }
.game-ic { font-size: 2.4rem; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #FFF1B8; font-size: .78rem; font-weight: 800; color: var(--ink); }
.tag.live { background: #C8EFD9; }
.sheet .cat-big { width: 150px; height: 150px; margin: -6px auto 0; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0; z-index: 30; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700; transition: .25s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes rattle { 25% { transform: rotate(-1.6deg); } 75% { transform: rotate(1.6deg); } }
@keyframes tok { 0% { opacity: 0; transform: translateY(6px) scale(.6); } 25% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-14px) scale(1); } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes twinkle { to { opacity: .55; } }
@keyframes drift { from { left: -180px; } to { left: 110%; } }
@keyframes smoke { 0% { opacity: 0; transform: translate(0, 0) scale(.5); } 20% { opacity: .8; } 100% { opacity: 0; transform: translate(14px, -46px) scale(1.6); } }
@keyframes glow { to { opacity: .7; } }
@keyframes knock { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-14deg); } 86% { transform: rotate(10deg); } }
@keyframes peek { 0%, 55%, 100% { transform: translateY(14px); } 65%, 90% { transform: translateY(0); } }
@keyframes sway { 50% { transform: rotate(5deg); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
@keyframes fadeout { to { opacity: 0; } }
