/* DEEPFOLD: styles. Palette = the Kenney 1-Bit sheet's eight colours (+ darker shades of its background). */
@font-face { font-family: 'KPixel'; src: url('assets/fonts/pixel.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'KMini'; src: url('assets/fonts/minisquare.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'KBlocks'; src: url('assets/fonts/blocks.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'KFuture'; src: url('assets/fonts/futurenarrow.ttf') format('truetype'); font-display: block; }

:root {
  --bg: #472d3c; --bg0: #1d121a; --bg1: #2d1c27; --bg2: #3a2432; --bg3: #52374a;
  --cream: #cfc6b8; --orange: #bf7958; --red: #e6482e; --blue: #3cacd7; --mauve: #7a444a; --green: #38d973; --gold: #f4b41b;
  --dim: #9b8c88; --line: #7a444a;
  --f-body: 'KPixel', 'Courier New', monospace; --f-head: 'KMini', 'KPixel', monospace; --f-logo: 'KBlocks', 'KMini', monospace; --f-num: 'KFuture', 'KPixel', monospace;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  --fs: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg0); color: var(--cream); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--f-body); font-size: var(--fs); line-height: 1.25; -webkit-font-smoothing: none; font-smooth: never; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
img.px, canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; flex: none; }
#app { position: fixed; inset: 0; background: var(--bg0); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; padding: var(--st) var(--sr) var(--sb) var(--sl); background:
  radial-gradient(ellipse at 50% 30%, rgba(122,68,74,.18), transparent 62%), var(--bg0); overflow: hidden; }
.screen.on { display: flex; animation: fadein .18s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 14px; }

/* ---- pixel panels: borders made of four shadows so corners are notched ---- */
.panel { background: var(--bg1); margin: 3px; box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 0 0 2px var(--bg2); padding: 10px 12px; position: relative; }
.panel.hi { --line: var(--cream); }
.panel.gold { --line: var(--gold); }
.panel.red { --line: var(--red); }
.panel.blue { --line: var(--blue); }
.panel.dark { background: var(--bg0); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg2); margin: 3px; padding: 9px 14px; border: 0; min-height: 40px; --line: var(--mauve);
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -4px 0 0 rgba(0,0,0,.28); text-transform: uppercase; letter-spacing: .06em; font-family: var(--f-head); font-size: var(--fs); position: relative; touch-action: manipulation; }
.btn:hover { --line: var(--orange); background: var(--bg3); }
.btn:active { transform: translateY(2px); box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 2px 0 0 rgba(0,0,0,.35); }
.btn.pri { background: var(--orange); color: var(--bg0); --line: var(--cream); text-shadow: none; }
.btn.pri:hover { background: var(--gold); }
.btn.go { background: var(--green); color: var(--bg0); --line: var(--cream); }
.btn.danger { background: var(--red); color: var(--bg0); --line: var(--cream); }
.btn.sm { min-height: 32px; padding: 5px 10px; font-size: 14px; }
.btn.sq { min-width: 40px; padding: 6px; }
.btn[disabled], .btn.off { opacity: .45; pointer-events: none; filter: grayscale(.4); }
.btn.on { --line: var(--gold); background: var(--bg3); }
.btn .k { font-family: var(--f-num); font-size: 11px; color: var(--dim); text-transform: none; letter-spacing: 0; }

.h1 { font-family: var(--f-head); font-size: 28px; text-transform: uppercase; letter-spacing: .08em; }
.h2 { font-family: var(--f-head); font-size: 20px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }
.h3 { font-family: var(--f-head); font-size: 16px; text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--dim); } .gold { color: var(--gold); } .red { color: var(--red); } .blue { color: var(--blue); } .green { color: var(--green); } .orange { color: var(--orange); } .cream { color: var(--cream); }
.sm { font-size: 14px; } .xs { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .col { display: flex; flex-direction: column; gap: 8px; } .wrapx { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; } .gap2 { gap: 4px; } .gap3 { gap: 12px; } .gap4 { gap: 18px; }
.center { text-align: center; justify-content: center; align-items: center; } .right { text-align: right; margin-left: auto; }
.num { font-family: var(--f-num); }
.rar-c { --rc: var(--cream); } .rar-u { --rc: var(--blue); } .rar-r { --rc: var(--gold); } .rar-m { --rc: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; background: var(--bg0); border: 2px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* bars */
.bar { height: 14px; background: var(--bg0); border: 2px solid var(--mauve); position: relative; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--red); transition: width .25s; }
.bar > i.lag { background: var(--cream); opacity: .5; transition: width .7s .15s; }
.bar.g > i { background: var(--green); } .bar.b > i { background: var(--blue); } .bar.o > i { background: var(--orange); }
.bar .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--f-num); font-size: 11px; color: #fff; text-shadow: 1px 1px 0 var(--bg0), -1px 1px 0 var(--bg0), 1px -1px 0 var(--bg0), -1px -1px 0 var(--bg0); z-index: 2; }

/* ---- title ---- */
#s-title { align-items: center; justify-content: center; text-align: center; }
#s-title .logo { font-family: var(--f-logo); font-size: clamp(38px, calc(var(--dw) * 0.11), 92px); letter-spacing: .12em; color: var(--gold); text-shadow: 4px 4px 0 var(--red), 8px 8px 0 var(--bg0); margin-bottom: 4px; line-height: 1.05; }
#s-title .tag-line { color: var(--cream); margin-bottom: 18px; font-size: 18px; max-width: 520px; padding: 0 16px; }
#s-title .menu { display: flex; flex-direction: column; gap: 6px; width: min(320px, calc(var(--dw) * 0.86)); }
#s-title .menu .btn { width: 100%; font-size: 18px; min-height: 46px; }
#parade { position: absolute; left: 0; right: 0; bottom: calc(var(--sb) + 8px); height: 96px; pointer-events: none; }
#s-title .foot { position: absolute; bottom: calc(var(--sb) + 4px); left: 0; right: 0; font-size: 12px; color: var(--dim); }
.pointsbadge { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 14px; }

/* ---- generic top bar ---- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg1); border-bottom: 3px solid var(--mauve); flex: none; }
.topbar .ttl { font-family: var(--f-head); font-size: 18px; text-transform: uppercase; letter-spacing: .08em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- setup ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 12px; padding: 4px; }
.pcard { cursor: pointer; text-align: left; display: block; width: 100%; color: inherit; --line: var(--mauve); }
.pcard.sel { --line: var(--gold); background: var(--bg2); }
.pcard .nm { font-family: var(--f-head); font-size: 18px; text-transform: uppercase; }
.skillrow { display: flex; gap: 6px; flex-wrap: wrap; }
.skbtn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--bg0); border: 2px solid var(--mauve); cursor: pointer; font-size: 13px; color: inherit; }
.skbtn.sel { border-color: var(--gold); background: var(--bg3); }
.skbtn.fixed { border-color: var(--bg3); cursor: default; }
.field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
input[type=text] { font: inherit; background: var(--bg0); color: var(--cream); border: 2px solid var(--mauve); padding: 6px 8px; min-width: 0; text-transform: lowercase; }
input[type=range] { accent-color: var(--orange); }

/* ---- map ---- */
#s-map .floors { display: flex; flex-direction: column-reverse; gap: 8px; padding: 6px 4px 18px; }
.floorrow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.floorrow .fn { width: 56px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--f-head); color: var(--dim); }
.floorrow.cur .fn { color: var(--gold); }
.floorrow.done { opacity: .5; } .floorrow.future { opacity: .7; }
.opt { flex: 1 1 150px; min-width: 0; text-align: left; display: flex; gap: 10px; align-items: flex-start; color: inherit; cursor: pointer; }
.opt .ic { flex: none; }
.opt .nm { font-family: var(--f-head); text-transform: uppercase; letter-spacing: .05em; }
.enemyrow { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 4px; }
.floorrow.cur .opt:hover { --line: var(--gold); background: var(--bg2); }
.runstrip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 10px; background: var(--bg1); border-bottom: 3px solid var(--mauve); flex: none; }
.relicrow { display: flex; gap: 4px; flex-wrap: wrap; }
.relicrow .ri { padding: 2px; background: var(--bg0); border: 2px solid var(--bg3); cursor: pointer; }

