/* Solo combat sandbox — /sim/
 * Product shell: testing-grounds lab (docs/sim/sim-product.md Phase 1).
 * Grid is CSS — do not replace with a generated image.
 */

body.page-sim {
  --bpb-frame-edge-x: 0px;
  --bpb-frame-edge-y: 0px;
  --sim-lab-paper: #f3f4f7;
  --sim-lab-paper-hi: #fafbfc;
  --sim-lab-paper-lo: #d6dae3;
  --sim-lab-grid: rgba(70, 88, 120, 0.11);
  --sim-lab-grid-strong: rgba(70, 88, 120, 0.2);
  --sim-lab-ink-wash: rgba(45, 55, 75, 0.14);
  --sim-footer-h: 2.35rem;
  /* Pull combat HUD up over the gap (round strips added height under bags) */
  --sim-hud-lift: 2.25rem;
  /* Viewport units inside the zoomed desktop stage (sim-desktop-scale.js). */
  --sim-vw: calc(1vw / var(--sim-desktop-scale, 1));
  --sim-vh: calc(1vh / var(--sim-desktop-scale, 1));

  /* Viewport shell — footer always on-screen; stage scrolls inside #main */
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--sim-lab-paper);
  background-image: none;
}

/* Math paper grid — even across the lab. */
body.page-sim::before {
  content: '';
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--sim-footer-h);
  z-index: 0;
  background-image:
    linear-gradient(to right, var(--sim-lab-grid-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--sim-lab-grid-strong) 1px, transparent 1px),
    linear-gradient(to right, var(--sim-lab-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--sim-lab-grid) 1px, transparent 1px);
  background-size:
    120px 120px,
    120px 120px,
    24px 24px,
    24px 24px;
  background-position: center top;
  background-repeat: repeat;
}

/* Keep the leather screen frame on other pages — not the lab. */
body.page-sim::after {
  content: none;
  display: none;
}

body.page-sim #site-nav,
body.page-sim #main,
body.page-sim #site-footer {
  position: relative;
  z-index: 1;
}

/* Fixed nav must not consume flex height (spacer handles clearance) */
body.page-sim #site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 0;
  overflow: visible;
  flex: 0 0 0;
  padding-top: 0;
  background: none;
}

/* Lab: tight under shelves — hang clearance overlaps the scrubber row */
body.page-sim .site-nav-shell {
  position: relative;
  z-index: 1;
  padding-top: 0;
  padding-bottom: 0;
}

body.page-sim .site-nav {
  padding: 0.55rem 0.5rem 0.65rem;
}

/* Clearance for fixed shelves + hanging tabs (host is height:0 so JS measure is useless) */
body.page-sim #site-nav-space {
  /* Preserve the full 1440p shelf clearance, while returning vertical room on
     1080p desktop displays. */
  flex: 0 0 clamp(9.5rem, 14.2vh, 12.75rem);
  height: clamp(9.5rem, 14.2vh, 12.75rem) !important;
  max-height: clamp(9.5rem, 14.2vh, 12.75rem);
  margin-bottom: 0 !important;
  pointer-events: none;
}

@media (max-width: 720px) {
  body.page-sim .site-nav {
    padding: 0.45rem 0.35rem 0.55rem;
  }

  body.page-sim #site-nav-space {
    flex-basis: 10.5rem;
    height: 10.5rem !important;
    max-height: 10.5rem;
  }
}

body.page-sim #site-footer {
  position: relative;
  z-index: 50;
  flex: 0 0 auto;
  margin-top: 0 !important;
  padding: 0;
  width: 100%;
  box-shadow: none;
}

body.page-sim .site-footer {
  margin-top: 0 !important;
}

body.page-sim .site-footer--slim {
  margin: 0 !important;
  /* No wood frame on the lab, so the bar sits on the viewport edge. */
  padding: 0.4rem 1rem max(0.4rem, env(safe-area-inset-bottom, 0px));
  border-radius: 0;
  border-top: 2px solid rgba(60, 38, 29, 0.45);
  background:
    linear-gradient(
      180deg,
      rgba(55, 42, 32, 0.92) 0%,
      rgba(40, 28, 20, 0.97) 100%
    );
  box-shadow: 0 -6px 18px rgba(40, 50, 70, 0.12);
}

