/* Pip and the Lantern Isles — warm lantern light on twilight paper. */
:root {
  --ink: #fff8ec; --muted: #e2d6c2; --night: #1b2346; --night2: #283466; --glow: #ffcf6b; --glow2: #ff8fb8; --leaf: #8ad66a;
  --panel: linear-gradient(170deg, rgba(40, 52, 102, .94), rgba(24, 30, 66, .96));
  --edge: rgba(255, 220, 160, .35);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --saga-font: 'Nunito', system-ui, sans-serif; --saga-name-font: 'Fredoka', 'Nunito', sans-serif;
  --saga-ink: #fff8ec; --saga-box-bg: linear-gradient(170deg, rgba(42, 52, 104, .93), rgba(26, 31, 70, .95)); --saga-box-edge: rgba(255, 214, 140, .45); --saga-accent: #ffcf6b; --saga-radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #10152e; color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; }

.game-shell { position: fixed; inset: 0; display: flex; flex-direction: column; }
.game-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: calc(6px + var(--safe-t)) calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l)); background: #141a36; border-bottom: 1px solid rgba(255,255,255,.07); font: 700 13px/1 'Nunito', sans-serif; z-index: 60; }
.back-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.game-bar-title { flex: 1; text-align: center; font-family: 'Fredoka', sans-serif; font-weight: 600; letter-spacing: .02em; color: var(--glow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-pill { padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); }
.icon-btn { width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(255,255,255,.08); cursor: pointer; }
.game-wrap { position: relative; flex: 1; overflow: hidden; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.veil { position: absolute; inset: 0; background: #0d1028; opacity: 0; pointer-events: none; transition: opacity .45s ease; z-index: 30; }
.veil.on { opacity: 1; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 31; }

/* ── HUD ── */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.hud.hidden { display: none; }
.hud-top { position: absolute; top: calc(12px); left: calc(14px + var(--safe-l)); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hearts { display: flex; gap: 4px; }
.hearts i { width: 30px; height: 28px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 30'%3E%3Cpath d='M16 28S2 19 2 9.5A7 7 0 0 1 16 6a7 7 0 0 1 14 3.5C30 19 16 28 16 28z' fill='%23ff5a7a' stroke='%23fff3f0' stroke-width='2.5'/%3E%3Cellipse cx='10' cy='10' rx='3' ry='2' fill='%23ffd0da'/%3E%3C/svg%3E"); filter: drop-shadow(0 3px 4px rgba(60,10,40,.4)); transition: transform .2s; }
.hearts i.empty { filter: grayscale(1) brightness(.55) drop-shadow(0 2px 3px rgba(0,0,0,.4)); opacity: .7; }
.hearts i.pop { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }
.beans { display: flex; align-items: center; gap: 7px; padding: 5px 14px 5px 8px; border-radius: 999px; background: rgba(24, 28, 62, .55); border: 2px solid rgba(255, 214, 120, .35); font: 700 20px/1 'Fredoka', sans-serif; color: #fff4d0; text-shadow: 0 2px 0 rgba(0,0,0,.25); backdrop-filter: blur(4px); }
.bean-ico { width: 18px; height: 22px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 35% 30%, #fff6c8, #ffc23a 45%, #e8861a); box-shadow: 0 0 10px rgba(255, 190, 60, .8); transform: rotate(28deg); }
.beans.bump b { animation: pop .25s; display: inline-block; }
.shards { display: flex; gap: 4px; }
.shards i { width: 26px; height: 26px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='none' stroke='%23c8c0ff' stroke-width='1.6' stroke-dasharray='2 2'/%3E%3C/svg%3E"); opacity: .65; }
.shards i.got { opacity: 1; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='%23ffb8ec' stroke='%23fff' stroke-width='1.4'/%3E%3C/svg%3E"); filter: drop-shadow(0 0 6px #ff8ad8); }
.pause-btn { position: absolute; top: 10px; right: calc(12px + var(--safe-r)); width: 44px; height: 44px; border-radius: 14px; border: 2px solid rgba(255,255,255,.2); background: rgba(24, 28, 62, .55); color: #fff; font-size: 14px; pointer-events: auto; cursor: pointer; backdrop-filter: blur(4px); }
.abilities { position: absolute; top: 58px; left: calc(14px + var(--safe-l)); display: flex; gap: 6px; }
.abilities span { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: rgba(24,28,62,.5); border: 1px solid rgba(255,214,140,.35); font-size: 15px; color: var(--glow); }
.banner { position: absolute; left: 50%; top: 20%; transform: translate(-50%, -10px); text-align: center; opacity: 0; transition: opacity .6s, transform .6s; text-shadow: 0 3px 18px rgba(20, 10, 40, .6); }
.banner.on { opacity: 1; transform: translate(-50%, 0); }
.banner small { display: block; font: 700 clamp(12px, 1.6vw, 16px)/1.2 'Nunito', sans-serif; letter-spacing: .24em; text-transform: uppercase; color: #ffe7b4; }
.banner b { display: block; font: 700 clamp(34px, 6vw, 70px)/1.05 'Fredoka', sans-serif; color: #fff; -webkit-text-stroke: 1px rgba(120, 60, 20, .25); }
.toast { position: absolute; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(10px); padding: 10px 18px; border-radius: 16px; background: rgba(28, 32, 72, .86); border: 2px solid var(--edge); font-weight: 700; line-height: 1.35; text-align: center; opacity: 0; transition: opacity .3s, transform .3s; width: max-content; max-width: min(560px, 88vw); box-shadow: 0 10px 26px rgba(0,0,0,.3); backdrop-filter: blur(4px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.prompt { position: absolute; left: 50%; bottom: calc(170px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 999px; background: rgba(255, 248, 230, .95); color: #3a2a20; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.prompt.hidden { display: none; }
.prompt kbd { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 9px; display: grid; place-items: center; background: #3a2a20; color: #fff4d8; font: 700 13px/1 'Fredoka', sans-serif; }
.bubble { position: absolute; left: 50%; bottom: calc(210px + var(--safe-b)); transform: translateX(-50%); width: min(520px, 90vw); padding: 14px 18px; border-radius: 18px; background: #fff7e6; color: #3a2a20; font-weight: 700; line-height: 1.4; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -10px; border: 10px solid transparent; border-top-color: #fff7e6; border-bottom: 0; transform: translateX(-50%); }
.bubble.hidden { display: none; }
.boss-bar { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); width: min(560px, 80vw); text-align: center; }
.boss-bar.hidden { display: none; }
.boss-bar b { font: 700 18px/1 'Fredoka', sans-serif; letter-spacing: .06em; color: #ffe4f6; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.boss-bar div { margin-top: 6px; height: 14px; border-radius: 999px; background: rgba(20, 16, 40, .7); border: 2px solid rgba(255, 200, 240, .5); overflow: hidden; }
.boss-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff6fb0, #ffc46a); transition: width .3s; }
.timer { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font: 700 22px/1 'Fredoka', sans-serif; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.timer.hidden { display: none; }

/* touch */
.stick { position: fixed; z-index: 11; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); background: rgba(20, 24, 56, .25); opacity: 0; transition: opacity .2s; pointer-events: none; }
.stick.on { opacity: 1; }
.stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 245, 220, .85); box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.touch { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 210px; height: 200px; display: none; pointer-events: auto; }
body.is-touch .touch { display: block; }
.tb { position: absolute; border-radius: 50%; border: 3px solid rgba(255,255,255,.55); background: rgba(30, 36, 80, .5); color: #fff; font: 700 26px/1 'Fredoka', sans-serif; backdrop-filter: blur(4px); touch-action: none; }
.tb.down { background: rgba(255, 207, 107, .7); transform: scale(.94); }
.tb-jump { width: 84px; height: 84px; right: 0; bottom: 0; background: rgba(255, 143, 184, .55); }
.tb-spin { width: 68px; height: 68px; right: 94px; bottom: 4px; }
.tb-roll { width: 60px; height: 60px; right: 16px; bottom: 96px; }
.tb-light { width: 60px; height: 60px; right: 92px; bottom: 84px; background: rgba(255, 207, 107, .4); }
.tb.locked { display: none; }

/* ── screens ── */
.screen { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 18px calc(16px + var(--safe-r)) calc(18px + var(--safe-b)) calc(16px + var(--safe-l)); z-index: 20; overflow-y: auto; }
.screen.on { display: flex; }
#scr-load { background: radial-gradient(circle at 50% 40%, #2c3a78, #10152e 70%); flex-direction: column; gap: 22px; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .9; text-align: center; filter: drop-shadow(0 6px 24px rgba(255, 180, 80, .35)); }
.logo-pre { font: 600 clamp(18px, 3vw, 28px)/1 'Fredoka', sans-serif; color: #ffe7b4; letter-spacing: .08em; }
.logo-main { font: 700 clamp(46px, 9vw, 104px)/1 'Fredoka', sans-serif; background: linear-gradient(180deg, #fff7d6 10%, #ffcf6b 55%, #ff8f5a); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 1.5px rgba(120, 50, 20, .35); }
.logo.big .logo-main { font-size: clamp(54px, 10.5vw, 124px); }
.load-bar { width: min(360px, 70vw); height: 12px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; border: 2px solid rgba(255,214,140,.3); }
.load-bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #ffcf6b, #ff8fb8); transition: width .25s; }
.load-text { margin: 0; color: var(--muted); font-weight: 700; }
#scr-title { align-items: flex-end; justify-content: center; background: linear-gradient(180deg, rgba(10, 14, 36, 0) 40%, rgba(10, 14, 36, .55)); }
.title-card { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 4vh; text-align: center; }
#scr-title .logo-pre { color: #fff4dc; text-shadow: 0 2px 0 rgba(120, 50, 20, .55), 0 4px 14px rgba(40, 20, 60, .55); }
#scr-title .logo { filter: drop-shadow(0 6px 18px rgba(40, 20, 60, .45)) drop-shadow(0 6px 24px rgba(255, 180, 80, .3)); }
/* wide screens: the menu sits on the left, Pip and Lumi stand on the right of the scene */
@media (min-aspect-ratio: 5/4) and (min-width: 820px) {
  #scr-title { align-items: center; justify-content: flex-start; padding-left: calc(6vw + var(--safe-l)); background: linear-gradient(90deg, rgba(14, 18, 44, .62) 0%, rgba(14, 18, 44, .32) 34%, rgba(14, 18, 44, 0) 58%); }
  #scr-title .title-card { align-items: flex-start; text-align: left; margin-bottom: 0; max-width: min(560px, 46vw); }
  #scr-title .logo { align-items: flex-start; text-align: left; }
  #scr-title .logo.big .logo-main { font-size: clamp(54px, 7.4vw, 118px); }
  #scr-title .menu { min-width: min(300px, 40vw); }
}
.tagline { margin: 0; max-width: 520px; color: #fff3dc; font-weight: 700; font-size: clamp(14px, 1.8vw, 18px); text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.menu { display: flex; flex-direction: column; gap: 10px; min-width: min(300px, 80vw); }
.menu.row, .row { flex-direction: row; justify-content: center; flex-wrap: wrap; display: flex; gap: 10px; margin-top: 16px; }
.menu button, .row button, .slot { pointer-events: auto; cursor: pointer; padding: 13px 22px; border-radius: 16px; border: 2px solid rgba(255, 220, 160, .4); background: rgba(30, 38, 84, .78); font: 600 18px/1 'Fredoka', sans-serif; letter-spacing: .02em; transition: transform .12s, background .2s, border-color .2s; }
.menu button:hover, .row button:hover, .menu button:focus-visible, .row button:focus-visible { transform: translateY(-2px); border-color: var(--glow); outline: none; background: rgba(48, 58, 120, .9); }
button.primary { background: linear-gradient(180deg, #ffd77e, #ffab4a); color: #4a2410; border-color: #fff0c8; box-shadow: 0 6px 0 #c9702a, 0 10px 24px rgba(255, 150, 60, .35); }
button.primary:hover, button.primary:focus-visible { background: linear-gradient(180deg, #ffe39e, #ffb85e); color: #4a2410; }
.press { margin: 0; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; color: #ffe7b4; animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; } }
.panel { width: min(520px, 100%); padding: 26px clamp(18px, 4vw, 34px); border-radius: 26px; background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 30px 60px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08); }
.panel.wide { width: min(720px, 100%); }
.panel h2 { margin: 0 0 16px; text-align: center; font: 700 clamp(26px, 4vw, 36px)/1.1 'Fredoka', sans-serif; color: var(--glow); }
#scr-slots, #scr-settings, #scr-howto, #scr-credits, #scr-pause, #scr-results, #scr-shop { background: rgba(10, 14, 36, .55); backdrop-filter: blur(6px); }
.slots { display: flex; flex-direction: column; gap: 12px; }
.slot { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; }
.slot .slot-n { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 207, 107, .18); font: 700 24px/1 'Fredoka', sans-serif; color: var(--glow); }
.slot b { display: block; font-size: 18px; }
.slot small { display: block; font: 700 13px/1.3 'Nunito', sans-serif; color: var(--muted); margin-top: 4px; }
.slot .slot-del { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2); background: transparent; font-size: 12px; color: var(--muted); }
.set { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 800; }
.set input[type=range] { width: 52%; accent-color: var(--glow); }
.seg { display: flex; border-radius: 12px; overflow: hidden; border: 2px solid rgba(255,220,160,.3); }
.seg button { padding: 8px 12px; border: 0; background: transparent; font: 700 14px/1 'Nunito', sans-serif; cursor: pointer; }
.seg button.on { background: var(--glow); color: #4a2410; }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.howto div { padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.05); }
.howto b { display: block; font: 700 17px/1.2 'Fredoka', sans-serif; color: var(--glow); margin-bottom: 4px; }
.howto span { color: var(--muted); font-weight: 700; font-size: 14px; line-height: 1.4; }
.credits p { color: var(--muted); font-weight: 700; line-height: 1.5; text-align: center; }
.pause-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; text-align: center; }
.pause-stats div { padding: 10px 6px; border-radius: 14px; background: rgba(255,255,255,.05); }
.pause-stats small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }
.pause-stats b { font: 700 20px/1.2 'Fredoka', sans-serif; }
.results { text-align: center; }
.results > small { color: #ffe7b4; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.res-shards { display: flex; justify-content: center; gap: 14px; margin: 6px 0 18px; }
.res-shards i { width: 54px; height: 54px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='rgba(255,255,255,.08)' stroke='%23a8a0e8' stroke-width='1.2'/%3E%3C/svg%3E"); transform: scale(.6); opacity: 0; transition: transform .4s cubic-bezier(.2,1.6,.4,1), opacity .3s; }
.res-shards i.show { transform: none; opacity: 1; }
.res-shards i.got { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='%23ffb8ec' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E"); filter: drop-shadow(0 0 10px #ff8ad8); }
.res-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.res-grid div { padding: 12px; border-radius: 16px; background: rgba(255,255,255,.06); }
.res-grid small { display: block; color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.res-grid b { font: 700 26px/1.2 'Fredoka', sans-serif; }
.res-note { color: #ffe7b4; font-weight: 800; min-height: 1.3em; }

/* map overlay */
.map-ui { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
.map-ui.hidden { display: none; }
.map-card { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); min-width: min(380px, 90vw); padding: 14px 22px; border-radius: 20px; background: var(--panel); border: 2px solid var(--edge); text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.map-card small { display: block; color: #ffe7b4; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; font-size: 11px; }
.map-card b { display: block; font: 700 26px/1.2 'Fredoka', sans-serif; color: #fff; }
.map-card span { display: block; color: var(--muted); font-weight: 700; font-size: 14px; }
.map-shards { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.map-shards i { width: 20px; height: 20px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='none' stroke='%23a8a0e8' stroke-width='1.6'/%3E%3C/svg%3E"); }
.map-shards i.got { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 6.6 7.2.9-5.3 5 1.4 7.1L12 17.6l-6.4 3.5L7 14l-5.3-5 7.2-.9z' fill='%23ffb8ec' stroke='%23fff' stroke-width='1.2'/%3E%3C/svg%3E"); }
.map-help { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; background: rgba(24, 28, 62, .6); font-weight: 800; color: #fff3dc; font-size: 13px; letter-spacing: .04em; white-space: nowrap; }
.map-top { position: absolute; right: calc(12px + var(--safe-r)); top: 10px; display: flex; gap: 10px; align-items: center; }
.map-top button { pointer-events: auto; width: 44px; height: 44px; border-radius: 14px; border: 2px solid rgba(255,255,255,.25); background: rgba(24,28,62,.6); font-size: 18px; cursor: pointer; }
.map-total { padding: 8px 14px; border-radius: 999px; background: rgba(24,28,62,.6); font: 700 15px/1 'Fredoka', sans-serif; }

/* shop */
.shop-wallet { text-align: center; color: var(--muted); font-weight: 800; margin: -6px 0 14px; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.shop button { pointer-events: auto; text-align: left; padding: 12px 14px; border-radius: 16px; border: 2px solid rgba(255,220,160,.3); background: rgba(255,255,255,.05); cursor: pointer; }
.shop button b { display: block; font: 700 17px/1.2 'Fredoka', sans-serif; }
.shop button small { display: block; color: var(--muted); font-weight: 700; margin: 4px 0 8px; line-height: 1.35; }
.shop button em { font-style: normal; font-weight: 800; color: var(--glow); }
.shop button.owned { opacity: .55; }
.shop button.on { border-color: var(--leaf); }

@media (max-width: 640px) {
  .hearts i { width: 24px; height: 22px; }
  .beans { font-size: 17px; }
  .game-bar-title { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .banner, .toast, .veil { transition: none; } .press { animation: none; } }

/* ── premium pass: journals, confirm, results, shop ── */
.slot-row { display: flex; gap: 8px; align-items: stretch; }
.slot-row .slot { flex: 1; min-width: 0; }
.slot { grid-template-columns: 54px 1fr auto; }
.slot.new { border-style: dashed; background: rgba(30, 38, 84, .5); }
.slot .slot-go { font: 700 26px/1 'Fredoka', sans-serif; color: var(--glow); opacity: .8; padding-right: 4px; }
.slot-body { min-width: 0; }
.slot-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font: 700 13px/1.2 'Nunito', sans-serif; color: #fff0d6; }
.slot-meter { display: block; height: 6px; margin-top: 9px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.slot-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffcf6b, #ff8fb8); box-shadow: 0 0 10px rgba(255, 190, 100, .6); }
.slot-pct { font: 700 22px/1 'Fredoka', sans-serif; color: var(--glow); }
.slot:hover, .slot:focus-visible { border-color: var(--glow); outline: none; background: rgba(48, 58, 120, .9); transform: translateY(-2px); }
.slot-row .slot-del { flex: 0 0 auto; pointer-events: auto; cursor: pointer; padding: 0 14px; border-radius: 16px; border: 2px solid rgba(255, 140, 140, .28); background: rgba(80, 24, 40, .35); color: #ffc9c9; font: 700 13px/1 'Nunito', sans-serif; transition: background .2s, border-color .2s; }
.slot-row .slot-del:hover, .slot-row .slot-del:focus-visible { background: rgba(150, 40, 60, .6); border-color: #ff9a9a; outline: none; }
.panel-kicker { display: block; text-align: center; color: #ffe7b4; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; font-size: 12px; margin-bottom: 4px; }
.confirm { position: absolute; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(8, 10, 28, .6); backdrop-filter: blur(5px); animation: fadeIn .18s ease; }
.confirm.hidden { display: none; }
.confirm .panel { width: min(420px, 100%); text-align: center; animation: rise .22s cubic-bezier(.2, 1.3, .4, 1); }
.confirm p { color: var(--muted); font-weight: 700; line-height: 1.45; margin: 0; }
.confirm button { pointer-events: auto; cursor: pointer; padding: 12px 20px; border-radius: 14px; border: 2px solid rgba(255, 220, 160, .4); background: rgba(30, 38, 84, .78); font: 600 17px/1 'Fredoka', sans-serif; }
button.danger { background: linear-gradient(180deg, #ff8a8a, #e2475e); border-color: #ffd0d0; color: #fff; box-shadow: 0 5px 0 #9a2236; }
.confirm button:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.screen.on .panel { animation: rise .26s cubic-bezier(.2, 1.3, .4, 1); }
.res-best { display: inline-block; margin: -6px auto 14px; padding: 6px 14px; border-radius: 999px; background: linear-gradient(180deg, #ffd77e, #ffab4a); color: #4a2410; font: 700 15px/1 'Fredoka', sans-serif; letter-spacing: .04em; box-shadow: 0 0 18px rgba(255, 190, 90, .55); animation: rise .4s .5s both cubic-bezier(.2, 1.6, .4, 1); }
.res-best.hidden { display: none; }
#res-score { color: var(--glow); }
.shop button { display: flex; gap: 12px; align-items: flex-start; }
.shop .shop-txt { min-width: 0; }
.shop .swatch { flex: 0 0 40px; height: 40px; border-radius: 12px; background: var(--c, rgba(255,255,255,.1)); border: 2px solid rgba(255,255,255,.35); box-shadow: inset 0 -6px 0 rgba(0,0,0,.18); display: grid; place-items: center; font-size: 20px; }
.shop .swatch.icon { background: rgba(255, 207, 107, .14); }
.shop button.afford { border-color: rgba(255, 207, 107, .7); }
.shop button.short em { color: #c9bfd8; }
.shop button:hover:not(:disabled), .shop button:focus-visible { border-color: var(--glow); outline: none; background: rgba(255,255,255,.1); }
.shop button:disabled { opacity: .45; cursor: not-allowed; }
.shop button.owned { opacity: .8; }
.shop button.on em { color: var(--leaf); }
@media (max-width: 520px) {
  .slot { grid-template-columns: 42px 1fr; padding: 12px; gap: 10px; }
  .slot .slot-n { width: 42px; height: 42px; font-size: 20px; }
  .slot .slot-pct, .slot .slot-go { display: none; }
  .slot-row .slot-del { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { .screen.on .panel, .confirm, .confirm .panel, .res-best { animation: none; } }
/* tall panels on short screens: centre when there is room, scroll from the top when there isn't */
.screen:not(#scr-load):not(#scr-title) { align-items: flex-start; }
.screen:not(#scr-load):not(#scr-title) > .panel { margin: auto; }

/* ── phone landscape / short screens: compact chrome so nothing is cut off ── */
@media (orientation: landscape) and (max-height: 500px) {
  .game-bar { padding-top: calc(2px + var(--safe-t)); padding-bottom: 2px; font-size: 12px; gap: 8px; }
  .game-bar .icon-btn { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
  .game-bar .player-pill { padding: 3px 8px; }
  .game-bar-title { font-size: 12px; }

  /* title: logo + menu side by side in a compact column */
  #scr-title { align-items: center; justify-content: flex-start; padding: 8px calc(12px + var(--safe-r)) 8px calc(4vw + var(--safe-l)); background: linear-gradient(90deg, rgba(14, 18, 44, .66) 0%, rgba(14, 18, 44, .3) 40%, rgba(14, 18, 44, 0) 62%); }
  #scr-title .title-card { align-items: flex-start; text-align: left; gap: 8px; margin: 0; max-width: min(400px, 52vw); }
  #scr-title .logo { align-items: flex-start; }
  #scr-title .logo-pre { font-size: 15px; }
  #scr-title .logo.big .logo-main { font-size: clamp(34px, 11vh, 52px); }
  #scr-title .tagline { font-size: 12.5px; max-width: 360px; }
  #scr-title .menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; min-width: 0; width: min(380px, 50vw); }
  #scr-title .menu button { padding: 10px 12px; font-size: 15px; }
  #scr-title .menu .primary { grid-column: 1 / -1; }
  .press { display: none; }

  /* panels */
  .screen { padding: 8px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l)); }
  .panel { padding: 12px 18px 14px; border-radius: 20px; }
  .panel.wide { width: min(760px, 100%); }
  .panel h2 { font-size: 22px; margin-bottom: 8px; }
  .panel-kicker { font-size: 10px; margin-bottom: 0; }
  .menu { gap: 7px; }
  .menu.row, .row { margin-top: 10px; }
  .menu button, .row button { padding: 9px 16px; font-size: 15px; border-radius: 13px; }
  button.primary { box-shadow: 0 4px 0 #c9702a, 0 8px 18px rgba(255, 150, 60, .3); }
  #scr-pause .panel { width: min(560px, 100%); }
  #scr-pause .menu { display: grid; grid-template-columns: 1fr 1fr; }
  #scr-pause .menu .primary { grid-column: 1 / -1; }
  #scr-pause .menu button[hidden] { display: none; }
  .pause-stats { margin-bottom: 10px; }
  .pause-stats div { padding: 6px; }
  .pause-stats b { font-size: 17px; }
  .slots { gap: 7px; }
  .slot { padding: 8px 12px; gap: 10px; grid-template-columns: 40px 1fr auto; }
  .slot .slot-n { width: 40px; height: 40px; font-size: 19px; border-radius: 12px; }
  .slot b { font-size: 15px; }
  .slot small { font-size: 11.5px; margin-top: 2px; }
  .slot-stats { margin-top: 4px; font-size: 12px; }
  .slot-meter { margin-top: 5px; height: 5px; }
  .slot-pct { font-size: 18px; }
  .set { padding: 6px 0; }
  .seg button { padding: 6px 10px; font-size: 13px; }
  .howto { gap: 7px; grid-template-columns: repeat(3, 1fr); }
  .howto div { padding: 8px 10px; }
  .howto b { font-size: 15px; }
  .howto span { font-size: 12px; }
  .shop { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .shop button { padding: 8px 10px; gap: 8px; }
  .shop .swatch { flex-basis: 30px; height: 30px; font-size: 15px; }
  .shop button b { font-size: 14px; }
  .shop button small { font-size: 11.5px; margin: 2px 0 4px; }
  .shop-wallet { margin: -4px 0 8px; font-size: 13px; }

  /* results: shards beside a 4-up stat row */
  .results h2 { margin-bottom: 4px; }
  .res-shards { margin: 2px 0 8px; gap: 10px; }
  .res-shards i { width: 36px; height: 36px; }
  .res-best { margin: -2px auto 8px; font-size: 13px; padding: 5px 12px; }
  .res-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .res-grid div { padding: 7px 6px; border-radius: 12px; }
  .res-grid small { font-size: 10px; }
  .res-grid b { font-size: 19px; }
  .res-note { margin: 8px 0 0; font-size: 13px; }

  /* HUD: messages live in the free middle strip between the stick and the buttons */
  .hud-top { top: 8px; gap: 10px; }
  .hearts i { width: 22px; height: 20px; }
  .beans { font-size: 16px; padding: 3px 10px 3px 6px; }
  .bean-ico { width: 14px; height: 17px; }
  .shards i { width: 20px; height: 20px; }
  .abilities { top: 40px; }
  .abilities span { width: 24px; height: 24px; font-size: 12px; border-radius: 8px; }
  .pause-btn { top: 6px; width: 38px; height: 38px; border-radius: 12px; }
  .banner { top: 13%; }
  .banner b { font-size: clamp(26px, 9vh, 40px); }
  .banner small { font-size: 11px; }
  .toast { top: 10px; bottom: auto; transform: translateX(-50%) translateY(-8px); max-width: min(440px, 46vw); padding: 7px 14px; font-size: 13px; border-radius: 13px; }
  .toast.on { transform: translateX(-50%); }
  .prompt { bottom: calc(12px + var(--safe-b)); padding: 5px 12px 5px 5px; font-size: 14px; }
  .prompt kbd { min-width: 24px; height: 24px; }
  .bubble { bottom: calc(54px + var(--safe-b)); width: min(440px, 50vw); padding: 10px 14px; font-size: 13.5px; line-height: 1.35; }
  .boss-bar { bottom: calc(10px + var(--safe-b)); width: min(380px, 46vw); }
  .boss-bar b { font-size: 14px; }
  .boss-bar div { height: 10px; margin-top: 4px; }
  .timer { top: 44px; font-size: 18px; }
  .touch { transform: scale(.8); transform-origin: 100% 100%; right: calc(10px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); }
  .stick { width: 104px; height: 104px; margin: -52px 0 0 -52px; }

  /* sky map */
  .map-card { bottom: calc(8px + var(--safe-b)); min-width: min(320px, 60vw); padding: 7px 16px 8px; border-radius: 16px; }
  .map-card b { font-size: 19px; }
  .map-card span { font-size: 12px; }
  .map-card small { font-size: 10px; }
  .map-shards { margin-top: 3px; }
  .map-shards i { width: 15px; height: 15px; }
  .map-help { top: 8px; font-size: 11.5px; padding: 5px 12px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .map-top { top: 6px; }
  .map-top button { width: 38px; height: 38px; }
  .map-total { font-size: 13px; padding: 6px 10px; }

  /* story scenes: thinner bars, smaller box and portrait, skip clear of the pause button */
  .saga-cine.on.bars .saga-bar { height: clamp(14px, 6vh, 26px); }
  .saga-caption { top: 30px; font-size: 14px; }
  .saga-dlg { bottom: max(8px, env(safe-area-inset-bottom)); width: min(760px, calc(100% - 24px)); }
  .saga-portrait { width: clamp(64px, 22vh, 96px); margin-right: -16px; }
  .saga-dlg.right .saga-portrait { margin-left: -16px; }
  .saga-box { min-height: 0; padding: 12px 18px 12px 26px; }
  .saga-dlg.right .saga-box { padding: 12px 26px 12px 18px; }
  .saga-text { font-size: 14.5px; line-height: 1.38; min-height: 2.6em; }
  .saga-name { top: -13px; font-size: 11px; padding: 3px 12px 4px; }
  .saga-skip { top: 6px; right: calc(56px + var(--safe-r)); padding: 7px 12px; font-size: 11px; }
  .confirm .panel { padding: 14px 18px; }
}
/* while a story scene plays, HUD toasts and banners step aside */
body:has(.saga-cine.on) .toast, body:has(.saga-cine.on) .banner { opacity: 0 !important; }
body:has(.saga-cine.on) .pause-btn { opacity: 0; pointer-events: none; }