/* ---- battle ---- */
#s-battle { background: var(--bg0); }
#b-top { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg1); border-bottom: 3px solid var(--mauve); flex: none; }
#b-hp { flex: 1; min-width: 0; max-width: 340px; }
#b-hp .bar { height: 18px; }
#b-floor { text-align: center; line-height: 1.1; min-width: 74px; }
#b-floor .f1 { font-family: var(--f-head); text-transform: uppercase; font-size: 15px; color: var(--gold); }
#b-floor .f2 { font-size: 12px; color: var(--dim); }
#b-gold { display: flex; align-items: center; gap: 4px; font-family: var(--f-num); font-size: 14px; color: var(--gold); min-width: 54px; }
#b-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#b-board { flex: 1; min-height: 120px; display: flex; align-items: flex-end; justify-content: center; position: relative; overflow: hidden; background: #140c12; }
#board { display: block; touch-action: none; cursor: crosshair; box-shadow: 0 0 0 3px var(--mauve), 0 0 0 6px var(--bg0); }
#banner { position: absolute; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none; font-family: var(--f-head); font-size: 26px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); text-shadow: 3px 3px 0 var(--bg0); opacity: 0; transition: opacity .2s; }
#banner.show { opacity: 1; } #banner.red { color: var(--red); }
#hintbar { position: absolute; left: 6px; right: 6px; top: 6px; display: none; z-index: 5; }
#hintbar.show { display: block; }
#hintbar .panel { --line: var(--gold); display: flex; gap: 10px; align-items: flex-start; font-size: 15px; background: var(--bg1); }
#b-panel { flex: none; display: flex; flex-direction: column; background: var(--bg1); border-top: 3px solid var(--mauve); padding: 6px 8px calc(6px); gap: 4px; }
#b-info { min-height: 76px; padding: 6px 10px; margin: 3px; font-size: 14px; }
#b-info .nm { font-family: var(--f-head); text-transform: uppercase; letter-spacing: .05em; }
#b-res { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 4px; min-height: 28px; }
.pips { display: inline-flex; gap: 2px; align-items: center; }
.pips .pip { width: 20px; height: 20px; position: relative; }
.pips .pip img { position: absolute; inset: 0; }
.pips .pip.off img { opacity: .22; }
.pips .pip.flash { animation: pipflash .5s; }
@keyframes pipflash { 0% { transform: scale(1.8); } 100% { transform: scale(1); } }
#incoming { margin-left: auto; font-family: var(--f-body); font-size: 15px; display: flex; align-items: center; gap: 6px; }
#incoming.lethal { color: var(--red); animation: blink 0.7s infinite; }
@keyframes blink { 50% { opacity: .45; } }
#b-skills { display: flex; gap: 4px; justify-content: center; flex-wrap: nowrap; padding: 2px 0; }
.sbtn { position: relative; flex: 1; max-width: 92px; min-width: 52px; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 2px; background: var(--bg2); border: 0; color: inherit; margin: 3px;
  box-shadow: 0 -3px 0 0 var(--line), 0 3px 0 0 var(--line), -3px 0 0 0 var(--line), 3px 0 0 0 var(--line), inset 0 -4px 0 rgba(0,0,0,.28); --line: var(--mauve); }
.sbtn.sel { --line: var(--gold); background: var(--bg3); transform: translateY(-3px); }
.sbtn.off { opacity: .42; filter: grayscale(.5); }
.sbtn .nm { font-size: 11px; text-transform: uppercase; text-align: center; line-height: 1; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.sbtn .cost { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 4px; background: var(--gold); color: var(--bg0); font-family: var(--f-num); font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg0); }
.sbtn .cost.free { background: var(--green); }
.sbtn .cdv { position: absolute; inset: 0; background: rgba(29,18,26,.78); display: none; align-items: center; justify-content: center; font-family: var(--f-num); font-size: 22px; color: var(--cream); }
.sbtn.cd .cdv { display: flex; }
.sbtn .key { position: absolute; left: 3px; top: 1px; font-family: var(--f-num); font-size: 10px; color: var(--dim); }
#b-acts { display: flex; gap: 4px; align-items: center; justify-content: center; padding-bottom: 2px; }
#b-acts .btn { flex: 0 0 auto; }
#b-acts .endbtn { flex: 1; max-width: 220px; font-size: 18px; }
.confirmbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 6; display: none; gap: 8px; }
.confirmbar.show { display: flex; }

:where(body.land) {
  #b-main { flex-direction: row; }
  #b-board { flex: 1; align-items: center; }
  #b-panel { width: 380px; border-top: 0; border-left: 3px solid var(--mauve); padding: 10px; gap: 8px; overflow-y: auto; }
  #b-info { min-height: 150px; font-size: 15px; }
  #b-skills { flex-wrap: wrap; }
  .sbtn { max-width: 108px; min-height: 72px; }
}
:where(body.port.short) { #b-info { min-height: 58px; } .sbtn { min-height: 56px; } }
:where(body.never) {
  #b-main { flex-direction: row; } #b-board { align-items: center; } #b-panel { width: 300px; border-top: 0; border-left: 3px solid var(--mauve); overflow-y: auto; }
  #b-skills { flex-wrap: wrap; } #b-info { min-height: 80px; }
}

/* ---- reward / shop / camp / event ---- */
.rcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; padding: 4px; }
.rcard { text-align: left; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 6px; --line: var(--rc, var(--mauve)); width: 100%; }
.rcard:hover { background: var(--bg2); }
.rcard .nm { font-family: var(--f-head); text-transform: uppercase; letter-spacing: .05em; color: var(--rc, var(--cream)); }
.rcard .rar { font-size: 11px; text-transform: uppercase; color: var(--rc, var(--dim)); letter-spacing: .1em; }
.rcard ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.rcard li::before { content: '+ '; color: var(--rc, var(--dim)); }
.rcard li.plain::before { content: ''; }
.price { display: inline-flex; align-items: center; gap: 4px; font-family: var(--f-num); color: var(--gold); }
.price.no { color: var(--red); }
.sold { opacity: .35; pointer-events: none; }
.summary { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; font-size: 15px; }
.summary .stat { text-align: center; }
.summary .stat b { display: block; font-family: var(--f-num); font-size: 20px; color: var(--gold); font-weight: normal; }