.page-sim .sim-main {
  position: relative;
  /* flex-basis 0 — basis:auto was sizing to content and overflowing the vh shell */
  flex: 1 1 0;
  min-height: 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  width: min(100%, calc(100% - 0.5rem));
  margin: 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Desktop keeps the 2560×1440 composition; nav and footer stay unscaled. */
@media (min-width: 1101px) {
  body.page-sim .sim-main,
  body.page-sim .sim-logbook {
    zoom: var(--sim-desktop-scale, 1);
  }
}

.sim-boot-skel {
  position: relative;
  z-index: 2;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.sim-boot-skel .sim-shell--field {
  flex: 1 1 auto;
  min-height: 0;
}

.sim-boot-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Default chamber (empty / error). Fight uses .sim-shell--field */
.sim-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.95rem 1.1rem 1.2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(248, 249, 252, 0.7) 100%);
  border: 1px solid rgba(70, 88, 120, 0.18);
  border-radius: 0.55rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(40, 50, 70, 0.04),
    0 18px 42px rgba(40, 50, 70, 0.1);
}

/* Full fight field: bags in top corners (game-like), mid = HUD/controls */
.sim-shell--field {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
  padding: 0 0.35rem 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: relative;
}

.sim-field {
  display: grid;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  /* Clip enlarged HUD counters so they cannot grow .sim-main scroll metrics */
  overflow: clip;
  /* Bags share the top row with mid; scrub floats over the center gap */
  grid-template-columns:
    minmax(0, 1fr)
    9rem
    minmax(0, 1fr);
  /* Row 2 is spare flex space; HUD is absolute (lifted) so strips do not push it down */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    'you mid opp'
    'you gap opp';
  gap: 0.35rem 0.75rem;
  align-items: start;
  padding-top: 0;
  padding-bottom: 0.75rem;
}

/* Named product regions (see docs/sim/sim-product.md Phase 1 layout) */
.sim-region {
  position: relative;
  min-width: 0;
}

.sim-region__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sim-region--controls {
  z-index: 5;
}

.sim-region--stage {
  z-index: 2;
}

.sim-region--log {
  z-index: 3;
}

.sim-region--hud {
  z-index: 4;
}

.sim-region--lab {
  z-index: 1;
}

.sim-field__scrub {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(22rem, calc(100% - 2rem));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0;
  pointer-events: none;
}

.sim-field__scrub > * {
  pointer-events: auto;
}

.sim-field__scrub > [data-sim-scrub] {
  width: 100%;
  flex: 0 0 auto;
}

.sim-fidelity {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.25rem 0.45rem;
  margin: 0 auto;
  padding: 0.2rem 0.55rem;
  max-width: 100%;
  font-family: var(--bpb-font-body);
  font-size: 0.72rem;
  color: #5a4030;
  background: rgba(255, 236, 220, 0.72);
  border: 1px solid rgba(60, 38, 29, 0.22);
  border-radius: 0.35rem;
  box-shadow: none;
}

.sim-fidelity__label {
  font-weight: 700;
  color: #3c261d;
  letter-spacing: 0.01em;
}

.sim-fidelity__pct {
  font-family: var(--bpb-font-display);
  font-size: 0.95rem;
  font-weight: 400;
  color: #8f2a22;
  min-width: 2.2rem;
}

.sim-fidelity__hint {
  opacity: 0.78;
  font-size: 0.7rem;
}

.sim-field__bag {
  min-width: 0;
  position: relative;
  z-index: 2;
}

.sim-field__bag--you {
  grid-area: you;
  justify-self: start;
  align-self: stretch;
  width: 100%;
  max-width: 45rem;
}

.sim-field__bag--opp {
  grid-area: opp;
  justify-self: end;
  align-self: stretch;
  width: 100%;
  max-width: 45rem;
  pointer-events: auto;
  z-index: 5;
}

.sim-opp-chrome {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0.45rem;
  width: 100%;
}

.sim-opp-chrome .sim-foe {
  margin-bottom: 0;
}

.sim-field__bag--empty {
  min-height: 0;
  pointer-events: none;
}

