/* Character screen (src/ui/characterScreen.js). Sizes are in --u: one pixel of the author's 1672×941 "character details"
   reference, scaled to the stage. Plates, brush, keycaps and icon atlases come from the UI kit (styles/kit.css).
   Grid rows (desktop): 1 top bar · 2 gap · 3 sheet · 4 gap · 5 quick bar / panel feet · 6 quick bar / key hints · 7 margin. */
body.char-sheet #hud, body.char-sheet #world-ui, body.char-sheet #touch { visibility: hidden; }
#charpanel {
  --u: min(calc(100cqw / 1672), calc(100cqh / 941));
  justify-content: center; align-items: center; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); pointer-events: auto;
  background: radial-gradient(ellipse 80% 75% at 50% 50%, #04101c66, #030a12d9);
}
.cp.ch-screen {
  --rc: var(--r-common);
  position: relative; width: calc(1672 * var(--u)); height: calc(941 * var(--u)); padding: calc(8 * var(--u)) calc(15 * var(--u)) 0; gap: 0;
  display: grid; grid-template-columns: calc(425 * var(--u)) calc(625 * var(--u)) calc(572 * var(--u)); column-gap: calc(10 * var(--u));
  grid-template-rows: calc(62 * var(--u)) calc(22 * var(--u)) calc(714 * var(--u)) calc(12 * var(--u)) calc(44 * var(--u)) calc(56 * var(--u)) minmax(0, 1fr);
  color: var(--kit-text); font: 400 calc(17 * var(--u)) / 1.3 var(--f-body); text-shadow: 0 1px 0 #0007;
}
.ch-screen h2, .ch-screen h3, .ch-screen p { margin: 0; }
.ch-screen button { font: inherit; color: inherit; touch-action: manipulation; }
/* Kit icons fill their box; the CharPanel bodies in .ch-wide keep their own icon sizes. */
.ch-screen :where(.ch-top, .ch-left, .ch-center, .ch-right, .ch-quick, .ch-hints, .ch-wide-head) svg { display: block; width: 100%; height: 100%; }
.ch-screen .kit-plate { --kit-edge: calc(20 * var(--u)); border-image-width: var(--kit-edge); min-height: 0; min-width: 0; }
.ch-screen .kit-key { font-size: calc(13 * var(--u)); border-radius: calc(4 * var(--u)); }