/* ---- modal / toast / tip ---- */
#modal { position: fixed; inset: 0; display: none; z-index: 50; background: rgba(20,12,18,.78); align-items: center; justify-content: center; padding: calc(var(--st) + 12px) 12px calc(var(--sb) + 12px); }
#modal.on { display: flex; animation: fadein .15s; }
#modal .box { max-width: 560px; width: 100%; max-height: 100%; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
#modal .box > .body { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; touch-action: pan-y; }
#modal .box.wide { max-width: 820px; }
#toasts { position: fixed; left: 0; right: 0; top: calc(var(--st) + 56px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 6px 12px; background: var(--bg1); box-shadow: 0 -3px 0 0 var(--gold), 0 3px 0 0 var(--gold), -3px 0 0 0 var(--gold), 3px 0 0 0 var(--gold); animation: toast 2.4s forwards; max-width: calc(var(--dw) * 0.88); text-align: center; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }
#tip { position: fixed; z-index: 70; display: none; max-width: 280px; padding: 6px 10px; background: var(--bg0); box-shadow: 0 -3px 0 0 var(--cream), 0 3px 0 0 var(--cream), -3px 0 0 0 var(--cream), 3px 0 0 0 var(--cream); font-size: 14px; pointer-events: none; }
#tip .nm { font-family: var(--f-head); text-transform: uppercase; color: var(--gold); }

/* ---- end screen ---- */
#s-end .big { font-family: var(--f-logo); font-size: clamp(34px, calc(var(--dw) * 0.09), 70px); letter-spacing: .1em; }
#s-end .big.win { color: var(--gold); text-shadow: 4px 4px 0 var(--red); } #s-end .big.lose { color: var(--red); text-shadow: 4px 4px 0 var(--bg0); }
.pline { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 2px dotted var(--bg3); font-size: 15px; }

/* ---- tree ---- */
#s-tree { background: #150d12; }
#tree-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#tree-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#tree-canvas.drag { cursor: grabbing; }
.tree-top { display: flex; gap: 6px; align-items: center; padding: 6px 8px; background: var(--bg1); border-bottom: 3px solid var(--mauve); flex-wrap: wrap; flex: none; }
.preset { padding: 4px 10px; min-height: 34px; font-size: 13px; }
#tree-sheet { position: absolute; left: 8px; right: 8px; bottom: calc(8px); z-index: 4; pointer-events: none; display: flex; justify-content: center; }
#tree-sheet .panel { pointer-events: auto; width: min(560px, 100%); }
#tree-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; z-index: 3; }
#tree-tools .btn { min-width: 40px; width: 40px; padding: 0; }
#tree-search { width: 130px; }
#tree-legend { position: absolute; left: 8px; top: 8px; z-index: 3; font-size: 12px; color: var(--dim); pointer-events: none; }
.sector-chip { display: inline-block; width: 10px; height: 10px; margin-right: 4px; }

/* ---- help ---- */
.helpbody { font-size: 15px; line-height: 1.35; display: flex; flex-direction: column; gap: 8px; }
.helpbody h3 { color: var(--gold); font-family: var(--f-head); text-transform: uppercase; letter-spacing: .06em; font-size: 16px; margin-top: 8px; }
.helpbody ul { margin: 0; padding-left: 18px; }
.legend { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }

:where(body.port) { & { --fs: 15px; } .wrap { padding: 8px; } .h1 { font-size: 22px; } }
:where(body.land) { & { --fs: 18px; } }
@media (prefers-reduced-motion: reduce) { .screen.on, #modal.on { animation: none; } }

/* ---- route map: left-to-right track of pins (after SSB64 Classic Mode) ---- */
.trackwrap { position: relative; display: flex; align-items: center; min-height: 0; background: #120a10; border-bottom: 3px solid var(--mauve); overflow: hidden; }
.track-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-x; cursor: grab; scrollbar-width: thin; scrollbar-color: var(--mauve) var(--bg0); }
.track-scroll.drag { cursor: grabbing; }
.track { position: relative; flex: none; }
.band { position: absolute; top: 0; bottom: 0; border-left: 3px solid rgba(0, 0, 0, .4); }
.band span { position: absolute; top: 8px; left: 14px; font-family: var(--f-head); font-size: 13px; text-transform: uppercase; letter-spacing: .14em; opacity: .75; }
.band.crypt { background: linear-gradient(180deg, rgba(122, 68, 74, .26), rgba(122, 68, 74, .04)); } .band.crypt span { color: var(--orange); }
.band.grove { background: linear-gradient(180deg, rgba(56, 217, 115, .14), rgba(56, 217, 115, .02)); } .band.grove span { color: var(--green); }
.band.ember { background: linear-gradient(180deg, rgba(230, 72, 46, .2), rgba(230, 72, 46, .03)); } .band.ember span { color: var(--red); }
.trk-svg { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.trk-svg path { fill: none; stroke-linecap: square; }
.trk-svg path.done { stroke: var(--gold); stroke-width: 5; stroke-dasharray: 2 9; }
.trk-svg path.skip { stroke: var(--bg3); stroke-width: 4; stroke-dasharray: 2 9; opacity: .5; }
.trk-svg path.cur { stroke: var(--cream); stroke-width: 5; stroke-dasharray: 2 9; animation: march 1s linear infinite; }
.trk-svg path.future { stroke: var(--mauve); stroke-width: 4; stroke-dasharray: 2 9; opacity: .75; }
@keyframes march { to { stroke-dashoffset: -22; } }
.bead { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--bg2); box-shadow: 0 0 0 3px var(--mauve); }
.bead.on { background: var(--gold); box-shadow: 0 0 0 3px var(--orange); }
.mark { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--f-head); font-size: 12px; letter-spacing: .1em; color: var(--dim); }
.hero { position: absolute; margin: -58px 0 0 -24px; z-index: 3; pointer-events: none; animation: hop .9s steps(2) infinite; }
@keyframes hop { 50% { transform: translateY(-4px); } }
.pin { position: absolute; width: 0; height: 0; padding: 0; border: 0; background: none; color: inherit; cursor: default; z-index: 2; --pc: var(--cream); }
.pin::before { content: ''; position: absolute; left: -42px; top: -100px; width: 84px; height: 124px; }
.pin .head { position: absolute; left: -27px; top: -84px; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; background: var(--bg2);
  box-shadow: 0 -3px 0 0 var(--pc), 0 3px 0 0 var(--pc), -3px 0 0 0 var(--pc), 3px 0 0 0 var(--pc), inset 0 -4px 0 rgba(0, 0, 0, .3); }