.sim-bag-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  /* Sit in the hang clearance so overflowing bag sprites don’t cover the name */
  margin: -2.65rem 0 1.9rem;
  position: relative;
  z-index: 6;
}

.sim-bag-title {
  margin: 0;
  font-family: var(--bpb-font-display);
  font-size: clamp(1.15rem, calc(1.6 * var(--sim-vw)), 1.55rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--bpb-label-fill, #ffecdc);
  text-shadow: var(--bpb-label-stroke);
}

.sim-bag-class-icon {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 0 #3c261d) drop-shadow(0 2px 4px rgba(20, 10, 5, 0.35));
}

/* Mid: Open Log centered between bags (game combat) */
.sim-field__mid {
  grid-area: mid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  min-width: 0;
  align-self: start;
  /* Clear the floating scrubber + coverage chip; keep Open Log lower than bag tops */
  padding: 9.25rem 0.25rem 0.35rem;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.sim-field__mid-actions {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sim-field__logbook {
  display: flex;
  justify-content: center;
  align-items: center;
}

.sim-field__logbook .sim-logbook-btn {
  width: 8.75rem;
}

.sim-field__controls {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: min(100%, 22rem);
}

.sim-field__hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.35rem;
  z-index: 4;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  transform: translateY(calc(-1 * var(--sim-hud-lift, 2.25rem)));
}

.sim-field__hud .sim-hud-row {
  pointer-events: auto;
}

/* Tablet and phone: the field grows with its rows and .sim-main scrolls.
   (Desktop fits one screen through sim-desktop-scale.js instead.) */
@media (max-width: 1100px) {
  .sim-shell--field,
  .sim-field {
    flex: 1 0 auto;
  }
}

/* Compact tablet: bags side by side with Open Log between them, the timer
   above, and the HUD below — stacked in flow so nothing floats over a bag.
   Wider screens zoom the 1440p composition instead (sim-desktop-scale.js). */
@media (min-width: 721px) and (max-width: 1100px) {
  .sim-shell--field {
    padding-inline: 0.2rem;
  }

  .sim-field {
    grid-template-columns: minmax(0, 1fr) clamp(6.25rem, 11vw, 9rem) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas:
      'scrub scrub scrub'
      'you mid opp'
      'hud hud hud';
    column-gap: clamp(0.35rem, 1vw, 0.75rem);
  }

  /* Room for the seed line and the report / settings dock under the HUD
     (sim-avatars.css loads later and resets .sim-field padding). */
  .sim-shell--field .sim-field {
    padding-bottom: 3.6rem;
  }

  .sim-field__scrub {
    position: static;
    transform: none;
    grid-area: scrub;
    justify-self: center;
    width: min(19rem, calc(100% - 1rem));
    /* Bag titles hang 2.65rem above their bags */
    margin-bottom: 2.9rem;
  }

  .sim-field__mid {
    gap: 0.5rem;
    padding-top: 0.5rem;
  }

  .sim-field__hud {
    position: static;
    transform: none;
    grid-area: hud;
    margin-top: 0.75rem;
  }

  .sim-field__logbook .sim-logbook-btn {
    width: 7.5rem;
  }

  .sim-field .sim-hud-row {
    --hud-s: 1.15;
    width: min(100%, calc(44rem * var(--hud-s)));
    gap: 0;
  }
}

.sim-field__tools {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  width: auto;
  box-sizing: border-box;
  padding: 0.15rem 8.75rem 0.35rem 1rem;
  text-align: right;
  pointer-events: none;
}

.sim-field__tools .sim-meta--tools,
.sim-field__tools .sim-meta--warn,
.sim-field__tools .sim-link-btn,
.sim-field__tools a,
.sim-field__tools code {
  pointer-events: auto;
}

.sim-field__tools .sim-meta--tools {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #5a6578;
  text-align: right;
}

/* Loading skeleton — same stage chrome as the live sim */
.sim-skel-board {
  width: 100%;
  height: auto !important;
  aspect-ratio: 9 / 7;
  max-height: 22rem;
}

.sim-skel-avatar {
  width: min(58%, 11.5rem);
  height: 16.5rem;
  max-width: 13.5rem;
  margin-top: auto;
  align-self: center;
}

.sim-skel-book {
  width: 8.75rem;
  height: 7.5rem;
}

.sim-skel-gear {
  width: 3.65rem;
  height: 3.65rem;
}

/* Same footprint as the live sheet (573×512 game px × --hud-k in sim-hud.css) */
.sim-skel-hud {
  box-sizing: border-box;
  width: calc(573px * 0.825);
  max-width: 100%;
  height: calc(512px * 0.825);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: calc(95px * 0.825) calc(70px * 0.825) calc(55px * 0.825);
}

.sim-hud[data-hud='player'] + .sim-skel-hud,
.sim-hud-row > .sim-skel-hud:first-of-type {
  justify-self: end;
}

.sim-hud-row > .sim-skel-hud:last-of-type {
  justify-self: start;
}

.sim-skel-hud-banner {
  position: relative;
  margin: calc(-1.15rem * var(--hud-s, 1.5)) auto 0.15rem;
}

.sim-skel-class {
  flex-shrink: 0;
}

.sim-skel-rail-slot {
  flex-shrink: 0;
}

.sim-field__bag .sim-bag-wrap {
  width: 100%;
}

.sim-field__bag .sim-bag.build-bag {
  width: 100%;
  max-width: 100%;
}

.sim-field .sim-hud-row {
  width: min(100%, calc(44rem * var(--hud-s, 1.5)));
  max-width: none;
  justify-content: center;
  gap: 1.75rem;
}

/* Keep legacy arena classnames harmless if anything still references them */
.sim-arena {
  display: contents;
}

.sim-arena__stage,
.sim-arena__rail,
.sim-arena__log {
  display: contents;
}

.sim-layout,
.sim-stage,
.sim-side {
  display: contents;
}

.sim-banner {
  margin: 0;
  padding: 0.55rem 0.85rem;
  font-family: var(--bpb-font-body);
  font-size: 0.95rem;
  color: #ffecdc;
  background: rgba(60, 38, 29, 0.72);
  border: 2px solid #3c261d;
  border-radius: 0.3rem;
  text-shadow:
    -0.06em -0.06em 0 #3c261d,
    0.06em -0.06em 0 #3c261d,
    -0.06em 0.06em 0 #3c261d,
    0.06em 0.06em 0 #3c261d;
}

.sim-banner strong {
  font-weight: 700;
  color: #ffd45a;
}

.sim-banner__cov {
  display: inline-block;
  margin-left: 0.35rem;
  opacity: 0.9;
  font-size: 0.88em;
}

.sim-mode {
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 0;
}

.sim-mode__btn {
  appearance: none;
  border: 2px solid #3c261d;
  border-radius: 0.25rem;
  background: rgba(255, 236, 220, 0.75);
  color: #3c261d;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  padding: 0.3rem 0.7rem;
  cursor: var(--bpb-cursor-pointer);
}

.sim-mode__btn.is-active,
.sim-mode__btn[aria-pressed='true'] {
  background: #e8c46a;
  box-shadow: inset 0 0 0 1px rgba(234, 201, 20, 0.5);
}

.sim-mode__btn:focus-visible {
  outline: 2px solid #ffd817;
  outline-offset: 2px;
}

/* In-game combat HUD (Health / Stamina / Buffs / Debuffs) */
.sim-hud-row {
  --hud-s: 1.5;
  /* Ribbon midline sits on the parchment top edge (game NameBanner). */
  --hud-box-head: calc(2.15rem * var(--hud-s));
  --hud-banner-lift: calc(0.85rem * var(--hud-s));
  --hud-banner-shift-y: calc(-50% - var(--hud-banner-lift));
  position: relative;
  overflow: visible;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  /* Space between the two stat sheets (box + banner move together). */
  gap: 1.75rem;
  align-items: start;
  justify-items: center;
  width: 100%;
}

.sim-hud[data-hud='player'] {
  justify-self: end;
}

.sim-hud[data-hud='dummy'] {
  justify-self: start;
}

/* Game CombatUI/Sheet/Sword.png — player blade + opponent flip_h, tight overlap */
.sim-hud-vs {
  position: absolute;
  left: 50%;
  /* Cross sits in the banner notch, slightly above the ribbon midline. */
  top: calc(var(--hud-box-head, calc(2.15rem * var(--hud-s, 1.5))) - var(--hud-banner-lift, 0px));
  z-index: 6;
  width: calc(2.45rem * var(--hud-s, 1.5));
  height: calc(2.55rem * var(--hud-s, 1.5));
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sim-hud-vs__blade {
  position: absolute;
  top: 0;
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
}

.sim-hud-vs__blade--you {
  left: 2%;
  z-index: 1;
}

.sim-hud-vs__blade--foe {
  right: 2%;
  z-index: 0;
  transform: scaleX(-1);
}

/* Combat HUD panel chrome: hud/sim-hud.css (geometry in hud/sim-hud-geo.js). */

.sim-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin: 0;
  padding-bottom: 0.15rem;
}

.sim-head__identity {
  min-width: 0;
  flex: 1 1 16rem;
}

.sim-head__tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  flex: 0 1 auto;
  max-width: 100%;
}

.sim-title {
  margin: 0;
  font-family: var(--bpb-font-display);
  font-size: clamp(1.55rem, calc(2.8 * var(--sim-vw)), 2rem);
  color: #2a3344;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.sim-meta {
  margin: 0.35rem 0 0;
  font-family: var(--bpb-font-body);
  font-size: 0.92rem;
  color: #3d4a5c;
}

.sim-meta--tools {
  margin: 0;
  text-align: right;
  font-size: 0.85rem;
  line-height: 1.45;
}

.page-sim .sim-main:has(> .sim-shell--status) {
  align-items: center;
  justify-content: safe center;
  padding: 1.25rem;
  box-sizing: border-box;
}

.sim-shell--status {
  width: min(42rem, 100%);
  max-width: 42rem;
  flex: 0 0 auto;
}

.sim-status__title {
  margin: 0.35rem 0 0;
  font-family: var(--bpb-font-display);
  font-size: 1.45rem;
  font-weight: 400;
  color: #2e3848;
}

.sim-status {
  margin: 0.85rem 0 0;
  font-family: var(--bpb-font-body);
  font-size: 1.05rem;
  color: #3d4a5c;
}

.sim-status--error {
  color: #6b3a32;
}

.sim-status__next {
  margin-top: 0.65rem;
  font-size: 0.98rem;
}

.sim-meta--warn {
  margin: 0.35rem 0 0;
  text-align: right;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #6b4a32;
}

.sim-status a {
  color: #3a5a8a;
  text-decoration: underline;
}

.sim-bags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: start;
}

