:root { --chalk: #f5f1e6; --dark: #24202b; --gold: #ffe296; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--dark); color: var(--chalk);
  font-family: "Comic Neue", "Chalkboard SE", "Segoe Print", "Bradley Hand", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: block; }
#title, #levels { background: url(../assets/bg/ch1_senja_emas.webp) center / cover; }
#title { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; }
#title.on { display: flex; }
#title::before, #levels::before { content: ""; position: absolute; inset: 0; background: rgba(20, 14, 30, .25); }
#title > * , #levels > * { position: relative; }
.logo { width: min(62vw, 110vh); filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
.note { margin: 0; font-size: 14px; opacity: .85; text-shadow: 0 1px 3px #000; }
.ver { position: absolute; bottom: 10px; font-size: 12px; opacity: .6; }

.chalk-btn { font: inherit; color: var(--chalk); background: rgba(36, 32, 43, .88); border: 3px dashed rgba(245,241,230,.85);
  border-radius: 999px; padding: .4em 1.2em; font-size: 22px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.35); text-shadow: 0 0 6px rgba(255,255,255,.25); }
.chalk-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.chalk-btn:disabled { opacity: .5; }
.chalk-btn.big { font-size: 30px; padding: .35em 2em; }
.chalk-btn.icon { width: 56px; height: 56px; padding: 0; font-size: 26px; display: grid; place-items: center; }
.chalk-btn.go { width: 68px; height: 68px; font-size: 30px; border-color: var(--gold); color: var(--gold); }
[hidden] { display: none !important; }

#levels header { display: flex; align-items: center; gap: 16px; padding: 16px 24px; }
#levels h2 { margin: 0; font-size: 28px; text-shadow: 0 2px 4px #000; }
#level-list { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 24px; justify-content: center; }
.lvl { font: inherit; color: var(--chalk); width: 150px; height: 130px; border-radius: 18px; cursor: pointer;
  background: rgba(36,32,43,.9); border: 3px dashed rgba(245,241,230,.8); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; box-shadow: 0 5px 0 rgba(0,0,0,.35); }
.lvl .n { font-size: 34px; font-weight: 700; }
.lvl .t { font-size: 14px; opacity: .9; }
.lvl .s { color: var(--gold); font-size: 18px; letter-spacing: 2px; }
.lvl .s i { font-style: normal; color: rgba(245,241,230,.25); }

#play { pointer-events: none; }
#play button { pointer-events: auto; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: 10px;
  display: flex; align-items: center; gap: 12px; }
#lvl-name { font-size: 18px; font-weight: 700; text-shadow: 0 2px 4px #000; }
.kapur-meter { display: flex; align-items: center; gap: 8px; background: rgba(36,32,43,.8); padding: 4px 12px 4px 6px; border-radius: 999px; }
.kapur-meter img { height: 46px; }
.kapur-meter .bar { width: 120px; height: 12px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; }
#kapur-fill { height: 100%; width: 100%; background: var(--chalk); border-radius: 8px; transition: width .1s; }
.hud-bottom { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 12px; align-items: center; }
#bubble { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: min(70vw, 620px);
  background: rgba(245,241,230,.95); color: var(--dark); padding: 10px 18px; border-radius: 18px; font-size: 17px; font-weight: 700;
  box-shadow: 0 4px 0 rgba(0,0,0,.3); text-align: center; }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(10,8,16,.55); }
.board { position: relative; background: #2a2630; border: 4px dashed rgba(245,241,230,.8); border-radius: 22px;
  padding: 20px 36px 18px; text-align: center; min-width: 340px; box-shadow: 0 10px 0 rgba(0,0,0,.35); }
.board h3 { margin: 0 0 6px; font-size: 24px; }
.kapur-cheer { position: absolute; left: -46px; bottom: 6px; height: 120px; animation: hop .8s ease-in-out infinite alternate; }
#res-stars { font-size: 52px; letter-spacing: 8px; }
#res-stars span { color: rgba(245,241,230,.2); display: inline-block; transform: scale(0); animation: pop .45s forwards; }
#res-stars span.on { color: var(--gold); text-shadow: 0 0 14px rgba(255,220,140,.8); }
#res-info { margin: 4px 0 12px; font-size: 16px; }
#res-info small { opacity: .7; }
.board .row { display: flex; gap: 16px; justify-content: center; }
@keyframes pop { 60% { transform: scale(1.35) rotate(-8deg); } 100% { transform: scale(1); } }
@keyframes hop { to { transform: translateY(-8px) rotate(4deg); } }

#rotate { position: fixed; inset: 0; z-index: 9; background: var(--dark); display: grid; place-content: center; text-align: center; }
#rotate div { font-size: 64px; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(90deg); } }
@media (max-height: 420px) {
  .chalk-btn.icon { width: 48px; height: 48px; font-size: 22px; }
  .chalk-btn.go { width: 58px; height: 58px; }
  .kapur-meter img { height: 38px; }
  .lvl { width: 130px; height: 110px; }
}

.img-btn { width: 58px; height: 58px; padding: 0; border: 0; background: none; cursor: pointer; filter: drop-shadow(0 4px 3px rgba(0,0,0,.4)); }
.img-btn img { width: 100%; height: 100%; display: block; pointer-events: none; }
.img-btn.go { width: 72px; height: 72px; }
.img-btn:active { transform: translateY(2px) scale(.96); }
#res-stars img { width: 64px; height: 64px; margin: 0 4px; transform: scale(0); animation: pop .45s forwards; }
#res-stars img.on { filter: drop-shadow(0 0 10px rgba(255,210,120,.8)); }
.board { background: url(../assets/ui/papan.webp) center / 100% 100% no-repeat; border: 0; box-shadow: none; padding: 34px 54px 30px; }
#bubble { background: rgba(36,32,43,.92); color: var(--chalk); border: 3px solid rgba(245,241,230,.85); }
@media (max-height: 420px) { .img-btn { width: 50px; height: 50px; } .img-btn.go { width: 62px; height: 62px; } #res-stars img { width: 52px; height: 52px; } }