.pin .stake { position: absolute; left: -9px; top: -29px; width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 19px solid var(--pc); }
.pin .base { position: absolute; left: -38px; top: -12px; width: 76px; height: 26px; background: var(--pc); clip-path: polygon(22% 0, 78% 0, 100% 50%, 78% 100%, 22% 100%, 0 50%); }
.pin .base::after { content: ''; position: absolute; inset: 5px 16px; background: rgba(0, 0, 0, .35); clip-path: polygon(20% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%); }
.pin .ck { position: absolute; right: -9px; bottom: -9px; padding: 2px; background: var(--bg0); box-shadow: 0 0 0 2px var(--green); line-height: 0; }
.pin.boss .head { left: -33px; top: -96px; width: 66px; height: 66px; background: #3a1c22; }
.pin.future { filter: grayscale(.35) brightness(.66); }
.pin.skip { opacity: .28; filter: grayscale(1); }
.pin.done { opacity: .9; }
.pin.cur { cursor: pointer; animation: pinbob 1.1s steps(2) infinite; }
.pin.cur:hover .head { background: var(--bg3); }
.pin.sel .head { --pc: var(--gold); background: var(--bg3); transform: scale(1.1); transform-origin: 50% 100%; box-shadow: 0 -3px 0 0 var(--gold), 0 3px 0 0 var(--gold), -3px 0 0 0 var(--gold), 3px 0 0 0 var(--gold), 0 0 0 7px rgba(244, 180, 27, .25), inset 0 -4px 0 rgba(0, 0, 0, .3); }
.pin.sel .stake { border-top-color: var(--gold); } .pin.sel .base { background: var(--gold); }
.pin:focus-visible .head { outline: 2px solid var(--gold); outline-offset: 5px; }
@keyframes pinbob { 50% { transform: translateY(-5px); } }
.fl { position: absolute; bottom: 8px; transform: translateX(-50%); font-family: var(--f-num); font-size: 13px; color: var(--dim); }
.fl.cur { color: var(--gold); font-size: 16px; } .fl.done { color: var(--orange); }
.mdetail { flex: none; margin: 8px 10px 10px; padding: 8px 12px; }

/* character cards: stacked so long class names never clip */
.pcard { text-align: center; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pcard .pc-sprite { height: 84px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 4px; }
.pcard .nm { font-size: 15px; letter-spacing: .03em; overflow-wrap: anywhere; }
.pcard .blurb { color: var(--cream); margin: 4px 0 2px; }
.pcard .pc-stats { display: flex; flex-direction: column; gap: 2px; align-items: center; }

/* ======== polish pass: readable type, desktop layouts, text effects ======== */
:root { --fs: 16px; }
:where(body.land) { & { --fs: 19px; } }
.sm { font-size: calc(var(--fs) - 2px); }
.xs { font-size: max(14px, calc(var(--fs) - 4px)); }
.btn { font-size: var(--fs); }
.btn.sm { font-size: max(14px, calc(var(--fs) - 3px)); }
.tag { font-size: max(13px, calc(var(--fs) - 4px)); }
.bar .t { font-size: 13px; }
#b-floor .f1 { font-size: calc(var(--fs) - 1px); } #b-floor .f2 { font-size: 14px; }
#b-gold { font-size: calc(var(--fs) - 2px); }
#b-info { font-size: calc(var(--fs) - 2px); }
.sbtn .nm { font-size: 13px; } .sbtn .key { font-size: 12px; } .sbtn .cost { font-size: 14px; min-width: 24px; height: 24px; }
.rcard .rar { font-size: 13px; } .rcard ul { font-size: calc(var(--fs) - 1px); gap: 4px; }
.rcard .nm { font-size: calc(var(--fs) + 1px); }
.pline { font-size: var(--fs); } .helpbody { font-size: calc(var(--fs) - 1px); line-height: 1.45; }
#tip { font-size: 16px; } #hintbar .panel { font-size: calc(var(--fs) - 1px); }
#tree-legend { font-size: 14px; } .mark { font-size: 14px; } .fl { font-size: 15px; } .band span { font-size: 14px; }
.summary { font-size: calc(var(--fs) - 1px); }
#s-title .tag-line { font-size: calc(var(--fs) + 2px); max-width: 640px; line-height: 1.45; }
#s-title .foot { font-size: 14px; }
.pcard .nm { font-size: calc(var(--fs) - 1px); } .pcard .blurb { font-size: calc(var(--fs) - 2px); } .pcard .xs { font-size: 14px; }
.skbtn { font-size: calc(var(--fs) - 3px); padding: 6px 10px; }
.mdetail { font-size: calc(var(--fs) - 2px); padding: 10px 14px; }
.mdetail .h3 { font-size: calc(var(--fs) + 3px); }

/* setup: two columns on desktop, buttons pinned to the bottom */
.setup-grid { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.setup-foot { flex: none; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 8px 10px calc(8px); background: var(--bg1); border-top: 3px solid var(--mauve); }
.setup-foot .btn.pri { min-width: 220px; font-size: calc(var(--fs) + 3px); }
:where(body.land) {
  #s-setup .wrap { max-width: 1240px; }
  .setup-grid { grid-template-columns: 1.3fr 1fr; }
  .setup-grid .cards { grid-template-columns: repeat(2, 1fr); }
}

/* reward / shop / camp / shrine: bigger, centred, less empty */
#s-reward .scroll > .wrap, #s-place .scroll > .wrap { min-height: 100%; justify-content: center; max-width: 1180px; }
.rcards { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.rcard { padding: 16px 16px 14px; gap: 10px; }
#s-place .rcards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.rcard:hover { transform: translateY(-3px); }
.rcard { transition: transform .08s steps(2); }
.scene { display: flex; gap: 22px; align-items: center; padding: 16px 20px; font-size: calc(var(--fs) + 2px); line-height: 1.45; }
.scene .scene-art { flex: none; padding: 8px; background: var(--bg0); box-shadow: 0 0 0 3px var(--bg3); }
#e-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
#e-opts .rcard .nm { font-size: calc(var(--fs) + 2px); }
:where(body.port) { .scene { flex-direction: column; text-align: center; } }

/* skill tree: details become a side card on desktop so the tree stays visible */
:where(body.land) {
  #tree-sheet { left: auto; right: 12px; bottom: 12px; justify-content: flex-end; }
  #tree-sheet .panel { width: 380px; }
  #tree-tools { right: auto; left: 12px; top: 40px; align-items: flex-start; }
}

/* battle side panel on desktop */
:where(body.land) {
  #b-panel { width: 440px; }
  #b-info { min-height: 160px; }
  .sbtn { max-width: 130px; min-height: 92px; }
  .sbtn .nm { font-size: 14px; }
}

/* ---- text effects ---- */
.ch { display: inline-block; white-space: pre; }
.fx-wave .ch { animation: fxwave 1.2s steps(4) infinite; animation-delay: calc(var(--i) * 80ms); }
@keyframes fxwave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.16em); } }
.fx-shake .ch { animation: fxshake .3s steps(2) infinite; animation-delay: calc(var(--i) * 37ms); }
@keyframes fxshake { 0% { transform: translate(0, 0); } 25% { transform: translate(-.05em, .05em); } 50% { transform: translate(.05em, -.05em); } 75% { transform: translate(.05em, .05em); } }
.fx-wiggle .ch { animation: fxwiggle 1.6s steps(2) infinite; animation-delay: calc(var(--i) * 110ms); transform-origin: 50% 80%; }
@keyframes fxwiggle { 0% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } 100% { transform: rotate(-3deg); } }
.fx-rainbow .ch { animation: fxrainbow 2.4s steps(1) infinite; animation-delay: calc(var(--i) * 140ms); }
@keyframes fxrainbow { 0% { color: var(--gold); } 25% { color: var(--orange); } 50% { color: var(--red); } 75% { color: var(--cream); } 100% { color: var(--gold); } }
.fx-pop .ch { animation: fxpop .5s steps(5) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes fxpop { 0% { transform: scale(0) translateY(.4em); opacity: 0; } 70% { transform: scale(1.3); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.fx-bob { animation: fxbob 1.1s steps(2) infinite; }
@keyframes fxbob { 50% { transform: translateY(-3px); } }
.fx-shakebox { animation: fxbox .28s steps(2) infinite; }
@keyframes fxbox { 0% { transform: translate(0, 0); } 33% { transform: translate(-2px, 1px); } 66% { transform: translate(2px, -1px); } }
#incoming.lethal { animation: fxbox .28s steps(2) infinite; }
#banner.show { animation: bannerpop .5s steps(5); }
@keyframes bannerpop { 0% { transform: scale(2.2); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); } }
.btn.pri.pulse { animation: fxbob 1.2s steps(2) infinite; }
.summary .stat b { display: inline-block; animation: fxpop .5s steps(5) both; }
.summary .stat:nth-child(2) b { animation-delay: .12s; } .summary .stat:nth-child(3) b { animation-delay: .24s; } .summary .stat:nth-child(4) b { animation-delay: .36s; } .summary .stat:nth-child(5) b { animation-delay: .48s; }
.pin.cur .head, .fl.cur { animation: none; }
.fl.cur { display: inline-block; animation: fxbob .9s steps(2) infinite; }
body.reduce .ch, body.reduce .fx-bob, body.reduce .fx-shakebox, body.reduce #incoming.lethal, body.reduce .btn.pri.pulse, body.reduce .summary .stat b, body.reduce .fl.cur { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .ch, .fx-bob, .fx-shakebox, #incoming.lethal, .btn.pri.pulse, .summary .stat b, .fl.cur { animation: none !important; } }
:where(body.land) { #b-info { flex: 1; } #b-panel { justify-content: flex-end; } }
.scene .scene-art { animation: fxbob 1.4s steps(2) infinite; }
body.reduce .scene .scene-art { animation: none; }
.skbtn { font-size: calc(var(--fs) - 2px); }
.summary .stat b { font-size: calc(var(--fs) + 8px); }
#s-end .panel { width: min(560px, 100%) !important; }
:where(body.port) { .setup-foot { flex-wrap: nowrap; gap: 6px; } .setup-foot .btn { flex: 1; min-width: 0 !important; padding-left: 6px; padding-right: 6px; } }
/* enemy intent list in the info panel: never cut off */
#b-info { display: flex; flex-direction: column; min-height: 0; }
.intentlist { margin-top: 6px; max-height: 120px; overflow-y: auto; }
.intentrow { cursor: pointer; align-items: flex-start; padding: 4px 6px; background: var(--bg0); }
.intentrow:hover { background: var(--bg3); }
.intentrow .grow { line-height: 1.3; }
:where(body.land) { #b-info { overflow: hidden; } .intentlist { max-height: none; flex: 1; min-height: 0; } }

/* enemy cards in the battle info panel */
.ecard { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--bg0); border-left: 4px solid var(--bg3); cursor: pointer; flex: 1 1 0; min-height: 0; max-height: 160px; }
.ecard:hover, .ecard.sel { background: var(--bg3); }
.ecard.hot { border-left-color: var(--red); background: #2c1218; } .ecard.hot:hover { background: #3b1a22; }
.ecard.cold { border-left-color: var(--blue); }
.ecard .ord { flex: none; align-self: flex-start; min-width: 24px; height: 28px; padding: 0 5px; background: var(--cream); color: var(--bg0); font-family: var(--f-num); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.ecard .eb { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ecard .enm { font-family: var(--f-head); text-transform: uppercase; letter-spacing: .04em; font-weight: normal; font-size: calc(var(--fs) - 1px); }
.ecard .bar { height: 16px; }
.ecard .eint { color: var(--orange); font-size: calc(var(--fs) - 2px); line-height: 1.3; }
.ecard.hot .eint { color: #ff8a6a; }
:where(body.port) { .ecard { padding: 5px 8px; flex: none; } .ecard .wk { display: none; } .ecard img.px { width: 32px; height: 32px; } .ecard .ord { height: 24px; font-size: 14px; } .ecard .bar { height: 12px; } }

.ecard { flex: 1 0 auto; max-height: none; }
.ecard .wk { margin-left: auto; }
:where(body.land) { .ecard { padding: 5px 10px; } .ecard .eb { gap: 2px; } .ecard .bar { height: 14px; } .intentlist { gap: 5px; margin-top: 4px; } .sbtn { min-height: 80px; } }
:where(body.port) {
  .ecard { gap: 8px; padding: 4px 8px; } .ecard .eb { gap: 2px; } .ecard .bar { height: 8px; border-width: 2px; } .ecard .bar .t { display: none; }
  .ecard .enm { font-size: 14px; } .ecard .eint { font-size: 14px; } .ecard img.px { width: 28px; height: 28px; } .ecard .ord { height: 22px; min-width: 22px; font-size: 13px; }
  .intentlist { max-height: 150px; gap: 3px; }
}

/* ================= ui v3: every frame is cut from the sprite sheet's own rounded-square tile ================= */
:root { --ps: 2px; } /* overridden on body by ui.fit */
.panel, .btn, .sbtn, .skbtn, .pcard, .rcard, .toast, #tip {
  box-shadow: none !important; margin: 0; background: none;
  border: calc(var(--frs, 3) * var(--ps)) solid transparent;
  border-image: var(--f, var(--fr-mauve-1)) var(--frs, 3) fill / calc(var(--frs, 3) * var(--ps)) stretch;
  image-rendering: pixelated;
}
.panel { --f: var(--fr-mauve-1); padding: 8px 12px; }
.panel.hi { --f: var(--fr-cream-1); } .panel.gold { --f: var(--fr-gold-1); } .panel.red { --f: var(--fr-red-1); } .panel.blue { --f: var(--fr-blue-1); } .panel.dark { --f: var(--fr-mauve-0); }
.panel.rar-c { --f: var(--fr-cream-1); } .panel.rar-u { --f: var(--fr-blue-1); } .panel.rar-r { --f: var(--fr-gold-1); } .panel.rar-m { --f: var(--fr-red-1); }
.rcard:hover { --f: var(--fr-gold-2); transform: translateY(-3px); }
.pcard { --f: var(--fr-mauve-1); padding: 8px 8px; } .pcard.sel { --f: var(--fr-gold-2); } .pcard:hover { --f: var(--fr-cream-2); } .pcard.sel:hover { --f: var(--fr-gold-2); }
.toast { --f: var(--fr-gold-1); } #tip { --f: var(--fr-cream-0); }

/* buttons: quiet by default, one loud primary, one set of states */
.btn { --f: var(--fr-mauve-2); color: var(--cream); letter-spacing: .04em; padding: 6px 14px; min-height: 42px; }
.btn, .btn:hover, .btn:active, .btn.pri, .btn.pri:hover, .btn.go, .btn.danger, .btn.on { background: none; }
.btn:hover { --f: var(--fr-cream-3); color: #fff; }
.btn:active { transform: translateY(2px); }
.btn.pri { --f: var(--fr-cream-o); color: var(--bg0); } .btn.pri:hover { --f: var(--fr-gold-o); color: var(--bg0); }
.btn.go { --f: var(--fr-cream-g); color: var(--bg0); } .btn.danger { --f: var(--fr-cream-r); color: var(--bg0); }
.btn.on { --f: var(--fr-gold-3); color: var(--gold); }
.btn[disabled], .btn.off { --f: var(--fr-mauve-1); opacity: .5; }
.btn.sm { min-height: 34px; padding: 3px 10px; } .btn.sq { min-width: 42px; padding: 4px; } .btn.sm.sq { min-width: 36px; }

/* battle skill hotbar: big icon slots, number key in the corner, cost as rings, name only in the info panel */
.skbtn { --f: var(--fr-mauve-1); } .skbtn.sel { --f: var(--fr-gold-2); }
#b-skills { gap: 8px; justify-content: center; flex-wrap: wrap; padding: 4px 0; }
.sbtn { --f: var(--fr-mauve-2); position: relative; flex: none; width: clamp(66px, calc(var(--dw) * 0.17), 88px); height: clamp(66px, calc(var(--dw) * 0.17), 88px); min-width: 0; min-height: 0; max-width: none; padding: 0; display: flex; align-items: center; justify-content: center; color: inherit; transition: transform .06s steps(2); }
.sbtn:hover { --f: var(--fr-cream-3); }
.sbtn.sel { --f: var(--fr-gold-3); transform: translateY(-5px); }
.sbtn.off { --f: var(--fr-mauve-1); opacity: .5; }
.sbtn .nm, .sbtn .cost { display: none; }
.sbtn .key { position: absolute; top: -2px; left: 2px; font-family: var(--f-num); font-size: 12px; color: var(--dim); }
.sbtn .cp { position: absolute; bottom: -3px; left: 0; right: 0; display: flex; justify-content: center; line-height: 0; }
.sbtn .cp img { margin: 0 -2px; }
.sbtn .cp b { font-weight: normal; font-family: var(--f-num); font-size: 11px; color: var(--green); background: var(--bg0); padding: 0 4px; }
.sbtn .cdv { background: rgba(29, 18, 26, .8); }
.sbtn.sel .key { color: var(--gold); }

/* actions row: small icon buttons, then one dominant End Turn */
#b-acts { gap: 8px; align-items: stretch; padding: 4px 0 2px; }
#b-acts .endbtn { flex: 1; max-width: none; font-size: calc(var(--fs) + 3px); min-height: 52px; }
.pulse-soft { animation: fxbob 1.2s steps(2) infinite; }

/* info panel: no frame inside the frame, a quiet header, flat divider-separated rows */
#b-info { border: 0; border-image: none; padding: 2px 4px; background: none; }
.ihead { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--bg3); }
.ihead .nm { font-size: calc(var(--fs) + 2px); color: var(--cream); }
.ihead .chip { font-size: calc(var(--fs) - 3px); color: var(--dim); }
.ecard { background: none; border-left: 4px solid transparent; border-bottom: 2px solid var(--bg3); padding: 7px 6px 7px 8px; }
.ecard:hover, .ecard.sel { background: rgba(122, 68, 74, .28); }
.ecard.hot { border-left-color: var(--red); background: rgba(230, 72, 46, .1); } .ecard.hot:hover { background: rgba(230, 72, 46, .2); }
.ecard.cold { border-left-color: var(--blue); }
.intentlist { gap: 0 !important; }
#b-res { padding: 4px 2px; }
#incoming { font-size: calc(var(--fs) - 1px); }

/* ================= ui v4: presentation pass ================= */
.screen { background: none; }
#s-battle { background: var(--bg0); } #s-tree { background: #150d12; }
#fxvig { position: fixed; inset: 0; pointer-events: none; z-index: 0; background: radial-gradient(ellipse at 50% 38%, rgba(29, 18, 26, 0) 30%, rgba(15, 8, 12, .88) 100%); }
.topbar, .runstrip, .setup-foot { position: relative; z-index: 1; }

/* Kenney pixel cursors */
body { cursor: var(--cur-arrow, auto); }
button, label, input, .pin.cur, .ecard, .rcard, .pcard, .skbtn, .sbtn, .ri, [data-id], [data-sk] { cursor: var(--cur-hand, pointer); }
#board { cursor: var(--cur-cross, crosshair); }
#tree-canvas, .track-scroll { cursor: var(--cur-grab, grab); }

/* primary buttons: the sheet's double-framed key tile, with its thicker bottom edge */
.btn.pri, .btn.go, .btn.danger {
  border-width: calc(3 * var(--ps)) calc(3 * var(--ps)) calc(4 * var(--ps));
  border-image: var(--k, var(--fk-cream-o)) 3 3 4 3 fill / calc(3 * var(--ps)) calc(3 * var(--ps)) calc(4 * var(--ps)) stretch;
}
.btn.pri { --k: var(--fk-cream-o); } .btn.pri:hover { --k: var(--fk-gold-o); } .btn.go { --k: var(--fk-cream-g); } .btn.go:hover { --k: var(--fk-gold-g); } .btn.danger { --k: var(--fk-cream-r); } .btn.danger:hover { --k: var(--fk-gold-r); }
.btn.pri:active, .btn.go:active, .btn.danger:active { transform: translateY(var(--ps)); }

/* title: selector arrow beside the hovered or focused menu item, run summary on Continue */
#s-title .menu { gap: 10px; width: min(360px, calc(var(--dw) * 0.86)); }
#s-title .menu .btn { position: relative; min-height: 52px; font-size: calc(var(--fs) + 2px); flex-direction: column; gap: 0; }
#s-title .menu .btn .sub { font-family: var(--f-body); font-size: 13px; text-transform: none; letter-spacing: 0; opacity: .8; }
#s-title .menu .btn:hover::before, #s-title .menu .btn:focus-visible::before { content: ''; position: absolute; left: -46px; top: 50%; width: 32px; height: 32px; margin-top: -16px; background: var(--ic-sel) center / contain no-repeat; image-rendering: pixelated; animation: selbob .5s steps(2) infinite; }
@keyframes selbob { 50% { transform: translateX(6px); } }
#s-title .logo { text-shadow: 4px 4px 0 var(--red), 8px 8px 0 var(--mauve), 12px 12px 0 var(--bg0); }

/* setup: the chosen character on a little stage */
.stage { display: flex; gap: 16px; align-items: center; }
.stage-art { flex: none; width: 168px; height: 168px; display: flex; align-items: center; justify-content: center; background-color: var(--bg0); box-shadow: 0 0 0 var(--ps) var(--bg3); }
.stage-art img { animation: fxbob 1s steps(2) infinite; }
.stage-mods { margin: 0; padding-left: 18px; color: var(--cream); }
.chip2 { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; background: var(--bg0); font-family: var(--f-num); font-size: 14px; }
:where(body.port) { .stage-art { width: 112px; height: 112px; } .stage-art img { width: 80px; height: 80px; } }

/* cards deal in one after another; tally lines too */
.rcards .rcard, .cards .pcard, #e-opts .rcard { animation: dealin .34s steps(6) backwards; }
.rcards .rcard:nth-child(2), .cards .pcard:nth-child(2), #e-opts .rcard:nth-child(2) { animation-delay: .08s; }
.rcards .rcard:nth-child(3), .cards .pcard:nth-child(3), #e-opts .rcard:nth-child(3) { animation-delay: .16s; }
.rcards .rcard:nth-child(4), .cards .pcard:nth-child(4) { animation-delay: .24s; }
.rcards .rcard:nth-child(n+5) { animation-delay: .32s; }
@keyframes dealin { 0% { transform: translateY(46px) scale(.92); opacity: 0; } 100% { transform: none; opacity: 1; } }
#s-end .pline { animation: dealin .3s steps(4) backwards; }
#s-end .pline:nth-child(3) { animation-delay: .15s; } #s-end .pline:nth-child(4) { animation-delay: .3s; } #s-end .pline:nth-child(5) { animation-delay: .45s; } #s-end .pline:nth-child(6) { animation-delay: .6s; } #s-end .pline:nth-child(7) { animation-delay: .75s; } #s-end .pline:nth-child(8) { animation-delay: .9s; }
.panel.rar-r, .panel.rar-m { animation-name: dealin, raregleam; animation-duration: .34s, 2.2s; animation-timing-function: steps(6), steps(4); animation-iteration-count: 1, infinite; animation-fill-mode: backwards, none; }
@keyframes raregleam { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.22); } }

/* battle: red flash when you are hit, slow pulse at low HP, dithered modal backdrop */
#b-board::after { content: ''; position: absolute; inset: 0; pointer-events: none; }
#b-board.hurt::after { animation: hurtflash .4s steps(6); }
@keyframes hurtflash { 0% { box-shadow: inset 0 0 110px 36px rgba(230, 72, 46, .6); } 100% { box-shadow: inset 0 0 0 0 rgba(230, 72, 46, 0); } }
#b-board.lowhp::after { animation: lowhp 1.2s steps(6) infinite; }
#b-board.lowhp.hurt::after { animation: hurtflash .4s steps(6); }
@keyframes lowhp { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(230, 72, 46, 0); } 50% { box-shadow: inset 0 0 80px 12px rgba(230, 72, 46, .3); } }
#modal { background-color: rgba(18, 10, 16, .62); background-image: var(--dither); background-size: 32px; image-rendering: pixelated; }
#modal .box { image-rendering: auto; animation: dealin .22s steps(5) backwards; }
body.reduce .rcard, body.reduce .pcard, body.reduce #s-end .pline, body.reduce #modal .box, body.reduce .stage-art img { animation: none !important; }
#s-title { padding-bottom: 118px; }
#s-title .menu .btn { flex-direction: row; gap: 8px; min-height: 46px; } #s-title .menu #t-cont { flex-direction: column; gap: 0; min-height: 56px; }
#s-title .menu { gap: 8px; } #s-title .tag-line { margin-bottom: 10px; } #s-title .pointsbadge { margin-bottom: 10px; }
.screen.on { animation: none; }
.cards .pcard { animation: none; }

.flipx { transform: scaleX(-1); }
#app { right: auto; bottom: auto; transform-origin: 0 0; }

.pips .pip { width: auto; height: auto; display: inline-flex; } .pips .pip img { position: static; }
:where(body.port) .ecard img.px { width: auto; height: auto; }
:where(body.land) .ecard { padding: 5px 6px 5px 8px; } :where(body.land) .ecard .eb { gap: 2px; }
.pcard .pc-sprite { height: auto; margin-bottom: 2px; } .pcard { gap: 2px; padding: 6px 8px; }

/* portrait: the board gets a full-width square first, the enemy list takes what is left (never less than one row) */
:where(body.port) {
  .intentlist { max-height: clamp(52px, calc(var(--dh) - var(--dw) - 330px), 200px); }
  #tg-intent { min-height: 34px; height: 38px; }
  .ihead { padding-bottom: 4px; }
}

/* ================= co-op ================= */
#s-coop .wrap { max-width: 860px; }
#co-name { text-transform: none; width: min(260px, 100%); }
.co-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
.co-pair .panel { gap: 8px; }
.co-pair .btn { align-self: flex-start; }
.co-codein { text-transform: uppercase; font-family: var(--f-num); font-size: calc(var(--fs) + 6px); letter-spacing: .3em; width: 100%; text-align: center; }
.co-err { color: var(--red); min-height: 20px; font-size: calc(var(--fs) - 1px); text-align: center; }
.co-code { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; --line: var(--gold); }
.co-cl { display: flex; flex-direction: column; gap: 2px; }
.co-bigcode { font-family: var(--f-logo); font-size: 44px; letter-spacing: .14em; color: var(--gold); text-shadow: 3px 3px 0 var(--red); line-height: 1; }
.co-status { color: var(--cream); text-align: center; padding: 2px 0; font-size: calc(var(--fs) + 1px); }
.co-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.co-seat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 12px 10px; --line: var(--mauve); }
.co-seat.you { --line: var(--gold); }
.co-seat.ready { --line: var(--green); }
.co-seat.empty { opacity: .8; }
.co-seat .co-art { width: 128px; height: 128px; display: flex; align-items: center; justify-content: center; background-color: var(--bg0); box-shadow: 0 0 0 var(--ps) var(--bg3); }
.co-seat .co-art img { animation: fxbob 1s steps(2) infinite; }
.co-nm { font-family: var(--f-head); font-size: calc(var(--fs) + 3px); text-transform: uppercase; letter-spacing: .05em; overflow-wrap: anywhere; }
.co-lead { align-self: center; max-width: 180px; text-align: center; }
.pin.hint .head { outline: 3px solid var(--blue); outline-offset: 3px; }
.partner-strip { display: flex; align-items: center; gap: 6px; min-width: 130px; max-width: 220px; padding: 2px 8px; background: var(--bg0); box-shadow: 0 0 0 2px var(--blue); margin-left: auto; }
.partner-strip .bar { height: 14px; }
#b-partner { display: none; }
body.coop #b-partner { display: block; }
.pchip { display: flex; align-items: center; gap: 8px; padding: 3px 8px; background: var(--bg0); box-shadow: 0 0 0 2px var(--blue); margin: 2px 3px; }
.pchip .bar { height: 14px; }
.pchip.ready { box-shadow: 0 0 0 2px var(--green); }
.pchip.down { box-shadow: 0 0 0 2px var(--red); opacity: .8; }
.pchip .pn { color: var(--blue); text-transform: uppercase; letter-spacing: .04em; }
:where(body.coop.port) { .intentlist { max-height: clamp(52px, calc(var(--dh) - var(--dw) - 372px), 200px); } }
#co-wait { position: absolute; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(var(--sb) + 14%); background-color: rgba(18, 10, 16, .5); background-image: var(--dither); background-size: 32px; image-rendering: pixelated; }
.co-waitbox { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 22px; --line: var(--blue); image-rendering: auto; }
.co-dots::after { content: ''; animation: codots 1.2s steps(4) infinite; }
@keyframes codots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
#co-off { position: absolute; z-index: 70; top: calc(var(--st) + 6px); left: 50%; transform: translateX(-50%); padding: 6px 12px; --line: var(--orange); font-size: 14px; white-space: nowrap; }
:where(body.port) { .co-pair, .co-seats { grid-template-columns: 1fr; } .co-seat { flex-direction: row; text-align: left; gap: 10px; } .co-seat .co-art { width: 72px; height: 72px; flex: none; } .co-seat .co-art img { width: 48px !important; height: 48px !important; } .co-bigcode { font-size: 34px; } }

:where(body.port.short) { .pchip { padding: 2px 6px; gap: 6px; margin: 1px 3px; } .pchip .bar { height: 12px; } }

/* ================= mobile: d-pad (Kenney Mobile Controls) and the board view controls ================= */
/* sized in real pixels: --ui is the layout scale, so dividing by it keeps a thumb-sized target on a small landscape phone too */
#viewctl, .mapctl { position: absolute; top: 6px; right: 6px; z-index: 4; display: flex; flex-direction: column; gap: calc(4px / var(--ui, 1)); }
#viewctl .btn, .mapctl .btn { width: calc(36px / var(--ui, 1)); min-width: 0; height: calc(36px / var(--ui, 1)); min-height: 0; padding: 0; opacity: .88; display: flex; align-items: center; justify-content: center; }
#viewctl .btn img, .mapctl .btn img { width: 56%; height: 56%; display: block; pointer-events: none; }
#viewctl .btn.off, .mapctl .btn.off { opacity: .35; }
#viewctl .btn.on, .mapctl .btn.on { --line: var(--gold); opacity: 1; }
#dpad { --dpx: calc(104px / var(--ui, 1)); position: absolute; bottom: 8px; width: var(--dpx); height: var(--dpx); z-index: 4; display: none; pointer-events: none; opacity: .66; transition: opacity .15s; }
#dpad::before { content: ''; position: absolute; inset: 4%; border-radius: 50%; background: radial-gradient(circle, rgba(15, 8, 12, .6) 0, rgba(15, 8, 12, .6) 55%, rgba(15, 8, 12, 0) 100%); }
#dpad.on { display: block; }
#dpad.left { left: 8px; } #dpad.right { right: 8px; }
#dpad.idle { opacity: .3; }
#dpad .dp { position: absolute; width: 50%; height: 50%; pointer-events: none; }
#dpad .dp img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#dpad .dp .b { opacity: 0; }
#dpad .dp.down .b { opacity: 1; }
#dpad .dp button { position: absolute; inset: 0; padding: 0; border: 0; background: transparent; pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
#dpad .n { left: 25%; top: 0; } #dpad .n button { clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); }
#dpad .e { left: 50%; top: 25%; } #dpad .e button { clip-path: polygon(45% 0, 100% 0, 100% 100%, 45% 100%, 0 50%); }
#dpad .s { left: 25%; top: 50%; } #dpad .s button { clip-path: polygon(0 45%, 50% 0, 100% 45%, 100% 100%, 0 100%); }
#dpad .w { left: 0; top: 25%; } #dpad .w button { clip-path: polygon(0 0, 55% 0, 100% 50%, 55% 100%, 0 100%); }

/* ---- heroes: the list of all twelve on the new run and co-op screens, and the menu in the skill tree ---- */
.cards.herocards, .setup-grid .cards.herocards { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px; }
.pcard.herocard { padding: 6px 4px; }
.pcard.herocard .pc-sprite { position: relative; height: 60px; margin-bottom: 2px; }
.pcard.herocard .nm { font-size: 13px; letter-spacing: .02em; }
.pcard.herocard.locked { --line: var(--bg3); background: var(--bg0); }
.pcard.herocard.locked .nm { color: var(--dim); }
.pcard.herocard .lockbadge { position: absolute; right: 2px; top: -2px; background: var(--bg0); padding: 1px; line-height: 0; box-shadow: 0 0 0 2px var(--gold); }
.pcard.herocard .unl-bar { width: 80%; margin: 2px auto; height: 6px; }
.unl-bar { display: block; width: 150px; height: 8px; background: var(--bg1); box-shadow: 0 0 0 2px var(--bg3); } .unl-bar i { display: block; height: 100%; background: var(--gold); }
.unlock-banner { align-items: center; }
.lockstage { align-items: flex-start; }
.herodd { gap: 8px; padding: 3px 10px 3px 6px; min-height: 40px; min-width: 200px; max-width: 340px; justify-content: flex-start; text-transform: none; letter-spacing: 0; }
.herodd .hd-art { flex: none; display: flex; }
.herodd .hd-txt { display: flex; flex-direction: column; gap: 0; align-items: flex-start; line-height: 1.15; min-width: 0; }
.herodd .hd-name { font-family: var(--f-head); text-transform: uppercase; font-size: 15px; letter-spacing: .05em; font-weight: normal; }
.herodd .hd-caret { margin-left: auto; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--cream); }
.herodd[aria-expanded="true"] { --line: var(--gold); background: var(--bg3); }
.herodd[aria-expanded="true"] .hd-caret { transform: rotate(180deg); }
.hero-menu { position: absolute; z-index: 30; width: min(460px, calc(var(--dw, 1100px) - 12px)); overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; background: var(--bg1); touch-action: pan-y; }
.hero-menu .hm-head { padding: 2px 6px 4px; }
.hm-row { flex: none; display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 4px 8px; background: var(--bg0); border: 2px solid var(--bg3); text-transform: none; letter-spacing: 0; }
.hm-row:hover { background: var(--bg2); border-color: var(--orange); }
.hm-row.on { border-color: var(--gold); background: var(--bg3); }
.hm-row.locked .hm-art { opacity: .6; }
.hm-row .hm-art { flex: none; display: flex; }
.hm-row .hm-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; align-items: flex-start; line-height: 1.2; }
.hm-row .hm-txt b { font-family: var(--f-head); text-transform: uppercase; font-size: 14px; letter-spacing: .05em; font-weight: normal; }
.hm-row .hm-stats { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-size: 14px; white-space: nowrap; }