.sim-bag-wrap--opp {
  opacity: 0.98;
}

/* Build-view round strip + video under each sim bag */
.sim-bag-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
}

.sim-bag-media.build-stage__media {
  width: 100%;
}

.sim-round-host.build-round-host {
  width: 100%;
  max-width: 100%;
}

.sim-round-host .build-round-panel {
  margin-inline: auto;
}

.sim-round-host .build-round__toggles {
  gap: 0.35rem;
}

.sim-round-host .build-round__nav {
  min-width: 0;
}

.sim-round-host .build-round__label {
  font-family: var(--bpb-font-body);
  font-size: 0.95rem;
  color: #3c261d;
  margin: 0;
}

.sim-round {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin: 0 0 0.4rem;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  color: #3c261d;
}

.sim-round__label {
  font-weight: 400;
}

.sim-round__select {
  appearance: auto;
  min-width: 10rem;
  padding: 0.22rem 0.45rem;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  font-weight: 400;
  color: #3c261d;
  background: #ffecdc;
  border: 2px solid #3c261d;
  border-radius: 0.2rem;
}

.sim-round__select:focus-visible {
  outline: 2px solid #eac914;
  outline-offset: 2px;
}

.sim-bag.build-bag {
  width: 100%;
}

.sim-dummy {
  position: relative;
  padding: 0.85rem 1rem 1rem;
  background: rgba(255, 236, 220, 0.55);
  border: 2px solid #3c261d;
  border-radius: 0.35rem;
  box-shadow: inset 0 0 0 1px rgba(234, 201, 20, 0.35);
}

