/* Story page, card boxes, victory screen and battle cards -- pixel skin. */

#story-view {
  grid-template-columns: 230px 1fr;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 52px);
  overflow: hidden;
}
#sp-chars { padding: 10px; overflow-y: auto; }
.sp-label {
  font-family: var(--font-num); font-size: 0.7rem; letter-spacing: 0.1em;
  color: var(--accent); text-shadow: 1px 1px 0 var(--ink); margin: 4px 0 8px;
  text-transform: uppercase;
}
#sp-char-list { display: flex; flex-direction: column; gap: 6px; }
.sp-char {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; text-transform: none; text-align: left; letter-spacing: 0;
}
.sp-char img { width: 34px; height: 46px; box-shadow: 0 0 0 2px var(--ink); }
.sp-char-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-char-prog { font-family: var(--font-num); font-size: 0.62rem; color: var(--text-dim); }
.sp-char.selected { background: var(--accent); color: var(--ink); }
.sp-char.selected .sp-char-prog { color: var(--ink); }
.sp-char.locked { opacity: 0.5; }
#sp-main { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.sp-empty { padding: 40px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.sp-hero { display: grid; grid-template-columns: auto 1fr minmax(240px, 34%); gap: 16px; padding: 14px; align-items: center; }
.sp-portrait { width: 128px; height: 176px; box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 rgba(0,0,0,.5); }
.sp-hero-info h2 { margin: 0; font-family: var(--font-display); font-size: 2rem; color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }
.sp-arch { color: var(--text-dim); font-family: var(--font-num); font-size: 0.7rem; margin-bottom: 10px; }
.sp-stats { display: flex; gap: 8px; margin-bottom: 10px; }
.sp-stat {
  display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 6px 8px;
  background: var(--panel-deep); border: 2px solid var(--ink); box-shadow: var(--bevel);
}
.sp-stat b { font-family: var(--font-display); font-size: 1.4rem; color: #fff; }
.sp-stat span { font-family: var(--font-num); font-size: 0.6rem; color: var(--text-dim); }
.sp-xp { height: 10px; background: var(--ink); border: 2px solid var(--ink); }
.sp-xp-fill { height: 100%; background: var(--accent); }
.sp-xp-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.sp-continue {
  align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 14px; background: var(--panel-deep); border: 2px solid var(--ink); box-shadow: var(--bevel);
}
.sp-kicker { font-family: var(--font-num); font-size: 0.62rem; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; }
.sp-next-title { font-family: var(--font-display); font-size: 1.3rem; color: #fff; }
.sp-next-sub { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 8px; }
.sp-play { font-size: 1.15rem; padding: 12px; animation: px-blink-soft 0.9s steps(2) infinite; }
.sp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sp-panel { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.sp-chapter { display: flex; gap: 10px; align-items: center; text-transform: none; text-align: left; letter-spacing: 0; padding: 7px 10px; }
.sp-ch-mark { font-family: var(--font-num); width: 14px; }
.sp-chapter.cleared .sp-ch-mark { color: var(--good); }
.sp-chapter.open { background: #4a3f78; }
.sp-chapter.open .sp-ch-mark { color: var(--accent); }
.sp-dim { color: var(--text-dim); font-size: 0.78rem; }
.sp-hint { color: var(--text-dim); font-size: 0.72rem; }
.sp-gear { display: grid; grid-template-columns: 70px auto 1fr auto; gap: 10px; align-items: center; padding: 4px 0; }
.sp-gear-name { font-family: var(--font-display); }
.sp-pips { display: flex; gap: 3px; }
.sp-pips i { width: 12px; height: 12px; background: var(--panel-deep); border: 2px solid var(--ink); }
.sp-pips i.on { background: var(--accent); }
.sp-up { font-size: 0.72rem; padding: 5px 8px; }
.sp-max { font-family: var(--font-num); color: var(--accent); font-size: 0.7rem; }
.sp-boxes { display: flex; gap: 12px; align-items: center; }
.sp-box-img { width: 72px; box-shadow: 0 0 0 2px var(--ink); }
.sp-box-img.ready { animation: px-bob 0.6s steps(2) infinite; }
.sp-open { align-self: flex-start; }

.sp-deck { padding: 12px; }
.sp-deck-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.sp-deck-head .sp-hint { flex: 1; }
.sp-deck-count { font-family: var(--font-display); font-size: 1.1rem; color: var(--good); }
.sp-deck-count.bad { color: var(--bad); }
.sp-coll { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.sp-card.card { width: auto; height: auto; opacity: 0.55; cursor: pointer; position: relative; }
.sp-card.card.in-deck { opacity: 1; box-shadow: var(--bevel), 0 4px 0 var(--ink), 0 0 0 2px var(--accent); }
.sp-card-count {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  font-family: var(--font-num); font-size: 0.72rem; background: rgba(0,0,0,.35); padding: 2px;
}
.sp-pm { padding: 0 8px; font-size: 1rem; line-height: 1.2; }
.sp-rar {
  position: absolute; top: 26px; right: 8px; font-family: var(--font-num); font-size: 0.5rem;
  padding: 1px 4px; border: 1px solid var(--ink); text-transform: uppercase;
}
.sp-rar-common { background: #847e87; color: #fff; }
.sp-rar-uncommon { background: #37946e; color: #fff; }
.sp-rar-rare { background: #fbd34d; color: var(--ink); }

/* ----------------------------------------------------------- box opening */
#box-overlay, #victory-overlay {
  position: fixed; inset: 0; z-index: 1400; display: none;
  align-items: center; justify-content: center; background: rgba(8, 6, 14, 0.9);
}
.box-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.box-kicker { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }
.box-chest { width: 192px; box-shadow: 0 0 0 3px var(--ink); }
.box-inner.shaking .box-chest { animation: px-shake 0.35s steps(6) 2; }
.box-inner.opened .box-chest { animation: box-pop 0.3s steps(3) forwards; }
@keyframes box-pop { to { transform: scale(1.3); opacity: 0; height: 0; } }
.box-cards { display: flex; gap: 18px; }
.box-card.card { width: 160px; height: 230px; opacity: 1; position: relative; transform: scale(0); }
.box-inner.opened .box-card {
  animation: box-deal 0.45s cubic-bezier(.2,.9,.3,1.3) forwards;
  animation-delay: calc(var(--i) * 0.25s + 0.2s);
}
@keyframes box-deal { from { transform: translateY(-120px) scale(0.2) rotate(-20deg); } to { transform: none; } }
.box-back { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #2c2442 0 4px, #3b3160 4px 8px); z-index: 2; }
.box-inner.opened .box-back {
  animation: box-flip 0.2s steps(2) forwards;
  animation-delay: calc(var(--i) * 0.25s + 0.75s);
}
@keyframes box-flip { to { opacity: 0; } }
.box-front { display: flex; flex-direction: column; gap: 3px; height: 100%; }
.box-front .card-text { flex: 1; }
.box-card.rar-rare { box-shadow: var(--bevel), 0 0 0 3px #fbd34d, 0 0 24px #fbd34d; }
.box-card.rar-uncommon { box-shadow: var(--bevel), 0 0 0 3px #37946e; }
.box-new {
  position: absolute; top: -12px; right: -12px; z-index: 3; background: var(--bad); color: #fff;
  font-family: var(--font-display); padding: 2px 8px; border: 2px solid var(--ink);
  animation: px-blink-soft 0.5s steps(2) infinite;
}
.box-rar {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); z-index: 3;
  font-family: var(--font-num); font-size: 0.6rem; background: var(--ink); color: var(--accent);
  padding: 2px 6px; text-transform: uppercase;
}
.box-btns, .vic-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ----------------------------------------------------------- victory */
.vic-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 34px;
  background: var(--panel); border: 2px solid var(--ink);
  box-shadow: var(--bevel), 6px 6px 0 rgba(0,0,0,.6); min-width: 360px;
}
.vic-title {
  font-family: var(--font-display); font-size: 2.6rem; color: var(--accent);
  text-shadow: 3px 3px 0 var(--accent-dark), 6px 6px 0 var(--ink);
}
.vic-box.lost .vic-title { color: var(--bad); text-shadow: 3px 3px 0 #6b1f2a, 6px 6px 0 var(--ink); }
.vic-sub { font-family: var(--font-display); color: var(--text-dim); }
.vic-rewards { display: flex; gap: 16px; }
.vic-reward { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-deep); border: 2px solid var(--ink); }
.vic-reward img { width: 48px; box-shadow: 0 0 0 2px var(--ink); }
.vic-reward b { font-family: var(--font-display); font-size: 1.2rem; color: var(--accent); }
.vic-hint { color: var(--text-dim); font-size: 0.85rem; }

/* ----------------------------------------------------------- battle cards */
.ba-moves { grid-template-columns: repeat(auto-fill, minmax(120px, 140px)); }
.ba-move.card {
  width: auto; height: auto; min-height: 0; padding: 4px; opacity: 1;
  text-align: left; text-transform: none; letter-spacing: 0;
}
.ba-move.card .card-text { font-size: 0.66rem; }

.bt-intent {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  margin-top: 4px; padding: 2px 6px; background: #6b1f2a; color: #ffd0d4;
  border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
  font-size: 0.68rem; text-align: center; animation: px-bob 0.8s steps(2) infinite;
}
.bt-intent b { font-family: var(--font-display); font-size: 1.1rem; color: #fff; }
.ba-move.card.idle { opacity: 0.4; cursor: default; filter: grayscale(0.5); }
.ba-incoming { color: #ff5d6c; font-family: var(--font-display); font-size: 1.3rem; animation: px-shake 0.35s steps(6) 2; }

/* ================================================================ in-game store */
#shop-view { grid-template-columns: 250px 1fr; gap: 12px; padding: 12px; height: calc(100vh - 52px); overflow: hidden; }
.shop-side { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.shop-wallet { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--panel-deep); border: 2px solid var(--ink); box-shadow: var(--bevel); }
.shop-wallet img { width: 40px; box-shadow: 0 0 0 2px var(--ink); }
.shop-wallet b { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); text-shadow: 2px 2px 0 var(--ink); }
.shop-wallet span { color: var(--text-dim); font-family: var(--font-num); font-size: 0.65rem; }
.shop-earn { font-size: 0.72rem; color: var(--text-dim); line-height: 1.4; }
.shop-chars { display: flex; flex-direction: column; gap: 6px; }
.shop-main { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.shop-head { display: flex; gap: 16px; align-items: center; padding: 14px; }
.shop-hero { width: 96px; height: 132px; box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 rgba(0,0,0,.5); }
.shop-head h2 { margin: 2px 0 4px; font-family: var(--font-display); font-size: 2rem; color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.shop-item { padding: 10px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.shop-pic { height: 132px; display: flex; align-items: center; justify-content: center; background: var(--panel-deep); border: 2px solid var(--ink); }
.shop-pic img { width: 64px; }
.shop-pic.big img { height: 124px; width: auto; }
.shop-rar { position: absolute; top: 14px; right: 14px; font-family: var(--font-num); font-size: 0.55rem; padding: 2px 5px; border: 2px solid var(--ink); text-transform: uppercase; }
.rar-common .shop-rar { background: #847e87; color: #fff; }
.rar-uncommon .shop-rar { background: #37946e; color: #fff; }
.rar-rare .shop-rar { background: #5b6ee1; color: #fff; }
.rar-epic .shop-rar { background: #d77bba; color: var(--ink); }
.shop-item.rar-epic { box-shadow: var(--bevel), 4px 4px 0 rgba(0,0,0,.5), 0 0 0 2px #d77bba; }
.shop-slot { font-family: var(--font-num); font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; }
.shop-name { font-family: var(--font-display); font-size: 1.05rem; color: #fff; }
.shop-text { font-size: 0.75rem; color: var(--text-dim); flex: 1; }
.shop-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop-price { font-family: var(--font-display); font-size: 1.15rem; color: var(--accent); text-shadow: 2px 2px 0 var(--ink); }
.shop-price::before { content: "◆ "; font-size: 0.8rem; }
.shop-item.owned .shop-pic { box-shadow: inset 0 0 0 2px var(--good); }
#account-coins { margin-left: 6px; padding: 1px 6px; background: var(--ink); color: var(--accent); font-family: var(--font-num); font-size: 0.65rem; }
#account-coins::before { content: "◆ "; }

/* themed gear icons and effect bars */
.cos-gear { width: 20px; height: 20px; display: block; image-rendering: pixelated; }
.cos-fx .bar-fill { animation: px-blink-soft 1.2s steps(2) infinite; }
.cos-fx.cos-gilded .bar-fill { background-color: #fbd34d !important; }
.cos-fx.cos-shadow .bar-fill { background-color: #a64fd0 !important; }
.cos-fx.cos-frost .bar-fill { background-color: #7fd6ff !important; }
.cos-fx.cos-gilded .stat-label, .cos-fx.cos-gilded > :first-child { color: #fbd34d; }
.cos-fx.cos-shadow .stat-label, .cos-fx.cos-shadow > :first-child { color: #d77bba; }
.cos-fx.cos-frost .stat-label, .cos-fx.cos-frost > :first-child { color: #9fe4ff; }

/* ================================================================ bazaar minigame */
#bazaar { position: fixed; inset: 0; z-index: 1300; display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #3a2a1a 0%, #140e0a 70%); }
.bz-box { position: relative; width: min(760px, 94vw); padding: 18px 22px; display: flex; flex-direction: column; gap: 14px;
  background: #2a1f18; border: 2px solid var(--ink); box-shadow: var(--bevel), 6px 6px 0 rgba(0,0,0,.6); }
.bz-title { font-family: var(--font-display); font-size: 1.9rem; color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }
.bz-sub { color: #d9b98a; font-size: 0.85rem; }
.bz-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bz-coins { display: flex; align-items: center; gap: 8px; font-family: var(--font-num); font-size: 0.75rem; color: #d9b98a; }
.bz-coins img { width: 36px; box-shadow: 0 0 0 2px var(--ink); }
.bz-coins b { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); }
.bz-sus { display: flex; align-items: center; gap: 4px; font-family: var(--font-num); font-size: 0.65rem; color: #d9b98a; }
.bz-sus span { margin-right: 4px; }
.bz-sus i { width: 22px; height: 14px; background: #1a120c; border: 2px solid var(--ink); }
.bz-sus i.on { background: var(--bad); animation: px-blink-soft 0.6s steps(2) infinite; }
.bz-stall { display: grid; grid-template-columns: 130px 1fr; gap: 18px; align-items: center; padding: 12px;
  background: repeating-linear-gradient(90deg, #6b3a1f 0 18px, #8f563b 18px 36px); border: 2px solid var(--ink); }
.bz-merchant { width: 130px; box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 rgba(0,0,0,.5); }
.bz-deal { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 10px 12px;
  background: rgba(20, 12, 8, 0.82); border: 2px solid var(--ink); }
.bz-item { font-family: var(--font-display); font-size: 1.4rem; color: #fff; }
.bz-price { font-family: var(--font-display); color: #d9b98a; }
.bz-price b { color: var(--accent); font-size: 1.3rem; }
.bz-card { width: 64px; height: 88px; display: flex; align-items: center; justify-content: center;
  background: #f1e3c2; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.bz-card span { font-family: var(--font-display); font-size: 2.4rem; color: #2a1d14; }
.bz-card.win { animation: px-pulse 0.4s steps(4); background: #c8f0a0; }
.bz-card.lose { animation: px-shake 0.35s steps(6); background: #f0a0a8; }
.bz-hint { font-size: 0.85rem; color: #d9b98a; }
.bz-hint b { color: #fff; }
.bz-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.bz-gotrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bz-got { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; opacity: 0.35;
  background: #1a120c; border: 2px solid var(--ink); font-size: 0.72rem; text-align: center; }
.bz-got img { width: 56px; box-shadow: 0 0 0 2px var(--ink); }
.bz-got.owned { opacity: 1; box-shadow: inset 0 0 0 2px var(--good); }
.bz-log { min-height: 1.3em; font-family: var(--font-display); font-size: 0.95rem; }
.bz-log.good { color: #8ff05a; }
.bz-log.bad { color: #ff7b86; }
.bz-fail { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(10, 6, 4, 0.9); text-align: center; padding: 24px; }
.bz-fail b { font-family: var(--font-display); font-size: 2.2rem; color: var(--bad); text-shadow: 3px 3px 0 var(--ink); }
.bz-fail span { max-width: 420px; color: #d9b98a; }
@media (max-width: 640px) { .bz-stall { grid-template-columns: 1fr; } .bz-merchant { width: 90px; } .bz-gotrow { grid-template-columns: repeat(2, 1fr); } }

/* idle disconnect */
#idle-banner { position: fixed; inset: 0; z-index: 1900; display: none; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(8, 6, 14, 0.82); cursor: pointer; }
#idle-banner b { font-family: var(--font-display); font-size: 2.4rem; color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }
#idle-banner span { max-width: 420px; color: var(--text-dim); }

/* ================================================================ chapter reader
   Pixel fonts need size to be readable: the story text was ~16px. */
.vn { width: min(1100px, 94vw); gap: 22px; }
.vn-portrait { width: 230px; image-rendering: pixelated; box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 rgba(0,0,0,.6); }
.vn-box {
  padding: 22px 28px;
  background: #120f1c;
  border: 3px solid var(--ink) !important;
  box-shadow: var(--bevel), 0 0 0 2px #4a3f6b, 8px 8px 0 rgba(0,0,0,.6);
}
.vn-speaker { font-size: 1.45rem; margin-bottom: 10px; text-shadow: 2px 2px 0 var(--ink); }
.vn-text { font-size: 1.55rem; line-height: 1.5; color: #fff; letter-spacing: 0.01em; text-shadow: 2px 2px 0 rgba(0,0,0,.6); }
.vn-note { font-size: 1.05rem; color: #c9c0e6; margin-top: 14px; padding-top: 10px; }
.vn-hint { font-size: 0.9rem; }
.vn-dot { width: 9px; height: 9px; }
@media (max-width: 760px) {
  .vn-portrait { width: 140px; }
  .vn-text { font-size: 1.25rem; }
  .vn-speaker { font-size: 1.2rem; }
}

/* story page: order toggle */
.sp-order { display: flex; gap: 4px; margin-bottom: 8px; }
.sp-order button { flex: 1; font-size: 0.7rem; padding: 5px 4px; }
.sp-order button.on { background: var(--accent); color: var(--ink); }
.sp-char-num { font-family: var(--font-num); font-size: 0.6rem; color: var(--accent); margin-right: 4px; }

/* chapter list: was the button's small caps size */
.sp-chapter { font-size: 1.15rem; padding: 10px 14px; gap: 12px; }
.sp-chapter .sp-ch-title { font-family: var(--font-display); font-size: 1.15rem; }
.sp-chapter .sp-ch-mark { font-size: 1rem; width: 18px; }
.sp-panel .sp-label { font-size: 0.85rem; }
.sp-gear-name, .sp-boxes b { font-size: 1.05rem; }
.sp-dim, .sp-hint { font-size: 0.85rem; }

/* ================================================================ story battle fx */
#battle-stage { position: relative; overflow: hidden; }
.bt-shot { position: absolute; width: 48px; height: 48px; z-index: 30; pointer-events: none;
  image-rendering: pixelated; transition: left 0.36s linear, top 0.36s linear; filter: drop-shadow(0 0 4px #fff8); }
.bt-unit { position: relative; }
.bt-bark { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); z-index: 25; width: max-content; max-width: 220px;
  padding: 6px 9px; background: #f4ecd8; color: #1a1528; font-family: var(--font-display); font-size: 0.85rem; line-height: 1.25;
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); animation: px-pulse 0.3s steps(3); }
.bt-bark::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
.bt-trait { font-size: 0.62rem; color: #ffd38a; margin-top: 2px; max-width: 160px; }
.bt-intent { font-size: 0.66rem; }
.bt-intent b { font-size: 1.05rem; }
.bt-intent.intent-heavy { background: #8c2a37; }
.bt-intent.intent-guard { background: #2f4a8a; color: #d6e2ff; }
.bt-intent.intent-ambush { background: #b05a12; color: #fff1d6; }
.bt-intent.intent-rally { background: #2f6a2a; color: #d9f7c4; }
.bt-intent.done { background: #3a3550; color: #a49cc0; animation: none; }
.ba-cards-left { margin-left: 14px; padding: 2px 8px; font-family: var(--font-num); font-size: 0.7rem; background: var(--accent); color: var(--ink); border: 2px solid var(--ink); }
.ba-cards-left.none { background: var(--bad); color: #fff; }
#boss-bar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: min(560px, 80%); z-index: 20;
  padding: 6px 10px 5px; background: rgba(12, 10, 20, 0.88); border: 2px solid var(--ink); box-shadow: var(--bevel), 3px 3px 0 var(--ink); }
#boss-bar .boss-name { font-family: var(--font-display); font-size: 1.1rem; color: #ff8a95; text-shadow: 2px 2px 0 var(--ink); text-align: center; }
#boss-bar .boss-track { position: relative; height: 14px; background: #2a0f16; border: 2px solid var(--ink); margin: 3px 0; }
#boss-bar .boss-fill { height: 100%; background: linear-gradient(to bottom, #ff6b7a 0 40%, #c23a3a 40%); transition: width 0.4s steps(8); }
#boss-bar .boss-half { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: #fbd34d; }
#boss-bar .boss-sub { font-size: 0.7rem; color: var(--text-dim); text-align: center; }
#boss-bar.phase2 { animation: px-shake 0.4s steps(6) 1; }
#boss-bar.phase2 .boss-fill { background: linear-gradient(to bottom, #ffb36b 0 40%, #df7126 40%); }
/* intent sits beside the foe, not under it, so the stage never clips the sprite */
#battle-foes .bt-unit { overflow: visible; }
#battle-foes .bt-intent { position: absolute; right: calc(100% + 6px); top: 18%; width: 118px; margin: 0; z-index: 15; }
#battle-stage { overflow: hidden; }

/* ================================================================ pixel map */
#map-wrap { position: relative; }
#map-pixels { position: absolute; left: 0; width: 100%; aspect-ratio: 1000 / 700; image-rendering: pixelated;
  border: 3px solid var(--ink); box-shadow: var(--bevel), 6px 6px 0 rgba(0,0,0,.5); pointer-events: none; }
#world-map.pixelized { position: relative; background: transparent !important; border-color: transparent !important; box-shadow: none !important; }
#world-map.pixelized .map-region { fill-opacity: 0 !important; stroke: transparent !important; filter: none !important; }
#world-map.pixelized .map-region.map-hover { fill: #fbf236 !important; fill-opacity: 0.22 !important; stroke: #fbf236 !important; stroke-width: 4 !important; stroke-opacity: 1 !important; }
#world-map.pixelized #map-features, #world-map.pixelized #map-wear, #world-map.pixelized > rect, #world-map.pixelized .map-sea-bg { display: none; }
#world-map.pixelized .map-label { font-family: "Pixelta", "Pixelify Sans", monospace !important; fill: #fff !important;
  paint-order: stroke; stroke: #0c0a14 !important; stroke-width: 5px !important; letter-spacing: 0.04em; font-style: normal !important; }
#world-map.pixelized * { shape-rendering: crispEdges; }
#map-title { font-family: var(--font-display); color: var(--accent); text-shadow: 3px 3px 0 var(--ink); }

/* ================================================================ marching on */
#battle-stage.marching #battle-sky {
  background-size: 100% 100%; background-repeat: repeat-x;
  animation: march-hills 2.4s linear infinite;
}
@keyframes march-hills { from { background-position: 0 0; } to { background-position: -100% 0; } }
#battle-stage.marching #battle-ground { animation: march-ground 0.5s steps(4) infinite; }
@keyframes march-ground { from { background-position: 0 0, 0 0; } to { background-position: -46px 0, 0 0; } }
#battle-stage.marching #battle-party .bt-art img { animation: march-step 0.4s steps(2) infinite !important; }
@keyframes march-step { 0% { transform: translateY(0); } 50% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
.bt-march { font-family: var(--font-display); font-size: 1.4rem; color: #fff; text-shadow: 2px 2px 0 var(--ink);
  animation: px-blink-soft 0.8s steps(2) infinite; }
#battle-foes .bt-unit.arrive { animation: foe-arrive 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes foe-arrive { from { transform: translateX(160%); opacity: 0; } 60% { opacity: 1; } to { transform: none; } }

/* pixel marks in the chapter list, boss warning */
img.sp-ch-mark { width: 24px; height: 24px; image-rendering: pixelated; flex-shrink: 0; }
.sp-ch-boss { width: 24px; height: 24px; margin-left: auto; image-rendering: pixelated; animation: px-bob 0.8s steps(2) infinite; }
.sp-boss-warn { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; padding: 6px 8px; font-size: 0.85rem;
  background: #4a1c22; color: #ffd0d4; border: 2px solid var(--ink); }
.sp-boss-warn.ready { background: #1f3a22; color: #d9f7c4; }
.sp-boss-warn img { width: 24px; height: 24px; image-rendering: pixelated; flex-shrink: 0; }

/* ================================================================ chest opening */
.chest-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 520px; justify-content: center; cursor: pointer; user-select: none; }
.chest { width: 220px; box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 rgba(0,0,0,.6); }
.chest.hop { animation: chest-hop 0.45s steps(5); }
@keyframes chest-hop { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-24px) scale(1.06, 0.94); }
  60% { transform: translateY(0) scale(0.94, 1.06); } 100% { transform: none; } }
.chest.glow-unc { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px #37946e, 0 0 30px #6abe30; }
.chest.glow-rare { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px #fbd34d, 0 0 40px #fbd34d; animation: chest-blink 0.5s steps(2) infinite; }
.chest.glow-epic { box-shadow: 0 0 0 3px var(--ink), 0 0 0 7px #d77bba, 0 0 60px #d77bba; animation: chest-blink 0.22s steps(2) infinite, px-shake 0.5s steps(4) infinite; }
@keyframes chest-blink { 0% { filter: brightness(1); } 100% { filter: brightness(1.7); } }
.chest.empty { filter: grayscale(0.7) brightness(0.6); animation: none; }
.chest-hint { font-family: var(--font-display); color: var(--text-dim); animation: px-blink-soft 0.8s steps(2) infinite; min-height: 1.2em; }
.chest-counter { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--ink); border: 2px solid #4a3f6b; }
.chest-counter img { width: 32px; image-rendering: pixelated; }
.chest-counter b { font-family: var(--font-display); font-size: 1.8rem; color: var(--accent); }
.chest-counter span { font-family: var(--font-num); font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; }
.chest-reveal { min-height: 200px; display: flex; align-items: flex-end; justify-content: center; }
.chest-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; min-width: 180px;
  background: var(--panel); border: 3px solid var(--ink); box-shadow: var(--bevel), 4px 4px 0 rgba(0,0,0,.6);
  animation: item-pop 0.45s cubic-bezier(.2,.9,.3,1.4) both; text-align: center; }
@keyframes item-pop { from { transform: translateY(120px) scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
.chest-item img { width: 128px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--ink); }
.chest-item.k-coins img, .chest-item.k-cosmetic img { width: 96px; box-shadow: none; }
.chest-item b { font-family: var(--font-display); font-size: 1.25rem; color: #fff; }
.chest-item span { font-family: var(--font-num); font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; }
.chest-item.r-uncommon { box-shadow: var(--bevel), 0 0 0 3px #37946e; }
.chest-item.r-rare { box-shadow: var(--bevel), 0 0 0 3px #fbd34d, 0 0 28px #fbd34d; }
.chest-item.k-cosmetic { box-shadow: var(--bevel), 0 0 0 3px #d77bba, 0 0 40px #d77bba; }
.chest-item.k-cosmetic span { color: #d77bba; font-size: 0.8rem; }
.chest-item.k-coins b { color: var(--accent); }
.chest-got { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 760px; min-height: 64px; }
.chest-item.small { min-width: 0; padding: 4px 6px; animation: none; }
.chest-item.small img { width: 48px; }
.chest-item.small b { font-size: 0.75rem; }
.chest-item.small span { font-size: 0.5rem; }