/* ---- the tree's suggested buy ---- */
.sugbox { margin-top: 8px; padding: 6px 8px; background: rgba(244, 180, 27, .1); box-shadow: inset 0 0 0 2px var(--gold); display: flex; flex-direction: column; gap: 2px; }
#tt-sug { gap: 6px; }

/* ---- route map: rooms that your route has cut off, and the links between them ---- */
.trk-svg path.live { stroke: var(--mauve); stroke-width: 4; stroke-dasharray: 2 9; opacity: .85; }
.trk-svg path.dead { stroke: var(--bg3); stroke-width: 3; stroke-dasharray: 2 11; opacity: .4; }
.pin.block, .pin.cut { opacity: .3; filter: grayscale(1) brightness(.6); }
.pin.block { cursor: not-allowed; }
.leads { align-items: center; flex-wrap: wrap; margin-top: 2px; gap: 10px; }

/* ---- keywords: elements and move types in running text get a colour and a small icon (js/kw.js) ---- */
.kw { white-space: nowrap; text-shadow: 0 1px 0 rgba(0, 0, 0, .65); }
.kw .kwi { width: 1.05em; height: 1.05em; margin: 0 .22em 0 .02em; vertical-align: -.2em; }
.tag .kwi { width: 1.1em; height: 1.1em; margin: 0; vertical-align: middle; }
.kw-phys { color: var(--kw-phys); } .kw-fire { color: var(--kw-fire); } .kw-frost { color: var(--kw-frost); } .kw-shock { color: var(--kw-shock); } .kw-void { color: var(--kw-void); }
.kw-melee { color: var(--kw-melee); } .kw-proj { color: var(--kw-proj); } .kw-area { color: var(--kw-area); } .kw-spell { color: var(--kw-spell); } .kw-move { color: var(--kw-move); } .kw-self { color: var(--kw-self); }
.tag.kwt { border-color: currentColor; text-shadow: none; }