.sim-dummy__label {
  margin: 0 0 0.4rem;
  font-family: var(--bpb-font-display);
  font-size: 1.15rem;
  color: #3c261d;
}

.sim-dummy__bar {
  height: 1.1rem;
  border-radius: 0.25rem;
  background: rgba(60, 38, 29, 0.35);
  overflow: hidden;
  border: 1px solid #3c261d;
}

.sim-dummy__fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #c94a3a 0%, #8f2a22 100%);
  transition: width 0.12s ease;
}

.sim-dummy__hp {
  margin: 0.35rem 0 0;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  color: #3c261d;
}

/* Damage numbers / buff labels: fx/sim-dmg-numbers.css */
/* Cooldown highlight: fx/sim-item-chrome.css (ItemProgress.gdshader) */

.sim-bag .bpb-bg__item {
  overflow: visible;
}

/* Source item pulses: BookOfLightActivationPulse and DarkResurectionPulse
 * both expand a single RingLight sprite over 0.7s. */
.sim-bag .bpb-bg__item.is-sim-book-light-pulse::after,
.sim-bag .bpb-bg__item.is-sim-dark-resurrection::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(190%, 9rem);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9001;
  background: center / contain no-repeat url('../../../assets/sim/vfx/RingLight.png');
  mix-blend-mode: screen;
  opacity: 0;
  animation: sim-item-invulnerability-pulse 0.7s ease-out both;
  will-change: transform, opacity;
}

