@font-face { font-family: 'PSDisplay'; src: url('assets/fonts/ps-display.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'PSBody'; src: url('assets/fonts/ps-body.woff2') format('woff2'); font-display: block; }

:root { --ink: #2b2a3a; --paper: #f6f0e1; --navy: #2f4a8a; --leaf: #6d8f3a; }
/* notch / home-bar insets as padding, read by game.js layout() so the page is scaled inside them */
#safe { position: fixed; inset: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
body {
  background: #8a6a4a;
  background-image: repeating-linear-gradient(92deg, rgba(0,0,0,.05) 0 3px, transparent 3px 22px),
                    linear-gradient(#93714f, #7a5b3d);
  font-family: 'PSBody', sans-serif; color: var(--ink);
  word-break: keep-all; overflow-wrap: break-word;   /* Korean wraps between words, never inside one */
}
#stage {
  position: absolute; left: 50%; top: 50%; width: 720px; height: 1280px;
  transform-origin: 0 0; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
/* touch-action on the canvas itself: iOS Safari does not reliably take it from html/body alone */
#cv { position: absolute; inset: 0; width: 720px; height: 1280px; display: block; touch-action: none; }
#ui { position: absolute; left: 0; top: 0; width: 540px; height: 960px; transform: scale(1.33333); transform-origin: 0 0; pointer-events: none; container-type: inline-size; }
#ui > * { pointer-events: auto; }
/* the in-run buttons' layer: the page's 540x960 box, moved to the middle of a landscape stage by --fx (game.js layout) */
#ui > #hud { position: absolute; left: var(--fx, 0px); top: 0; width: 540px; height: 960px; pointer-events: none; }
#hud > button { pointer-events: auto; }
.hidden { display: none !important; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#title { background: rgba(246, 240, 225, .35); }
#cards, #pause, #results { background: rgba(43, 42, 58, .55); }
#cards { background: rgba(43, 42, 58, .8); }   /* dark enough that the canvas HUD (combo, score, slots) does not read through the offer */

.paper {
  background: var(--paper); border-radius: 6px; padding: 26px 28px;
  box-shadow: 0 3px 0 #d8cfb8, 0 10px 26px rgba(0,0,0,.3);
  text-align: center; position: relative;
}
.paper::before { /* masking tape strip */
  content: ''; position: absolute; top: -12px; left: 50%; width: 110px; height: 26px; margin-left: -55px;
  background: rgba(214, 196, 140, .75); transform: rotate(-2deg);
}
/* Lobby = title: top bar (hero, stars, clips, icons), the hero on the desk, the squad strip, the stage card and the
   sortie button, the tab bar. Laid out in the 540x960 UI box; the top bar is 72 tall, the tab bar 96. */
#title { justify-content: flex-start; padding: 76px 18px 124px;   /* bottom: the raised lobby tab (16) and the sortie ring (9) stay clear of the button */ background: radial-gradient(120% 70% at 50% 36%, rgba(255,248,226,.55), rgba(246,240,225,.2) 60%, rgba(120,92,60,.18)); }
#title > * { flex-shrink: 0; }
.logo { text-align: center; margin-top: 0; position: relative; }
.logo h1 { font-size: 46px; }
html[lang="en"] .logo h1 { font-size: 44px; line-height: 1; }
#tSub { margin: 4px 0 0; font-size: 15px; }
#tMeta:empty { display: none; }
/* the desk under the page: a pencil, a clip, shavings and eraser crumbs at the edges, out of the way of the buttons */
.tDesk { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dk { position: absolute; opacity: .9; filter: drop-shadow(2px 3px 0 rgba(43,42,58,.12)); }
.dk-pencil { width: 300px; left: -70px; top: 300px; transform: rotate(-58deg); }
.dk-clip { width: 30px; right: 26px; top: 160px; transform: rotate(14deg); }
.dk-shav { width: 92px; right: -20px; top: 430px; opacity: .75; transform: rotate(20deg); }
.dk-crumb { width: 74px; left: -12px; top: 210px; opacity: .55; transform: rotate(-12deg); }
/* top bar */
#lobBar { position: absolute; left: 0; top: 0; width: 540px; height: 72px; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 6px 8px 0;
  background: linear-gradient(rgba(246,240,225,.96), rgba(246,240,225,.82)); border-bottom: 2px solid rgba(43,42,58,.55); box-shadow: 0 3px 0 rgba(43,42,58,.08); }
.tAva { flex: none; width: 60px; height: 60px; padding: 0; border: 2.5px solid var(--ink); border-radius: 12px 15px 11px 14px; background: #fdf3c4; overflow: hidden; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
.tAva img { width: 100%; height: 118%; object-fit: cover; object-position: 50% 4%; display: block; }
.tCur { display: flex; gap: 6px; flex: 1; min-width: 0; }
.pill { position: relative; display: flex; align-items: center; gap: 3px; height: 44px; padding: 0 10px 0 4px; border: 2px solid var(--ink); border-radius: 22px 20px 21px 19px; background: #fffaf0; cursor: pointer; font: 20px 'PSDisplay', sans-serif; color: var(--ink); white-space: nowrap; }
.pill img { width: 34px; height: 34px; object-fit: contain; margin: -4px 0 -4px -6px; }
.pill b { font-weight: normal; }
#tStars { padding-bottom: 6px; }
.sbar { position: absolute; left: 30px; right: 10px; bottom: 5px; height: 5px; background: rgba(43,42,58,.15); border-radius: 3px; overflow: hidden; }
.sbar s { display: block; height: 100%; width: 0; background: #e0a81c; }
.tIcons { display: flex; gap: 4px; flex: none; }
.ibtn { width: 56px; height: 56px; padding: 0; border: 2px solid var(--ink); border-radius: 11px 14px 10px 13px; background: #fffaf0; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 2px 2px 0 var(--ink); color: var(--ink); }
.ibtn svg { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ibtn svg .f { fill: var(--ink); stroke: none; }
.ibtn.txt { font: 22px 'PSDisplay', sans-serif; }
#muteBtn .off, #muteBtn.muted .on { display: none; }
#muteBtn.muted .off { display: inline; }
.ibtn:active, .pill:active, .tAva:active { transform: translate(1px, 2px); box-shadow: none; }
/* tab bar: the lobby's sections, the lobby itself raised in the middle; a red ink dot counts what is new or affordable */
#tabBar { position: absolute; left: 0; bottom: 0; width: 540px; height: 96px; z-index: 5; display: flex; align-items: flex-end; gap: 4px; padding: 0 6px 6px;
  background: linear-gradient(rgba(233,222,196,.97), rgba(216,200,166,.98)); border-top: 2px solid var(--ink); box-shadow: 0 -3px 0 rgba(43,42,58,.08); }
.nav { position: relative; flex: 1; height: 82px; padding: 4px 0 0; border: 2px solid rgba(43,42,58,.35); border-radius: 10px 12px 9px 11px; background: rgba(255,250,240,.7); cursor: pointer; font: 15px 'PSDisplay', sans-serif; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
.nav img { width: 50px; height: 50px; object-fit: contain; display: block; transition: transform .2s; }
#tbHero { object-fit: cover; object-position: 50% 6%; border-radius: 8px; }
.nav span { white-space: nowrap; line-height: 1.1; margin-top: 2px; }
.nav.home { flex: 1.25; height: 98px; margin-top: -16px; border: 2.5px solid var(--ink); background: #fdf3c4; box-shadow: 2px 3px 0 var(--ink); }
.nav.home img { width: 62px; height: 62px; transform: rotate(-8deg); }
.nav.on { border-color: var(--ink); background: #fdf3c4; box-shadow: 2px 3px 0 var(--ink); transform: translateY(-4px); }
.nav.on img { transform: scale(1.08) rotate(-4deg); }
.nav.home.on img { transform: scale(1.06) rotate(-8deg); }
.nav:active { transform: translate(1px, 2px); box-shadow: none; }
.badge { position: absolute; right: 4px; top: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px 11px 12px 10px; background: #c2453b; color: #fffaf0; font: 16px/22px 'PSDisplay', sans-serif; font-style: normal; border: 1.5px solid #fffaf0; box-shadow: 0 0 0 1.5px #7a2a22; }
.badge:empty { display: none; }
.nav.home .badge { right: 10px; }
/* the lobby sections sit between the bars */
#heroSel, #stageSel, #shop, #starBook, #settings, #howto { padding: 84px 0 106px; }
#heroSel .paper, #stageSel .paper, #shop .paper, #starBook .paper, #howto .paper { max-height: 100%; }
/* the tabbed sections go back through the tab bar's lobby button, so their own back button gives its room to the list */
#heroSel .backBtn, #stageSel .backBtn, #shop .backBtn { display: none; }
#starBook { background: rgba(43, 42, 58, .35); }
#starBook .paper { display: flex; flex-direction: column; }
#starBook .paper > * { flex-shrink: 0; }
#sbMeter { width: 100%; }
.sbTop { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sbTop b { font: 24px 'PSDisplay', sans-serif; font-weight: normal; color: #a8780b; }
.sbTop span { font-size: 15px; opacity: .8; }
.ruler { position: relative; height: 22px; margin: 12px 14px 54px; border: 2px solid var(--ink); border-radius: 4px; background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(43,42,58,.25) 9px 10px), #fffaf0; }
.ruler .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(224,168,28,.7); }
.ruler .mk { position: absolute; top: -6px; width: 0; display: flex; flex-direction: column; align-items: center; }
.ruler .mk::before { content: ''; width: 3px; height: 30px; background: var(--ink); }
.ruler .mk b { font: 15px 'PSDisplay', sans-serif; font-weight: normal; white-space: nowrap; }
.ruler .mk em { font-style: normal; font-size: 12px; white-space: nowrap; display: flex; align-items: center; opacity: .8; }
.ruler .mk em .clip { width: 14px; height: 14px; }
.ruler .mk small { position: absolute; top: -18px; font-size: 11px; color: var(--leaf); white-space: nowrap; }
.ruler .mk.ok::before { background: var(--leaf); }
.ruler .mk:last-child { align-items: flex-end; }
.ruler .mk:last-child b, .ruler .mk:last-child em { transform: translateX(6px); }
#sbGrid { width: 100%; min-height: 0; overflow-y: auto; touch-action: pan-y; flex: 0 1 auto; margin: 4px 0 8px; }
.sgr { display: grid; grid-template-columns: 40px 1fr repeat(4, 62px); align-items: center; gap: 4px; padding: 4px 2px; border-bottom: 1px dashed rgba(43,42,58,.25); text-align: left; }
.sgr b { font: 18px 'PSDisplay', sans-serif; font-weight: normal; }
.sgr span { font-size: 14px; line-height: 1.15; }
.sgr i { font-style: normal; text-align: center; font-size: 16px; white-space: nowrap; }
.sgr i u { text-decoration: none; color: rgba(43,42,58,.18); }
.sgr i u.on { color: #e0a81c; }
.sgh i { font: 13px 'PSDisplay', sans-serif; color: var(--dc); }
.sgr.lock { opacity: .45; }
/* the hero on the desk: a lamp's warm pool, an ink bloom, a soft shadow, paper scraps fluttering and ink drops rising */
.tLamp { position: absolute; left: 50%; top: 4%; width: 380px; height: 92%; margin-left: -190px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,232,160,.75), rgba(255,232,160,.25) 60%, transparent); animation: lamp 5s ease-in-out infinite; }
.tShadow { position: absolute; left: 50%; bottom: 2px; width: 200px; height: 24px; margin-left: -100px; border-radius: 50%; background: radial-gradient(closest-side, rgba(43,42,58,.28), transparent); animation: shadow 3.2s ease-in-out infinite; }
.tFx { position: absolute; inset: 0; pointer-events: none; }
.scrap { position: absolute; left: var(--x); top: var(--y); width: 22px; height: 16px; background: #f4e9c8; border: 1.5px solid rgba(43,42,58,.45); border-radius: 2px 4px 3px 2px; transform: rotate(var(--r)); animation: scrap var(--t) var(--d) ease-in-out infinite; }
.scrap.s2 { background: #bfe0d2; width: 16px; height: 20px; }
.scrap.s3 { background: #f2c4b0; width: 18px; height: 13px; }
.drop { position: absolute; left: var(--x); bottom: 8%; width: var(--s); height: var(--s); border-radius: 50% 50% 50% 0; background: #2f346e; opacity: 0; transform: rotate(-45deg); animation: inkRise var(--t) var(--d) ease-in infinite; }
@keyframes lamp { 50% { opacity: .82; transform: scale(1.03); } }
@keyframes shadow { 50% { transform: scaleX(.86); opacity: .75; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
@keyframes scrap { 0%, 100% { transform: translate(0, 0) rotate(var(--r)) rotateX(0); } 30% { transform: translate(6px, -14px) rotate(calc(var(--r) + 18deg)) rotateX(55deg); } 65% { transform: translate(-5px, -6px) rotate(calc(var(--r) - 10deg)) rotateX(-30deg); } }
@keyframes inkRise { 0% { opacity: 0; transform: translateY(0) rotate(-45deg) scale(.6); } 15% { opacity: .7; } 100% { opacity: 0; transform: translateY(-230px) rotate(-45deg) scale(1.1); } }
/* the stage card: the chapter's page with its desk things and the boss, the stage, tier and stars */
#tCard { position: relative; display: flex; align-items: center; gap: 12px; width: 480px; height: 96px; margin-top: 10px; padding: 6px 34px 6px 8px; text-align: left; cursor: pointer;
  border: 2.5px solid var(--ink); border-radius: 10px 14px 11px 13px; background: #fffaf0; box-shadow: 3px 4px 0 var(--ink); font-family: inherit; color: inherit; }
#tCard .art { position: relative; flex: none; width: 128px; height: 80px; border: 2px solid rgba(43,42,58,.6); border-radius: 6px 8px 5px 7px; overflow: hidden; background: #f7f1e2; }
#tCard.ch0 .art { background: repeating-linear-gradient(transparent 0 15px, rgba(105,145,210,.35) 15px 16px), #f7f1e2; }
#tCard.ch1 .art { background: repeating-linear-gradient(0deg, transparent 0 15px, rgba(255,255,255,.22) 15px 16px), repeating-linear-gradient(90deg, transparent 0 15px, rgba(255,255,255,.22) 15px 16px), #6f9a78; }
#tCard.ch2 .art { background: repeating-linear-gradient(transparent 0 9px, rgba(90,70,40,.16) 9px 10px), #ecdfc4; }
#tCard .art img { position: absolute; object-fit: contain; }
#tCard .a1 { width: 58px; height: 58px; left: -6px; top: 22px; transform: rotate(-14deg); opacity: .9; }
#tCard .a2 { width: 44px; height: 44px; right: -6px; top: -4px; transform: rotate(18deg); opacity: .9; }
#tCard .boss { width: 76px; height: 76px; left: 50%; top: 4px; margin-left: -38px; filter: drop-shadow(2px 2px 0 rgba(43,42,58,.3)); animation: bossBob 2.8s ease-in-out infinite; }
#tCard .info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#tCard small { font-size: 13px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tCard b { font: 25px/1.1 'PSDisplay', sans-serif; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tCard .info > span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#tCard .dtag { font-size: 15px; vertical-align: 0; }
#tCard .stars u { text-decoration: none; font-size: 20px; color: rgba(43,42,58,.2); }
#tCard .stars u.on { color: #e0a81c; }
#tCard .clr { font-style: normal; font-size: 13px; color: var(--leaf); }
#tCard .lk { font-style: normal; font-size: 13px; padding: 0 6px; border: 1.5px dashed var(--ink); border-radius: 4px; opacity: .75; }
#tCard .go { position: absolute; right: 8px; top: 50%; margin-top: -20px; font: 34px/40px 'PSDisplay', sans-serif; font-style: normal; opacity: .55; }
#tCard .newb, .snode .newb { position: absolute; left: -8px; top: -12px; font: 14px/20px 'PSDisplay', sans-serif; font-style: normal; padding: 0 7px; background: #c2453b; color: #fffaf0; border: 1.5px solid #fffaf0; box-shadow: 0 0 0 1.5px #7a2a22; border-radius: 5px 7px 4px 6px; transform: rotate(-8deg); }
#tCard:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
@keyframes bossBob { 50% { transform: translateY(-3px) rotate(2deg); } }
/* the sortie button: the biggest thing on the page, a felt-marker yellow that breathes */
#startBtn { position: relative; width: 380px; height: 100px; margin-top: 12px; padding: 0 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 18px 24px 16px 22px; background: linear-gradient(#ffd75e, #f0b52c); box-shadow: 3px 5px 0 var(--ink), inset 0 -6px 0 rgba(168,100,10,.25); color: var(--ink); font-family: 'PSDisplay', sans-serif; }
#startBtn b { font-size: 44px; line-height: 1; font-weight: normal; }
#startBtn small { font-size: 16px; opacity: .8; margin-top: 3px; }
#startBtn small:empty { display: none; }
#startBtn::after { content: ''; position: absolute; inset: -9px; border: 3px dashed rgba(217,154,30,.75); border-radius: 24px 30px 22px 28px; pointer-events: none; animation: sortieRing 2.4s ease-in-out infinite; }
#startBtn:active { transform: translate(2px, 4px) scale(.98); box-shadow: 1px 1px 0 var(--ink), inset 0 -3px 0 rgba(168,100,10,.25); }
@keyframes sortieRing { 0%, 100% { opacity: .35; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.02); } }
/* entrance: the lobby's pieces drop onto the desk one after another */
#title.in .en { animation: enterUp .45s cubic-bezier(.2,.9,.3,1.25) both; }
#title.in .logo { animation-name: enterDown; }
#title.in #tHero { animation-delay: .08s; }
#title.in .tName { animation-delay: .16s; }
#title.in #tParty { animation-delay: .22s; }
#title.in #tCard { animation-delay: .28s; }
#title.in #startBtn { animation-delay: .36s; }
@keyframes enterUp { from { opacity: 0; transform: translateY(28px) scale(.96); } }
@keyframes enterDown { from { opacity: 0; transform: translateY(-24px) rotate(-3deg); } }
.chip { font: 17px 'PSBody', sans-serif; color: var(--ink); min-height: 66px; min-width: 66px; padding: 0 14px; background: rgba(255,250,240,.88); border: 1.5px solid rgba(43,42,58,.55); border-radius: 8px 10px 7px 9px; cursor: pointer; white-space: nowrap; }
#boot { background: rgba(246, 240, 225, .92); z-index: 9; font: 20px 'PSBody', sans-serif; color: var(--ink); text-align: center; }
#boot p { margin: 0 0 10px; }
.srow { display: flex; align-items: center; gap: 12px; width: 400px; margin: 10px 0; font: 19px 'PSBody', sans-serif; color: var(--ink); }
.srow span { width: 110px; text-align: left; }
.srow input { flex: 1; height: 44px; accent-color: #2f4a8a; }
.srow b { width: 56px; text-align: right; font-weight: normal; }
.meta-line.warn { color: #c2453b; }
.logo h1 { display: inline-block; line-height: 1; margin: 0; max-width: 500px; transform: rotate(-2deg); text-shadow: 2px 3px 0 #fffaf0; white-space: nowrap; }
/* a felt-marker stroke drawn under the logo once */
.logo h1::after { content: ''; display: block; height: 9px; margin: 3px 6% 0; background: #e0a81c; opacity: .8; border-radius: 40% 60% 45% 55% / 60% 40% 60% 40%; transform-origin: left; animation: inkDraw .7s .35s ease-out both; }
/* the hero stage takes whatever height the rest leaves */
#tHero { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 2px; flex: 1 1 0; min-height: 0; max-height: 340px; }
.tStage { position: relative; width: 330px; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
#tBloom { position: absolute; left: 15px; top: 12%; width: 300px; max-height: 84%; object-fit: contain; opacity: .3; transform: rotate(-8deg); }
#tImg { position: relative; height: 96%; width: 320px; object-fit: contain; object-position: bottom; filter: drop-shadow(3px 6px 0 rgba(43,42,58,.18)); animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; margin-bottom: 10px; }
.tStage.swap #tBloom { animation: bloom .45s ease-out; }
.tStage.swap #tImg { animation: popIn .35s ease-out, bob 3.2s .35s ease-in-out infinite; }
.arrow { width: 62px; height: 62px; flex: none; font: 38px/1 'PSDisplay', sans-serif; color: var(--ink); background: rgba(255,250,240,.9); border: 2px solid var(--ink); border-radius: 50% 46% 52% 48%; box-shadow: 2px 3px 0 var(--ink); cursor: pointer; padding: 0 0 4px; position: relative; z-index: 1; }
.arrow:active { transform: translate(2px, 3px); box-shadow: none; }
.tName { width: 400px; margin-top: -12px; padding: 8px 16px 8px; }
.tName::before { left: 14px; margin-left: 0; width: 76px; transform: rotate(-9deg); }
.tName h2 { font-size: 32px; margin: 0; line-height: 1.1; }
#tTags, .htags { display: flex; justify-content: center; gap: 6px; margin: 2px 0 4px; }
#tTags span, .htags span { font-size: 15px; padding: 1px 9px; border: 1.5px solid var(--hc); border-left-width: 5px; color: var(--ink); background: #fffaf0; border-radius: 5px 7px 4px 6px; white-space: nowrap; }
#tPlay { margin: 0; font-size: 16px; }
#tParty { display: flex; justify-content: center; gap: 8px; margin: 10px 0 0; }
.tp { width: 66px; height: 70px; padding: 2px; background: #fffaf0; border: 2px solid rgba(43,42,58,.45); border-radius: 8px 11px 7px 10px; cursor: pointer; transition: transform .15s; }
.tp img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; display: block; }
.tp.on { background: #fdf3c4; border-color: var(--hc); box-shadow: 0 0 0 2px var(--hc), 2px 3px 0 var(--ink); transform: translateY(-3px); }
.tp:active { transform: scale(.94); }
.meta-line { font-size: 15px; margin: 6px 0 0; opacity: .75; }
.meta-line.warn { color: #c2453b; opacity: 1; }
@keyframes inkDraw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes bloom { from { transform: rotate(-8deg) scale(.4); opacity: .6; } to { transform: rotate(-8deg) scale(1); opacity: .3; } }
@keyframes popIn { from { transform: translateY(14px) scale(.94); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  #tImg, .tStage.swap #tImg, .tStage.swap #tBloom, .logo h1::after, .tLamp, .tShadow, .scrap, .drop, #tCard .boss, #startBtn::after, #title.in .en { animation: none; }
  .drop { display: none; }
}
#howto .paper { display: flex; flex-direction: column; max-height: 100%; }
#howto h2, #howto .btn { flex-shrink: 0; }
#howto .btn { min-height: 66px; }
#hwList { text-align: left; font-size: 16px; line-height: 1.45; list-style: none; padding: 0 4px; margin: 6px 0 14px; min-height: 0; overflow-y: auto; touch-action: pan-y; }
#hwList > li { margin: 8px 0; }
#hwList > li > b { display: inline-block; padding: 0 8px; border-bottom: 3px solid rgba(224,168,28,.7); }
#hwList > li > b { font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 19px; }
h1, h2 { font-family: 'PSDisplay', sans-serif; font-weight: normal; margin: 0 0 6px; }
h1 { font-size: 54px; line-height: 1.05; color: var(--navy); }
h2 { font-size: 38px; word-break: keep-all; }
#rHead { font-size: 32px; }
.hero-name { font-family: 'PSDisplay', sans-serif; font-size: 24px; margin: 0 0 12px; color: var(--leaf); }
.how { font-size: 15px; line-height: 1.45; margin: 14px 0 4px; opacity: .85; }
.best { font-size: 16px; margin: 6px 0; min-height: 1em; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }

.btn {
  font-family: 'PSDisplay', sans-serif; font-size: 26px; color: var(--ink);
  background: #fffaf0; border: 2px solid var(--ink); border-radius: 10px 14px 9px 13px;
  padding: 8px 26px; margin: 6px; cursor: pointer; box-shadow: 2px 3px 0 var(--ink); white-space: nowrap; min-height: 66px;
}
.tab, .dtab, .card .tag, .card .slot, .card .lv, .pk span, .hcard b { white-space: nowrap; }
.btn:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.big { font-size: 36px; padding: 8px 46px; background: #fdf3c4; }
.btn.small { font-size: 18px; padding: 4px 14px; }
.menu { width: 400px; display: flex; flex-direction: column; align-items: center; }
.menu .btn { width: 260px; }

/* Level-up cards: the kind colour (--kc) runs down the icon tile and the tag; the icon is large, the level pips and the
   fusion strip sit under the name; event picks and fusions get their own frames. Cards deal in one after another. */
#cards h2 { color: #fffaf0; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(43,42,58,.6); margin-bottom: 14px; text-align: center; padding: 0 14px; animation: headIn .3s ease-out both; }
@keyframes headIn { from { opacity: 0; transform: translateY(-12px) scale(.92); } }
#cardOwn { display: flex; justify-content: center; gap: 8px; width: 500px; margin-bottom: 10px; }
#cardOwn:empty { display: none; }
#cardOwn .og { display: flex; gap: 3px; padding: 4px; background: rgba(246,240,225,.92); border: 1.5px solid var(--ink); border-radius: 7px 9px 6px 8px; }
#cardOwn .og.p { background: rgba(232,236,240,.92); }
#cardOwn span { position: relative; width: 34px; height: 34px; border-radius: 5px; background: #fffaf0; border: 1px solid rgba(43,42,58,.3); }
#cardOwn span.emp { border-style: dashed; background: transparent; }
#cardOwn span.evo { border-color: #b8860b; background: #fdf3c4; }
#cardOwn img { width: 100%; height: 100%; object-fit: contain; display: block; }
#cardOwn b { position: absolute; right: -3px; bottom: -4px; min-width: 15px; height: 15px; padding: 0 2px; border-radius: 4px; background: var(--ink); color: #fffaf0; font: 11px/15px 'PSDisplay', sans-serif; font-weight: normal; text-align: center; }
#cardList { display: flex; flex-direction: column; gap: 14px; width: 486px; }
#cardNote { width: 470px; margin: 12px 0 0; padding: 5px 10px; font-size: 15px; line-height: 1.35; color: var(--ink); background: #fdf3c4; border: 1.5px dashed var(--ink); border-radius: 6px; word-break: keep-all; }
#cardNote:empty { display: none; }
.card {
  --kc: #8a8698; --kl: #f1ede4;
  position: relative; display: flex; align-items: stretch; gap: 12px; text-align: left;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 9px 13px 10px 12px;
  padding: 8px 30px 9px 8px; cursor: pointer; box-shadow: 3px 4px 0 var(--ink);
  font-family: inherit; color: inherit; width: 100%;
  animation: cardIn .26s cubic-bezier(.2,.9,.3,1.2) both;
}
.card:nth-child(2) { transform: rotate(.5deg); }
.card:nth-child(3) { transform: rotate(-.4deg); }
.card:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
@keyframes cardIn { from { opacity: 0; transform: translateX(-40px) rotateY(55deg) scale(.94); } }
.card .ic { position: relative; flex: none; width: 96px; min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--kl); border: 2px solid var(--kc); border-top-width: 8px; border-radius: 7px 9px 6px 8px; padding: 2px 0 4px; }
.card .ic img { width: 80px; height: 80px; object-fit: contain; filter: drop-shadow(1px 2px 0 rgba(43,42,58,.18)); }
.card .bd { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.card .nm { font-family: 'PSDisplay', sans-serif; font-size: 27px; line-height: 1.1; }
.card .lv { font-size: 15px; color: var(--leaf); margin-left: 6px; }
.card .tag { font-size: 14px; background: #fdf3c4; border: 1px solid var(--ink); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.card .ds { font-size: 17px; line-height: 1.35; margin-top: 3px; }
.card .pair { font-size: 13px; opacity: .7; margin-top: 2px; }
.card .pair.lone { color: #a3352d; }
.card .slot { font-size: 12px; border: 1px solid var(--ink); border-radius: 4px; padding: 0 4px; margin-left: 6px; opacity: .7; }
.card .key { position: absolute; right: 8px; top: 6px; font-family: 'PSDisplay', sans-serif; font-size: 20px; opacity: .4; }
/* the kinds: new (green), stats on an attack (navy) or a support (slate), a rule change (red), a small rule (orange),
   again on a maxed skill (kraft, dashed), evolution (gold), fusion (plum) */
.k-new { --kc: #3f7d3a; --kl: #eaf3dc; }
.k-act { --kc: #2f4a8a; --kl: #e6ebf5; }
.k-pas { --kc: #6a6f86; --kl: #ecedf2; }
.k-qual { --kc: #c2453b; --kl: #fbe6e0; }
.k-minor { --kc: #d0802a; --kl: #fbeedc; }
.k-inf { --kc: #8a7a5a; --kl: #f1ebdc; }
.k-evo { --kc: #b8860b; --kl: #fdf3c4; }
.k-fuse { --kc: #7a2350; --kl: #f6e4ee; }
/* card kinds (runcards.js): a solid tab in the kind colour (also in the pause inspector's level lists) */
.kd { display: inline-block; font: 14px/19px 'PSDisplay', sans-serif; border: 1.5px solid var(--kc, var(--ink)); border-radius: 3px 5px 3px 4px; padding: 0 6px; margin-left: 6px; white-space: nowrap; vertical-align: 3px; background: var(--kc, #f6f0e1); color: #fffaf0; }
.kd.k-inf { border-style: dashed; background: var(--kl); color: var(--kc); }
.kd.k-act, .kd.k-pas { background: var(--kl); color: var(--kc); }
ul.lvl > li > .kd { flex: none; align-self: flex-start; margin: 1px 4px 0 0; }
/* family under the icon: one colour per family of the hero */
.fam { font: 13px/17px 'PSDisplay', sans-serif; padding: 0 6px; border-radius: 8px; background: var(--fc); color: #fffaf0; white-space: nowrap; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.fam b { font-weight: normal; }
.fam.f0 { --fc: #3a6fa8; } .fam.f1 { --fc: #8a5a2a; } .fam.f2 { --fc: #5b7a2a; }
/* level pips */
.pips { display: flex; align-items: center; gap: 3px; margin-top: 3px; }
.pips > i:not(.lvc) { width: 15px; height: 9px; border: 1.5px solid var(--kc); border-radius: 2px 3px 2px 3px; background: transparent; }
.pips > i.on { background: var(--kc); }
.pips > i.nx { background: #e0a81c; border-color: var(--ink); animation: pip 0.9s ease-in-out infinite; }
.pips .lvc { margin-left: 6px; }
@keyframes pip { 50% { transform: translateY(-2px); } }
/* fusion strip: the recipe this card moves forward */
.fu { display: flex; align-items: center; gap: 4px; margin-top: 5px; padding: 2px 6px 2px 3px; background: #f6e4ee; border: 1.5px dashed #7a2350; border-radius: 6px; font-size: 14px; }
.fu .fi { width: 26px; height: 26px; object-fit: contain; }
.fu b { font: 15px 'PSDisplay', sans-serif; font-weight: normal; color: #7a2350; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fu .parts { display: flex; gap: 2px; margin-left: auto; flex: none; }
.fu .parts img { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; background: #fffaf0; border: 1.5px solid rgba(43,42,58,.25); opacity: .55; }
.fu .parts img.ok { opacity: 1; border-color: var(--leaf); }
.fu .parts img.now { opacity: 1; border-color: #e0a81c; box-shadow: 0 0 0 2px #e0a81c; }
.fu em { font-style: normal; font-family: 'PSDisplay', sans-serif; white-space: nowrap; flex: none; }
.fu em u { text-decoration: none; color: #7a2350; }
.fu.done { background: rgba(255,250,240,.7); border-style: solid; }
.fu.done .parts { margin-left: 0; }
.fu.done .parts img { opacity: 1; border-color: var(--leaf); }
.fu.done em { font: 13px 'PSBody', sans-serif; opacity: .8; white-space: normal; flex: 1; }
/* evolution and fusion: a double frame and a glow behind the icon */
.card.evo { background: #fffbe8; border-color: #8a6a1a; box-shadow: 3px 4px 0 #8a6a1a, 0 0 0 4px #fdf3c4, 0 0 22px rgba(240,190,60,.75); }
.card.fuse { background: #fdf6fa; border-color: #5a1a3a; border-width: 3px; box-shadow: 3px 4px 0 #5a1a3a, 0 0 0 4px #f6e4ee, 0 0 22px rgba(122,35,80,.45); }
.card.evo .ic::before, .card.fuse .ic::before { content: ''; position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; margin: -50px 0 0 -48px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,230,140,.9), transparent); animation: glow 1.6s ease-in-out infinite; }
.card.fuse .ic::before { background: radial-gradient(closest-side, rgba(230,160,200,.85), transparent); }
.card .ic img { position: relative; }
@keyframes glow { 50% { transform: scale(1.15); opacity: .7; } }
.card.br { background: #fdf2ee; }
.card.inf { background: #f3eee2; border-style: dashed; }
/* event picks: the screen and the cards framed in the event's colour, a corner ribbon naming it */
.card.ev { --kc: #b8860b; --kl: #fff4cc; }
.card .rib { position: absolute; right: -6px; top: -11px; font: 14px/21px 'PSDisplay', sans-serif; padding: 0 9px; color: #fffaf0; background: var(--kc); border: 1.5px solid var(--ink); border-radius: 4px 6px 3px 5px; transform: rotate(3deg); box-shadow: 1px 2px 0 var(--ink); }
.card.ev:first-child .key { top: auto; bottom: 6px; }
.card.bless.b-star { background: #fff9e0; border-color: #8a6a1a; box-shadow: 3px 4px 0 #8a6a1a; }
.card.bless.b-star .ic { border-style: dashed; border-top-style: solid; }
.card.bless.b-case { --kc: #3e5f7a; --kl: #e4edf3; background: #f1f5f8; border-color: #2c4459; box-shadow: 3px 4px 0 #2c4459; }
.card.bless.b-case .ic { background: repeating-linear-gradient(90deg, var(--kl) 0 6px, #d6e2ea 6px 8px); }
.card.deal { --kc: #b02a22; --kl: #fbe3de; background: #fff6f2; border-color: #7a1a14; box-shadow: 3px 4px 0 #7a1a14; }
.card.heal.pass { background: #f1ede4; border-style: dashed; box-shadow: 2px 3px 0 rgba(43,42,58,.6); opacity: .9; }
#cards.ev-star { background: radial-gradient(80% 60% at 50% 45%, rgba(224,168,28,.35), rgba(43,42,58,.6)); }
#cards.ev-case { background: radial-gradient(80% 60% at 50% 45%, rgba(62,95,122,.4), rgba(43,42,58,.62)); }
#cards.ev-deal { background: radial-gradient(80% 60% at 50% 45%, rgba(176,42,34,.35), rgba(43,42,58,.66)); }
#cards.ev-star h2 { color: #ffe28a; }
#cards.ev-deal h2 { color: #ffd2c8; }
@media (prefers-reduced-motion: reduce) { .card, #cards h2, .pips > i.nx, .card.evo .ic::before, .card.fuse .ic::before { animation: none; } }
.card.ct + .card:not(.ct) { opacity: .85; }
.pk.fu { border-style: double; border-width: 3px; }
#supplyNum { font-family: 'PSDisplay', sans-serif; font-size: 120px; color: #fdf3c4; text-shadow: 0 4px 0 var(--ink); text-align: center; }

/* pause inspector: icon rows (attacks, supports, promotions) and the explanation of the tapped one */
#pause .menu { width: 510px; padding: 20px 14px 14px; }
#pause .row { margin-top: 2px; gap: 8px; }
#pause .menu .btn { width: 150px; margin: 0; padding: 5px 8px; font-size: 22px; }
#pause #resumeBtn { background: #fdf3c4; }
#pSkills { width: 100%; margin: 2px 0 6px; }
.prow { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.prow em { width: 52px; flex: none; font-style: normal; font-size: 14px; text-align: right; line-height: 1.1; opacity: .75; }
.prow > div { display: flex; flex-wrap: wrap; gap: 4px; }
.pk { width: 66px; padding: 2px 0 1px; border: 2px solid rgba(43,42,58,.45); border-radius: 7px 9px 6px 8px; background: #fffaf0; cursor: pointer; font-family: inherit; color: inherit; }
.pk img { width: 46px; height: 46px; object-fit: contain; display: block; margin: 0 auto; }
.pk span { display: block; font-size: 13px; line-height: 1.1; }
.pk.evo { border-color: #b8860b; background: #fdf3c4; }
.pk.lean { border-style: dashed; border-color: var(--leaf); }
.pk.pf img { object-position: top; }
.pk.on { border-color: var(--ink); box-shadow: 2px 3px 0 var(--ink); transform: translateY(-2px); background: #fdf3c4; }
.pnext { font-size: 15px; opacity: .7; }
#pInfo { width: 100%; text-align: left; font-size: 16px; line-height: 1.38; background: #fffaf0; border: 1.5px solid rgba(43,42,58,.35); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; max-height: 500px; overflow-y: auto; touch-action: pan-y; }
#pInfo h4 { font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 23px; margin: 0 0 3px; }
#pInfo h4 small { font-family: 'PSBody', sans-serif; font-size: 14px; opacity: .7; }
#pInfo p { margin: 3px 0; }
#pInfo .lean, #pInfo .dim { font-size: 15px; }
#pInfo .lean { color: var(--leaf); }
#pInfo .dim { opacity: .7; }
/* promotion choice: portrait cards, the full form shown */
#cards.promo #cardList { gap: 16px; }
.card.ct { background: #fbf4e4; border-style: dashed; }
.card.ct .risk { color: #a8331f; }
.card.ct .gain { color: var(--leaf); font-weight: bold; }
.ctt span { display: block; }
.ctt b { display: inline-block; min-width: 2.6em; font-size: 13px; padding: 0 4px; margin-right: 4px; border: 1px solid currentColor; border-radius: 4px; text-align: center; font-weight: bold; }
.ctt .when { font-style: normal; font-weight: normal; font-size: 13px; white-space: nowrap; color: var(--ink); background: #fdf3c4; border: 1px dashed var(--ink); border-radius: 4px; padding: 0 4px; }
/* contract chips in play: small, see-through, under the skill slots (lower while the boss bar is up) */
#ctChips { position: absolute; left: 8px; top: 120px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; pointer-events: none; }
#ctChips.low { top: 192px; }   /* clear of the boss bar and the label under it */
#ui:has(#cards:not(.hidden)) #ctChips { display: none; }   /* a card offer owns the screen */
.ctc span { white-space: nowrap; }
.ctc { pointer-events: auto; display: flex; align-items: center; gap: 3px; height: 24px; padding: 0 6px 0 2px; border: 1.5px solid rgba(43,42,58,.6); border-radius: 6px 8px 5px 7px; background: rgba(251,244,228,.72); font: 12px 'PSBody', sans-serif; color: var(--ink); cursor: pointer; }
.ctc img { width: 20px; height: 20px; object-fit: contain; }
.ctc b { font-size: 12px; min-width: 8px; }
.ctc.s-paid { border-color: var(--leaf); }
.ctc.s-paid b { color: var(--leaf); }
.ctc.s-fail { opacity: .6; }
.ctc.s-fail b { color: #a8331f; }
.ctn { margin: 2px 0 0; max-width: 300px; padding: 3px 7px; font-size: 13px; line-height: 1.25; background: rgba(238,245,224,.9); border: 1.5px solid var(--leaf); border-radius: 6px; }
.ctn.bad { background: rgba(251,228,222,.9); border-color: #a8331f; }
#rCts .ok { color: var(--leaf); }
#rCts .no { color: #a8331f; opacity: .8; }
.pk.ct { border-style: dashed; }
.prtag { font-size: 15px; padding: 0 6px; border: 1.5px dashed var(--ink); border-radius: 5px; background: #fdf3c4; }
/* stage select: the picked stage's reward preview, start and boss practice */
#ssPick { width: 100%; margin: 0 0 6px; padding: 6px 8px; background: #fffaf0; border: 1.5px dashed var(--ink); border-radius: 7px; }
#ssPick .pv { font-size: 14px; line-height: 1.35; word-break: keep-all; }
#ssPick .pv b { font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 18px; margin-right: 4px; }
#ssPick .pv span { margin-right: 8px; white-space: nowrap; }
#ssPick .pv .rep { color: #a8501f; }
#ssPick .pv .hb { color: #2f6b45; }
#ssPick .pv .ms { display: block; white-space: normal; opacity: .85; }
#ssPick .go { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
#ssPick #ssGo { font-size: 26px; padding: 6px 20px; }
#ssPick .prac { display: flex; align-items: center; gap: 4px; margin-left: auto; }
#ssPick .prac em { font-style: normal; font-size: 13px; width: 44px; line-height: 1.1; text-align: right; word-break: keep-all; }
#ssPick .pb { width: 66px; height: 66px; padding: 0; border: 2px solid rgba(43,42,58,.4); border-radius: 7px; background: #fffaf0; cursor: pointer; }
#ssPick .pb img { width: 58px; height: 60px; object-fit: cover; object-position: top; display: block; margin: 0 auto; }
#ssPick .pb.on { border-color: var(--ink); background: #fdf3c4; box-shadow: 2px 2px 0 var(--ink); }
#ssPick #ssPrac { font-size: 17px; padding: 4px 10px; }
#ssPick .prl { margin: 0 0 0 auto; font-size: 13px; opacity: .7; max-width: 250px; word-break: keep-all; }
#rCts { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 6px; margin: 2px 0; font-size: 14px; }
#rCts:empty { display: none; }
#rCts em { font-style: normal; opacity: .7; }
#rCts span { padding: 0 6px; border: 1px dashed var(--ink); border-radius: 4px; background: #fbf4e4; }
.card.promo { align-items: flex-start; background: #fffaf0; border-width: 3px; }
.card.promo .ic { width: 112px; border-color: var(--ink); background: #fdf3c4; }
.card.promo .ic img { width: 104px; height: 140px; object-fit: contain; object-position: top; }
.card.promo .nm { font-size: 30px; }
.card.promo .ds { font-size: 15px; }
/* structured descriptions (game.js description layout): one clause per line, numbers picked out, short tags */
.n { color: #a8501f; font-weight: bold; }
ul.dr { list-style: none; margin: 2px 0 0; padding: 0; }
ul.dr li { position: relative; padding-left: 12px; margin: 2px 0; line-height: 1.3; }
ul.dr li::before { content: ''; position: absolute; left: 1px; top: .55em; width: 5px; height: 5px; border-radius: 50%; background: rgba(43,42,58,.45); }
ul.dr li.cont { margin-left: 12px; }
.st { display: inline; }
.st i { display: inline-block; font-style: normal; font-size: .82em; line-height: 1.35; padding: 0 5px; margin: 1px 0 1px 4px; border: 1px dashed rgba(43,42,58,.5); border-radius: 4px; background: #fbf4e4; }
.lab { font-style: normal; font-size: .8em; padding: 0 5px; margin-right: 5px; border: 1px solid rgba(43,42,58,.4); border-radius: 4px; background: #efe7d2; white-space: nowrap; vertical-align: 1px; }
.sum { line-height: 1.35; }
.cond { color: #5a5670; }
.arr { font-style: normal; margin: 0 5px; color: var(--leaf); }
.tg { display: inline-block; font-style: normal; font-size: 13px; line-height: 18px; padding: 0 6px; margin-right: 5px; border-radius: 4px 6px 4px 5px; color: #fffaf0; white-space: nowrap; vertical-align: 2px; }
.tg-still { background: #2f4a8a; } .tg-move { background: #4f7a2a; } .tg-graze { background: #a8780b; } .tg-kill { background: #a8331f; }
.tg-combo { background: #7a2350; } .tg-bold { background: #2f346e; } .tg-hit { background: #8a4b2a; } .tg-eraser { background: #b04a6a; }
.tg-meter { background: #fffaf0; color: var(--ink); border: 1.5px solid var(--ink); line-height: 15px; }
.lvc { font-style: normal; font: 14px/18px 'PSDisplay', sans-serif; padding: 0 5px; border: 1.5px solid var(--ink); border-radius: 4px 6px 4px 5px; background: #fdf3c4; white-space: nowrap; display: inline-block; }
.card .lvc { margin-bottom: 2px; }
.brn { margin-top: 3px; }
.brn em { font-style: normal; opacity: .6; margin: 0 2px; }
/* a tall hand (Lv3 cards, promotions in English) scrolls instead of leaving the page */
#cards { justify-content: safe center; overflow-x: hidden; overflow-y: auto; touch-action: pan-y; padding: 12px 0; }
/* stage select: the stage list scrolls if a long chapter text or English labels need the room */
#stageSel .paper { max-height: 100%; }
#stageSel .paper > * { flex-shrink: 0; }
#stageSel #ssList { flex: 0 1 auto; min-height: 0; overflow-y: auto; touch-action: pan-y; padding: 2px 4px 6px 2px; }
#cards > * { flex-shrink: 0; }
#hsInfo { position: relative; }
#pause .menu { max-height: 950px; }
#pause .menu > * { flex-shrink: 0; }
#pause #pInfo { flex: 0 1 auto; min-height: 120px; max-height: none; }
.grp { margin-top: 6px; }
.glab { display: block; font-style: normal; font-size: 13px; opacity: .6; margin-bottom: 1px; }
ul.lvl { list-style: none; margin: 0; padding: 0; }
ul.lvl > li { display: flex; gap: 6px; align-items: flex-start; margin: 3px 0; padding: 1px 2px; line-height: 1.3; }
ul.lvl > li > .lvc { flex: none; min-width: 3.1em; text-align: center; }
ul.lvl > li.off { opacity: .45; }
ul.lvl > li.nx { background: rgba(253,243,196,.8); border-radius: 4px; }
ul.lvl > li.nx > .lvc { background: var(--leaf); color: #fffaf0; }
ul.lvl em { font-style: normal; font-size: .85em; opacity: .7; }
.grp.evo { padding: 4px 7px 5px; background: rgba(240,190,60,.12); border-radius: 5px; }
.grp.evo.ok { background: #fdf3c4; }
.evh small { font-size: 13px; opacity: .7; }
.pdesc { margin: 0 0 4px; font-size: 14px; font-style: italic; opacity: .7; }
.pplay { font-size: 16px; line-height: 1.3; padding: 4px 8px; background: #eef5e0; border-left: 4px solid var(--leaf); border-radius: 3px 6px 6px 3px; }
.pplay .lab { background: var(--leaf); color: #fffaf0; border-color: var(--leaf); }
.plean { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-top: 5px; font-size: 14px; }
.plean img { width: 30px; height: 30px; object-fit: contain; }
.plean span { margin-left: 3px; }
.pstat { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.pstat span { font-size: 13px; padding: 0 6px; border: 1px dashed var(--ink); border-radius: 4px; background: #fbf4e4; white-space: nowrap; }
#rTable { font-size: 18px; margin: 4px 0; border-spacing: 10px 2px; }
#rTable td:nth-child(odd) { text-align: right; opacity: .7; }
#rTable td:nth-child(even) { text-align: left; font-family: 'PSDisplay', sans-serif; font-size: 24px; }
/* results: how far the run got (10 waves + 3 boss phases), what felled the hero, where the clips came from, next goal */
#rProg { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 2px 0; font-size: 15px; }
#rProg div { display: flex; align-items: center; gap: 3px; }
#rProg i { width: 20px; height: 12px; border: 1.5px solid rgba(43,42,58,.5); border-radius: 3px; background: rgba(43,42,58,.06); }
#rProg i.b { width: 26px; }
#rProg .bIco { width: 24px; height: 24px; object-fit: contain; margin: -6px 0 -6px 6px; }
#rProg i.on { background: var(--leaf); border-color: var(--ink); }
#rProg i.b.on { background: #c2453b; }
#rProg i.far { border-style: dashed; border-width: 2px; border-color: var(--ink); }
#rCause { margin: 2px 0; font-size: 16px; color: #a8331f; min-height: 0; }
#rCause:empty, #rGoal:empty, #rClips:empty { display: none; }
#rClips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px 10px; width: 400px; font-size: 14px; opacity: .85; }
#rClips b { font-family: 'PSDisplay', sans-serif; font-weight: normal; color: var(--leaf); }
#rBest { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 4px 0 2px; }
#rBest small { font-size: 13px; opacity: .7; }
#rGoal { margin: 2px 0 6px; padding: 4px 10px; font-size: 16px; background: #fdf3c4; border: 1.5px dashed var(--ink); border-radius: 6px; word-break: keep-all; }

#bombBtn {
  position: absolute; left: 10px; bottom: 14px; width: 70px; height: 70px; border-radius: 12px 16px 11px 15px;
  border: 2px solid var(--ink); background: rgba(255,250,240,.88); box-shadow: 2px 3px 0 var(--ink); padding: 0; cursor: pointer;
}
#bombBtn.empty { opacity: .55; }
#ssPick .twist { margin: 0 0 4px; font-size: 14px; color: #7a2350; word-break: keep-all; }
#bombBtn, #penBtn { transition: opacity .12s; }
#bombBtn.under, #penBtn.under { opacity: .12; }   /* the hero is flying under the button: it must never hide the hero */
#bombBtn img { width: 48px; height: 48px; object-fit: contain; display: block; margin: 3px auto 0; }
#bombBtn span {
  position: absolute; right: -10px; top: -10px; min-width: 26px; height: 26px; line-height: 26px; border-radius: 13px;
  background: var(--ink); color: #fffaf0; font-family: 'PSDisplay', sans-serif; font-size: 17px; text-align: center;
}
#bombBtn i { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 7px; background: rgba(43,42,58,.25); border-radius: 3px; overflow: hidden; }
#bombBtn b { display: block; height: 100%; width: 0; background: #e58fa0; }
/* Bold Pen nib button (pen.js): bottom right, the eraser's twin; see-through so ink passing under it stays readable.
   The bar is the Pen gauge (time left during Bold Pen); the nib fills with ink as the gauge refills for Overstroke. */
#penBtn {
  position: absolute; right: 10px; bottom: 14px; width: 70px; height: 70px; border-radius: 15px 11px 16px 12px;
  border: 2px solid var(--ink); background: rgba(255,250,240,.78); box-shadow: -2px 3px 0 var(--ink); padding: 0; cursor: pointer; touch-action: none; overflow: visible;
}
#penBtn img { position: relative; width: 26px; height: 56px; object-fit: contain; display: block; margin: 2px auto 0; transform: rotate(28deg); opacity: .55; }
#penBtn.ready img, #penBtn.bold img, #penBtn.over img { opacity: 1; }
#penBtn s { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 0; border-radius: 0 0 10px 9px; background: rgba(47,52,110,.28); }
#penBtn i { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 7px; background: rgba(43,42,58,.25); border-radius: 3px; overflow: hidden; }
#penBtn b { display: block; height: 100%; width: 0; background: #2f346e; }
#penBtn.bold { background: rgba(232,226,246,.85); }
#penBtn.bold b { background: #6d5aa8; }
#penBtn em { position: absolute; right: -4px; top: -27px; white-space: nowrap; font: 14px 'PSDisplay', sans-serif; font-style: normal; color: var(--ink); background: #fdf3c4; border: 1.5px solid var(--ink); border-radius: 4px 6px 3px 5px; padding: 1px 6px; transform: rotate(-3deg); }
#penBtn em:empty { display: none; }
#penBtn.ready, #penBtn.over { animation: penReady 1s ease-in-out infinite; }
#penBtn.ready::after, #penBtn.over::after { content: ''; position: absolute; inset: -7px; border: 3px dashed #d99a1e; border-radius: 18px 14px 19px 15px; pointer-events: none; }
@keyframes penReady { 50% { transform: translateY(-3px) rotate(-2deg); } }
.pk.pen img { transform: rotate(28deg); }
#rDmg { width: 330px; margin: 0 0 6px; }
#rDmg .h { font-size: 15px; opacity: .7; margin-bottom: 4px; }
#rDmg .r { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 3px 0; }
#rDmg img { width: 26px; height: 26px; object-fit: contain; }
#rDmg .bar { flex: 1; height: 12px; background: rgba(43,42,58,.12); border-radius: 3px; overflow: hidden; }
#rDmg .bar b { display: block; height: 100%; background: var(--leaf); }
#rDmg .v { width: 52px; text-align: right; font-family: 'PSDisplay', sans-serif; }
#heroSel, #stageSel, #shop { background: rgba(43, 42, 58, .35); }
.sel { width: 500px; display: flex; flex-direction: column; align-items: center; padding: 22px 20px; }
#hsList { display: flex; gap: 6px; justify-content: center; margin: 6px 0 10px; }
.hcard {
  width: 88px; padding: 4px 2px 6px; border: 2px solid var(--ink); border-radius: 8px 11px 7px 10px; background: #fffaf0;
  cursor: pointer; font-family: inherit; color: inherit; box-shadow: 2px 3px 0 var(--ink);
}
.hcard img { width: 76px; height: 92px; object-fit: contain; display: block; margin: 0 auto; }
.hcard b { display: block; font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 14px; line-height: 1.1; }
html[lang=en] .hcard b { font-size: 11.5px; letter-spacing: -0.2px; }   /* "Origami Ranger" fits the card on one line */
.hcard.on { background: #fdf3c4; border-color: var(--hc); box-shadow: 2px 3px 0 var(--hc), 0 0 0 3px var(--hc); transform: translateY(-4px); }
#hsInfo { width: 100%; text-align: left; font-size: 15px; line-height: 1.4; margin-bottom: 4px; }
#hsInfo h3 { font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 30px; margin: 0; }
#hsInfo .tag { margin: 0 0 6px; opacity: .75; }
#hsInfo p { margin: 4px 0; }
#hsInfo h3, #hsInfo .tag { text-align: center; }
.hdl { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; margin: 6px 0 2px; font-size: 14px; }
.hdl dt { font-family: 'PSDisplay', sans-serif; font-size: 15px; white-space: nowrap; padding-top: 1px; }
.hdl dd { margin: 0; }
.hdl ul.dr { margin: 0; }
/* hero details: back · lesson replay · stage select fit one row at phone width, never splitting a label */
#heroSel .row { flex-wrap: wrap; gap: 6px; }
#heroSel .row .btn { margin: 0; padding: 8px 16px; font-size: 22px; }
#heroSel .row .btn.small { font-size: 18px; }
#heroSel .row #hsGo { font-size: 26px; padding: 8px 20px; }
#heroSel .paper { max-height: 100%; }
#hsInfo { min-height: 0; overflow-y: auto; touch-action: pan-y; }
#hsInfo .stat { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px 8px; align-items: center; font-size: 14px; }
#hsInfo .stat i { height: 9px; background: rgba(43,42,58,.15); border-radius: 3px; overflow: hidden; }
#hsInfo .stat b { display: block; height: 100%; background: var(--leaf); }
#hsInfo .sks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 6px; }
#heroSel .sel { padding: 22px 12px 16px; }
#hsInfo .sks button, .ptree button { padding: 0; background: rgba(255,250,240,.9); border: 1px solid rgba(43,42,58,.3); border-radius: 6px; cursor: pointer; }
#hsInfo .sks img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; display: block; }
#hsInfo button.on { border: 2px solid var(--ink); background: #fdf3c4; }
.ptree { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ptree em { font-style: normal; font-size: 13px; width: 64px; line-height: 1.15; opacity: .75; }
.ptree > div { display: flex; align-items: center; gap: 2px; flex: 1; justify-content: center; }
.ptree img { width: 62px; height: 70px; object-fit: contain; object-position: top; display: block; }
.ptree i { font-style: normal; opacity: .6; }
#hsSk { margin-top: 6px; padding: 6px 8px; background: #fffaf0; border: 1.5px solid rgba(43,42,58,.35); border-radius: 6px; font-size: 15px; line-height: 1.35; }
#hsSk > b { font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 19px; margin-right: 6px; }
#ssTabs { display: flex; gap: 4px; margin: 4px 0; }
.tab { font-family: 'PSDisplay', sans-serif; font-size: 18px; padding: 4px 10px; border: 2px solid var(--ink); border-radius: 8px 8px 0 0; background: #e9e1cc; cursor: pointer; color: var(--ink); }
.tab.on { background: #fdf3c4; transform: translateY(2px); }
#ssDesc { margin: 4px 0 8px; }
#ssList { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-bottom: 6px; }
.snode {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 8px 12px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: 8px 12px 9px 11px; background: #fffaf0; box-shadow: 3px 4px 0 var(--ink); font-family: inherit; color: inherit;
}
.snode.on { background: #fdf3c4; }
.snode { position: relative; }
.dtab { position: relative; }
.dtab.nw::after { content: ''; position: absolute; right: -5px; top: -5px; width: 14px; height: 14px; border-radius: 50%; background: #c2453b; border: 1.5px solid #fffaf0; box-shadow: 0 0 0 1.5px #7a2a22; }
.snode img { width: 70px; height: 70px; object-fit: contain; flex: none; }
.snode b { display: block; font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 24px; }
.snode span { display: block; font-size: 14px; opacity: .8; }
.snode .stars i, #rStars span { font-style: normal; color: rgba(43,42,58,.2); font-size: 18px; }
.snode .stars i.on, #rStars span.on { color: #e0a81c; }
.snode.lock { opacity: .45; cursor: default; box-shadow: none; }
.snode.lock img { filter: grayscale(1) brightness(.4); }
.snode em { margin-left: auto; font-style: normal; font-size: 14px; }
#rStars { font-size: 34px; letter-spacing: 6px; min-height: 4px; }
#rStars span { font-size: 34px; }
#rStage { margin: 0 0 2px; }
#shList { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-bottom: 8px; }
.upg {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%; padding: 5px 6px 5px 10px;
  border: 2px solid var(--ink); border-radius: 8px 11px 9px 10px; background: #fffaf0; box-shadow: 2px 3px 0 var(--ink);
}
.upg > img { width: 46px; height: 46px; object-fit: contain; flex: none; }
.upg > div { flex: 1; min-width: 0; }
.upg b { display: block; font-family: 'PSDisplay', sans-serif; font-weight: normal; font-size: 20px; }
.upg span { display: block; font-size: 13px; opacity: .8; }
.upg .pips { display: flex; gap: 3px; margin-top: 3px; opacity: 1; }
.upg .pips i { width: 14px; height: 6px; background: rgba(43,42,58,.18); border-radius: 2px; }
.upg .pips i.on { background: var(--leaf); }
.upg .rfp { font-size: 12px; margin-top: 2px; opacity: .7; font-style: italic; }
/* buy: the next level's price; refund (↺): the last level back for what it cost */
.ubuy, .uref { flex: none; height: 66px; font-family: 'PSDisplay', sans-serif; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ubuy { min-width: 78px; gap: 3px; font-size: 20px; padding: 0 8px; background: #fdf3c4; border: 2px solid var(--ink); border-radius: 8px 10px 7px 9px; box-shadow: 2px 2px 0 var(--ink); }
.ubuy:active, .uref:active { transform: translate(1px, 2px); box-shadow: none; }
.ubuy:disabled { background: #fffaf0; opacity: .5; box-shadow: none; cursor: default; }
.upg.maxed .ubuy { opacity: 1; color: var(--leaf); }
.uref { width: 66px; flex-direction: column; font-size: 13px; line-height: 1.05; background: transparent; border: 1.5px dashed rgba(43,42,58,.6); border-radius: 7px 9px 6px 8px; }
.uref b { font-size: 20px; }
.uref:disabled { opacity: .25; cursor: default; }
#shop .paper { position: relative; }
#shop .row { margin-top: 0; }
#shop .row .btn, #ssTabs .tab { min-height: 66px; }
#shConfirm, #stConfirm { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; background: rgba(246,240,225,.95); border-radius: 6px; }
#shAsk, #stAsk { font-size: 22px; line-height: 1.4; margin: 0 0 8px; word-break: keep-all; }
#shClips { display: flex; align-items: center; justify-content: center; gap: 4px; }
.clip { width: 22px; height: 22px; object-fit: contain; }
/* difficulty tiers: felt tabs in the tier colour (game.js DIFF_COL mirrors these) */
.d-easy { --dc: #4f7a2a; } .d-normal { --dc: #2f4a8a; } .d-hard { --dc: #a8501f; } .d-nightmare { --dc: #7a2350; }
#ssDiff { display: flex; gap: 5px; margin: 6px 0 2px; }
.dtab { font-family: 'PSDisplay', sans-serif; font-size: 19px; padding: 6px 10px; min-width: 86px; min-height: 66px; border: 2px solid var(--dc); border-radius: 9px 12px 8px 11px; background: #fffaf0; color: var(--dc); cursor: pointer; }
.dtab.on { background: var(--dc); color: #fffaf0; box-shadow: 2px 3px 0 var(--ink); transform: translateY(-2px); }
#ssDiffDesc { font-size: 14px; line-height: 1.35; margin: 4px 0 8px; min-height: 2.7em; opacity: .85; word-break: keep-all; }
.snode .dclr { margin-top: 3px; opacity: 1; }
.dclr i { display: inline-block; font-style: normal; font-size: 11px; line-height: 15px; padding: 0 4px; margin-right: 3px; border: 1px solid var(--dc); border-radius: 4px; color: var(--dc); opacity: .6; }
.dclr i.ok { background: var(--dc); color: #fffaf0; opacity: 1; }
.dclr i.no { border-style: dashed; opacity: .35; }
.snode.dlock { opacity: .7; cursor: default; box-shadow: none; }
.dtag { display: inline-block; font-size: 17px; padding: 0 7px; border-radius: 5px; background: var(--dc); color: #fffaf0; vertical-align: 2px; }
#rerollBtn { margin-top: 14px; }
#nextBtn { font-size: 28px; white-space: nowrap; padding: 8px 20px; }
/* the card a gamepad's d-pad points at */
.card.padon { outline: 4px dashed #e0a81c; outline-offset: 4px; }
/* settings: full screen, save backup to a file and back */
#settings .srow2 { flex-wrap: wrap; gap: 6px; margin-top: 4px; }
#settings .srow2 .btn { margin: 0; min-height: 56px; }
#stSave { margin-top: 6px; min-height: 1em; }
#stSave:empty { display: none; }
#stPrivacy { color: var(--navy); }
/* loading bar under the boot note */
#bootBar { width: 300px; height: 14px; margin: 4px auto 6px; border: 2px solid var(--ink); border-radius: 7px; background: #fffaf0; overflow: hidden; }
#bootFill { display: block; height: 100%; width: 0; background: #e0a81c; transition: width .2s; }
/* a phone held sideways (touch screen, short): portrait-only, ask to turn it */
#rotate { display: none; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; text-align: center;
  background: #f6f0e1; color: var(--ink); font: 22px 'PSBody', sans-serif; }
#rotate b { display: block; font-size: 64px; line-height: 1; margin-bottom: 10px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 50% { transform: rotate(90deg); } }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 540px) { #rotate { display: flex; } }
#pauseBtn {
  position: absolute; right: 10px; top: 40px; width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--ink); background: rgba(255,250,240,.85); font-weight: bold; font-size: 16px; cursor: pointer;
}

/* ---------------------------------------------------------------- landscape window (html.wide, game.js layout)
   The stage fills the window: the play page in the middle on the desk, the run's panels either side of it, the lobby
   spread over a full-width sketchbook page. */
.side { display: none; }
.wide #stage { box-shadow: none; background: repeating-linear-gradient(92deg, rgba(0,0,0,.05) 0 3px, transparent 3px 22px), linear-gradient(#93714f, #7a5b3d); }
.wide #cv { box-shadow: 0 0 0 2px rgba(43,42,58,.5), 0 10px 40px rgba(0,0,0,.45); }
.wide .side { position: absolute; top: 0; bottom: 0; width: var(--fx); padding: 24px 28px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; pointer-events: none; }
#sideL { left: 0; }
#sideR { right: 0; }
.sp { width: 100%; max-width: 440px; background: var(--paper); border-radius: 6px 9px 5px 8px; padding: 12px 16px; box-shadow: 0 3px 0 #d8cfb8, 0 8px 20px rgba(0,0,0,.3); font-size: 18px; line-height: 1.3; }
.sp td:first-child::first-letter { text-transform: uppercase; }
.sp > b, .sp.who b, .sp h4 { display: block; font: 24px/1.15 'PSDisplay', sans-serif; font-weight: normal; margin: 0 0 4px; }
.sp h4 { font-size: 19px; margin: 6px 0 4px; opacity: .8; }
.sp h4:first-child { margin-top: 0; }
.sp > span:not(.dtag):not(.prtag), .sp.who span { display: block; margin-top: 4px; }
.sp > b { display: inline-block; margin-right: 8px; }
.sp .dtag { font-size: 15px; }
.sp.who { display: flex; gap: 14px; align-items: center; }
.sp.who img { width: 104px; height: 120px; object-fit: contain; object-position: top; flex: none; }
.sp.who > div { flex: 1; min-width: 0; }
.gb { display: block; height: 12px; margin-top: 3px; background: rgba(43,42,58,.15); border-radius: 4px; overflow: hidden; }
.gb s { display: block; height: 100%; }
.sp table { width: 100%; border-collapse: collapse; }
.sp td { padding: 2px 0; }
.sp td:last-child { text-align: right; font: 22px 'PSDisplay', sans-serif; }
.sp .sks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.sp .sks span { display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 15px; }
.sp .sks img { width: 34px; height: 34px; object-fit: contain; flex: none; }
.sp .sks em { font-style: normal; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp .sks u { text-decoration: none; flex: none; color: var(--leaf); }
.sp .sks .evo u { color: #b8860b; }
.sp.keys td { font-size: 16px; }
.sp.keys td:last-child { font: 16px 'PSBody', sans-serif; }
.sp kbd { font: 15px 'PSDisplay', sans-serif; padding: 0 6px; border: 1.5px solid var(--ink); border-radius: 4px; background: #fffaf0; white-space: nowrap; }
/* lobby: one wide sketchbook page; the bars span it, the hero on the left, the pick and the sortie on the right */
.wide #lobBar, .wide #tabBar { width: 100%; }
.wide #tabBar { justify-content: center; }
.wide .nav { flex: 0 1 170px; }
.wide .nav.home { flex-basis: 210px; }
.wide #title, .wide #heroSel, .wide #stageSel, .wide #shop, .wide #starBook, .wide #settings, .wide #howto {
  background: linear-gradient(90deg, transparent 0 110px, rgba(194,69,59,.3) 110px 112px, transparent 112px),
    repeating-linear-gradient(transparent 0 33px, rgba(105,145,210,.25) 33px 34px), #f6f0e1;
}
.wide #title { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 500px); grid-template-rows: auto auto auto auto auto 1fr;
  grid-template-areas: "logo meta" "hero name" "hero party" "hero card" "hero start" "hero ."; justify-content: center; align-content: center; column-gap: 60px; padding: 90px 40px 120px; }
.wide #title .logo { grid-area: logo; align-self: end; }
.wide #tMeta { grid-area: meta; }
.wide #tHero { grid-area: hero; max-height: none; height: 600px; align-self: center; }
.wide .tStage { width: 400px; }
.wide #tImg { width: 390px; }
.wide #title .tName { grid-area: name; margin: 30px auto 0; }
.wide #tParty { grid-area: party; }
.wide #tCard { grid-area: card; margin: 16px auto 0; }
.wide #startBtn { grid-area: start; margin: 22px auto 0; }
/* a level-up offer side by side when the window has the room */
@container (min-width: 1300px) {
  #cardList { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: stretch; width: 100%; padding: 0 30px; }
  #cardList .card { width: 400px; }
}
