/* =====================================================================
   Pink & Whiskers 2 — UI styles
   Palette taken from the character sheet: Mia pink, Whiskers orange,
   harbour-night blue, cream cards. Type: Lilita One (chunky headings,
   echoes the logo) + Nunito (rounded, readable for kids).
   ===================================================================== */
:root {
  --pink: #ff4f9a; --pink-d: #d6336f; --orange: #f39a2e; --gold: #ffc93c;
  --night: #1d2b5a; --night-d: #121a38; --ink: #2b2140; --cream: #fff8ec; --sky: #8fd3ff;
  --card-shadow: 0 6px 0 rgba(18, 26, 56, .35), 0 18px 40px rgba(18, 26, 56, .35);
  --head: 'Lilita One', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1230; color: var(--ink); font-family: var(--body); -webkit-user-select: none; user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.6em; padding: .05em .4em; margin: 0 .15em; border-radius: .45em; background: var(--cream); color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 4px; font: 900 .85em var(--body); text-align: center; }

/* ---------- overlays & cards ---------- */
.overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; z-index: 20; padding: 2rem; }
.overlay.dim { background: rgba(13, 18, 48, .55); backdrop-filter: blur(3px); }
.card { background: var(--cream); border: 4px solid var(--ink); border-radius: 28px; padding: 1.6rem 2rem; box-shadow: var(--card-shadow); max-width: 560px; width: 100%; text-align: center; }
.card.wide { max-width: 720px; text-align: left; }
.card h2, .overlay > h2 { font: 400 2.4rem var(--head); margin: 0 0 .6rem; color: var(--night); letter-spacing: .5px; }
.overlay > h2 { color: #fff; text-shadow: 0 4px 0 var(--night-d); }
.card h3 { font: 400 1.8rem var(--head); margin: 0 0 .4rem; color: var(--night); }
.card small { font-weight: 900; color: var(--pink-d); }
.card p { font-weight: 700; line-height: 1.5; }
.small { font-size: .9rem; opacity: .8; }
pre { background: var(--night); color: #fff; padding: .6rem 1rem; border-radius: 12px; font-size: 1rem; text-align: left; }

.btn { font: 400 1.25rem var(--head); letter-spacing: .5px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-bottom-width: 7px; border-radius: 999px; padding: .55em 1.6em; cursor: pointer; min-width: 220px; transition: transform .08s; }
.btn:hover { transform: translateY(-2px); background: #fff3d6; }
.btn:active { transform: translateY(3px); border-bottom-width: 4px; }
.btn:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.btn.primary { background: var(--pink); color: #fff; text-shadow: 0 2px 0 var(--pink-d); }
.btn.primary:hover { background: #ff69ab; }
.btn.big { font-size: 1.6rem; }
.btn.ghost { background: #efe6f6; color: var(--ink); }
.btn.danger { background: #ffd9cf; color: #8a2020; }
.btn.danger:hover { background: #ffc4b4; }
.menu nav { display: flex; flex-direction: column; gap: .7rem; align-items: center; }
.menu .card .btn { margin-top: .6rem; }

/* ---------- logo (type-built, matches the PINK / WHISKERS / 2 lock-up) ---------- */
.logo { position: relative; display: grid; grid-template-columns: auto auto; align-items: end; justify-items: center; line-height: .82; transform: rotate(-3deg); margin-bottom: 1rem; }
.logo span { font-family: var(--head); -webkit-text-stroke: 3px var(--night-d); paint-order: stroke fill; }
.logo .l1 { grid-column: 1; font-size: clamp(3.6rem, 9vw, 7rem); color: var(--pink); text-shadow: 0 6px 0 var(--night-d), 0 10px 20px rgba(0,0,0,.3); }
.logo .amp { grid-column: 1; font-size: clamp(1.4rem, 3vw, 2rem); color: #fff; margin: .1em 0; }
.logo .l2 { grid-column: 1; font-size: clamp(3.6rem, 9vw, 7rem); color: var(--gold); text-shadow: 0 6px 0 #b05a12, 0 10px 20px rgba(0,0,0,.3); }
.logo .num { grid-column: 2; grid-row: 1 / span 3; align-self: center; font-size: clamp(6rem, 15vw, 11rem); color: #3a8af0; text-shadow: 0 8px 0 var(--night-d); margin-left: .1em; }
.logo .ribbon { grid-column: 1 / span 2; margin-top: .6rem; font-size: clamp(1.1rem, 2.6vw, 1.8rem); color: #2a3fd0; -webkit-text-stroke: 0; background: #fff; border: 4px solid var(--night-d); border-radius: 999px; padding: .25em 1em .2em; box-shadow: 0 5px 0 var(--night-d); transform: rotate(1deg); }
.logo.small { transform: rotate(-3deg) scale(.6); }
#splash { position: fixed; inset: 0; z-index: 4; background: #0d1230 center / cover no-repeat; }
#title { justify-content: center; align-items: flex-start; padding-left: 7vw; gap: .6rem; background: linear-gradient(90deg, rgba(13,18,48,.55), rgba(13,18,48,.15) 45%, rgba(13,18,48,0) 70%); }
#title nav { align-items: flex-start; }
#title .logo { transform: rotate(-3deg) scale(.85); transform-origin: left center; margin-bottom: 0; }
#title .foot { color: #fff; font-weight: 800; text-shadow: 0 2px 4px rgba(0,0,0,.6); position: absolute; bottom: 18px; left: 7vw; margin: 0; }

/* ---------- loading ---------- */
#loading { background: radial-gradient(circle at 50% 40%, #2c3f86, #0d1230 70%); color: #fff; }
#load-bar { width: min(420px, 70vw); height: 22px; border: 3px solid #fff; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.12); }
#load-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--pink) 0 14px, #ff7ab4 14px 28px); transition: width .2s; }
#load-text { font-weight: 800; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-weight: 900; }
.hud-left { position: absolute; left: max(14px, env(safe-area-inset-left)); top: 12px; display: flex; flex-direction: column; gap: 6px; }
.hud-char { display: flex; align-items: center; transition: transform .2s, opacity .2s; opacity: .8; transform: scale(.88); transform-origin: left center; }
.hud-char.active { opacity: 1; transform: scale(1); }
.hud-char .por { width: 74px; height: 74px; border-radius: 50%; background: #fff center/cover; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--ink), 0 6px 12px rgba(0,0,0,.35); position: relative; z-index: 2; }
.hud-char.cat .por { width: 54px; height: 54px; margin-left: 12px; }
.hud-char.active .por { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px var(--gold), 0 6px 12px rgba(0,0,0,.35); }
.bar-wrap { margin-left: -16px; padding: 6px 14px 6px 24px; background: rgba(29, 43, 90, .82); border: 3px solid var(--ink); border-radius: 0 999px 999px 0; display: flex; align-items: center; gap: 8px; }
#hud-hearts { display: flex; gap: 4px; }
.heart { width: 30px; height: 27px; display: inline-block; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 29'%3E%3Cpath d='M16 28 3 15C-1 11 1 3 8 3c4 0 6 3 8 5 2-2 4-5 8-5 7 0 9 8 5 12z' fill='%23ff3d5a' stroke='%23fff' stroke-width='2.5'/%3E%3Cellipse cx='9' cy='9' rx='3' ry='2' fill='%23fff' opacity='.7'/%3E%3C/svg%3E"); transition: transform .2s, filter .2s; }
.heart.empty { filter: grayscale(1) brightness(.6); opacity: .55; transform: scale(.8); }
#hud-energy { width: 110px; height: 14px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden; border: 2px solid #fff; }
#hud-energy i { display: block; height: 100%; background: linear-gradient(90deg, #ffd84f, #ffb02e); transition: width .15s; }
.hud-char .mode { color: #fff; font-size: .75rem; opacity: .85; }
.hud-obj { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); color: #fff; background: rgba(29, 43, 90, .7); padding: .35em 1.1em; border-radius: 999px; font-size: .95rem; border: 2px solid rgba(255,255,255,.4); max-width: 44%; text-align: center; }
.hud-obj:empty { display: none; }
.hud-right { position: absolute; right: max(14px, env(safe-area-inset-right)); top: 14px; display: flex; gap: 10px; align-items: center; pointer-events: auto; }
.pill { display: flex; align-items: center; gap: 6px; background: rgba(29, 43, 90, .82); color: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 16px 4px 6px; font-size: 1.25rem; }
.pill .ico { width: 32px; height: 32px; background: no-repeat center/contain; }
.ico.star { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='m16 2 4.3 9 9.7 1.2-7.1 6.7 1.9 9.6L16 23.7l-8.8 4.8 1.9-9.6L2 12.2 11.7 11z' fill='%23ffcf3a' stroke='%23b8741a' stroke-width='2'/%3E%3C/svg%3E"); }
.ico.key { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='10' cy='11' r='7' fill='none' stroke='%23e7b04a' stroke-width='4'/%3E%3Cpath d='M15 15 28 28M22 22l3-3M25 25l3-3' stroke='%23e7b04a' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.round { width: 50px; height: 50px; border-radius: 14px; border: 3px solid var(--ink); background: #fff; font: 900 1.3rem var(--body); cursor: pointer; box-shadow: 0 4px 0 var(--ink); }
.round .pz { display: inline-block; width: 16px; height: 18px; border-left: 6px solid var(--night); border-right: 6px solid var(--night); }
#bossbar { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(520px, 60%); color: #fff; text-align: center; font: 400 1.3rem var(--head); text-shadow: 0 2px 0 var(--ink); }
#bossbar .track { height: 18px; border: 3px solid var(--ink); border-radius: 999px; background: rgba(0,0,0,.4); overflow: hidden; margin-top: 4px; }
#bossbar i { display: block; height: 100%; background: linear-gradient(90deg, #ff6a3d, #ffb02e); transition: width .4s; }

#objective { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 12; background: var(--cream); border: 4px solid var(--ink); border-radius: 20px; padding: .5rem 1.6rem .7rem; text-align: center; box-shadow: var(--card-shadow); }
#objective small { font-weight: 900; color: var(--pink-d); font-size: .8rem; }
#objective p { margin: 0; font: 400 1.6rem var(--head); color: var(--night); }
#objective.pop { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: translateX(-50%) scale(.4); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
#hint { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 12; background: rgba(29, 43, 90, .92); color: #fff; padding: .7rem 1.4rem; border-radius: 18px; border: 3px solid #fff; font-weight: 800; font-size: 1.05rem; max-width: min(760px, 86%); text-align: center; line-height: 1.5; }
#toast { position: fixed; top: 34%; left: 50%; transform: translateX(-50%); z-index: 12; background: var(--gold); color: var(--ink); border: 3px solid var(--ink); padding: .4rem 1.2rem; border-radius: 999px; font-weight: 900; animation: pop .35s; box-shadow: 0 4px 0 var(--ink); }
#prompt { position: fixed; left: 0; top: 0; z-index: 11; pointer-events: none; color: #fff; font-weight: 900; background: rgba(29, 43, 90, .88); padding: 4px 12px 4px 6px; border-radius: 999px; border: 2px solid #fff; white-space: nowrap; animation: bob 1s ease-in-out infinite alternate; }
@keyframes bob { to { margin-top: -6px; } }
#fps { position: fixed; bottom: 4px; right: 8px; color: #fff; font: 700 12px monospace; z-index: 30; opacity: .7; }

#stagecard { position: fixed; left: 0; right: 0; top: 30%; z-index: 13; text-align: center; pointer-events: none; color: #fff; }
#stagecard small { font: 900 1.1rem var(--body); background: var(--pink); padding: .2em .9em; border-radius: 999px; border: 3px solid var(--ink); }
#stagecard h2 { font: 400 4.4rem var(--head); margin: .3rem 0; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
#stagecard.run { animation: stagein 3.6s ease both; }
@keyframes stagein { 0% { opacity: 0; transform: translateY(30px) scale(.9); } 12%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-20px); } }

/* ---------- dialogue ---------- */
#dialog { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(900px, 94%); z-index: 15; display: flex; align-items: flex-end; cursor: pointer; }
#dialog .portrait { flex: 0 0 auto; width: 132px; height: 132px; border-radius: 50%; background: #fff center/cover; border: 5px solid #fff; box-shadow: 0 0 0 4px var(--ink), 0 8px 18px rgba(0,0,0,.4); z-index: 2; margin-right: -26px; margin-bottom: 8px; }
#dialog .portrait.none { display: none; }
#dialog .portrait.ghost { filter: sepia(.6) hue-rotate(150deg) saturate(1.5) brightness(1.1); opacity: .85; }
#dialog .bubble { position: relative; flex: 1; background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; padding: 1.3rem 1.6rem 1.2rem 2.6rem; box-shadow: var(--card-shadow); min-height: 112px; }
#dialog .name { position: absolute; top: -18px; left: 34px; color: #fff; font: 400 1.25rem var(--head); padding: .1em .9em; border-radius: 999px; border: 3px solid var(--ink); letter-spacing: .5px; }
#dialog .text { margin: 0; font-size: 1.3rem; font-weight: 800; line-height: 1.45; min-height: 2.9em; }
#dialog .next { position: absolute; right: 18px; bottom: 10px; color: var(--pink-d); animation: bob .5s infinite alternate; }
#dialog.narration .bubble { background: #f3ead7; font-style: italic; padding-left: 1.6rem; }

/* ---------- puzzles ---------- */
.puzzle-card { max-width: 700px; }
.pz-help { margin-top: 0; }
.pz-body { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin: 1rem 0; }
.pz-body.shake { animation: shake .4s; }
.pz-body.solved { animation: glow .9s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes glow { 50% { filter: drop-shadow(0 0 24px #ffd84f) brightness(1.2); } }
.dials { display: flex; gap: 1.4rem; }
.dial { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .8rem; border-radius: 22px; background: var(--night); border: 4px solid var(--ink); }
.dial.slot1 { box-shadow: 0 0 0 5px #e8504a; } .dial.slot2 { box-shadow: 0 0 0 5px #4ab86a; } .dial.slot3 { box-shadow: 0 0 0 5px #4a8ae8; }
.dial small { color: #fff; font-weight: 800; font-size: .75rem; opacity: .8; max-width: 110px; }
.dial .arrow { width: 64px; height: 40px; border-radius: 12px; border: 3px solid var(--ink); background: var(--gold); font-size: 1.2rem; cursor: pointer; }
.sym { width: 96px; height: 96px; background: url(../assets/ui/symbols.png) 0 0 / 600% 100% no-repeat; filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.sym.turn { animation: spinin .25s; }
@keyframes spinin { from { transform: rotate(-40deg) scale(.8); } }
#nb-symbols { display: flex; gap: .6rem; justify-content: center; margin-bottom: .6rem; }
#nb-symbols .sym { width: 56px; height: 56px; background-color: var(--night); border-radius: 50%; border: 4px solid; }
#nb-symbols .slot1 { border-color: #e8504a; } #nb-symbols .slot2 { border-color: #4ab86a; } #nb-symbols .slot3 { border-color: #4a8ae8; }
.clockwrap { display: flex; gap: 1.6rem; align-items: center; }
.clock { position: relative; width: 210px; height: 210px; border-radius: 50%; background: radial-gradient(#fffaf0 60%, #f0e2c0); border: 8px solid #b8862e; box-shadow: inset 0 0 0 4px var(--ink), 0 6px 0 var(--ink); }
.clock .num { position: absolute; transform: translate(-50%, -50%); font: 400 1.2rem var(--head); color: var(--night); }
.clock .hand { position: absolute; left: 50%; bottom: 50%; width: 8px; height: 70px; margin-left: -4px; background: var(--pink-d); border-radius: 4px; transform-origin: 50% 100%; transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.clock .pin { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: var(--ink); }
.gears { display: flex; flex-direction: column; gap: .6rem; }
.gearbtn { display: grid; grid-template-columns: 44px auto; grid-template-rows: auto auto; align-items: center; column-gap: .6rem; text-align: left; background: #fff; border: 3px solid var(--ink); border-bottom-width: 6px; border-radius: 16px; padding: .4rem .9rem; cursor: pointer; font-family: var(--body); }
.gearbtn .gearicon { grid-row: span 2; font-size: 2.2rem; color: #b8862e; transition: transform .4s; display: inline-block; }
.gearbtn b { font: 400 1.4rem var(--head); color: var(--night); }
.gearbtn small { color: var(--ink); font-weight: 800; }
.turns { font-weight: 900; margin: 0; }
.slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; width: 100%; }
.slots .slot { display: flex; gap: .6rem; align-items: center; min-height: 64px; border: 3px dashed #8a7fa8; border-radius: 16px; padding: .4rem .7rem; text-align: left; font-weight: 800; color: #8a7fa8; }
.slots .slot.filled { border-style: solid; border-color: var(--night); background: #e6f8ff; color: var(--ink); cursor: pointer; }
.slots .slot b { font: 400 1.6rem var(--head); color: var(--pink-d); }
.pool { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.frag { background: linear-gradient(135deg, #5ab8c8, #8a6ad8); color: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: .5rem .9rem; font: 800 .95rem var(--body); cursor: pointer; max-width: 300px; text-align: left; box-shadow: 0 4px 0 var(--ink); }

/* ---------- notebook / chapters / summary ---------- */
.notebook { text-align: left; background: repeating-linear-gradient(#fff8ec 0 30px, #e8dcc4 30px 31px); }
#nb-list { list-style: none; padding: 0; max-height: 46vh; overflow-y: auto; font-weight: 800; line-height: 1.5; }
#nb-list li { padding: .3rem 0 .3rem 1.6rem; position: relative; }
#nb-list li::before { content: '✦'; position: absolute; left: 0; color: var(--pink); }
/* ---------- stage select (stylised cards with preview pictures) ---------- */
#chapters { background: radial-gradient(circle at 50% 0%, rgba(255, 79, 154, .35), rgba(13, 18, 48, .85) 60%), repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 18px, transparent 18px 36px); overflow-y: auto; justify-content: flex-start; padding-top: 3vh; }
.ribbon-title { position: relative; margin-bottom: .4rem; }
.ribbon-title span { display: inline-block; font: 400 clamp(1.8rem, 4vw, 2.8rem) var(--head); color: #fff; background: var(--pink); padding: .2em 1.2em .25em; border: 4px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 var(--ink); transform: rotate(-1.5deg); text-shadow: 0 3px 0 var(--pink-d); }
.ribbon-title::before, .ribbon-title::after { content: ''; position: absolute; top: 18px; width: 40px; height: 44px; background: var(--pink-d); border: 4px solid var(--ink); z-index: -1; }
.ribbon-title::before { left: -28px; transform: rotate(-1.5deg); clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%); }
.ribbon-title::after { right: -28px; transform: rotate(-1.5deg); clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%); }
#chapter-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; width: min(1180px, 100%); padding: .6rem; }
.chapter { --tilt: 0deg; background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; padding: 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: .5rem; font-family: var(--body); box-shadow: 0 7px 0 var(--ink), 0 14px 26px rgba(0,0,0,.35); transform: rotate(var(--tilt)); transition: transform .18s, box-shadow .18s; }
.chapter:hover:not(.locked), .chapter:focus-visible { transform: rotate(0deg) translateY(-6px) scale(1.03); box-shadow: 0 11px 0 var(--ink), 0 20px 32px rgba(0,0,0,.4); }
.chapter .thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; border: 3px solid var(--ink); background: #1d2b5a center / cover no-repeat; overflow: hidden; }
.chapter .badge { position: absolute; left: 8px; top: 8px; font: 900 .85rem var(--body); color: #fff; background: var(--pink); border: 2px solid var(--ink); border-radius: 999px; padding: .1em .7em; }
.chapter .play { position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); border: 3px solid var(--ink); color: var(--ink); font-size: 1.1rem; box-shadow: 0 3px 0 var(--ink); }
.chapter .lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.4rem; background: rgba(13, 18, 48, .6); backdrop-filter: grayscale(1); }
.chapter .info { display: flex; flex-direction: column; gap: .15rem; padding: 0 .3rem .2rem; }
.chapter strong { font: 400 1.35rem var(--head); color: var(--night); line-height: 1.1; display: flex; align-items: center; gap: .45rem; }
.chapter strong .num { flex: 0 0 auto; width: 1.7em; height: 1.7em; display: grid; place-items: center; border-radius: 50%; background: var(--night); color: var(--gold); font-size: .9em; border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.chapter small { font-weight: 700; font-size: .82rem; color: #5a4a6a; line-height: 1.3; min-height: 2.2em; }
.keysrow { display: flex; align-items: center; gap: 4px; margin-top: .2rem; }
.keysrow i { width: 22px; height: 22px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='10' cy='11' r='7' fill='none' stroke='%23b8aac8' stroke-width='4'/%3E%3Cpath d='M15 15 28 28M22 22l3-3M25 25l3-3' stroke='%23b8aac8' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.keysrow i.got { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='10' cy='11' r='7' fill='none' stroke='%23e7a83a' stroke-width='4'/%3E%3Cpath d='M15 15 28 28M22 22l3-3M25 25l3-3' stroke='%23e7a83a' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E"); }
.keysrow em { margin-left: auto; font-style: normal; font-weight: 900; font-size: .8rem; color: var(--pink-d); }
.chapter.locked { cursor: not-allowed; filter: saturate(.4); opacity: .8; }
.card .row { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: .8rem; }
.card .row .btn { min-width: 180px; margin-top: 0; }
#settings .card { background: linear-gradient(180deg, #fff8ec, #fde9d2); }
#settings h2::before { content: '⚙ '; color: var(--pink); }
.stats { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1.6rem; font-weight: 900; font-size: 1.15rem; text-align: left; margin: 1rem auto; max-width: 320px; }
.stats dd { margin: 0; color: var(--pink-d); }
.ending { background: radial-gradient(circle at 50% 30%, rgba(255, 200, 120, .25), rgba(13, 18, 48, .7)); }
.moral { font: 400 clamp(1.8rem, 4vw, 2.6rem) var(--head) !important; color: var(--night); line-height: 1.2 !important; }
.keys { width: 100%; border-collapse: collapse; font-weight: 800; }
.keys td { padding: .35rem .4rem; border-bottom: 2px dashed #e0d2b4; }
.keys td:first-child { white-space: nowrap; width: 1%; }
label { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-weight: 900; margin: .7rem 0; }
label.check { justify-content: flex-start; }
input[type=range] { width: 55%; accent-color: var(--pink); }
select { font: 800 1rem var(--body); padding: .3rem .6rem; border-radius: 10px; border: 3px solid var(--ink); }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: none; }
#touch button { pointer-events: auto; width: 74px; height: 74px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); background: rgba(29, 43, 90, .55); color: #fff; font: 900 1.6rem var(--body); touch-action: none; }
#touch button.sm { width: 54px; height: 54px; font-size: 1.2rem; }
#touch button.jump { width: 92px; height: 92px; background: rgba(255, 79, 154, .7); }
#touch .tl { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: 18px; display: flex; gap: 10px; align-items: flex-end; }
#touch .tr { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: 18px; display: flex; gap: 10px; align-items: flex-end; }
#touch .tpause { position: absolute; top: 80px; right: 16px; width: 48px !important; height: 48px !important; font-size: 1rem !important; }

#fade { position: fixed; inset: 0; background: #0d1230; opacity: 0; pointer-events: none; z-index: 40; transition: opacity .4s; }
#fade.on { opacity: 1; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 39; }
#flash.go { animation: flash var(--flash-time, .6s) ease-out; }
@keyframes flash { 0% { opacity: var(--flash-opacity, .9); } 100% { opacity: 0; } }

/* =====================================================================
   RESPONSIVE: ui.js layout() sets --ui (overall UI scale) and --touch from the screen size and
   orientation, plus body classes .is-portrait / .is-compact. Change the overall size with config ui.uiScale.
   ===================================================================== */
.overlay, #hud, #dialog, #objective, #hint, #toast, #stagecard { zoom: var(--ui, 1); }
#touch { zoom: var(--touch, 1); }
#prompt { font-size: calc(16px * var(--ui, 1)); }
#chapters, .card, #nb-list, .overlay { touch-action: pan-y; }
.overlay { max-height: 100%; }
.title-logo { width: 620px; max-width: 100%; height: auto; transform: rotate(-2deg); filter: drop-shadow(0 12px 18px rgba(10, 14, 40, .45)); animation: logoIn .8s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes logoIn { from { transform: rotate(-2deg) scale(.6); opacity: 0; } }
.load-logo { width: 460px; max-width: 80%; height: auto; }
#bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 11; }
.say { position: absolute; left: 0; top: 0; background: #fff; color: var(--ink); border: 3px solid var(--ink); border-radius: 18px; padding: .4em .9em; font: 900 calc(15px * var(--ui, 1)) var(--body); max-width: calc(240px * var(--ui, 1)); text-align: center; box-shadow: 0 4px 0 var(--ink); margin-top: -14px; }
.say::after { content: ''; position: absolute; left: 50%; bottom: -11px; width: 16px; height: 16px; background: #fff; border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.say.pop { animation: sayPop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes sayPop { from { scale: .3; opacity: 0; } }
/* touch controls: compact 2-row cluster on the right */
#touch .tr { display: grid; grid-template-columns: repeat(3, auto); grid-template-areas: "swap whistle ." "interact gadget jump"; gap: 10px; align-items: end; justify-items: center; }
#touch [data-key=swap] { grid-area: swap; } #touch [data-key=whistle] { grid-area: whistle; } #touch [data-key=interact] { grid-area: interact; }
#touch [data-key=gadget] { grid-area: gadget; } #touch [data-key=jump] { grid-area: jump; }
.talking #touch { display: none; }
/* stage select: locked cards stay secret */
.chapter .thumb.secret { background: radial-gradient(circle at 50% 45%, #3a4a8a, #141a3a 75%); display: grid; place-items: center; }
.chapter .thumb.secret .qm { font: 400 4rem var(--head); color: rgba(255, 255, 255, .25); }
.chapter .thumb.secret .lock { inset: auto 10px 8px auto; background: none; font-size: 1.6rem; backdrop-filter: none; }
/* ---------- portrait (phones / tablets held upright) ---------- */
.is-portrait #splash { background-position: 82% center; }
.is-portrait #title { align-items: center; justify-content: flex-start; padding: 6% 1rem 5rem; background: linear-gradient(180deg, rgba(13, 18, 48, .55), rgba(13, 18, 48, .05) 38%, rgba(13, 18, 48, .1) 60%, rgba(13, 18, 48, .7)); }
.is-portrait #title nav { align-items: center; margin-top: auto; }
.is-portrait #title .btn { min-width: 300px; }
.is-portrait .title-logo { width: 500px; }
.is-portrait #title .foot { left: 0; right: 0; text-align: center; padding: 0 1.2rem; bottom: 1.2rem; }
.is-portrait .hud-right { flex-wrap: wrap; justify-content: flex-end; max-width: 230px; row-gap: 8px; }
.is-portrait .hud-obj { top: 200px; max-width: 92%; }
.is-portrait #objective { top: 250px; }
.is-portrait #chapter-list { grid-template-columns: repeat(2, 1fr); }
.is-portrait #dialog { bottom: 170px; }
.is-portrait #hint { bottom: 190px; }
.is-portrait #dialog .portrait { width: 100px; height: 100px; }
/* ---------- compact landscape (phones on their side) ---------- */
.is-compact:not(.is-portrait) #title { padding-top: 1rem; padding-bottom: 1rem; gap: .3rem; }
.is-compact:not(.is-portrait) .title-logo { width: 560px; }
.is-compact:not(.is-portrait) #title .btn { padding: .4em 1.4em; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