.sim-bag .bpb-bg__item.is-sim-book-light-pulse::after {
  filter: sepia(0.7) saturate(1.35) drop-shadow(0 0 0.25rem rgba(255, 210, 95, 0.8));
}

.sim-bag .bpb-bg__item.is-sim-dark-resurrection::after {
  filter: hue-rotate(245deg) saturate(1.7) drop-shadow(0 0 0.25rem rgba(177, 106, 255, 0.85));
}

@keyframes sim-item-invulnerability-pulse {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.05);
  }
  42% {
    opacity: 0.75;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sim-bag .bpb-bg__item.is-sim-book-light-pulse::after,
  .sim-bag .bpb-bg__item.is-sim-dark-resurrection::after {
    animation: none;
    opacity: 0.45;
  }
}

.sim-card--flip .bpb-bg__spin:not(.bpb-bg__spin--shadow) {
  animation: sim-card-flip 0.3s ease-in-out;
  transform-origin: 50% 50%;
}

@keyframes sim-card-flip {
  0% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(0.04);
  }
  100% {
    transform: scaleX(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sim-hud--hit,
  .sim-card--flip .bpb-bg__spin:not(.bpb-bg__spin--shadow) {
    animation: none !important;
  }

  .sim-hud__trail {
    transition: none;
  }
}


.sim-link-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  color: #5a4030;
  font-family: var(--bpb-font-body);
  font-size: inherit;
  text-decoration: underline;
  cursor: var(--bpb-cursor-pointer);
}

.sim-link-btn:hover {
  color: #3c261d;
}

.sim-link-btn:disabled,
.sim-link-btn[aria-disabled='true'] {
  color: #8a7568;
  text-decoration: none;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Premium hard gate — the lock card is the only thing in #main */
.sim-lock-screen {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

.sim-lock {
  position: relative;
  width: min(26rem, 100%);
  margin: 0;
  padding: 1.4rem 1.5rem 1.3rem;
  text-align: center;
  pointer-events: auto;
  border: 2px solid transparent;
  border-radius: 0.4rem;
  background:
    linear-gradient(rgba(255, 236, 220, 0.96), rgba(255, 236, 220, 0.96)) padding-box,
    linear-gradient(145deg, #fce871, #ff9a3c, #ff6b9a, #7eb6ff, #5dff7a) border-box;
  box-shadow: 0 10px 28px rgba(40, 24, 12, 0.16);
}

.sim-lock--skel {
  display: grid;
  gap: 0.6rem;
  justify-items: center;
}

.sim-lock__title {
  margin: 0 0 0.45rem;
  font-family: var(--bpb-font-display);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
  color: #3c261d;
}

.sim-lock__line {
  margin: 0;
  font-family: var(--bpb-font-body);
  font-size: 1rem;
  line-height: 1.45;
  color: #3c261d;
}

.sim-lock__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

/* Look comes from .home-preset-button (button-preset.css); this sets size only. */
.sim-lock__btn.home-preset-button {
  appearance: none;
  min-height: 2.6rem;
  min-width: 8.5rem;
  padding: 0.45rem 1.2rem;
  font-size: 1.15rem;
}

.sim-runs {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 236, 220, 0.5);
  border: 2px solid #3c261d;
  border-radius: 0.3rem;
}

.sim-runs__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.sim-runs__btn {
  appearance: none;
  border: 2px solid #3c261d;
  border-radius: 0.25rem;
  background: #ffecdc;
  color: #3c261d;
  font-family: var(--bpb-font-body);
  font-size: 0.82rem;
  padding: 0.28rem 0.55rem;
  cursor: var(--bpb-cursor-pointer);
}

.sim-runs__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sim-runs__btn:not(:disabled):hover {
  background: #e8c46a;
}

.sim-runs__hint {
  font-family: var(--bpb-font-body);
  font-size: 0.78rem;
  color: #5a4030;
}

.sim-runs__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 9rem;
  overflow: auto;
}

.sim-runs__empty {
  font-family: var(--bpb-font-body);
  font-size: 0.78rem;
  color: #5a4030;
}

.sim-runs__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem;
  align-items: stretch;
}