/* ---- Fall Deeper: the summit screen, and the abyss on the route map ---- */
.band.abyss { background: linear-gradient(180deg, rgba(150, 100, 255, .2), rgba(60, 30, 120, .05)); } .band.abyss span { color: #b79bff; }
.summit-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: min(900px, 100%); text-align: left; }
.summit-choices ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.summit-choices .btn { align-self: flex-start; }
body.port .summit-choices { grid-template-columns: 1fr; }

/* ---- legendary glow without WebGL: the same idea in plain CSS (when the shader layer is off or unavailable) ---- */
.nogl .rcard.rar-r, body.reduce .rcard.rar-r { filter: drop-shadow(0 0 6px rgba(244, 180, 27, .6)); }
.nogl .rcard.rar-m, body.reduce .rcard.rar-m { filter: drop-shadow(0 0 8px rgba(255, 96, 60, .75)); }

/* ---- 1-bit UI pack skin: the raised sheet buttons give way to the pack's frame, and dialogs get its big sparkle panel ---- */
body.ui1 .btn.pri, body.ui1 .btn.go, body.ui1 .btn.danger { border-width: calc(var(--frs) * var(--ps)); border-image: var(--f) var(--frs) fill / calc(var(--frs) * var(--ps)) stretch; }
body.ui1 .btn.pri:active, body.ui1 .btn.go:active, body.ui1 .btn.danger:active { transform: translateY(var(--ps)); }
body.ui1 #modal .box { border: calc(8 * var(--ps)) solid transparent; border-image: var(--fr-big-0) 8 fill / calc(8 * var(--ps)) stretch; padding: 8px 12px; image-rendering: pixelated; }
body.ui1 .lockbadge img { display: block; }

/* movement pattern diagram */
.mdiag { display: inline-grid; grid-template-columns: repeat(7, 9px); gap: 1px; padding: 3px; background: var(--bg0); flex: none; }
.mdiag i { width: 9px; height: 9px; background: #2d1c27; }
.mdiag i.me { background: var(--cream); } .mdiag i.slide { background: var(--green); } .mdiag i.leap { background: var(--gold); } .mdiag i.step { background: #cfc6b8; } .mdiag i.hop { background: var(--orange); }
.mrow { align-items: center; }

/* run modifiers */
.mutgrid { display: flex; flex-wrap: wrap; gap: 6px; }
.mut { min-height: 34px; }
