:root {
  --cream: #FFF4E3; --card: #FFFFFF; --line: #EBD9BF; --ink: #3B2416; --muted: #7A5A44;
  --pink: #C93D63; --teal: #2F8F9D;
  --display: 'Baloo 2', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --body: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--cream); color: var(--ink); font-family: var(--body); font-weight: 700; touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; padding: 0; touch-action: none; }
button:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
svg { display: block; }

#app { max-width: 560px; margin: 0 auto; height: 100dvh; padding: calc(env(safe-area-inset-top) + 8px) 12px calc(env(safe-area-inset-bottom) + 10px); display: flex; flex-direction: column; gap: 8px; }

.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.stat { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.stat small { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat b { font-family: var(--display); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat.time { margin-left: auto; }

.stage { position: relative; flex: none; width: 100%; aspect-ratio: 19 / 18; border-radius: 20px; overflow: hidden; border: 3px solid var(--ink); background: #BFE3EA; }
#view { width: 100%; height: 100%; display: block; }

.overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(255, 244, 227, .92); overflow: auto; }
.card { background: var(--card); border: 3px solid var(--ink); border-radius: 22px; padding: 14px 16px; text-align: center; max-width: 340px; width: 100%; box-shadow: 0 5px 0 var(--ink); }
.card h1, .card h2 { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1; margin: 2px 0 6px; color: var(--teal); }
.card p { margin: 0 0 8px; font-size: 14px; line-height: 1.3; }
.hint { color: var(--muted); font-size: 12px !important; margin: 8px 0 0 !important; }
.hero-pup { width: 150px; margin: 0 auto; }
.levels { display: flex; flex-direction: column; gap: 6px; }
.lvl { display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 12px; border-radius: 14px; border: 3px solid var(--ink); background: var(--teal); color: #fff; box-shadow: 0 4px 0 var(--ink); }
.lvl:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.lvl[disabled] { background: #C9B8A6; cursor: default; box-shadow: 0 4px 0 #8A7866; border-color: #8A7866; }
.lvl .n { font-family: var(--display); font-weight: 800; font-size: 26px; width: 22px; text-align: center; }
.lvl .t { flex: 1; font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1.05; }
.lvl .t small { display: block; font-family: var(--body); font-size: 11px; font-weight: 700; opacity: .9; }
.lvl .b { font-size: 14px; letter-spacing: 1px; }

.final { display: flex; flex-direction: column; align-items: center; margin: 2px 0 6px; }
.final b { font-size: 34px; line-height: 1.1; letter-spacing: 3px; }
.final small { font-family: var(--display); font-weight: 800; font-size: 22px; }
#endNote { font-size: 13px; color: var(--muted); }
.big-btn { display: block; width: 100%; padding: 10px; border-radius: 16px; background: var(--pink); color: #fff; font-family: var(--display); font-weight: 800; font-size: 22px; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); margin-top: 6px; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.small-btn { display: inline-block; margin: 8px 6px 0; padding: 6px 12px; border-radius: 12px; background: #fff; border: 2px solid var(--ink); font-family: var(--display); font-weight: 800; font-size: 15px; }

.pad { flex: 1; min-height: 120px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 0 2px; }
.pad-side { display: flex; gap: 12px; align-items: center; }
.pbtn { width: 84px; height: 84px; border-radius: 26px; background: #fff; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); font-family: var(--display); font-weight: 800; font-size: 28px; color: var(--ink); }
.pbtn.on, .pbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); background: #F3E5D2; }
.pbtn.jump { background: var(--pink); color: #fff; width: 104px; height: 104px; border-radius: 50%; font-size: 24px; }
.pbtn.jump.on { background: #A9304F; }
.pbtn.wrench { background: #FFD166; font-size: 17px; width: 78px; height: 78px; border-radius: 50%; }
.pbtn.wrench.on { background: #E8B94E; }
@media (max-width: 380px) { .pbtn { width: 72px; height: 72px; } .pbtn.jump { width: 92px; height: 92px; } .pbtn.wrench { width: 68px; height: 68px; } }
@media (orientation: landscape) and (max-height: 520px) {
  #app { max-width: none; }
  .stage { flex: 1; width: auto; min-height: 0; aspect-ratio: auto; }
  .pad { position: absolute; inset: auto 12px 12px 12px; min-height: 0; pointer-events: none; }
  .pad button { pointer-events: auto; opacity: .85; }
}