.sim-runs__pick {
  appearance: none;
  text-align: left;
  border: 1px solid rgba(60, 38, 29, 0.45);
  border-radius: 0.2rem;
  background: rgba(255, 236, 220, 0.7);
  padding: 0.3rem 0.45rem;
  cursor: var(--bpb-cursor-pointer);
}

.sim-runs__item.is-selected .sim-runs__pick {
  background: rgba(234, 201, 20, 0.35);
  border-color: #3c261d;
}

.sim-runs__title {
  display: block;
  font-family: var(--bpb-font-display);
  font-size: 0.9rem;
  color: #3c261d;
}

.sim-runs__meta {
  display: block;
  font-family: var(--bpb-font-body);
  font-size: 0.7rem;
  color: #5a4030;
}

.sim-runs__del {
  appearance: none;
  border: 1px solid #3c261d;
  border-radius: 0.2rem;
  background: #ffecdc;
  color: #3c261d;
  width: 1.7rem;
  cursor: var(--bpb-cursor-pointer);
  font-size: 1rem;
  line-height: 1;
}

.sim-runs__compare {
  margin: 0.4rem 0 0.55rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(60, 38, 29, 0.4);
  border-radius: 0.2rem;
  background: rgba(60, 38, 29, 0.06);
}

.sim-runs__compare-title {
  margin: 0 0 0.35rem;
  font-family: var(--bpb-font-display);
  font-size: 0.95rem;
  color: #3c261d;
}

.sim-runs__diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
}

.sim-runs__diff dt {
  font-family: var(--bpb-font-body);
  font-size: 0.72rem;
  color: #5a4030;
}

.sim-runs__diff dd {
  margin: 0 0 0.2rem;
  font-family: var(--bpb-font-body);
  font-size: 0.85rem;
  color: #3c261d;
}

.sim-runs__delta {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.8;
}

@media (max-width: 720px) {
  .sim-field {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      'scrub'
      'you'
      'opp'
      'mid'
      'hud';
  }

  .sim-field .sim-hud-row {
    width: 100%;
    --hud-s: 1.15;
    gap: 0.12rem;
  }

  .sim-hud-row {
    --hud-s: 1.15;
    gap: 0.12rem;
  }

  .sim-field__scrub {
    position: static;
    transform: none;
    width: 100%;
    grid-area: scrub;
    pointer-events: auto;
  }

  .sim-field__bag--you,
  .sim-field__bag--opp {
    justify-self: center;
    width: min(100%, 22rem);
  }

  .sim-field__bag--empty {
    display: none;
  }

  .sim-field__mid {
    align-self: center;
    padding-top: 0.35rem;
  }

  .sim-field__hud {
    position: static;
    transform: none;
    grid-area: hud;
    margin-top: calc(-1 * min(var(--sim-hud-lift, 2.25rem), 5rem));
    pointer-events: auto;
  }

  .sim-field__tools {
    padding-inline: 0.75rem 8rem;
    text-align: right;
  }

  .sim-field__tools .sim-meta--tools {
    text-align: right;
  }

  .sim-hud-row {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .sim-hud-vs {
    display: none;
  }
}
