* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; font-family: "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: 0; }

/* ---------- Layar awal ---------- */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50; background: linear-gradient(160deg, #8fd3ff 0%, #c3b5ff 55%, #ffc6e0 100%); padding: 16px; }
.screen.on { display: flex; }
.card { background: #fff; border-radius: 32px; padding: 28px 26px; text-align: center; box-shadow: 0 14px 0 rgba(0,0,0,.08), 0 20px 40px rgba(60,40,140,.2); max-width: 420px; width: 100%; }
.card.wide { max-width: 760px; }
.card h1 { margin: 0 0 6px; font-size: 34px; color: #5f3dc4; letter-spacing: .5px; }
.card .sub { margin: 0 0 14px; color: #868e96; font-size: 17px; }
.code { font-size: 40px; letter-spacing: 6px; color: #343a40; margin: 6px 0 16px; font-weight: bold; }
.code.shake { animation: shake .4s; color: #e03131; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key { height: 70px; border-radius: 22px; background: #f1f3f5; font-size: 32px; font-weight: bold; color: #343a40; box-shadow: 0 6px 0 #dee2e6; display: flex; align-items: center; justify-content: center; }
.key:active { transform: translateY(4px); box-shadow: 0 2px 0 #dee2e6; }
.key.ok { background: #51cf66; color: #fff; box-shadow: 0 6px 0 #2f9e44; }
.key.del { color: #868e96; }
.kids { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-top: 12px; }
.kid { background: #f8f9fa; border-radius: 28px; padding: 18px 18px 14px; width: 170px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 8px 0 #e9ecef; transition: transform .1s; }
.kid:active { transform: translateY(5px) scale(.98); box-shadow: 0 3px 0 #e9ecef; }
.kid .face { width: 92px; height: 92px; border-radius: 18px; position: relative; border: 3px solid rgba(0,0,0,.12); }
.kid .face i { position: absolute; top: 32px; width: 11px; height: 16px; background: #222; border-radius: 50%; }
.kid .face i:first-child { left: 24px; } .kid .face i:nth-child(2) { right: 24px; }
.kid .face b { position: absolute; left: 26px; right: 26px; top: 52px; height: 18px; border: 5px solid #222; border-top: 0; border-radius: 0 0 30px 30px; }
.kid .shirt { width: 120px; height: 46px; border-radius: 14px 14px 8px 8px; margin-top: 4px; border: 3px solid rgba(0,0,0,.12); }
.kid span { margin-top: 10px; font-size: 24px; font-weight: bold; color: #343a40; }
.empty { color: #495057; font-size: 18px; line-height: 1.6; }
.empty a { color: #7048e8; }
.btn { margin-top: 14px; padding: 14px 26px; border-radius: 18px; background: #7c6cf0; color: #fff; font-size: 18px; font-weight: bold; }
.loader { display: flex; gap: 14px; }
.loader i { width: 26px; height: 26px; border-radius: 50%; background: #fff; animation: hop .9s infinite ease-in-out; }
.loader i:nth-child(2) { animation-delay: .15s; } .loader i:nth-child(3) { animation-delay: .3s; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-22px); } }

/* ---------- HUD ---------- */
#hud { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud.on { display: block; }
#hud button, #hud .counters { pointer-events: auto; }
.counters { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); display: flex; gap: 8px; }
.ctr { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.92); border-radius: 22px; padding: 5px 14px 5px 6px; box-shadow: 0 4px 0 rgba(0,0,0,.1); }
.ctr span svg { width: 32px; height: 32px; display: block; }
.ctr b { font-size: 22px; color: #343a40; min-width: 18px; }
.ctr.bump { animation: bump .45s; }
@keyframes bump { 40% { transform: scale(1.3); } }
.topright { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); display: flex; gap: 8px; }
.round { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.92); color: #5f3dc4; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.round svg { width: 28px; height: 28px; }
.round.small { width: 44px; height: 44px; opacity: .75; }
.round.small svg { width: 22px; height: 22px; }
.round:active { transform: translateY(3px); }
#btn-repeat { display: none; background: #ffd43b; color: #5f3dc4; animation: pulse 1.6s infinite; }
#btn-repeat.on { display: flex; }
@keyframes pulse { 50% { transform: scale(1.08); } }
#btn-music .slash { display: none; stroke: #e03131; }
#btn-music.off .slash { display: inline; }
#btn-music.off { color: #adb5bd; }

#banner { position: absolute; top: calc(74px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%) scale(.6); opacity: 0; transition: .25s; background: rgba(255,255,255,.95); border-radius: 26px; padding: 8px 22px 10px; text-align: center; box-shadow: 0 6px 0 rgba(0,0,0,.1); pointer-events: auto; cursor: pointer; }
#banner.on { opacity: 1; transform: translateX(-50%) scale(1); }
#banner .target { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 70px; }
#banner .big { font-size: 64px; color: #7048e8; line-height: 1; }
#banner .spk { font-size: 46px; color: #7048e8; display: flex; }
#banner .emo { font-size: 56px; line-height: 1; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif; }
#banner .slot { display: inline-flex; align-items: center; justify-content: center; min-width: 74px; height: 62px; border-radius: 14px; background: #f1f3f5; color: #adb5bd; font-size: 38px; font-weight: bold; border: 4px solid #ced4da; }
#banner .slot.on { background: #ffe8cc; color: #d9480f; border-color: #ffc078; }
#banner .slot.cur { border-color: #f76707; }
#banner .grp { display: inline-flex; align-items: center; justify-content: center; width: 58px; height: 58px; border-radius: 14px; color: #fff; font-size: 36px; font-weight: bold; }
#banner .grp.red { background: #ff6b6b; } #banner .grp.blue { background: #4dabf7; }
#banner .op { font-size: 40px; color: #495057; }
.dots { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #dee2e6; }
.dots i.on { background: #fab005; }

#caption { position: absolute; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(80vw, 640px); background: rgba(33,37,41,.72); color: #fff; padding: 8px 18px; border-radius: 18px; font-size: 19px; text-align: center; opacity: 0; transition: opacity .2s; }
#caption.on { opacity: 1; }

#celebrate { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0); pointer-events: none; }
#celebrate.on { animation: cel 2.6s ease-out forwards; }
#celebrate .cel { display: flex; gap: 6px; }
#celebrate .cel svg { width: 110px; height: 110px; filter: drop-shadow(0 8px 0 rgba(0,0,0,.15)); }
#celebrate .cel svg:nth-child(2) { width: 140px; height: 140px; margin-top: -20px; }
@keyframes cel { 0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); } 15% { transform: translate(-50%, -50%) scale(1.15) rotate(5deg); } 25% { transform: translate(-50%, -50%) scale(1) rotate(0); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(.8); } }

.flyer { position: fixed; z-index: 30; width: 40px; height: 40px; margin: -20px 0 0 -20px; pointer-events: none; transition: transform .7s cubic-bezier(.5,-0.4,.7,1), opacity .7s; }
.flyer svg { width: 40px; height: 40px; }

/* Joystick & tombol aksi */
#stick { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; background: rgba(255,255,255,.25); border: 3px solid rgba(255,255,255,.6); display: none; }
#stick.on { display: block; }
#knob { position: absolute; left: 35px; top: 35px; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 4px 0 rgba(0,0,0,.15); }
.actions { position: absolute; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); width: 250px; height: 220px; }
.act { position: absolute; width: 70px; height: 70px; border-radius: 50%; background: rgba(124,108,240,.85); display: flex; align-items: center; justify-content: center; box-shadow: 0 5px 0 rgba(0,0,0,.2); touch-action: none; }
.act svg { width: 44px; height: 44px; }
.act span svg { width: 46px; height: 46px; display: block; }
.act.down { transform: translateY(4px) scale(.95); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
#btn-jump { right: 0; bottom: 0; width: 104px; height: 104px; background: rgba(51,154,240,.9); }
#btn-jump svg { width: 60px; height: 60px; }
#btn-eat { right: 118px; bottom: 6px; background: rgba(255,77,141,.85); }
#btn-dance { right: 104px; bottom: 92px; background: rgba(250,176,5,.9); }
#btn-wave { right: 22px; bottom: 126px; background: rgba(81,207,102,.9); }
@media (pointer: fine) and (hover: hover) { .actions { transform: scale(.85); transform-origin: bottom right; } }

/* ---------- Toko ---------- */
#shop { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(30,20,70,.45); padding: 12px; }
#shop.on { display: flex; }
#shop .panel { background: #fff; border-radius: 30px; width: min(760px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 12px 0 rgba(0,0,0,.12); overflow: hidden; }
#shop .head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff3bf; }
#shop .tabs { flex: 1; display: flex; gap: 10px; justify-content: center; }
#shop .tabs button { width: 74px; height: 62px; border-radius: 18px; background: #fff; box-shadow: 0 4px 0 #f1e3a0; display: flex; align-items: center; justify-content: center; }
#shop .tabs button.on { background: #7c6cf0; box-shadow: 0 4px 0 #5f3dc4; }
#shop .items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; padding: 16px; overflow-y: auto; }
#shop .item { background: #f8f9fa; border-radius: 22px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 5px 0 #e9ecef; border: 4px solid transparent; }
#shop .item:active { transform: translateY(3px); }
#shop .item .pic { height: 60px; display: flex; align-items: center; }
#shop .item .nm { font-size: 13px; color: #868e96; }
#shop .item .price { display: flex; align-items: center; gap: 3px; font-size: 20px; font-weight: bold; color: #e67700; min-height: 26px; }
#shop .item .price svg { width: 22px; height: 22px; }
#shop .item.own { background: #ebfbee; }
#shop .item.eq { border-color: #51cf66; }
#shop .item.poor { opacity: .55; }

/* ---------- Malam ---------- */
#night { position: fixed; inset: 0; z-index: 45; display: none; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, rgba(40,50,110,.75), rgba(10,14,40,.92)); color: #fff; text-align: center; }
#night.on { display: flex; animation: fadein 1.5s; }
@keyframes fadein { from { opacity: 0; } }
#night .moon { width: 120px; height: 120px; border-radius: 50%; box-shadow: -26px 10px 0 0 #ffe066; transform: translateX(14px); margin-bottom: 18px; }
#night .zzz span { display: inline-block; font-size: 46px; font-weight: bold; color: #c5d0ff; animation: zz 2.4s infinite; }
#night .zzz span:nth-child(2) { font-size: 36px; animation-delay: .4s; } #night .zzz span:nth-child(3) { font-size: 28px; animation-delay: .8s; }
@keyframes zz { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-14px); opacity: 1; } }
#night .bye { font-size: 32px; margin: 18px 0 8px; }
#night .hint { font-size: 14px; opacity: .6; max-width: 320px; }

#toast { position: fixed; left: 50%; bottom: 40%; transform: translateX(-50%); background: rgba(33,37,41,.85); color: #fff; padding: 10px 18px; border-radius: 16px; z-index: 60; opacity: 0; transition: .2s; pointer-events: none; }
#toast.on { opacity: 1; }

@media (max-height: 480px) {
  .actions { transform: scale(.78); transform-origin: bottom right; }
  #banner { top: 64px; padding: 4px 16px 6px; } #banner .target { min-height: 54px; } #banner .big { font-size: 48px; }
  #caption { bottom: 110px; font-size: 16px; }
}
