/* Fonts: Poppins, Comic Neue and Knewave, bundled under the SIL Open Font License 1.1 */
@font-face{font-family:"Poppins";font-weight:600;font-style:normal;font-display:swap;src:url("../assets/fonts/poppins-latin-600-normal.woff2") format("woff2")}
@font-face{font-family:"Poppins";font-weight:700;font-style:normal;font-display:swap;src:url("../assets/fonts/poppins-latin-700-normal.woff2") format("woff2")}
@font-face{font-family:"Poppins";font-weight:800;font-style:normal;font-display:swap;src:url("../assets/fonts/poppins-latin-800-normal.woff2") format("woff2")}
@font-face{font-family:"Comic Neue";font-weight:700;font-style:normal;font-display:swap;src:url("../assets/fonts/comic-neue-latin-700-normal.woff2") format("woff2")}
@font-face{font-family:"Knewave";font-weight:400;font-style:normal;font-display:swap;src:url("../assets/fonts/knewave-latin-400-normal.woff2") format("woff2")}

:root {
  --purple: #5b1fbf; --orange: #f26b1d; --gold: #ffd23f; --navy: #1a2a5e; --green: #2e7d38;
  --ink: #1d1740; --blue: #1c3fd6; --cap: #fff3a6; --red: #e23c3c;
  --ui: Poppins, "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --comic: "Comic Neue", "Comic Sans MS", "Chalkboard SE", Poppins, system-ui, sans-serif;
  --brush: Knewave, "Permanent Marker", "Marker Felt", Impact, Poppins, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); overscroll-behavior: none; }
body { font-family: var(--ui); color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
#app { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hrt { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 28C3 18 3 6 10.500 6c3 0 5 2 5.500 4 .5-2 2.500-4 5.500-4C29 6 29 18 16 28z' fill='%23e23c3c' stroke='%231d1740' stroke-width='2.500' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.hrt.off { filter: grayscale(1) brightness(1.7); opacity: .55; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; display: none; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left)); pointer-events: none; }
#hud.on { display: flex; }
.chip { background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 5px 14px; font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 var(--ink); white-space: nowrap; }
#lvname { background: var(--purple); color: #fff; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#prog { font-variant-numeric: tabular-nums; }
#prog b { font-size: 16px; } #prog span { font-weight: 600; }
.hbtns { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; }
.hbtns button { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--gold); box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--ink); }
.hbtns button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.hbtns svg { width: 22px; height: 22px; }
#btn-sound .x { display: none; } #btn-sound.off .x { display: block; } #btn-sound.off .w { display: none; }
#btn-sound.off { background: #fff; }

.caption { background: var(--cap); border: 3px solid var(--ink); font-family: var(--comic); font-weight: 700; font-size: 17px; line-height: 1.3; padding: 8px 12px; margin: 0; box-shadow: 3px 3px 0 rgba(29,23,64,.25); text-wrap: pretty; }
.caption.center { text-align: center; }
#hint { position: absolute; top: calc(17% + 34px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -10px) scale(.9); max-width: min(900px, calc(100% - 28px)); width: max-content; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; font-size: 33px; line-height: 1.22; padding: 16px 26px 16px 78px; border-width: 5px; text-align: left; box-shadow: 5px 5px 0 rgba(29,23,64,.35); z-index: 2; }
#hint::before { content: "!"; position: absolute; left: 16px; top: 50%; width: 44px; height: 44px; margin-top: -25px; border-radius: 50%; background: var(--orange); color: #fff; border: 3px solid var(--ink); font: 800 29px/44px var(--ui); text-align: center; }
#hint.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#hint.bump { animation: hintbump .5s ease-out; }
@keyframes hintbump { 0% { transform: translate(-50%, 0) scale(.8); } 55% { transform: translate(-50%, 0) scale(1.08); } 100% { transform: translate(-50%, 0) scale(1); } }

