/* PREMIUM · Petualangan Kita — game 8-bit, palet NES, piksel tajam */
:root {
  --bg: #1b1b2f;
  --panel: #2b2b44;
  --panel-hi: #44446a;
  --panel-lo: #15152a;
  --white: #f4f4f4;
  --gold: #fcd34d;
  --red: #c8323a;
  --red-lo: #9d2a2e;
  --px: "Press Start 2P", monospace;
  --vt: "VT323", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: #0f0f1b; color: var(--white); font-family: var(--vt); overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.stage { position: relative; height: 100dvh; max-width: 440px; margin: 0 auto; background: var(--bg); display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.screen { position: relative; flex: none; width: 100%; aspect-ratio: 120 / 150; max-height: calc(100dvh - 176px); margin: 0 auto; background: #000; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

/* HUD */
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 10px 0; font-family: var(--px); font-size: 12px; line-height: 1.6; text-shadow: 2px 2px 0 #000; pointer-events: none; }
.hud .lv b { display: block; color: var(--gold); font-weight: 400; }
.hud-r { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.hearts { color: #ff8a8f; }
.mute { width: 36px; height: 36px; background: rgba(0, 0, 0, .45); border: 2px solid var(--white); font-family: var(--px); font-size: 12px; }
.mute.off { opacity: .5; text-decoration: line-through; }
.bossbar { position: absolute; left: 10px; right: 10px; top: 52px; font-family: var(--px); font-size: 12px; text-shadow: 2px 2px 0 #000; }
.bossbar .bar { height: 10px; margin-top: 6px; border: 2px solid var(--white); background: #000; }
.bossbar i { display: block; height: 100%; width: 100%; background: var(--red); transition: width .2s steps(4); }
.banner { position: absolute; left: 0; right: 0; top: 38%; text-align: center; font-family: var(--px); font-size: 14px; line-height: 1.8; color: var(--white); text-shadow: 3px 3px 0 #000; animation: blink .9s steps(2) 3; pointer-events: none; }
.banner b { display: block; color: var(--gold); font-weight: 400; font-size: 12px; }
@keyframes blink { 50% { opacity: .2; } }

/* dialog */
.dialog { position: absolute; left: 8px; right: 8px; top: 58px; border: 4px solid var(--white); background: #000; box-shadow: 0 0 0 4px #000; padding: 10px 12px 12px; cursor: pointer; }
.dialog .who { display: block; font-family: var(--px); font-weight: 400; font-size: 12px; color: var(--gold); margin-bottom: 6px; }
.dialog p { margin: 0; font-size: 23px; line-height: 1.05; min-height: 48px; }
.dialog .next { position: absolute; right: 10px; bottom: 6px; font-size: 14px; animation: blink .7s steps(2) infinite; }
.opts { display: grid; gap: 6px; margin-top: 10px; }
.opts:empty { display: none; }
.opts button { text-align: left; min-height: 40px; padding: 6px 10px; border: 2px solid var(--white); font-size: 22px; background: #111; }
.opts button:hover, .opts button:focus-visible { background: var(--panel); }
.opts button.right { background: #1f6f3a; }
.opts button.wrong { background: #7a1f24; }

/* tombol */
.pad { flex: 0 1 220px; min-height: 168px; display: flex; justify-content: space-between; align-items: center; padding: 10px 22px max(14px, env(safe-area-inset-bottom)); touch-action: none; }
.dpad { display: flex; gap: 8px; }
.k { touch-action: none; }
.dpad .k { width: 66px; height: 66px; background: var(--panel); box-shadow: inset -4px -4px 0 var(--panel-lo), inset 4px 4px 0 var(--panel-hi); color: #c9c9ec; font-family: var(--px); font-size: 16px; }
.dpad .k.on, .dpad .k:active { box-shadow: inset 4px 4px 0 var(--panel-lo); transform: translateY(2px); }
.ab { display: flex; gap: 14px; transform: rotate(-12deg); }
.ab .k { width: 68px; height: 68px; border-radius: 50%; background: var(--red); box-shadow: inset -5px -5px 0 var(--red-lo), 0 5px 0 #000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ab .k span { font-family: var(--px); font-size: 16px; }
.ab .k small { font-size: 16px; line-height: 1; margin-top: 3px; }
.ab .k.on, .ab .k:active { transform: translateY(4px); box-shadow: inset -2px -2px 0 var(--red-lo), 0 1px 0 #000; }
.ab .b { margin-top: 26px; background: #6c5ce7; box-shadow: inset -5px -5px 0 #3f33a8, 0 5px 0 #000; }
.ab .b.on, .ab .b:active { box-shadow: inset -2px -2px 0 #3f33a8, 0 1px 0 #000; }

/* overlay umum */
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.px-title { margin: 0; font-family: var(--px); font-size: 16px; line-height: 1.6; color: var(--gold); text-shadow: 3px 3px 0 #000; }
.px-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 22px; background: var(--red); box-shadow: inset -4px -4px 0 var(--red-lo), 0 4px 0 #000; font-family: var(--px); font-size: 12px; color: var(--white); text-decoration: none; }
.px-btn:active { transform: translateY(3px); box-shadow: inset -2px -2px 0 var(--red-lo), 0 1px 0 #000; }
.px-btn.ghost { background: var(--panel); box-shadow: inset -4px -4px 0 var(--panel-lo), 0 4px 0 #000; }
.px-link { margin-top: 14px; min-height: 44px; font-size: 21px; color: #c9c9ec; text-decoration: underline; }

/* judul */
.title { background: var(--bg); padding: 0; }
#titleBg { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; object-fit: cover; object-position: center bottom; }
.title::after { content: ""; position: absolute; inset: 0 0 auto; height: 70%; background: linear-gradient(rgba(15, 15, 35, .82), rgba(15, 15, 35, .55) 70%, transparent); pointer-events: none; }
.title-inner { z-index: 1; }
.title-inner { position: relative; display: flex; flex-direction: column; align-items: center; padding: 24px 18px; margin-bottom: 18vh; }
.title .sub { margin: 0; font-size: 22px; color: #dfe4ff; text-shadow: 2px 2px 0 #000; }
.logo { margin: 12px 0 0; font-family: var(--px); font-weight: 400; font-size: clamp(20px, 6.6vw, 26px); line-height: 1.5; color: var(--gold); text-shadow: 3px 3px 0 #b45309, 6px 6px 0 #000; }
.pick-label { margin: 26px 0 10px; font-family: var(--px); font-size: 12px; color: var(--white); text-shadow: 2px 2px 0 #000; }
.pick { display: flex; gap: 14px; }
.pick button { width: 116px; padding: 10px 6px 8px; background: rgba(0, 0, 0, .55); border: 3px solid #666; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 22px; }
.pick button[aria-pressed="true"] { border-color: var(--gold); background: rgba(0, 0, 0, .75); }
.pick canvas { width: 48px; height: 72px; image-rendering: pixelated; }
.start { margin-top: 26px; animation: hop 1s steps(2) infinite; }
@keyframes hop { 50% { transform: translateY(-4px); } }

/* level selesai */
.clear { background: rgba(10, 10, 25, .92); gap: 12px; }
.clear .px-title { margin-bottom: 4px; }
.photo-frame { flex: none; width: min(52%, 190px); aspect-ratio: 1; border: 4px solid var(--white); box-shadow: 0 0 0 4px #000, 8px 8px 0 4px #000; background: #222; position: relative; }
.photo-frame canvas, .photo-frame img { width: 100%; height: 100%; display: block; image-rendering: pixelated; object-fit: cover; }
.clear .caption { margin: 0; font-family: var(--px); font-size: 12px; color: #c9c9ec; }
.clear .msg { margin: 0; font-size: 26px; line-height: 1.05; max-width: 300px; }
.clear .score { margin: 0; font-family: var(--px); font-size: 12px; color: #ff8a8f; }

/* credits */
.credits { background: #000; justify-content: flex-start; overflow: hidden; }
.roll { padding-top: 100%; animation: roll 16s linear forwards; }
@keyframes roll { to { transform: translateY(-100%); } }
.roll.done { animation: none; padding-top: 30px; }
#creditLines p { margin: 22px 0; font-size: 27px; line-height: 1.1; }
.credits .from { margin: 30px 0 0; font-family: var(--px); font-size: 12px; color: var(--gold); }
.final-score { margin: 20px 0 0; font-family: var(--px); font-size: 12px; color: #ff8a8f; }
.thanks { margin: 30px 0 0; font-family: var(--px); font-size: 12px; line-height: 1.8; }
.credit-actions { position: absolute; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 12px; }

@media (max-height: 680px) {
  .pad { min-height: 150px; }
  .dpad .k { width: 58px; height: 58px; }
  .ab .k { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .roll { animation-duration: 1ms; }
  .start, .banner, .dialog .next { animation: none; }
}
