@font-face { font-family: Andika; src: url(../munch/fonts/andika-bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
:root {
  --ink: #2a1850; --paper: #fff8ec; --pink: #ff5d9e; --yellow: #ffd23f; --teal: #2ec4b6; --sky: #8fd3ff;
  --shadow: 0 4px 0 rgba(42, 24, 80, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: Andika, 'Comic Sans MS', system-ui, sans-serif; font-weight: 700; color: var(--ink); background: #2a1850; user-select: none; -webkit-user-select: none; touch-action: none; }
body:not(.ready) .screen { visibility: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.screen { position: fixed; inset: 0; }
.screen[hidden], [hidden] { display: none !important; }

.big { background: var(--yellow); border: 4px solid var(--ink); border-radius: 18px; padding: 10px 28px; font-size: clamp(20px, 4vh, 30px); box-shadow: var(--shadow); }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(42, 24, 80, .35); }
.ghostbtn { background: transparent; border: 3px solid currentColor; border-radius: 14px; padding: 6px 16px; font-size: 16px; }
.mute { background: rgba(255, 255, 255, .85); border-radius: 50%; width: 44px; height: 44px; font-size: 20px; }
.mute.corner { position: absolute; top: 12px; right: 12px; }

/* ---- title */
#title { background: radial-gradient(circle at 50% 40%, #ffe9a8, #ff9ecb 55%, #8a5cf6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh; padding: 16px; }
h1 { margin: 0; display: flex; gap: .3em; flex-wrap: wrap; justify-content: center; font-size: clamp(34px, 9vh, 76px); line-height: 1; }
h1 span { color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); transform: rotate(-3deg); display: inline-block; }
h1 span + span { color: var(--yellow); transform: rotate(2deg); }
.demo .mon { animation: bob 1.6s ease-in-out infinite; }
#title .btns { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.credit { margin: 0; font-size: 15px; opacity: .8; }

/* ---- monsters */
.mon { position: relative; flex: none; }
.mon-box { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mon-box .pt { position: absolute; pointer-events: none; filter: drop-shadow(0 2px 0 rgba(42, 24, 80, .25)); }
.mon-box .pt.back { filter: brightness(.72) saturate(.85); }
.mon-box .arm { animation: wave 2.4s ease-in-out infinite; }
.mon-box .arm.back { animation-delay: -1.2s; }
.mon-box .head { animation: nod 2s ease-in-out infinite; transform-origin: 50% 95%; }
@keyframes wave { 50% { transform: rotate(calc(var(--turn) - 10deg)); } }
@keyframes nod { 50% { transform: rotate(4deg) translateY(2px); } }
@keyframes bob { 50% { transform: translateY(-6px); } }
.mon-box .pt.swing { animation: swing .55s ease-out; }
.mon-box .arm.swing { animation: armswing .55s ease-out; }
@keyframes swing { 40% { transform: scale(1.25) rotate(-8deg); } }
@keyframes armswing { 40% { transform: rotate(calc(var(--turn) + 40deg)) scale(1.15); } }
.mon.lunge { animation: lunge .6s ease-out; }
#foe .mon.lunge { animation-name: lunge-l; }
@keyframes lunge { 35% { transform: translateX(22vw) rotate(6deg); } }
@keyframes lunge-l { 35% { transform: translateX(-22vw) rotate(-6deg); } }
.mon.ouch { animation: ouch .45s; }
@keyframes ouch { 0%, 100% { filter: none; } 20% { transform: translateX(-12px); filter: brightness(2) saturate(0); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } }
.mon.gone { transition: transform .8s, opacity .8s; transform: translateY(30px) rotate(20deg) scale(.6); opacity: 0; }

/* ---- stickers */
.stk { position: relative; background: #fff; border: 4px solid var(--ink); border-radius: 18px; padding: 6px; width: clamp(84px, 17vh, 140px); display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow); }
.stk img { width: 100%; aspect-ratio: 1; object-fit: contain; pointer-events: none; }
.stk .w { font-size: clamp(16px, 3vh, 24px); line-height: 1.1; }
.stk .k { position: absolute; top: -10px; left: -10px; font-style: normal; background: #fff; border: 3px solid var(--ink); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-size: 15px; }
.stk .by { position: absolute; bottom: -12px; font-size: 11px; font-style: normal; background: var(--yellow); border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; white-space: nowrap; }
.stk .super, .stk .x { position: absolute; top: -12px; right: -10px; background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 0 6px; font-size: 13px; transform: rotate(8deg); }
.stk.on { background: #fff3a8; outline: 5px solid var(--pink); }
.stk.weak img { opacity: .7; }
.stk:active { transform: translateY(3px); }
.stk.small { width: clamp(74px, 13vh, 104px); }
.stk.locked { background: rgba(255, 255, 255, .4); border-style: dashed; box-shadow: none; }
.stk.locked img { filter: brightness(0); opacity: .25; }
.stk.none { justify-content: center; min-height: 80px; }

/* ---- building */
#build { background: linear-gradient(#bfe8ff, #e9ffd8); display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; padding: 12px; }
#build h2 { margin: 0; font-size: clamp(26px, 6vh, 44px); }
.preview { display: grid; place-items: end center; min-height: 30vh; }
.ghost { font-size: 15vh; opacity: .3; }
.choices { display: flex; gap: clamp(10px, 3vw, 26px); justify-content: center; flex-wrap: wrap; }
@media (orientation: landscape) and (max-height: 520px) {
  #build { display: grid; grid-template-columns: 1fr 1.4fr; grid-template-rows: auto 1fr auto; align-items: center; justify-items: center; }
  #build h2 { grid-column: 1 / -1; }
  #build .preview { grid-row: 2 / 4; }
}

/* ---- map */
#map { background: #000; }
#viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
#world { position: absolute; left: 0; top: 0; background-size: 100% 100%; will-change: transform; }
.spot { position: absolute; background: none; padding: 0; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; animation: bobspot 2s ease-in-out infinite; }
@keyframes bobspot { 50% { margin-top: -5px; } }
.spot .tag { background: rgba(255, 255, 255, .92); border: 3px solid var(--ink); border-radius: 12px; padding: 1px 8px; font-size: 14px; white-space: nowrap; margin-top: -6px; }
.spot.boss .mon { filter: brightness(.55) saturate(.4); }
.spot.boss.awake .mon { filter: drop-shadow(0 0 12px #ff3d6e); animation: shake .5s infinite; }
.spot.boss.done .mon { filter: none; }
.spot.boss .tag { background: var(--yellow); }
@keyframes shake { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px max(10px, env(safe-area-inset-left)); pointer-events: none; flex-wrap: wrap; }
.bar > * { pointer-events: auto; }
.bar button { background: rgba(255, 255, 255, .92); border: 3px solid var(--ink); border-radius: 14px; min-width: 44px; height: 44px; font-size: 18px; padding: 0 10px; display: flex; align-items: center; gap: 6px; }
.bar button:disabled { opacity: .4; }
#land-name { background: var(--ink); color: #fff; border-radius: 14px; padding: 6px 14px; font-size: 20px; }
#wake { background: rgba(255, 255, 255, .92); border: 3px solid var(--ink); border-radius: 14px; padding: 6px 12px; font-size: 15px; }
.grow { flex: 1; }
#me-mini { display: inline-block; height: 40px; overflow: hidden; margin: -6px 0; }
#me-mini .mon { transform: scale(.55); transform-origin: 0 0; height: 40px !important; }
#b-lab { height: 52px !important; }
#arrow { position: absolute; font-size: 46px; color: #ff3d6e; -webkit-text-stroke: 2px #fff; pointer-events: none; animation: pulse .8s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
@media (max-width: 640px) { .lbl { display: none; } #wake { font-size: 13px; } }

/* ---- battle */
#battle { background-size: cover; background-position: center; display: flex; flex-direction: column; }
#battle::before { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .35); backdrop-filter: blur(3px); }
#battle > * { position: relative; }
.hud { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; }
.hp { display: flex; align-items: center; gap: 6px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 10px; flex: 1; max-width: 380px; box-shadow: var(--shadow); }
.hp b { white-space: nowrap; font-size: 16px; }
.barbg { flex: 1; height: 14px; background: #e4dcef; border-radius: 8px; overflow: hidden; border: 2px solid var(--ink); }
.barfg { height: 100%; background: linear-gradient(#7ef08a, #2fbf4a); transition: width .4s; }
.theirs .barfg { background: linear-gradient(#ff98b7, #ff3d6e); }
.hp span:last-child { min-width: 28px; text-align: right; }
.arena { flex: 1; display: flex; justify-content: space-around; align-items: flex-end; padding: 0 4vw; min-height: 0; }
.side { position: relative; display: flex; align-items: flex-end; }
.side .mon { animation: bob 1.8s ease-in-out infinite; }
#foe .mon { animation-delay: -.9s; }
.dmg { position: absolute; top: 10%; left: 50%; transform: translateX(-50%); font-size: 40px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; animation: rise 1.1s forwards; z-index: 5; }
.dmg.big { font-size: 56px; color: var(--yellow); }
@keyframes rise { to { transform: translate(-50%, -70px); opacity: 0; } }
#msg { text-align: center; margin: 4px auto; font-size: clamp(18px, 3.6vh, 26px); background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 16px; min-height: 1.6em; }
#moves { display: flex; justify-content: center; gap: 14px; padding: 8px 8px max(14px, env(safe-area-inset-bottom)); }
#moves .stk { width: clamp(58px, 14vh, 120px); padding: 3px; }
@media (max-height: 420px) { .hud { padding: 4px 10px; } #msg { margin: 2px auto; padding: 2px 12px; } #moves { padding-top: 4px; gap: 10px; } }
#moves.off { pointer-events: none; opacity: .5; }
#b-run { position: absolute; bottom: 14px; right: 14px; background: #fff; border: 3px solid var(--ink); border-radius: 50%; width: 46px; height: 46px; font-size: 20px; }
.kinds { position: absolute; bottom: 4px; left: 12px; margin: 0; font-size: 12px; opacity: .75; }
@media (max-width: 640px) { .kinds { display: none; } }

/* ---- quiz */
#quiz { position: fixed; inset: 0; background: rgba(42, 24, 80, .55); display: grid; place-items: center; z-index: 20; padding: 12px; }
.qcard { background: var(--paper); border: 5px solid var(--ink); border-radius: 26px; padding: 14px 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 94vw; max-height: 96vh; box-shadow: 0 8px 0 rgba(0, 0, 0, .3); position: relative; animation: popin .25s ease-out; }
@keyframes popin { from { transform: scale(.8); opacity: 0; } }
.qpic { height: clamp(90px, 28vh, 220px); max-width: 60vw; object-fit: contain; }
.ask { margin: 0; font-size: clamp(18px, 3.4vh, 24px); }
.opts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.opt { background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 8px 20px; font-size: clamp(28px, 6.5vh, 46px); min-width: 2.6em; box-shadow: var(--shadow); letter-spacing: .02em; }
.opt.yes { background: #7ef08a; }
.opt.no { opacity: .35; text-decoration: line-through; animation: no .3s; }
.opt.hint { outline: 6px solid var(--yellow); animation: pulse .8s infinite; }
@keyframes no { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.gapword { font-size: clamp(36px, 8vh, 60px); letter-spacing: .04em; }
.hole { display: inline-block; min-width: .8em; border-bottom: 5px solid var(--pink); color: var(--pink); text-align: center; margin: 0 2px; }
.hear { position: absolute; top: 10px; right: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 50%; width: 48px; height: 48px; font-size: 22px; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.slot { width: clamp(34px, 7.5vh, 54px); height: clamp(44px, 9.5vh, 68px); border-radius: 10px; display: grid; place-items: center; font-size: clamp(28px, 6.5vh, 46px); background: #fff; border: 3px solid var(--ink); }
.slot.blank { background: #f1e8ff; border-style: dashed; }
.slot.now { outline: 4px solid var(--pink); }
.slot.ghost { color: rgba(42, 24, 80, .3); }
.slot.filled { background: #d9ffd9; border-style: solid; }
.slots.done .slot { background: #7ef08a; animation: bob .4s; }
.tray { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.tile { width: clamp(46px, 9vh, 64px); height: clamp(46px, 9vh, 64px); background: var(--yellow); border: 4px solid var(--ink); border-radius: 14px; font-size: clamp(26px, 6vh, 40px); box-shadow: var(--shadow); }
.tile.used { visibility: hidden; }
.tile.bounce { animation: no .3s; background: #ffb3c6; }
.qcard.wide .choices { margin: 10px 0 8px; }
@media (max-height: 460px) { .qcard { flex-direction: row; flex-wrap: wrap; justify-content: center; } .qpic { height: 30vh; } }

/* ---- workshop */
#lab { background: linear-gradient(135deg, #ffe9a8, #ffc6e0); display: flex; gap: 12px; padding: 12px; }
#lab .left { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; flex: none; width: min(36vw, 320px); }
#lab .left p { margin: 0; text-align: center; }
#lab .rows { flex: 1; overflow-y: auto; touch-action: pan-y; padding-bottom: 20px; }
#lab h3 { margin: 6px 0; }
#lab .list { display: flex; gap: 12px; overflow-x: auto; padding: 12px 6px 16px; touch-action: pan-x pan-y; }
#lab .list .stk { flex: none; }
@media (orientation: portrait) { #lab { flex-direction: column; } #lab .left { width: auto; flex-direction: row; } #lab .preview { min-height: 0; } }

/* ---- champion */
#champ { background: radial-gradient(circle, #fff3a8, #ff9ecb 60%, #8a5cf6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; padding: 16px; }
#champ .sub { font-size: 20px; margin: 0; }

#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 16px; font-size: 18px; z-index: 30; max-width: 92vw; text-align: center; }
