:root {
  --sky: #5ec8ff;
  --ink: #2a1a3a;
  --muted: #6b5a7a;
  --card: #fffdf7;
  --sun: #ffd166;
  --orange: #ff9f43;
  --pink: #ff8fab;
  --green: #5bd77a;
  --line: rgba(42, 26, 58, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sky); color: var(--ink); font-family: Fredoka, "Baloo 2", system-ui, sans-serif; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* kamera */
#cam { position: fixed; left: 14px; bottom: 14px; width: 190px; aspect-ratio: 4/3; border-radius: 22px; overflow: hidden; background: #1b2a44; border: 4px solid #fff; box-shadow: 0 14px 30px -12px rgba(42,26,58,.45); z-index: 5; }
#cam video, #cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#cam-status { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; font-size: 12px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(27,42,68,.85)); }

/* HUD */
#hud { position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; align-items: center; z-index: 11; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 3px solid #fff; box-shadow: 0 8px 20px -10px rgba(42,26,58,.4); font-weight: 700; font-size: 20px; line-height: 1; }
.pill small { font-size: 12px; color: var(--muted); }
.pill.score { background: var(--sun); }
.pill .ico { width: 20px; height: 20px; fill: #c77800; }
.pill.gesture { margin-left: auto; background: var(--green); color: #0d3b1d; font-size: 15px; transition: transform .15s; }
.pill.gesture.pulse { transform: scale(1.15); }
.round.off { opacity: .45; text-decoration: line-through; }
.round { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; background: var(--card); font-size: 18px; cursor: pointer; box-shadow: 0 8px 20px -10px rgba(42,26,58,.4); }
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-10px); padding: 10px 18px; border-radius: 999px; background: var(--pink); color: #fff; font-weight: 700; font-size: 20px; opacity: 0; transition: opacity .2s, transform .2s; z-index: 6; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* overlay */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; background: radial-gradient(ellipse at center, rgba(94,200,255,.35), rgba(60,150,220,.55)); z-index: 10; }
.card { position: relative; width: min(520px, 100%); padding: 28px 28px 24px; border-radius: 32px; background: var(--card); border: 5px solid #fff; box-shadow: 0 30px 60px -24px rgba(42,26,58,.5); text-align: center; animation: pop .35s cubic-bezier(.2,.9,.3,1.3) both; }
.card.small { width: min(420px, 100%); }
.mascot { width: 96px; margin: -72px auto 4px; filter: drop-shadow(0 8px 10px rgba(42,26,58,.25)); animation: bob 2.4s ease-in-out infinite; }
h1 { margin: 0; font-size: clamp(40px, 9vw, 60px); font-weight: 700; line-height: 1; letter-spacing: -.01em; }
h1 span { color: var(--orange); }
h2 { margin: 0 0 6px; font-size: 28px; font-weight: 700; }
.lead { color: var(--muted); margin: 8px 0 18px; font-size: 17px; line-height: 1.4; }
.lead b { color: var(--ink); font-size: 22px; }
.moves { list-style: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.moves li { display: grid; justify-items: center; gap: 2px; padding: 12px 8px; border-radius: 20px; background: #eef7ff; border: 2px solid #d8ecff; }
.moves .fig { width: 54px; height: 54px; }
.moves b { font-size: 15px; }
.moves span { font-size: 12px; color: var(--muted); }
.btn { display: block; width: 100%; padding: 14px 18px; border: 0; border-radius: 20px; font: inherit; font-weight: 700; font-size: 18px; cursor: pointer; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.big { color: #fff; background: linear-gradient(180deg, var(--orange), #ff7a1a); box-shadow: 0 6px 0 #d55d00, 0 16px 30px -12px rgba(255,122,26,.6); }
.btn.big:active { box-shadow: 0 2px 0 #d55d00; }
.btn.soft { margin-top: 10px; background: #eef7ff; color: var(--ink); border: 2px solid #d8ecff; }
.fine { font-size: 12px; color: var(--muted); margin: 14px 0 0; line-height: 1.4; }
.bar { height: 14px; border-radius: 99px; background: #eef7ff; border: 2px solid #d8ecff; overflow: hidden; }
#calib-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #9cf0b0); transition: width .2s linear; }
.stars { font-size: 44px; letter-spacing: 4px; color: var(--sun); line-height: 1; margin-bottom: 6px; text-shadow: 0 3px 0 #e0a800; }

/* bintang & power-up */
.pill.coins { background: #fff4c2; transition: transform .15s; }
.pill.coins.pulse { transform: scale(1.15); }
#powers { position: fixed; top: 66px; left: 12px; display: grid; gap: 6px; z-index: 5; pointer-events: none; }
.pw { position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 12px 9px; border-radius: 16px; background: var(--card); border: 3px solid #fff; font-weight: 700; font-size: 14px; box-shadow: 0 8px 20px -10px rgba(42,26,58,.4); overflow: hidden; animation: pop .25s both; }
.pw i { position: absolute; left: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, var(--green), #9cf0b0); font-style: normal; }
.pw.shield i { background: linear-gradient(90deg, #4c9aff, #9ccfff); }
.pw.double i { background: linear-gradient(90deg, #ffb703, #ffe08a); }

/* tombol kecil & dompet */
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.wallet { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: #fff4c2; border: 2px solid #ffe08a; font-weight: 700; font-size: 18px; }
.btn.chip { width: auto; padding: 10px 16px; font-size: 16px; background: #ffe3ef; color: var(--ink); border: 2px solid #ffc2d8; }
.earned { margin: -6px 0 12px; font-size: 20px; font-weight: 700; color: #c77800; }
.earned span { font-size: 15px; color: var(--muted); font-weight: 600; }
.unlock-hint { margin: -4px 0 14px; padding: 8px 12px; border-radius: 14px; background: #eafbea; color: #1d6b33; font-weight: 600; font-size: 15px; }

/* lemari */
#shop { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: flex-end; padding: 16px; pointer-events: none; }
.sheet { pointer-events: auto; width: min(430px, 100%); max-height: calc(100% - 8px); overflow: auto; padding: 18px 18px 16px; border-radius: 28px; background: var(--card); border: 5px solid #fff; box-shadow: 0 30px 60px -24px rgba(42,26,58,.5); animation: pop .3s cubic-bezier(.2,.9,.3,1.3) both; }
.sheet header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet header h2 { margin-right: auto; }
.sheet header .round { box-shadow: none; border-color: #eee6f3; }
.sheet h2 { margin: 0; font-size: 24px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; border-radius: 16px; background: #eef7ff; margin-bottom: 12px; }
.tab { padding: 9px; border: 0; border-radius: 12px; background: transparent; font: inherit; font-weight: 700; font-size: 15px; color: var(--muted); cursor: pointer; }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 4px 10px -6px rgba(42,26,58,.4); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; margin-bottom: 14px; }
.skin { position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 6px 9px; border-radius: 18px; background: #fff; border: 3px solid #eee6f3; font: inherit; cursor: pointer; transition: transform .1s, border-color .15s; }
.skin:active { transform: scale(.96); }
.skin.sel { border-color: var(--orange); box-shadow: 0 0 0 3px #ffe0c2; }
.skin .sw { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: inset 0 -8px 0 rgba(0,0,0,.08); }
.skin .sw::before { content: ""; position: absolute; left: -3px; right: -3px; top: -3px; height: 45%; border-radius: 50% 50% 30% 30% / 100% 100% 30% 30%; background: var(--cream); border: 3px solid var(--ink); border-bottom-width: 0; }
.skin .sw em { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); font-style: normal; font-size: 20px; }
.skin b { font-size: 14px; }
.skin small { font-size: 12px; font-weight: 700; color: var(--muted); }
.skin.locked .sw { filter: grayscale(.85) brightness(1.1); opacity: .7; }
.skin.locked small { color: #c77800; }
.skin.cant small { color: #b35c7a; }
.ups { display: grid; gap: 8px; margin-bottom: 14px; }
.up { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: #fff; border: 3px solid #eee6f3; text-align: left; }
.up .ic { font-size: 30px; text-align: center; }
.up b { display: block; font-size: 15px; }
.up small { color: var(--muted); font-size: 12px; }
.up .lv { display: flex; gap: 4px; margin-top: 4px; }
.up .lv span { width: 22px; height: 7px; border-radius: 9px; background: #eee6f3; }
.up .lv span.on { background: var(--green); }
.up button { padding: 9px 12px; border: 0; border-radius: 14px; background: linear-gradient(180deg, var(--orange), #ff7a1a); color: #fff; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 4px 0 #d55d00; white-space: nowrap; }
.up button:disabled { background: #eee6f3; color: var(--muted); box-shadow: none; cursor: default; }

@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

@media (max-width: 640px) {
  #cam { width: 120px; border-width: 3px; }
  .pill { font-size: 16px; padding: 7px 11px; }
  .pill.best { display: none; }
  #powers { top: 58px; }
  #shop { padding: 8px; }
  .sheet { width: 100%; max-height: 58%; padding: 14px 14px 12px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .card { padding: 22px 16px 18px; }
  .moves li { padding: 10px 6px; }
  .moves .fig { width: 44px; height: 44px; }
  .moves b { font-size: 13px; }
}
/* HP mendatar (layar pendek): kartu dipadatkan supaya tidak terpotong */
@media (max-height: 480px) {
  .overlay { place-items: start center; padding-top: 10px; }
  #over, #pause { padding-top: 56px; }
  .mascot { display: none; }
  .earned { margin: -4px 0 8px; font-size: 17px; }
  .unlock-hint { margin: -2px 0 8px; padding: 5px 10px; font-size: 13px; }
  h2 { font-size: 22px; margin-bottom: 2px; }
  .card .fine, #start .lead { display: none; }
  .moves span { display: none; }
  .card { padding: 16px 18px 14px; }
  h1 { font-size: 36px; }
  .lead { margin: 4px 0 10px; font-size: 15px; }
  .moves { margin-bottom: 10px; }
  .moves li { padding: 6px; }
  .moves .fig { width: 34px; height: 34px; }
  .btn { padding: 10px 14px; font-size: 16px; }
  .fine { margin-top: 8px; }
  .stars { font-size: 26px; margin-bottom: 2px; }
  .sheet { max-height: calc(100% - 4px); }
}
/* HP tegak yang sempit: HUD dipadatkan supaya semua tombol muat */
@media (max-width: 430px) {
  #hud { gap: 5px; }
  .pill { font-size: 14px; padding: 6px 9px; gap: 4px; border-width: 2px; }
  .pill small { font-size: 10px; }
  .round { width: 34px; height: 34px; font-size: 15px; border-width: 2px; }
  .pill.gesture { font-size: 11px; padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .mascot { animation: none; }
  .pill.gesture, #toast, .btn { transition: none; }
}

/* progres: level, misi harian, prestasi */
.btn.chip.ach-btn { background: #fff4c2; border-color: #ffe08a; }
.prog { margin: 0 0 14px;
   padding: 12px 14px; border-radius: 20px; background: #f4f0ff; border: 2px solid #e4dcff; text-align: left; }
.prog h3 { margin: 10px 0 6px; font-size: 15px; }
.lvl { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.lvl b { font-size: 18px; }
.lvl small { font-size: 12px; color: var(--muted); font-weight: 600; }
.bar.xp, .missions .bar, .ach-list .bar, .xp-row .bar { display: block; height: 10px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--green), #9cf0b0); transition: width .4s; }
.bar.xp i { background: linear-gradient(90deg, #8b5cf6, #c4b5fd); }
.next { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.next b { color: var(--ink); }
.missions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.missions li { display: grid; grid-template-columns: 1fr 70px; grid-template-areas: "t b" "s s"; gap: 2px 8px; align-items: center; padding: 7px 10px; border-radius: 14px; background: #fff; border: 2px solid #ece6ff; font-size: 13px; font-weight: 600; }
.missions li span:first-child { grid-area: t; }
.missions li .bar { grid-area: b; }
.missions li small { grid-area: s; font-size: 11px; color: var(--muted); }
.missions li.done { background: #eafbea; border-color: #c7efcc; }
.missions li.bonus { display: block; text-align: center; color: #1d6b33; }
.over-prog { margin: -4px 0 12px; display: grid; gap: 6px; text-align: left; }
.xp-row { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.xp-row .lv { font-weight: 700; }
.xp-row small { color: var(--muted); font-size: 12px; }
.gain { margin: 0; padding: 7px 10px; border-radius: 12px; background: #fff7d6; font-size: 14px; font-weight: 600; }
.gain.lvup { background: #efe7ff; }
.gain.rest { background: #e6f6ff; }
.ach-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; text-align: left; max-height: 55vh; overflow-y: auto; }
.ach-list li { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 16px; background: #fff; border: 2px solid #eee6f3; }
.ach-list li.done { background: #fff8e1; border-color: #ffe08a; }
.ach-list li.stat { display: block; text-align: center; font-size: 13px; color: var(--muted); background: #f4f0ff; border-color: #e4dcff; }
.ach-list .ic { font-size: 28px; text-align: center; }
.ach-list b { display: block; font-size: 15px; margin-bottom: 4px; }
.ach-list small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.skin .ti { display: grid; place-items: center; width: 52px; height: 52px; font-size: 32px; border-radius: 50%; background: #f4f0ff; border: 3px solid var(--ink); }
.skin.locked .ti { filter: grayscale(.7); opacity: .7; }
@media (max-width: 640px) {
  .row { gap: 6px; }
  .row .wallet { padding: 7px 10px; font-size: 16px; }
  .row .btn.chip { padding: 9px 10px; font-size: 14px; }
  .missions li { grid-template-columns: 1fr 54px; font-size: 12.5px; }
}

.prog.after { margin: 14px 0 0; }