/* ---- Top bar: brand · tabs · motto · close ------------------------------------------------------------------- */
.ch-top { grid-area: 1 / 1 / 2 / -1; display: flex; align-items: center; gap: calc(26 * var(--u)); min-width: 0; }
.ch-brand { flex: 0 0 calc(350 * var(--u)); display: flex; align-items: center; gap: calc(12 * var(--u)); min-width: 0; }
.ch-brand-palm { flex: 0 0 auto; width: calc(44 * var(--u)); height: calc(52 * var(--u)); color: var(--kit-orange); filter: drop-shadow(0 2px 0 #0009); }
.ch-brand b { display: block; font: italic 900 calc(34 * var(--u)) / .9 var(--f-display); text-transform: uppercase; letter-spacing: .01em; color: #fff; text-shadow: 0 calc(3 * var(--u)) 0 #0009; white-space: nowrap; }
.ch-brand small { display: block; margin-top: calc(4 * var(--u)); font: italic 600 calc(14 * var(--u)) / 1 var(--f-display); text-transform: uppercase; letter-spacing: .05em; color: var(--kit-sky); white-space: nowrap; }
.ch-tabs { display: flex; gap: calc(8 * var(--u)); flex: 1 1 auto; min-width: 0; }
.ch-tab { position: relative; isolation: isolate; flex: 1 1 0; min-width: max-content; display: flex; align-items: center; justify-content: center; gap: calc(9 * var(--u));
  min-height: calc(52 * var(--u)); padding: 0 calc(9 * var(--u)); white-space: nowrap; border: 1px solid var(--kit-line-soft); border-radius: calc(4 * var(--u));
  background: linear-gradient(#10243899, #08131f99); box-shadow: inset 0 0 0 1px #0006; cursor: pointer;
  font: italic 700 calc(20 * var(--u)) / 1 var(--f-display) !important; text-transform: uppercase; letter-spacing: .01em; color: #e3eaf1 !important; }
.ch-tab-ico { flex: 0 0 auto; width: calc(24 * var(--u)); height: calc(24 * var(--u)); color: #dfe8f0; }
.ch-tab .kit-key { min-width: calc(24 * var(--u)); height: calc(22 * var(--u)); padding: 0 calc(5 * var(--u)); font-size: calc(12 * var(--u)); font-style: normal; border-width: 1px; opacity: .85; }
.ch-tab:hover { border-color: var(--kit-line); }
.ch-tab.on { border-color: transparent; background: none; box-shadow: none; color: #111a24 !important; text-shadow: none; }
.ch-tab.on::before { content: ''; position: absolute; inset: calc(-5 * var(--u)) calc(-16 * var(--u)); z-index: -1; border-style: solid; border-width: 0 calc(40 * var(--u));
  border-image: var(--kit-brush-clean) 0 150 fill / 0 calc(40 * var(--u)) stretch; }
.ch-tab.on .ch-tab-ico { color: #111a24; }
.ch-tab.on .kit-key { background: #111a24; border-color: #111a24; color: #fff; }
.ch-motto { flex: 0 0 auto; display: flex; align-items: center; gap: calc(8 * var(--u)); white-space: pre-line; text-align: right;
  font: italic 900 calc(20 * var(--u)) / .95 var(--f-display); text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 #0009; }
.ch-motto span { width: calc(30 * var(--u)); height: calc(38 * var(--u)); color: var(--kit-orange); }
.ch-x { flex: 0 0 auto; display: grid; place-items: center; width: calc(46 * var(--u)); height: calc(46 * var(--u)); min-width: 32px; min-height: 32px; padding: calc(11 * var(--u));
  border: 1px solid var(--kit-line-soft); border-radius: calc(4 * var(--u)); background: #0a1726cc; color: #c3d0dc; cursor: pointer; }
.ch-x:hover { color: #fff; border-color: var(--kit-orange); }

/* ---- Shared bits ---------------------------------------------------------------------------------------------- */
.ch-h { display: flex; align-items: center; gap: calc(10 * var(--u)); padding-bottom: calc(10 * var(--u)); border-bottom: 1px solid var(--kit-line-faint);
  font: italic 800 calc(24 * var(--u)) / 1 var(--f-display); text-transform: uppercase; letter-spacing: .01em; color: #fff; }
.ch-h-ico { flex: 0 0 auto; width: calc(24 * var(--u)); height: calc(28 * var(--u)); color: var(--kit-orange); }
.ch-h small { margin-left: auto; font: italic 600 calc(17 * var(--u)) / 1 var(--f-display); color: var(--kit-sky); }
.ch-h2 { display: flex; align-items: baseline; justify-content: space-between; gap: calc(8 * var(--u)); font: italic 700 calc(19 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-sky); }
.ch-sub { display: block; margin-bottom: calc(6 * var(--u)); font: italic 600 calc(15 * var(--u)) / 1 var(--f-display); text-transform: uppercase; letter-spacing: .03em; color: var(--kit-sky); }
.ch-link { padding: calc(2 * var(--u)) 0; border: 0; background: none; cursor: pointer; font: italic 700 calc(15 * var(--u)) / 1 var(--f-display) !important; text-transform: uppercase; color: var(--kit-orange) !important; }
.ch-link:hover { color: var(--kit-orange-l) !important; }
.ch-screen .kit-bar { height: calc(9 * var(--u)); min-height: 5px; }

/* ---- Left: character details ---------------------------------------------------------------------------------- */
.ch-left { grid-area: 3 / 1 / 6 / 2; display: flex; flex-direction: column; gap: calc(14 * var(--u)); padding: calc(4 * var(--u)) calc(12 * var(--u)) calc(8 * var(--u));
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4c6a87 #0000; }
.ch-id { display: grid; gap: calc(6 * var(--u)); }
.ch-name { font: italic 900 calc(40 * var(--u)) / .95 var(--f-display); text-transform: uppercase; color: #fff; text-shadow: 0 calc(3 * var(--u)) 0 #0009; overflow-wrap: anywhere; }
.ch-level { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: calc(4 * var(--u)) calc(12 * var(--u));
  font: italic 700 calc(18 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-sky); }
.ch-level b { font-size: 1.25em; color: #fff; }
.ch-level small { grid-column: 2; justify-self: end; font: 500 calc(14 * var(--u)) / 1 var(--f-body); color: var(--kit-dim); text-transform: none; }
.ch-xp > i { background: linear-gradient(90deg, var(--kit-orange-d), var(--kit-orange) 60%, var(--kit-orange-l)); }
.ch-class { display: grid; grid-template-columns: calc(46 * var(--u)) minmax(0, 1fr); gap: calc(12 * var(--u)); align-items: start; padding: calc(10 * var(--u)) calc(12 * var(--u));
  border: 1px solid var(--kit-line-soft); border-radius: calc(4 * var(--u)); background: linear-gradient(#0a1726d9, #0b1a29e6); box-shadow: inset 0 0 calc(24 * var(--u)) #0008; }
.ch-class-ico { width: calc(46 * var(--u)); height: calc(46 * var(--u)); padding: calc(8 * var(--u)); box-sizing: border-box; border: 1px solid #f6a62366; border-radius: 50%; color: var(--kit-orange); background: #f6a62314; }
.ch-class b { display: block; font: italic 800 calc(21 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-orange); }
.ch-class p { margin-top: calc(4 * var(--u)); font-size: calc(15 * var(--u)); line-height: 1.3; color: #c3d0dc; }
.ch-vitals, .ch-core { display: grid; gap: calc(9 * var(--u)); }
.ch-vital, .ch-stat { display: grid; grid-template-columns: calc(22 * var(--u)) calc(92 * var(--u)) minmax(0, 1fr) calc(86 * var(--u)); align-items: center; gap: calc(10 * var(--u));
  font: 500 calc(16 * var(--u)) / 1.1 var(--f-body); color: #dce4eb; }
.ch-stat { grid-template-columns: calc(22 * var(--u)) calc(108 * var(--u)) minmax(0, 1fr) calc(70 * var(--u)); }
.ch-vital > b, .ch-stat > b { justify-self: end; font: 700 calc(15 * var(--u)) / 1 var(--f-body); color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-vital-ico, .ch-stat-ico { width: calc(20 * var(--u)); height: calc(20 * var(--u)); color: var(--kit-sky); }
.ch-vital.is-hp .ch-vital-ico { color: var(--kit-hp); }
.ch-vital.is-stam .ch-vital-ico { color: var(--kit-stam); }
.ch-vital.is-load .ch-vital-ico { color: var(--kit-load); }
.ch-vital.is-hp .kit-bar > i { background: linear-gradient(90deg, #9e2420, var(--kit-hp) 55%, #ff7a62); }
.ch-vital.is-stam .kit-bar > i { background: linear-gradient(90deg, #1c6aa3, var(--kit-stam) 55%, #9fdcff); }
.ch-vital.is-load .kit-bar > i { background: linear-gradient(90deg, #a8700f, var(--kit-load) 55%, #ffd77d); }
.ch-vital .kit-bar, .ch-stat .kit-bar { height: calc(10 * var(--u)); }
.ch-vital .kit-bar > i, .ch-xp > i { transition: width .25s ease-out; }
.ch-quote { margin-top: auto !important; display: flex; align-items: flex-end; justify-content: space-between; gap: calc(10 * var(--u)); padding-top: calc(6 * var(--u)); white-space: pre-line;
  font: italic 700 calc(23 * var(--u)) / 1.05 var(--f-display); text-transform: uppercase; color: #e9eef3; }
.ch-quote span { flex: 0 0 auto; width: calc(42 * var(--u)); height: calc(50 * var(--u)); color: var(--kit-orange); opacity: .9; }

/* ---- Center: the figure on a turntable -------------------------------------------------------------------------- */
.ch-center { grid-area: 3 / 2 / 4 / 3; position: relative; min-width: 0; min-height: 0; }
.ch-views { position: absolute; left: calc(5 * var(--u)); top: calc(23 * var(--u)); display: grid; gap: calc(14 * var(--u)); width: calc(96 * var(--u)); z-index: 1; }
.ch-view { position: relative; width: 100%; height: calc(124 * var(--u)); padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid #6f8fae99; border-radius: calc(4 * var(--u)); background: radial-gradient(ellipse at 50% 70%, #1d3d5c, #0b1826 75%); box-shadow: inset 0 0 0 1px #0007, 0 calc(4 * var(--u)) calc(10 * var(--u)) #0007; }
.ch-view canvas { display: block; width: 100%; height: 100%; }
.ch-view:hover { border-color: var(--kit-line); }
.ch-view.on { border: 2px solid var(--kit-orange); box-shadow: 0 0 calc(12 * var(--u)) #f6a62366, inset 0 0 0 1px #0007; }
.ch-model { position: absolute; left: calc(105 * var(--u)); right: 0; top: 0; bottom: calc(40 * var(--u)); cursor: grab; touch-action: none; user-select: none; }
.ch-model:active { cursor: grabbing; }
.ch-model canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.ch-floor { position: absolute; left: 50%; bottom: 3%; width: 62%; height: 11%; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(closest-side, #f6a62338, #7db7e61f 55%, #0000); box-shadow: 0 0 0 1px #7db7e626, inset 0 0 0 calc(3 * var(--u)) #f6a62324; }
.ch-cam { position: absolute; left: calc(105 * var(--u)); right: 0; bottom: 0; height: calc(34 * var(--u)); display: flex; align-items: center; justify-content: center; gap: calc(24 * var(--u));
  font: italic 600 calc(15 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-dim); }
.ch-cam > span, .ch-cam button { display: inline-flex; align-items: center; gap: calc(7 * var(--u)); white-space: nowrap; }
.ch-cam-ico { display: inline-block; width: calc(18 * var(--u)); height: calc(18 * var(--u)); color: var(--kit-sky); font-style: normal; }
.ch-cam button { padding: calc(4 * var(--u)) calc(6 * var(--u)); border: 0; border-radius: calc(4 * var(--u)); background: none; cursor: pointer;
  font: italic 600 calc(15 * var(--u)) / 1 var(--f-display) !important; text-transform: uppercase; color: #e3eaf1 !important; }
.ch-cam button:hover { color: var(--kit-orange) !important; }

/* ---- Right: equipment + item details ------------------------------------------------------------------------- */
.ch-right { grid-area: 3 / 3 / 6 / 4; display: grid; grid-template-rows: calc(405 * var(--u)) minmax(0, 1fr); gap: calc(15 * var(--u)); min-height: 0; min-width: 0; }
.ch-right-top { display: flex; flex-direction: column; gap: calc(12 * var(--u)); padding: calc(4 * var(--u)) calc(12 * var(--u)) calc(6 * var(--u)); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4c6a87 #0000; }
.ch-equip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(12 * var(--u)) calc(12 * var(--u)); }
.ch-slot { position: relative; display: grid; gap: calc(5 * var(--u)); min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.ch-slot.ch-fixed:not(button) { cursor: default; }
.ch-slot-label { font: italic 600 calc(14 * var(--u)) / 1 var(--f-display); text-transform: uppercase; letter-spacing: .02em; color: var(--kit-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-slot-box { position: relative; display: grid; place-items: center; height: calc(80 * var(--u)); box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--rc) 70%, #6f8fae); border-radius: calc(4 * var(--u)); background: radial-gradient(ellipse at 50% 40%, #16304a, #0b1826 75%);
  box-shadow: inset 0 0 0 1px #0007, inset 0 0 calc(18 * var(--u)) color-mix(in srgb, var(--rc) 22%, transparent); transition: border-color .15s, box-shadow .15s; }
.ch-slot.is-empty .ch-slot-box { border-color: #5f80a055; background: #0a1522b3; box-shadow: inset 0 0 calc(18 * var(--u)) #0008; }
.ch-slot.ch-fixed .ch-slot-box { border-color: #6f8fae99; }
.ch-slot.r3 .ch-slot-box, .ch-slot.r4 .ch-slot-box { box-shadow: inset 0 0 0 1px #0007, inset 0 0 calc(18 * var(--u)) color-mix(in srgb, var(--rc) 30%, transparent), 0 0 calc(12 * var(--u)) color-mix(in srgb, var(--rc) 45%, transparent); }
.ch-slot:hover .ch-slot-box { border-color: var(--kit-line); }
.ch-slot.focus .ch-slot-box, .ch-slot.sel .ch-slot-box { border: 2px solid var(--kit-orange); box-shadow: 0 0 calc(14 * var(--u)) #f6a62359, inset 0 0 calc(18 * var(--u)) #f6a62322; }
.ch-slot-ico { width: 84%; height: 84%; }
.ch-slot-ghost { width: calc(44 * var(--u)); height: calc(44 * var(--u)); color: #8fa8c1; opacity: .3; font-style: normal; }
.ch-slot-plus { position: absolute; right: calc(7 * var(--u)); top: calc(7 * var(--u)); width: calc(16 * var(--u)); height: calc(16 * var(--u)); color: #8fa8c1; opacity: .55; }
.ch-slot.is-empty .ch-slot-box { grid-template-areas: 'c'; }
.ch-slot.is-empty .ch-slot-ghost { grid-area: c; }
.ch-screen .lv { position: absolute; left: calc(6 * var(--u)); bottom: calc(4 * var(--u)); font: 700 calc(13 * var(--u)) / 1 var(--f-body); font-style: normal; color: #c3d0dc; text-shadow: 0 1px 0 #000; }
.ch-count { position: absolute; right: calc(7 * var(--u)); bottom: calc(5 * var(--u)); font: 700 calc(15 * var(--u)) / 1 var(--f-body); color: #fff; text-shadow: 0 1px 2px #000; }
.ch-slot.is-pack:hover .ch-count { color: var(--kit-orange-l); }
.ch-equip-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: calc(16 * var(--u)); align-items: end; margin-top: auto; padding-top: calc(10 * var(--u)); border-top: 1px solid var(--kit-line-faint); }
.ch-belt-row { display: flex; gap: calc(9 * var(--u)); }
.ch-belt-slot { display: grid; place-items: center; width: calc(60 * var(--u)); height: calc(50 * var(--u)); box-sizing: border-box; padding: calc(4 * var(--u));
  border: 1px solid #6f8fae99; border-radius: calc(4 * var(--u)); background: radial-gradient(ellipse at 50% 40%, #16304a, #0b1826 75%); }
.ch-belt-ico { width: 100%; height: 100%; }
.ch-belt-slot.is-missing { border-style: dashed; border-color: #5f80a066; background: #0a1522b3; }
.ch-belt-slot.is-missing .ch-belt-ico { opacity: .32; filter: grayscale(1); }
.ch-belt-slot.is-soon { border-style: dashed; border-color: #5f80a055; background: #0a1522b3; padding: calc(16 * var(--u)); color: #8fa8c1; opacity: .55; }
.ch-gold { text-align: right; }
.ch-gold-row { display: flex; align-items: center; justify-content: flex-end; gap: calc(8 * var(--u)); height: calc(50 * var(--u)); }
.ch-gold-ico { width: calc(40 * var(--u)); height: calc(40 * var(--u)); }
.ch-gold-row b { font: italic 800 calc(30 * var(--u)) / 1 var(--f-display); color: var(--kit-orange-l); text-shadow: 0 2px 0 #0009; font-variant-numeric: tabular-nums; }

.ch-item { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: calc(10 * var(--u)); padding: calc(4 * var(--u)) calc(12 * var(--u)) calc(4 * var(--u)); }
.ch-item .cp-detail { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4c6a87 #0000; }
.ch-item:has(.ch-card) .ch-quote2 { display: none; }
.ch-quote2 { justify-self: end; white-space: pre-line; text-align: right; font: italic 700 calc(15 * var(--u)) / 1.05 var(--f-display); text-transform: uppercase; color: #9fb4c8; opacity: .8; }
.ch-pick { display: grid; place-items: center; height: 100%; min-height: calc(60 * var(--u)); text-align: center; font: italic 500 calc(17 * var(--u)) / 1.3 var(--f-body); color: var(--kit-dim); }
/* The card: art + rarity, name and slot on top; the stat rows in two columns across; value and actions at the foot. */
.ch-card { display: grid; grid-template-columns: calc(104 * var(--u)) minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: 'art chip' 'art name' 'art small' 'art note' 'list list' 'vs vs' 'foot foot'; gap: calc(4 * var(--u)) calc(16 * var(--u)); align-items: start; }
.ch-card-body { display: contents; }
.ch-chip { grid-area: chip; justify-self: start; padding: calc(3 * var(--u)) calc(9 * var(--u)) calc(2 * var(--u)); border: 1px solid var(--rc); border-radius: calc(3 * var(--u));
  background: color-mix(in srgb, var(--rc) 22%, #0b1826); font: italic 700 calc(13 * var(--u)) / 1 var(--f-display); text-transform: uppercase; letter-spacing: .04em; color: color-mix(in srgb, var(--rc) 55%, #fff); }
.ch-card-art { grid-area: art; display: grid; place-items: center; width: calc(104 * var(--u)); height: calc(104 * var(--u)); box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--rc) 75%, #6f8fae); border-radius: calc(4 * var(--u)); background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--rc) 16%, #16304a), #0b1826 75%);
  box-shadow: inset 0 0 calc(22 * var(--u)) color-mix(in srgb, var(--rc) 25%, transparent); }
.ch-card-ico { width: 92%; height: 92%; }
.ch-card.is-empty { grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: 'art chip' 'art name' 'art small' 'art note'; }
.ch-card.is-empty .ch-card-art { padding: calc(30 * var(--u)); color: #8fa8c1; opacity: .4; border-style: dashed; }
.ch-card-name { grid-area: name; font: italic 800 calc(25 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: #fff; text-shadow: 0 2px 0 #0009; overflow-wrap: anywhere; }
.ch-card-body > small:not(.ch-vs) { grid-area: small; font: 500 calc(14 * var(--u)) / 1.1 var(--f-body); color: var(--kit-dim); }
.ch-card-note { grid-area: note; font: italic 500 calc(14 * var(--u)) / 1.2 var(--f-body); color: var(--kit-sky); }
.ch-cs-list { grid-area: list; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: calc(4 * var(--u)) calc(20 * var(--u)); margin-top: calc(6 * var(--u)); }
.ch-cs { display: grid; grid-template-columns: calc(18 * var(--u)) minmax(0, 1fr) auto calc(62 * var(--u)); align-items: center; gap: calc(8 * var(--u));
  padding-bottom: calc(3 * var(--u)); border-bottom: 1px solid var(--kit-line-faint); font: 500 calc(15 * var(--u)) / 1.1 var(--f-body); color: #dce4eb; }
.ch-cs-ico { width: calc(17 * var(--u)); height: calc(17 * var(--u)); color: var(--kit-sky); }
.ch-cs > b { font-weight: 700; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-cs > em { justify-self: end; font: 700 calc(13 * var(--u)) / 1 var(--f-body); font-style: normal; white-space: nowrap; }
.ch-cs > em.up { color: var(--kit-ok); } .ch-cs > em.down { color: var(--kit-bad); }
.ch-cs.is-bad > b, .ch-cs.is-bad > span:not(.ch-cs-ico) { color: var(--kit-bad); }
.ch-cs.is-lost { opacity: .7; }
.ch-vs { grid-area: vs; justify-self: end; font: italic 500 calc(12 * var(--u)) / 1 var(--f-body); color: var(--kit-dim); }
.ch-card-foot { grid-area: foot; position: sticky; bottom: 0; z-index: 1; display: flex; background: linear-gradient(#0b1a2900, #0b1a29f2 30%); align-items: center; justify-content: space-between; gap: calc(12 * var(--u)); padding-top: calc(8 * var(--u)); }
.ch-value { display: inline-flex; align-items: center; gap: calc(6 * var(--u)); font: italic 600 calc(15 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-dim); }
.ch-value b { font-size: 1.25em; color: var(--kit-orange-l); }
.ch-value-ico { width: calc(26 * var(--u)); height: calc(26 * var(--u)); }
.ch-acts { display: flex; gap: calc(10 * var(--u)); flex-wrap: wrap; justify-content: flex-end; }
.ch-acts .btn { min-height: calc(42 * var(--u)); font-size: calc(17 * var(--u)) !important; padding: calc(8 * var(--u)) calc(18 * var(--u)); }
.ch-cands { margin-top: calc(12 * var(--u)); padding-top: calc(10 * var(--u)); border-top: 1px solid var(--kit-line-faint); }
.ch-cands p { font-size: calc(14 * var(--u)); color: var(--kit-dim); }
.ch-cands-row { display: flex; flex-wrap: wrap; gap: calc(8 * var(--u)); }
.ch-cands-row .ch-cell { width: calc(58 * var(--u)); }

/* Item cells (bag, candidates): a painted icon on a navy slot with a rarity edge. */
.ch-cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 0; box-sizing: border-box; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--rc) 70%, #6f8fae); border-radius: calc(4 * var(--u)); background: radial-gradient(ellipse at 50% 40%, #16304a, #0b1826 75%);
  box-shadow: inset 0 0 0 1px #0007, inset 0 0 calc(14 * var(--u)) color-mix(in srgb, var(--rc) 22%, transparent); }
.ch-cell.is-empty { cursor: default; border-color: #5f80a040; background: #0a1522b3; box-shadow: inset 0 0 calc(14 * var(--u)) #0008; }
.ch-cell.r3, .ch-cell.r4 { box-shadow: inset 0 0 calc(14 * var(--u)) color-mix(in srgb, var(--rc) 30%, transparent), 0 0 calc(10 * var(--u)) color-mix(in srgb, var(--rc) 45%, transparent); }
.ch-cell:not(.is-empty):hover { border-color: var(--kit-line); }
.ch-cell.sel { border: 2px solid var(--kit-orange); box-shadow: 0 0 calc(12 * var(--u)) #f6a62366; }
.ch-cell-ico { width: 86%; height: 86%; }
.ch-cell .new { position: absolute; right: calc(-4 * var(--u)); top: calc(-6 * var(--u)); padding: calc(2 * var(--u)) calc(5 * var(--u)) calc(1 * var(--u)); border-radius: calc(3 * var(--u));
  background: var(--kit-orange); color: #111a24; font: italic 800 calc(11 * var(--u)) / 1 var(--f-display); letter-spacing: .04em; text-shadow: none; }

/* ---- Inventory tab: the gear bag on the left, the goods backpack on the right ---------------------------------- */
.ch-purse { display: flex; gap: calc(22 * var(--u)); font: 500 calc(16 * var(--u)) / 1 var(--f-body); color: var(--kit-dim); }
.ch-purse > span { display: inline-flex; align-items: center; gap: calc(6 * var(--u)); }
.ch-purse b { color: #fff; font-weight: 700; }
.ch-purse-ico { width: calc(30 * var(--u)); height: calc(30 * var(--u)); }
.ch-bag { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: calc(8 * var(--u)); }
.ch-left .shop { gap: calc(8 * var(--u)); }
.ch-cap { height: calc(10 * var(--u)); min-height: 5px; border: 1px solid #5f80a066; border-radius: 5px; background: #07111c; overflow: hidden; }
.ch-cap > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a8700f, var(--kit-load) 55%, #ffd77d); }
.ch-cap.is-weight > i { background: linear-gradient(90deg, #2f6f9e, #6fb7e6); }
.ch-cap.is-over > i, .ch-vital.is-over .kit-bar > i { background: linear-gradient(90deg, #a8321f, #ff7a4d); }
.ch-meter { display: grid; grid-template-columns: calc(84 * var(--u)) minmax(0, 1fr) auto; align-items: center; gap: calc(10 * var(--u));
  font: italic 600 calc(15 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-dim); }
.ch-meter b { font: 600 calc(15 * var(--u)) / 1 var(--f-body); color: #fff; font-variant-numeric: tabular-nums; }
.ch-good.is-pending { border-style: dashed; opacity: .75; }
/* SRV01: hunger and thirst vitals, the penalty they apply and food cells that eat on click. */
.ch-needs { display: grid; grid-template-columns: 1fr 1fr; gap: calc(14 * var(--u)); }
.ch-need { display: grid; grid-template-columns: calc(22 * var(--u)) auto minmax(0, 1fr) auto; align-items: center; gap: calc(7 * var(--u));
  font: 500 calc(15 * var(--u)) / 1.1 var(--f-body); color: #dce4eb; }
.ch-need .kit-bar { height: calc(10 * var(--u)); }
.ch-need > b { font: 700 calc(15 * var(--u)) / 1 var(--f-body); color: #fff; font-variant-numeric: tabular-nums; }
.ch-need.is-food .ch-vital-ico { color: #f0a050; }
.ch-need.is-water .ch-vital-ico { color: #6cc4f0; }
.ch-need.is-food .kit-bar > i { background: linear-gradient(90deg, #9c5410, #e58a2b 55%, #ffd29a); }
.ch-need.is-water .kit-bar > i { background: linear-gradient(90deg, #1a6493, #3aa6e0 55%, #b9ecff); }
.ch-need.is-low > b { color: #ff7a4d; }
.ch-needs[hidden], .ch-need-pen[hidden] { display: none; }
.ch-need-pen { font-size: calc(14 * var(--u)); color: #ff9a6b; }
button.ch-good { padding: 0; font: inherit; color: inherit; cursor: pointer; }
.ch-good.is-food { border-color: #f6a623aa; }
.ch-good.is-food:hover, .ch-good.is-food:focus-visible { border-color: var(--kit-orange); background: radial-gradient(ellipse at 50% 40%, #2a3f22, #0b1826 75%); }
.ch-eat { position: absolute; left: 0; right: 0; top: 2px; font: italic 700 calc(11 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: var(--kit-orange); opacity: 0; transition: opacity .15s; }
.ch-good.is-food:hover .ch-eat, .ch-good.is-food:focus-visible .ch-eat { opacity: 1; }
@media (pointer: coarse) { .ch-eat { opacity: .9; } }
.ch-goods { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: calc(8 * var(--u)); }
.ch-good { position: relative; display: grid; place-items: center; aspect-ratio: 1; box-sizing: border-box; border: 1px solid #6f8fae99; border-radius: calc(4 * var(--u));
  background: radial-gradient(ellipse at 50% 40%, #16304a, #0b1826 75%); box-shadow: inset 0 0 0 1px #0007; }
.ch-good.is-empty { border-color: #5f80a040; background: #0a1522b3; }
.ch-good-ico { width: 80%; height: 80%; }
.ch-good b { position: absolute; right: calc(5 * var(--u)); bottom: calc(3 * var(--u)); font: 700 calc(14 * var(--u)) / 1 var(--f-body); color: #fff; text-shadow: 0 1px 2px #000; }
.ch-right-top > .ch-belt { margin-top: auto; padding-top: calc(10 * var(--u)); border-top: 1px solid var(--kit-line-faint); }

/* ---- Quick access bar --------------------------------------------------------------------------------------- */
.ch-screen .ch-quick { --kit-edge: calc(14 * var(--u)); grid-area: 5 / 2 / 7 / 3; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 0 calc(8 * var(--u)) calc(2 * var(--u)); }
.ch-quick .ch-sub { margin-bottom: calc(4 * var(--u)); font-size: calc(13 * var(--u)); }
.ch-q-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: calc(8 * var(--u)); min-height: 0; }
.ch-q { position: relative; display: grid; place-items: center; min-height: 0; box-sizing: border-box; border: 1px solid #6f8fae99; border-radius: calc(4 * var(--u));
  background: radial-gradient(ellipse at 50% 40%, #16304a, #0b1826 75%); box-shadow: inset 0 0 0 1px #0007; }
.ch-q-key { position: absolute; left: calc(3 * var(--u)); top: calc(3 * var(--u)); padding: calc(1 * var(--u)) calc(3 * var(--u)); border-radius: calc(2 * var(--u));
  background: #000a; font: 700 calc(10 * var(--u)) / 1 var(--f-display); letter-spacing: .03em; color: #e3eaf1; }
.ch-q-ico { width: calc(32 * var(--u)); height: calc(32 * var(--u)); color: #dfe8f0; }
.ch-q-ico:has(.ch-q-art) { width: calc(46 * var(--u)); height: calc(46 * var(--u)); }
.ch-q-art { display: block; width: 100%; height: 100%; }
.ch-q b { position: absolute; right: calc(4 * var(--u)); bottom: calc(2 * var(--u)); font: 700 calc(13 * var(--u)) / 1 var(--f-body); color: #fff; text-shadow: 0 1px 2px #000; }

/* ---- Key hints ----------------------------------------------------------------------------------------------- */
.ch-hints { grid-row: 6; display: flex; align-items: center; gap: calc(22 * var(--u)); padding-top: calc(8 * var(--u));
  font: italic 700 calc(16 * var(--u)) / 1 var(--f-display); text-transform: uppercase; color: #e9eef3; }
.ch-hints > span { display: inline-flex; align-items: center; gap: calc(8 * var(--u)); }
.ch-hints .kit-key { font-style: normal; }
.ch-hints-l { grid-column: 1; }
.ch-hints-r { grid-column: 3; justify-content: flex-end; }

/* ---- Wide tabs (skills, journal, pearls, all stats): the CharPanel bodies in one plate, retinted navy -------- */
/* A plate this large shows the frame's tiled fill as a pattern: keep the worn edge, fill with plain navy. */
.ch-screen .ch-wide { border-image: var(--kit-frame) 48 / var(--kit-edge) round; background: linear-gradient(#0d1c2cf2, #0a1726f2) padding-box; }
@media (pointer: coarse), (max-width: 760px) { .ch-screen .ch-wide { border-image-slice: 24; } }
.ch-wide { grid-area: 3 / 1 / 6 / -1; padding: calc(6 * var(--u)) calc(18 * var(--u)) calc(10 * var(--u)); overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #4c6a87 #0000; font: 500 15px / 1.35 var(--f-body); }
.ch-wide-head { margin-bottom: 10px; }
.ch-wide .cp-empty { padding: 40px 0; font: italic 600 18px / 1.3 var(--f-body); }
.ch-wide :is(.st-table, .mast-card, .q-card, .tt-top, .tt-list, .tt-detail, .shop-row, .pearl-card) {
  border-radius: 4px; background: linear-gradient(#0a1726d9, #0b1a29e6); box-shadow: inset 0 0 24px #0008; border: 1px solid var(--kit-line-soft); }
.ch-wide :is(.shop h4, .cp-quests h4, .tt-list h4, .cp-pearls h4) { font: italic 800 19px / 1 var(--f-display); text-transform: uppercase; color: var(--kit-sky); text-shadow: none; }
.ch-wide :is(.mc-head b, .q-card b, .tt-weapon b) { font: italic 800 18px / 1.05 var(--f-display); text-transform: uppercase; color: #fff; }
.ch-wide .q-card { border-left: 3px solid var(--kit-orange); }
.ch-wide .q-card.ready { border-left-color: var(--kit-ok); box-shadow: 0 0 12px #8fe06b33, inset 0 0 24px #0008; }
.ch-wide .q-card.offer { border-left-color: var(--kit-sky); }
.ch-wide .st-row { border-bottom-color: var(--kit-line-faint); font-weight: 500; }
.ch-wide .st-row b { font-weight: 700; color: #fff; }
.ch-wide .tiers span { border-color: var(--kit-line-soft); background: #07111c; }
.ch-wide .tiers span.ok { color: #111a24; border-color: var(--kit-orange); background: var(--kit-orange); }
.ch-wide :is(.tt-slot, .tt-card) { border: 1px solid #6f8fae99; border-radius: 4px; background: radial-gradient(ellipse at 30% 20%, #16304a, #0b1826 80%); color: var(--kit-text); }
.ch-wide :is(.tt-slot, .tt-card).tattoo { box-shadow: inset 0 0 0 1px #b36bffaa; }
.ch-wide :is(.tt-card, .tt-slot).sel { outline: 2px solid var(--kit-orange); outline-offset: 1px; }
.ch-wide .tt-card .in { background: var(--kit-orange); color: #111a24; }
.ch-wide .pearl-card { border-color: color-mix(in srgb, var(--pearl, #e8d9ff) 55%, #5f80a0); }
.ch-wide .pearl-give select { background: #0b1826; border-color: var(--kit-line); color: var(--kit-text); }

/* ---- Landscape phones: three columns over the full stage; the quick bar and key hints step aside ------------ */
@container stage (max-height: 520px) {
  #charpanel { background: #030a12e6; }
  .cp.ch-screen { width: 100%; height: 100%; padding: 4px 6px 4px; column-gap: 6px; font-size: 12px;
    grid-template-columns: minmax(0, 31fr) minmax(0, 25fr) minmax(0, 44fr); grid-template-rows: 36px 4px minmax(0, 1fr) 0 0 0 0; }
  .ch-screen .kit-plate { --kit-edge: 12px; }
  .ch-screen .kit-key { font-size: 10px; }
  .ch-screen .ch-quick, .ch-hints, .ch-motto, .ch-brand small, .ch-tab .kit-key, .ch-views, .ch-cam > span, .ch-quote, .ch-quote2, .ch-vs { display: none; }
  .ch-top { gap: 8px; }
  .ch-brand { flex: 0 0 auto; gap: 6px; }
  .ch-brand-palm { width: 22px; height: 26px; }
  .ch-brand b { font-size: 17px; }
  .ch-tabs { gap: 4px; }
  .ch-tab { min-width: 0; min-height: 30px; gap: 5px; padding: 0 6px; font-size: 12px !important; }
  .ch-tab span:not(.ch-tab-ico, .kit-key) { overflow: hidden; text-overflow: ellipsis; }
  .ch-tab-ico { width: 15px; height: 15px; }
  .ch-tab.on::before { inset: -3px -8px; border-width: 0 22px; border-image-width: 0 22px; }
  .ch-x { width: 34px; height: 34px; padding: 8px; }
  .ch-h { gap: 6px; padding-bottom: 5px; font-size: 14px; }
  .ch-h-ico { width: 14px; height: 16px; }
  .ch-h small { font-size: 12px; }
  .ch-h2 { font-size: 12px; }
  .ch-sub { margin-bottom: 4px; font-size: 11px; }
  .ch-link { font-size: 11px !important; padding: 6px 0; }
  .ch-screen .kit-bar, .ch-vital .kit-bar, .ch-stat .kit-bar, .ch-cap { height: 6px; min-height: 0; }
  .ch-left { gap: 7px; padding: 0 2px 4px; }
  .ch-id { gap: 3px; }
  .ch-name { font-size: 20px; }
  .ch-level { gap: 2px 8px; font-size: 12px; }
  .ch-level small { font-size: 10px; }
  .ch-class { grid-template-columns: 26px minmax(0, 1fr); gap: 7px; padding: 5px 7px; }
  .ch-class-ico { width: 26px; height: 26px; padding: 4px; }
  .ch-class b { font-size: 13px; }
  .ch-class p { font-size: 10.5px; line-height: 1.2; margin-top: 2px; }
  .ch-vitals, .ch-core { gap: 5px; }
  .ch-vital, .ch-stat { grid-template-columns: 13px 52px minmax(0, 1fr) 54px; gap: 5px; font-size: 11px; }
  .ch-stat { grid-template-columns: 13px 62px minmax(0, 1fr) 44px; }
  .ch-vital > b, .ch-stat > b { font-size: 10.5px; }
  .ch-vital-ico, .ch-stat-ico { width: 12px; height: 12px; }
  /* SRV01 / INV02 rows: icons carry the meters' names (title), the + stays a touch target. */
  .ch-needs { gap: 8px; }
  .ch-need { grid-template-columns: 13px minmax(0, 1fr) 22px; gap: 5px; font-size: 11px; }
  .ch-need-name { display: none; }
  .ch-need > b { font-size: 10.5px; }
  .ch-need-pen { font-size: 10.5px; }
  .ch-meter { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 6px; font-size: 11px; }
  .ch-meter b { font-size: 10.5px; }
  .ch-model { left: 0; bottom: 0; }
  .ch-cam { left: auto; right: 0; bottom: 0; height: auto; }
  .ch-cam button { padding: 6px; font-size: 10px !important; }
  .ch-cam button .kit-key { min-width: 22px; height: 20px; }
  .ch-right { grid-template-rows: auto auto; gap: 6px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4c6a87 #0000; }
  .ch-right-top { gap: 7px; padding: 0 2px 4px; overflow: visible; }
  .ch-equip { gap: 6px; }
  .ch-slot { gap: 3px; }
  .ch-slot-label { font-size: 9.5px; }
  .ch-slot-box { height: 48px; }
  .ch-slot-ghost { width: 22px; height: 22px; }
  .ch-slot-plus { width: 10px; height: 10px; right: 4px; top: 4px; }
  .ch-screen .lv { left: 3px; bottom: 2px; font-size: 9px; }
  .ch-count { right: 4px; bottom: 3px; font-size: 10px; }
  .ch-equip-foot { gap: 8px; padding-top: 6px; }
  .ch-belt-row { gap: 5px; }
  .ch-belt-slot { width: 38px; height: 34px; padding: 2px; }
  .ch-belt-slot.is-soon { padding: 10px; }
  .ch-gold-row { height: 34px; gap: 5px; }
  .ch-gold-ico { width: 26px; height: 26px; }
  .ch-gold-row b { font-size: 18px; }
  .ch-item { grid-template-rows: auto auto; gap: 5px; padding: 0 2px 4px; }
  .ch-item .cp-detail { overflow: visible; }
  .ch-pick { min-height: 40px; font-size: 11px; }
  .ch-card { grid-template-columns: 62px minmax(0, 1fr); gap: 3px 9px; }
  .ch-cs-list { grid-template-columns: minmax(0, 1fr); }
  .ch-chip { font-size: 9.5px; padding: 2px 5px 1px; }
  .ch-card-art { width: 62px; height: 62px; }
  .ch-card.is-empty .ch-card-art { padding: 16px; }
  .ch-card-name { font-size: 15px; }
  .ch-card-body > small:not(.ch-vs), .ch-card-note { font-size: 10.5px; }
  .ch-cs-list { gap: 3px; margin-top: 3px; }
  .ch-cs { grid-template-columns: 12px minmax(0, 1fr) auto 52px; gap: 5px; padding-bottom: 2px; font-size: 11px; }
  .ch-cs-ico { width: 11px; height: 11px; }
  .ch-cs > em { font-size: 9.5px; }
  .ch-card-foot { gap: 6px; padding-top: 4px; }
  .ch-value { font-size: 11px; gap: 4px; }
  .ch-value-ico { width: 16px; height: 16px; }
  .ch-acts { gap: 6px; }
  .ch-acts .btn { min-height: 32px; font-size: 13px !important; padding: 6px 12px; }
  .ch-cands { margin-top: 6px; padding-top: 5px; }
  .ch-cands p { font-size: 10.5px; }
  .ch-cands-row { gap: 5px; }
  .ch-cands-row .ch-cell { width: 40px; }
  .ch-cell .new { font-size: 8px; padding: 1px 3px; right: -3px; top: -4px; }
  .ch-purse { gap: 12px; font-size: 11px; }
  .ch-purse-ico { width: 18px; height: 18px; }
  .ch-bag { gap: 5px; }
  .ch-goods { gap: 5px; }
  .ch-good b { font-size: 10px; right: 3px; bottom: 2px; }
  .ch-wide { grid-area: 3 / 1 / 4 / -1; padding: 0 4px 6px; font-size: 12px; }
}