#bag { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: none; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 6px 10px 6px 14px; box-shadow: 0 4px 0 var(--ink); pointer-events: none; max-width: calc(100% - 16px); }
#bag.on { display: flex; }
#team { font-weight: 700; font-size: 13px; line-height: 1.1; color: var(--navy); white-space: nowrap; }
#team b { font-size: 18px; color: var(--blue); }
#slots { display: flex; gap: 6px; }
.slot { width: 46px; height: 46px; border-radius: 12px; border: 3px dashed #b9bfd9; background: #f1f3fb; display: grid; place-items: center; }
.slot.full { border: 3px solid var(--ink); background: var(--cap); animation: pop .25s; }
.slot img { width: 36px; height: 36px; display: block; }
@keyframes pop { from { transform: scale(.6); } 70% { transform: scale(1.12); } to { transform: scale(1); } }

/* ---------- overlay screens ---------- */
#overlay { position: absolute; inset: 0; display: none; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: calc(14px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); background: rgba(26,42,94,.62); }
#overlay.on { display: grid; place-items: center; }
#overlay.title { background: linear-gradient(180deg, rgba(26,42,94,.2), rgba(91,31,191,.38)); }
#overlay.peek { background: none; pointer-events: none; place-items: end center; }
.peekbar { pointer-events: auto; }

.panel { background: #fff; border: 4px solid var(--ink); border-radius: 10px; box-shadow: 8px 8px 0 rgba(29,23,64,.45); padding: 20px 22px 22px; width: min(640px, 100%); animation: rise .3s ease-out; }
.panel.wide { width: min(820px, 100%); } .panel.small { width: min(420px, 100%); }
.panel.comic { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Ccircle cx='2' cy='2' r='1.100' fill='%23ffd23f' fill-opacity='.35'/%3E%3C/svg%3E"); }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .panel, .slot.full, .hrt.pop, #hint.bump { animation: none !important; } }

.brush { font-family: var(--brush); font-weight: 400; font-size: clamp(36px, 9vw, 58px); line-height: .95; margin: 4px 0 16px; transform: rotate(-3deg); letter-spacing: .01em; text-transform: uppercase; isolation: isolate; }
.brush.huge { font-size: clamp(50px, 13vw, 96px); margin: 0 0 4px; }
.brush span { display: inline-block; filter: drop-shadow(3px 4px 0 rgba(29,23,64,.3)); -webkit-text-stroke: .07em #fff; paint-order: stroke fill; }
.brush .b1 { color: var(--blue); }
.brush .b2 { color: var(--orange); }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .brush span { -webkit-text-stroke: 0; filter: drop-shadow(0 0 0 #fff) drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(3px 4px 0 rgba(29,23,64,.3)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; padding: .08em .1em .1em .04em; }
  .brush .b1 { background-image: linear-gradient(180deg, #2f6bff 10%, #1c3fd6 50%, #0d1f8f 95%); }
  .brush .b2 { background-image: linear-gradient(180deg, #ffd23f 12%, #f9951f 50%, #e8451a 92%); }
}
.brush .hrt { width: .55em; height: .55em; margin-left: .08em; vertical-align: .1em; transform: rotate(12deg); }
.brush.nowrap { white-space: nowrap; }
.chapter { display: inline-block; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 12px; border-radius: 999px; margin-bottom: 8px; }

.strip { display: flex; gap: 16px; align-items: center; }
.frame { position: relative; flex: 0 0 auto; }
.kim { width: clamp(120px, 30vw, 190px); aspect-ratio: 1; border: 4px solid var(--ink); background: var(--gold); overflow: hidden; box-shadow: 4px 4px 0 rgba(29,23,64,.3); transform: rotate(-2deg); }
.kim canvas, .kim img { width: 100%; height: 100%; display: block; object-fit: cover; }
.caps { flex: 1; min-width: 0; display: grid; gap: 10px; }
.speech { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 28px; padding: 10px 16px; font-family: var(--comic); font-weight: 700; font-size: 18px; line-height: 1.25; text-align: center; margin-top: 12px; max-width: 230px; text-wrap: balance; }
.speech::before { content: ""; position: absolute; left: 50%; top: -15px; margin-left: -9px; border: 9px solid transparent; border-top: 0; border-bottom: 15px solid var(--ink); }
.speech::after { content: ""; position: absolute; left: 50%; top: -9px; margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom: 11px solid #fff; }
.speech.left { margin: 0; max-width: none; text-align: left; font-size: 19px; }
.speech.left::before { left: -15px; top: 50%; margin: -9px 0 0; border: 9px solid transparent; border-left: 0; border-right: 15px solid var(--ink); }
.speech.left::after { left: -9px; top: 50%; margin: -6px 0 0; border: 6px solid transparent; border-left: 0; border-right: 11px solid #fff; }
.speech b { color: var(--purple); }
.goal { margin: 0; font-size: 15px; line-height: 1.4; } .goal b { color: var(--purple); }

.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.btns.col { flex-direction: column; align-items: stretch; }
.btn { font: 800 16px var(--ui); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 18px; min-height: 46px; background: #fff; box-shadow: 0 4px 0 var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn:hover { filter: brightness(1.06); } .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, .lvl:focus-visible, .hbtns button:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.btn.big { font-size: 20px; padding: 12px 30px; }
.btn.orange { background: var(--orange); color: #fff; } .btn.purple { background: var(--purple); color: #fff; }
.btn.gold { background: var(--gold); } .btn.green { background: var(--green); color: #fff; }

.hearts { font-size: 46px; display: flex; gap: 10px; margin: 0 0 12px; }
.hrt.pop { animation: pop .45s both; }
.verse { margin: 12px 0 0; padding: 12px 16px; border-left: 6px solid var(--purple); background: #f4efff; border-radius: 0 10px 10px 0; }
.verse p { margin: 0 0 4px; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--navy); text-wrap: pretty; }
.verse cite { font-style: normal; font-weight: 700; font-size: 13px; color: var(--purple); }
.unlock { margin-top: 18px; padding: 14px; border: 3px dashed var(--purple); border-radius: 12px; background: #f4efff; text-align: center; }
.unlock p { margin: 0 0 10px; font-size: 18px; color: var(--navy); }

.how { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; line-height: 1.4; }
.how b { color: var(--purple); }
.keys { font-size: 13.5px; line-height: 1.5; background: #f1f3fb; border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; }

.book { font: 800 15px var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--purple); margin: 14px 0 8px; }
.levels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lvl { position: relative; text-align: left; font-family: var(--ui); color: var(--ink); border: 4px solid var(--ink); border-radius: 6px; padding: 12px 12px 12px 58px; min-height: 92px; cursor: pointer; box-shadow: 4px 4px 0 rgba(29,23,64,.3); display: grid; gap: 3px; align-content: start; }
.lvl.l1 { background: #dfe9ff; } .lvl.l2 { background: #ffe7c7; } .lvl.l3 { background: #dff5d2; } .lvl.l4 { background: #f0e2ff; }
.lvl:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(29,23,64,.3); }
.lvl .num { position: absolute; left: 10px; top: 10px; width: 38px; height: 38px; border-radius: 50%; background: var(--purple); color: #fff; font: 400 24px var(--brush); display: grid; place-items: center; border: 3px solid var(--ink); }
.lvl .lt { font: 400 23px/1 var(--brush); color: var(--blue); text-transform: uppercase; }
.lvl .lg { font-size: 13px; font-weight: 600; line-height: 1.3; }
.lvl .hs { font-size: 20px; display: flex; gap: 3px; }
.lvl.locked { filter: grayscale(1); opacity: .7; cursor: default; }

/* title */
.title-wrap { width: min(880px, 100%); display: grid; gap: 12px; justify-items: center; }
.title-card { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); background: rgba(255,255,255,.93); border: 4px solid var(--ink); border-radius: 10px; padding: clamp(14px, 3vw, 26px); box-shadow: 8px 8px 0 rgba(29,23,64,.45); animation: rise .4s ease-out; }
.title-card .kim { width: clamp(130px, 28vw, 260px); }
.title-text { min-width: 0; }
.sub { font: 400 clamp(20px, 5vw, 34px)/1 var(--brush); color: var(--purple); margin: 0 0 12px; transform: rotate(-3deg); text-transform: uppercase; }
.tiny { font-size: 13px; font-weight: 700; color: var(--purple); margin: 12px 0 0; }
.credit { margin: 0; font-size: 12.5px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); text-align: center; }

@media (max-width: 620px) {
  .strip { flex-direction: column; align-items: stretch; }
  .strip .frame { display: flex; align-items: flex-start; gap: 12px; }
  .strip .speech { margin: 8px 0 0; flex: 1; }
  .strip .speech::before { left: -15px; top: 26px; margin: 0; border: 9px solid transparent; border-left: 0; border-right: 15px solid var(--ink); }
  .strip .speech::after { left: -9px; top: 29px; margin: 0; border: 6px solid transparent; border-left: 0; border-right: 11px solid #fff; }
  .speech.left::before, .speech.left::after { display: none; }
  .title-card { flex-direction: column; text-align: center; }
  .title-card .btns { justify-content: center; }
  .levels { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .chip { font-size: 12.5px; padding: 4px 10px; } #prog span { display: none; }
  .caption { font-size: 15.500px; }
  .slot { width: 40px; height: 40px; } .slot img { width: 31px; height: 31px; }
  #bag { flex-direction: column; gap: 3px; padding: 4px 8px 7px; } #team { font-size: 12px; } #team b { font-size: 14px; }
  #hint { font-size: 27px; padding: 12px 16px 12px 62px; top: calc(12% + 30px + env(safe-area-inset-top)); }
  #hint::before { left: 10px; width: 38px; height: 38px; margin-top: -22px; font: 800 25px/38px var(--ui); }
}
@media (max-height: 480px) {
  .title-card .kim { width: clamp(110px, 30vh, 180px); }
  .brush.huge { font-size: clamp(40px, 16vh, 70px); }
  .panel { padding: 12px 16px 14px; } .brush { font-size: clamp(30px, 11vh, 46px); margin-bottom: 8px; }
  .kim { width: clamp(90px, 34vh, 150px); }
  .title-card .caption { display: none; }
  #hint { top: calc(60px + env(safe-area-inset-top)); font-size: 25px; padding: 8px 16px 8px 60px; }
  #hint::before { left: 10px; width: 36px; height: 36px; margin-top: -21px; font: 800 24px/36px var(--ui); }
  .slot { width: 38px; height: 38px; } .slot img { width: 30px; height: 30px; }
}

/* market tray (chapter 11) */
#bag.nobag { display: none !important; }
#tray { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 8px 10px; box-shadow: 0 4px 0 var(--ink); max-width: calc(100% - 12px); }
#tray button { width: 62px; height: 62px; border-radius: 14px; border: 3px solid var(--ink); background: var(--cap); box-shadow: 0 3px 0 var(--ink); cursor: pointer; padding: 0; display: grid; place-items: center; position: relative; }
#tray button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#tray button:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
#tray img { width: 46px; height: 46px; display: block; pointer-events: none; }
#tray kbd { position: absolute; left: 3px; top: 1px; font: 700 10px var(--ui); color: var(--purple); }
@media (max-width: 620px) { #tray { gap: 5px; padding: 6px; } #tray button { width: 50px; height: 50px; } #tray img { width: 38px; height: 38px; } #tray kbd { display: none; } }
