@font-face { font-family: 'andika'; src: url('../munch/fonts/andika-bold.woff2') format('woff2'); font-weight: 700 900; font-display: block; }
@font-face { font-family: 'andika'; src: url('../munch/fonts/andika-regular.woff2') format('woff2'); font-weight: 400 600; font-display: block; }

:root {
  --ink: #1d2b3a; --cream: #fff9ec; --paper: #fdf3dc; --sun: #ffc23d; --gold: #f2b01e; --sea: #1d6f8f; --deep: #123246;
  --mint: #2fbf7f; --tomato: #ff5d4a; --violet: #9b5cff; --orange: #ff8a1f; --teal: #1fb5c9;
  --font: 'andika', 'Century Gothic', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; background: #8ccbf0; font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ── hud */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud .hotbar, #hud .pico { pointer-events: auto; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; }
.crosshair::before, .crosshair::after { content: ''; position: absolute; background: #fff; mix-blend-mode: difference; }
.crosshair::before { left: 10px; top: 0; width: 2px; height: 22px; }
.crosshair::after { top: 10px; left: 0; height: 2px; width: 22px; }
.mine-ring { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; opacity: 0; transition: opacity .1s; }
.mine-ring.on { opacity: 1; }
.mine-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mine-ring circle { fill: none; stroke: #fff; stroke-width: 4; stroke-dasharray: 0 100; stroke-linecap: round; filter: drop-shadow(0 0 2px #0008); }

.top-left { position: absolute; left: 10px; top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lvl { display: flex; align-items: center; gap: 6px; background: #0007; border-radius: 999px; padding: 3px 10px 3px 3px; color: #fff; }
.lvl b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--mint); font-size: 15px; box-shadow: inset 0 -3px 0 #0003; }
.xpbar { width: 90px; height: 8px; border-radius: 4px; background: #fff3; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7dffb2, #2fbf7f); transition: width .4s; }
.chip { background: #0007; color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 15px; font-weight: 700; }
.quest-mini { background: #0006; color: #fff; border-radius: 12px; padding: 6px 10px; font-size: 15px; line-height: 1.35; max-width: 260px; }
.quest-mini:empty { display: none; }
.quest-mini .q { display: flex; gap: 6px; align-items: center; }
.quest-mini .q.done { opacity: .6; text-decoration: line-through; }
.quest-mini .bar { flex: none; font-variant-numeric: tabular-nums; color: var(--sun); }

.top-right { position: absolute; right: 10px; top: calc(10px + var(--safe-t)); display: flex; gap: 6px; align-items: center; }
.hbtn { width: 46px; height: 46px; border-radius: 14px; background: #0007; font-size: 22px; display: grid; place-items: center; box-shadow: inset 0 -3px 0 #0004; }
.hbtn:active { transform: translateY(2px); }
.compass { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(#fff9ec, #e8d6a8); border: 3px solid var(--gold); display: grid; place-items: center; font-size: 20px; color: var(--tomato); }
.compass i { display: inline-block; transition: transform .2s; font-style: normal; }

.hotbar { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 3px; background: #0006; padding: 4px; border-radius: 12px; }
.slot { position: relative; width: 50px; height: 50px; border-radius: 9px; background: #ffffff1a; border: 2px solid transparent; display: grid; place-items: center; }
.slot.sel { border-color: #fff; background: #ffffff3a; box-shadow: 0 0 0 2px #0006; }
.slot img { width: 38px; height: 38px; image-rendering: pixelated; pointer-events: none; }
.slot .em { font-size: 28px; pointer-events: none; }
.slot b { position: absolute; right: 3px; bottom: 0; color: #fff; font-size: 13px; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
@media (max-width: 560px) { .slot { width: 36px; height: 36px; } .slot img { width: 27px; height: 27px; } .slot .em { font-size: 20px; } .hotbar { gap: 2px; padding: 3px; } }

.tut { position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--cream); border-radius: 18px; padding: 10px 10px 10px 14px; max-width: min(620px, 62vw); font-size: 21px; font-weight: 700; line-height: 1.3; box-shadow: 0 4px 14px #0005; pointer-events: auto; animation: pop .25s; }
.tut b { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--sun); font-size: 17px; }
.tut.talking { box-shadow: 0 0 0 4px var(--sun), 0 4px 14px #0005; }
.tut button { flex: none; width: 44px; height: 44px; border-radius: 50%; background: #0000000f; font-size: 20px; }
.tut button#tut-hear { background: var(--teal); color: #fff; }
@media (max-width: 700px) { .tut { top: calc(62px + var(--safe-t)); max-width: 92vw; font-size: 17px; } }
.pico-face.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); box-shadow: 0 0 0 8px #ffc23d88; } }
.pico { position: absolute; left: 10px; bottom: calc(76px + var(--safe-b)); display: flex; align-items: flex-end; gap: 8px; max-width: min(460px, 70vw); }
.pico-face { flex: none; width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #b6f0ff, #3ab0d8); border: 3px solid #fff; font-size: 34px; display: grid; place-items: center; box-shadow: 0 3px 8px #0004; cursor: pointer; transform-origin: 50% 90%; }
.pico-face.talk { animation: bob .28s ease-in-out infinite alternate; }
@keyframes bob { from { transform: rotate(-6deg) scale(1); } to { transform: rotate(6deg) scale(1.06); } }
.pico-say { background: var(--cream); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-size: 20px; line-height: 1.35; box-shadow: 0 3px 10px #0004; animation: pop .2s; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@media (max-width: 560px) { .pico { bottom: calc(52px + var(--safe-b)); } .pico-face { width: 46px; height: 46px; font-size: 26px; } .pico-say { font-size: 15px; } }

.toast-box { position: absolute; right: 12px; bottom: calc(80px + var(--safe-b)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.toast { background: #000a; color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 16px; display: flex; gap: 6px; align-items: center; animation: toast 2.4s forwards; }
.toast img { width: 22px; height: 22px; image-rendering: pixelated; }
@keyframes toast { 0% { transform: translateX(30px); opacity: 0; } 10%, 80% { transform: none; opacity: 1; } 100% { opacity: 0; } }

.touch-ui { position: absolute; inset: 0; pointer-events: none; }
.joy { position: absolute; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; background: #fff2; border: 2px solid #fff5; display: none; }
.joy.on { display: block; }
.joy i { position: absolute; left: 30px; top: 30px; width: 50px; height: 50px; border-radius: 50%; background: #fff8; }
.jump-btn { position: absolute; right: 22px; bottom: calc(86px + var(--safe-b)); width: 72px; height: 72px; border-radius: 50%; background: #fff3; border: 2px solid #fff7 !important; color: #fff; font-size: 34px; pointer-events: auto; }
.click-to-play { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: #000a; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 18px; }

/* ── title */
#title { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(#0000 40%, #0005), transparent; padding: 20px; overflow: auto; }
.title-card { text-align: center; max-width: 520px; width: 100%; }
.logo { margin: 0; line-height: .85; font-weight: 900; letter-spacing: -1px; text-transform: uppercase; filter: drop-shadow(0 6px 0 #0005); }
.logo span { display: block; }
.logo .l1 { font-size: clamp(56px, 15vw, 104px); color: var(--sun); -webkit-text-stroke: 3px #7a4a08; paint-order: stroke fill; }
.logo .l2 { font-size: clamp(42px, 11vw, 76px); color: #fff; -webkit-text-stroke: 3px var(--deep); paint-order: stroke fill; margin-top: 4px; }
.tagline { color: #fff; font-size: 20px; text-shadow: 0 2px 4px #0008; margin: 14px 0 18px; }
.lang-pick { display: inline-flex; background: #0005; border-radius: 999px; padding: 4px; gap: 4px; }
.lang-pick button { padding: 8px 18px; border-radius: 999px; background: transparent; color: #fff; font-size: 17px; font-weight: 700; }
.lang-pick button.on { background: #fff; color: var(--ink); }
.age-pick { margin-top: 16px; background: #0005; border-radius: 18px; padding: 12px; color: #fff; }
.age-pick p { margin: 0 0 8px; font-size: 18px; }
.ages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ages button { min-width: 54px; padding: 10px 8px; border-radius: 12px; background: #fff2; color: #fff; font-weight: 700; font-size: 18px; }
.ages button.on { background: var(--sun); color: var(--ink); }
.title-btns { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 20px; }
.big { padding: 16px 48px; border-radius: 18px; background: var(--mint); color: #fff; font-size: 26px; font-weight: 900; box-shadow: inset 0 -5px 0 #0003, 0 6px 14px #0004; }
.big:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 #0003; }
.big:disabled { opacity: .5; }
.title-small { padding: 8px 18px; border-radius: 12px; background: #0005; color: #fff; font-size: 15px; }
.loading { color: #fff; min-height: 1.4em; text-shadow: 0 1px 3px #000; }
.back-home { position: fixed; left: 14px; top: calc(12px + var(--safe-t)); color: #fff; text-decoration: none; font-size: 15px; background: #0005; padding: 6px 12px; border-radius: 999px; }

/* ── panels */
#panel { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; padding: max(10px, var(--safe-t)) 10px max(10px, var(--safe-b)); z-index: 5; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.panel-card { touch-action: pan-y; position: relative; background: var(--paper); border-radius: 22px; width: min(640px, calc((100vw - 20px) / var(--z, 1))); max-height: calc((100dvh - 20px) / var(--z, 1)); zoom: var(--z, 1); overflow: auto; padding: 18px 18px 20px; box-shadow: 0 10px 40px #0007, inset 0 0 0 4px #e8d3a4; animation: pop .2s; }
.panel-card.wide { width: min(860px, calc((100vw - 20px) / var(--z, 1))); }
.panel-card h2 { margin: 0 44px 10px 0; font-size: 26px; display: flex; align-items: center; gap: 8px; }
.x { position: absolute; right: 12px; top: 12px; width: 38px; height: 38px; border-radius: 50%; background: #0001; font-size: 22px; line-height: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { padding: 7px 14px; border-radius: 999px; background: #0000000f; font-weight: 700; }
.tabs button.on { background: var(--ink); color: #fff; }

/* questions */
.q-emoji { font-size: 92px; text-align: center; line-height: 1.1; margin: 6px 0; }
.q-prompt { font-size: 30px; line-height: 1.45; text-align: center; margin: 6px 0 14px; }
.q-prompt.long { font-size: 24px; text-align: left; }
.passage { background: #fffdf6; border-radius: 14px; padding: 14px 18px; font-size: 26px; line-height: 1.55; margin-bottom: 12px; border: 2px solid #ecdcb8; }
.passage h3 { margin: 0 0 4px; font-size: 28px; }
.w { cursor: pointer; border-radius: 4px; }
.w:hover { background: #ffc23d55; }
.w.speaking { background: var(--sun); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.one { grid-template-columns: 1fr; }
.choice { padding: 14px 10px; border-radius: 16px; background: #fff; font-size: 30px; font-weight: 700; box-shadow: inset 0 -4px 0 #0001, 0 2px 0 #0001; border: 3px solid #e7d6ae !important; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 66px; }
.choice .ce { font-size: 36px; }
.choice.small { font-size: 21px; text-align: left; justify-content: flex-start; }
.choice:active { transform: translateY(2px); }
.choice.ok { background: #c9f5dc; border-color: var(--mint) !important; animation: yes .4s; }
.choice.bad { background: #ffd9d2; border-color: var(--tomato) !important; animation: shake .35s; opacity: .6; }
@keyframes yes { 50% { transform: scale(1.06); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.hear-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 999px; background: var(--teal); color: #fff; font-weight: 700; font-size: 20px; box-shadow: inset 0 -4px 0 #0003; }
.hear-row { display: flex; justify-content: center; gap: 8px; margin: 4px 0 10px; }
.big-hear { width: 96px; height: 96px; border-radius: 50%; font-size: 44px; background: var(--teal); color: #fff; display: block; margin: 8px auto 14px; box-shadow: inset 0 -5px 0 #0003; }
.steps { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.steps i { width: 14px; height: 14px; border-radius: 50%; background: #0002; }
.steps i.done { background: var(--mint); }
.steps i.now { background: var(--sun); box-shadow: 0 0 0 3px #ffc23d55; }

/* number pad (locks) */
.lock { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.dial { width: 70px; height: 86px; border-radius: 14px; background: linear-gradient(#5a6b7a, #34414d); color: #fff; display: grid; place-items: center; font-size: 46px; font-weight: 900; box-shadow: inset 0 -5px 0 #0004; border: 3px solid #23303a; }
.dial.now { border-color: var(--sun); }
.dial.ok { background: linear-gradient(#3fd08f, #1f9a63); }
.pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; }
.pad button { padding: 14px 0; border-radius: 14px; background: #fff; font-size: 26px; font-weight: 900; box-shadow: inset 0 -4px 0 #0001; border: 3px solid #e7d6ae; }

/* spelling */
.spell-word { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.spell-word span { width: 50px; height: 60px; border-radius: 12px; background: #fff; border: 3px dashed #c9b27e; display: grid; place-items: center; font-size: 34px; font-weight: 900; }
.spell-word span.given { border-style: solid; background: #f3ead2; color: #8a7a5a; }
.spell-word span.filled { border-style: solid; border-color: var(--violet); color: var(--violet); }
.spell-word span.now { box-shadow: 0 0 0 4px #9b5cff44; }
.spell-word span.gap { width: 18px; border: 0; background: none; }
.ghost { text-align: center; font-size: 30px; letter-spacing: 3px; color: #b8a47a; margin-top: -4px; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tile { position: relative; width: 52px; height: 56px; border-radius: 12px; background: linear-gradient(#c79bff, #8e4bff); color: #fff; font-size: 30px; font-weight: 900; box-shadow: inset 0 -4px 0 #0003; }
.tile b { position: absolute; right: 3px; bottom: 1px; font-size: 12px; }
.tile:disabled { opacity: .3; }
.gem-n { background: linear-gradient(#ffc27a, #ff8a1f); }

/* inventory / crafting / book */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.cell { position: relative; background: #fff; border-radius: 14px; padding: 6px 4px 4px; text-align: center; border: 3px solid #eadbb7; font-size: 15px; font-weight: 700; line-height: 1.15; min-height: 84px; }
.cell img { width: 40px; height: 40px; image-rendering: pixelated; display: block; margin: 0 auto 2px; }
.cell .em { font-size: 34px; display: block; line-height: 40px; }
.cell b.n { position: absolute; right: 6px; top: 4px; font-size: 13px; }
.cell.sel { border-color: var(--ink); }
.cell.lockd { opacity: .35; filter: grayscale(1); }
.cell.gold { background: linear-gradient(#fff6c8, #ffd95e); border-color: var(--gold); }
.hint { font-size: 17px; color: #6a5a3a; margin: 8px 0; }
.hotbar-edit { display: flex; gap: 4px; justify-content: center; margin: 10px 0 4px; flex-wrap: wrap; }
.hotbar-edit .slot { background: #0000000d; border-color: #0001; }
.hotbar-edit .slot.sel { border-color: var(--ink); }
.recipe { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 10px; border: 3px solid #eadbb7; margin-bottom: 8px; text-align: left; width: 100%; }
.recipe img { width: 40px; height: 40px; image-rendering: pixelated; }
.recipe .em { font-size: 32px; width: 40px; text-align: center; }
.recipe .rn { flex: 1; font-size: 21px; font-weight: 700; }
.recipe .rn small { display: block; font-weight: 400; font-size: 15px; color: #6a5a3a; }
.recipe.no { opacity: .5; }
.reward { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.reward .cell { min-width: 96px; min-height: 100px; animation: pop .3s backwards; cursor: pointer; }
.reward .cell img { width: 52px; height: 52px; }
.reward .cell .em { font-size: 44px; line-height: 52px; }
.meter { height: 12px; border-radius: 6px; background: #0001; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--mint); }
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.row label { flex: 1; font-weight: 700; }
.seg { display: inline-flex; background: #0000000f; border-radius: 999px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 999px; background: transparent; font-weight: 700; }
.seg button.on { background: var(--ink); color: #fff; }
.btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.btn { padding: 12px 22px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 700; font-size: 18px; box-shadow: inset 0 -4px 0 #0004; }
.btn.go { background: var(--mint); }
.btn.soft { background: #0000001a; color: var(--ink); box-shadow: none; }
.map-note { background: #f1dfb0; border-radius: 10px; padding: 16px; font-size: 25px; line-height: 1.6; border: 3px solid #c9a35a; font-family: var(--font); }
.big-n { font-size: 54px; font-weight: 900; text-align: center; color: var(--orange); }
.days { display: flex; gap: 3px; align-items: flex-end; height: 60px; margin: 6px 0; }
.days i { flex: 1; background: var(--teal); border-radius: 3px 3px 0 0; min-height: 2px; }

.small-prompt { font-size: 22px; margin: 0 0 10px; }
/* phones: still big, but two answers have to fit side by side */
@media (max-width: 520px) {
  .q-prompt { font-size: 24px; } .q-prompt.long { font-size: 20px; }
  .passage { font-size: 21px; padding: 12px 14px; } .passage h3 { font-size: 23px; }
  .choice { font-size: 23px; padding: 12px 8px; } .choice.small { font-size: 18px; }
  .small-prompt { font-size: 19px; }
  .tut { font-size: 16px; } .pico-say { font-size: 16px; }
}
