:root {
  color-scheme: dark;
  --bg: #08111b;
  --panel: rgba(15, 29, 40, 0.92);
  --panel-2: rgba(24, 46, 60, 0.94);
  --line: rgba(255, 221, 146, 0.24);
  --text: #fff8e6;
  --muted: #cbd6cf;
  --gold: #ffd166;
  --green: #7dd87d;
  --blue: #74d7ff;
  --red: #ff7a7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(140deg, rgba(4, 11, 18, 0.94), rgba(10, 35, 28, 0.9)),
    url("../../assets/beast-tactician-battle-bg.webp") center / cover fixed,
    var(--bg);
}

button,
select {
  font: inherit;
}

button {
  min-height: 44px;
}

.is-hidden {
  display: none !important;
}

.guardian-app {
  min-height: 100vh;
}

.battle-ad-reserve {
  display: none;
}

body.guardian-playing {
  width: 100vw;
  height: 100vh;
  min-height: 0 !important;
  overflow: hidden !important;
  touch-action: none;
  overscroll-behavior: none;
}

body.guardian-playing .guardian-topbar,
body.guardian-playing .game-page-info {
  display: none !important;
}

body.guardian-stage .locale-box,
body.guardian-stage .game-page-info {
  display: none !important;
}

body.guardian-playing .guardian-app {
  width: 100vw;
  height: 100vh;
  min-height: 0;
}

body.guardian-playing .game-panel {
  position: fixed;
  z-index: 50;
  left: var(--guardian-left, 0);
  top: var(--guardian-top, 0);
  width: 390px;
  height: 788px;
  min-height: 788px;
  margin: 0;
  transform: scale(var(--guardian-scale, 1));
  transform-origin: top left;
  grid-template-rows: 96px minmax(0, 1fr) 54px;
  gap: 8px;
  overflow: hidden;
}

body.guardian-playing .battle-ad-reserve {
  position: fixed;
  z-index: 49;
  left: var(--guardian-left, 0);
  top: calc(var(--guardian-top, 0px) + var(--guardian-content-height, 0px));
  display: block;
  width: var(--guardian-width, 100vw);
  height: 56px;
  pointer-events: none;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(4, 10, 16, 0.72);
}

body.guardian-playing #menuBtn {
  width: 48px;
  min-width: 48px;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 24px;
}

body.guardian-playing .hud-row {
  display: grid;
  grid-template-columns: 48px repeat(4, minmax(42px, 1fr)) 44px;
  grid-template-rows: 42px 38px;
  gap: 4px;
  padding: 6px;
}

body.guardian-playing .hud-row > div {
  min-width: 0;
  text-align: center;
}

body.guardian-playing .hud-row span {
  font-size: 0.62rem;
}

body.guardian-playing .hud-row strong {
  font-size: 0.78rem;
}

body.guardian-playing .wave-intel-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  min-height: 34px;
  padding: 4px 8px;
  overflow: hidden;
  text-align: left;
}

body.guardian-playing .wave-intel-panel strong {
  overflow: hidden;
  font-size: 0.72rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.guardian-playing .battle-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 350px minmax(0, 1fr);
}

body.guardian-playing .canvas-shell {
  grid-row: 1;
}

body.guardian-playing .build-panel {
  grid-row: 2;
  display: grid;
  grid-template-rows: auto 112px 76px;
  align-content: start;
  overflow: hidden;
  padding: 8px;
}

body.guardian-playing .build-panel h3 {
  margin-bottom: 4px;
}

body.guardian-playing .build-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  grid-template-columns: none;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  touch-action: pan-x;
  scroll-snap-type: x proximity;
}

body.guardian-playing .build-cards::-webkit-scrollbar {
  display: none;
}

body.guardian-playing .build-card {
  min-height: 104px;
  grid-template-columns: 42px 1fr;
  gap: 5px;
  scroll-snap-align: start;
}

body.guardian-playing .build-card img {
  width: 42px;
  height: 42px;
}

body.guardian-playing .build-card span {
  font-size: 0.7rem;
}

body.guardian-playing .selected-info {
  max-height: 76px;
  min-height: 48px;
  margin-top: 5px;
  padding: 6px 8px;
  overflow: hidden;
}

body.guardian-playing .selected-info span {
  display: inline;
  margin-right: 8px;
  font-size: 0.7rem;
}

body.guardian-playing .command-row {
  display: grid;
  grid-template-columns: 1.35fr repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
}

body.guardian-playing .command-row button {
  min-width: 0;
  padding: 5px;
  font-size: 0.72rem;
  line-height: 1.05;
  white-space: normal;
}

.guardian-topbar,
.hud-row,
.boss-panel,
.stage-header,
.command-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guardian-topbar {
  justify-content: space-between;
  padding: 14px clamp(14px, 3vw, 34px);
  background: rgba(5, 13, 22, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
}

.back-btn,
.locale-box,
.secondary-btn,
.primary-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  font-weight: 900;
}

.back-btn,
.secondary-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
}

.back-btn {
  display: grid;
  grid-template-columns: 16px 28px;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 48px;
  gap: 4px;
  text-decoration: none;
}

.back-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand-lockup span,
.locale-box span,
.hud-row span,
.profile-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-lockup h1 {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
}

.locale-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
}

.locale-box select {
  max-width: 144px;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 800;
}

.guardian-app:not(.is-playing) .locale-box {
  display: flex !important;
  visibility: visible !important;
}

.guardian-app:not(.is-playing) .locale-box select {
  display: block !important;
  visibility: visible !important;
  min-width: 88px;
}

.locale-box option {
  color: #111827;
}

.sound-btn {
  min-width: 96px;
  padding: 9px 12px;
  white-space: nowrap;
}

.secondary-btn[aria-pressed="true"] {
  color: #122018;
  background: linear-gradient(180deg, #dfffe4, var(--green));
  border-color: rgba(125, 216, 125, 0.7);
}

.menu-panel,
.stage-panel {
  width: min(1120px, calc(100% - 28px));
  margin: 22px auto;
}

.menu-panel {
  display: grid;
  grid-template-columns: minmax(240px, 420px) 1fr;
  gap: clamp(18px, 4vw, 38px);
  align-items: center;
  padding: clamp(18px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.36);
}

.poster-frame {
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.poster-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.release-badge {
  width: fit-content;
  margin: 0 0 12px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #1b1608;
  background: linear-gradient(180deg, #fff2bd, var(--gold));
  font-weight: 950;
}

.menu-copy h2 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
}

.menu-hint,
.hold-notice,
.modal-card p {
  color: var(--muted);
  line-height: 1.65;
}

.profile-grid,
.tech-grid {
  display: grid;
  gap: 10px;
}

.profile-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 20px 0;
}

.profile-grid div,
.tech-card,
.stage-card,
.build-card,
.selected-info {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.profile-grid div {
  padding: 13px;
}

.profile-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.menu-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-btn,
.secondary-btn {
  padding: 10px 14px;
  cursor: pointer;
}

[data-cosmetic-id="goldenFrame"] {
  min-width: 220px;
  max-width: 100%;
}

.primary-btn {
  color: #1b1608;
  background: linear-gradient(180deg, #fff0aa, var(--gold));
}

.stage-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.stage-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.stage-header h2 {
  margin: 0;
}

.stage-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(270px, 30%);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 8px;
  padding: 4px 4px 12px;
  scrollbar-width: thin;
}

.stage-card,
.tech-card,
.build-card {
  padding: 12px;
  text-align: left;
}

.stage-card {
  cursor: pointer;
  min-height: 184px;
  scroll-snap-align: center;
  scroll-margin-inline: 8px;
}

.stage-card[aria-current="true"] {
  outline: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.12);
}

.stage-card[aria-disabled="true"] {
  opacity: 0.48;
  cursor: not-allowed;
}

.stage-card .stage-status {
  font-weight: 900;
  color: #f6d879;
}

.stage-card .stage-intel,
.stage-card .stage-reward {
  margin-top: 6px;
  font-size: 0.82rem;
}

.stage-card .stage-intel b,
.stage-card .stage-reward b {
  color: #dff6df;
}

.stage-card strong,
.build-card strong,
.tech-card strong {
  display: block;
  color: var(--gold);
  margin-bottom: 4px;
}

.game-panel {
  width: min(1240px, calc(100% - 18px));
  height: calc(100vh - 104px);
  min-height: 620px;
  margin: 10px auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.hud-row {
  justify-content: space-between;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.hud-row > div {
  min-width: 78px;
}

.hud-row strong {
  display: block;
}

.boss-panel {
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 122, 122, 0.36);
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(86, 16, 31, 0.72), rgba(18, 35, 45, 0.9));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.boss-panel span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.boss-panel strong {
  display: block;
  color: #ffe1a3;
  line-height: 1.1;
}

.boss-meter {
  flex: 1 1 240px;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
}

.boss-meter div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff7a7a, #ffd166);
  transition: width 0.2s ease;
}

#bossHpText {
  min-width: 46px;
  color: #ffe1a3;
  text-align: right;
}

#bossHintText {
  max-width: 220px;
}

.wave-intel-panel {
  flex: 1 1 270px;
  min-width: 240px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(136, 220, 178, 0.28);
  border-radius: 14px;
  background: rgba(9, 24, 22, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.wave-intel-panel span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 950;
  text-transform: uppercase;
}

.wave-intel-panel strong {
  min-width: 0;
  color: #dff6df;
  font-size: 0.94rem;
  line-height: 1.25;
}

.battle-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 10px;
}

.build-panel {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.build-panel h3 {
  margin: 0 0 10px;
}

.build-cards {
  display: grid;
  gap: 8px;
}

.build-card {
  min-height: 82px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 9px;
  align-items: center;
}

.build-card.is-selected {
  outline: 2px solid var(--gold);
}

.build-card.is-unaffordable {
  border-color: rgba(255, 122, 122, 0.42);
  background: rgba(42, 18, 20, 0.74);
}

.build-card.is-unaffordable img,
.build-card.is-unaffordable strong,
.build-card.is-unaffordable span:not(.build-affordability) {
  opacity: 0.58;
}

.build-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
}

.build-card span,
.stage-card span,
.tech-card span {
  display: block;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.88rem;
}

.build-card .build-affordability {
  margin-top: 2px;
  color: #9fe3ae;
  font-weight: 950;
}

.build-card.is-unaffordable .build-affordability {
  color: #ff9a9a;
  opacity: 1;
}

.selected-info {
  margin-top: 10px;
  padding: 10px;
}

.selected-info span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.canvas-shell {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(3, 10, 12, 0.86);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#gameCanvas:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -6px;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(560px, 90%);
  padding: 10px 14px;
  border-radius: 999px;
  color: #1b1608;
  background: linear-gradient(180deg, #fff6cc, var(--gold));
  font-weight: 950;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

.command-row {
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.modal-panel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: rgba(4, 10, 16, 0.7);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.42);
}

.result-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  text-align: center;
}

.result-card h2,
.result-card p {
  margin: 0;
}

body.guardian-playing #resultPanel.modal-panel {
  position: absolute;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  padding: 18px;
  overflow: auto;
}

body.guardian-playing #resultPanel .modal-card {
  max-height: 100%;
}

body.guardian-result .game-panel > .hud-row,
body.guardian-result .game-panel > .boss-panel,
body.guardian-result .game-panel > .battle-layout,
body.guardian-result .game-panel > .command-row {
  pointer-events: none;
}

.result-card img {
  width: 96px;
  height: 96px;
  justify-self: center;
  object-fit: contain;
}

.skill-report {
  color: var(--green);
  font-weight: 900;
}

.result-stars {
  margin: 8px 0;
  color: var(--gold);
  font-size: 1.25rem;
  font-weight: 950;
  letter-spacing: 0;
}

.result-reward {
  padding: 10px 12px;
  border: 1px solid rgba(255, 209, 102, 0.24);
  border-radius: 10px;
  color: #ffe7a3;
  background: rgba(255, 209, 102, 0.08);
  font-weight: 850;
}

.result-progress,
.result-unlock {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(116, 215, 255, 0.09);
  color: #c8f1ff;
  font-weight: 850;
}

.result-progress {
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.result-unlock {
  border: 1px solid rgba(125, 216, 125, 0.28);
  background: rgba(125, 216, 125, 0.09);
  color: #bdf3bd;
}

.result-card .result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, 44px);
  gap: 10px;
}

.result-card .result-actions button {
  width: 100%;
  min-height: 44px;
}

#nextStageBtn { grid-column: 1; grid-row: 1; }
#rerollRewardBtn { grid-column: 2; grid-row: 1; }
#rerollRewardBtn.is-confirming,
#reviveBtn.is-confirming {
  border-color: var(--gold);
  background: rgba(255, 209, 102, 0.18);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.16);
}
#retryBtn { grid-column: 1; grid-row: 2; }
#resultMenuBtn { grid-column: 2; grid-row: 2; }

@media (max-width: 780px) {
  .guardian-topbar {
    gap: 8px;
    padding: 10px;
  }

  .brand-lockup span {
    display: none;
  }

  .locale-box span {
    display: none;
  }

  .menu-panel {
    grid-template-columns: 1fr;
    width: calc(100% - 16px);
    margin: 8px auto;
    padding: 12px;
    gap: 10px;
  }

  .poster-frame {
    width: min(100%, 300px);
    justify-self: center;
  }

  .menu-copy h2 {
    margin-bottom: 6px;
    font-size: 1.65rem;
  }

  .menu-hint {
    margin: 4px 0;
    line-height: 1.35;
  }

  .profile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 8px 0;
    gap: 6px;
  }

  .profile-grid div {
    min-width: 0;
    padding: 7px;
  }

  .stage-panel {
    padding: 14px;
  }

  .stage-rail {
    grid-auto-columns: minmax(258px, 82%);
  }

  .stage-card {
    min-height: 192px;
  }

  .game-panel {
    width: calc(100% - 10px);
    max-width: calc(100vw - 10px);
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  body.guardian-playing .game-panel {
    width: 390px;
    max-width: none;
    height: 788px;
    min-height: 788px;
  }

  .hud-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  body.guardian-playing .hud-row {
    display: grid;
    overflow: hidden;
  }

  body.guardian-playing .hud-row > div {
    min-width: 62px;
  }

  body.guardian-playing .wave-intel-panel {
    flex: 1 1 auto;
    min-width: 190px;
  }

  .boss-panel {
    align-items: stretch;
    gap: 8px;
  }

  .boss-panel > div:first-child {
    min-width: 112px;
  }

  #bossHintText {
    display: none;
  }

  .wave-intel-panel {
    flex: 1 1 100%;
    min-width: 0;
  }

  .battle-layout {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  body.guardian-playing .battle-layout {
    grid-template-columns: 1fr;
  }

  .build-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 148px;
  }

  body.guardian-playing .build-panel {
    max-height: none;
  }

  .build-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.guardian-playing .build-cards {
    grid-template-columns: none;
  }

  .canvas-shell {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    aspect-ratio: 3 / 2;
  }

  body.guardian-playing .canvas-shell {
    width: auto;
    max-width: none;
    aspect-ratio: auto;
  }

  .command-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .result-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

/* Main and Stage share one invariant logical canvas on phone and desktop. */
body:not(.guardian-playing) .guardian-app {
  width: min(100%, 390px);
  margin-inline: auto;
}

body:not(.guardian-playing) .guardian-topbar {
  width: 390px;
  max-width: 100%;
  min-height: 72px;
  margin-inline: auto;
  padding: 10px;
  gap: 8px;
}

body:not(.guardian-playing) .brand-lockup h1 {
  font-size: 1.35rem;
}

body:not(.guardian-playing) .brand-lockup span,
body:not(.guardian-playing) .locale-box span {
  display: none;
}

body:not(.guardian-playing) .locale-box {
  width: 112px;
  min-width: 112px;
  height: 48px;
  padding: 6px 8px;
}

body:not(.guardian-playing) .sound-btn {
  display: none;
}

body:not(.guardian-playing) .menu-panel {
  grid-template-columns: 1fr;
  width: 374px;
  max-width: calc(100% - 16px);
  margin: 8px auto;
  padding: 12px;
  gap: 10px;
}

body:not(.guardian-playing) .poster-frame {
  width: 300px;
  max-width: 100%;
  height: 300px;
  aspect-ratio: auto;
  justify-self: center;
}

body:not(.guardian-playing) .menu-copy h2 {
  margin-bottom: 6px;
  font-size: 1.65rem;
  line-height: 1.15;
}

body:not(.guardian-playing) .menu-hint {
  margin: 4px 0;
  line-height: 1.35;
}

body:not(.guardian-playing) .profile-grid {
  grid-template-columns: repeat(3, 112px);
  margin: 8px 0;
  gap: 6px;
}

body:not(.guardian-playing) .profile-grid div {
  width: 112px;
  min-width: 112px;
  height: 72px;
  padding: 7px;
  overflow: hidden;
}

body.guardian-stage .guardian-app {
  width: min(100%, 390px);
  min-height: min(788px, 100dvh);
  margin-inline: auto;
}

body.guardian-stage .stage-panel {
  width: 382px;
  max-width: calc(100% - 8px);
  min-height: min(732px, calc(100dvh - 56px));
  margin: 4px auto 0;
  padding: 14px;
}

body.guardian-stage .stage-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  height: 48px;
  margin-bottom: 14px;
}

body.guardian-stage .stage-header h2 {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font-size: 1.25rem;
  text-align: center;
}

body.guardian-stage .stage-header #stageBackBtn {
  grid-column: 1;
  grid-row: 1;
}

body.guardian-stage .stage-rail {
  width: 354px;
  max-width: 100%;
  grid-auto-columns: 264px;
  padding: 18px 45px 26px;
  gap: 14px;
  cursor: grab;
  scrollbar-width: none;
  touch-action: pan-x;
}

body.guardian-stage .stage-rail::-webkit-scrollbar {
  display: none;
}

body.guardian-stage .stage-rail.is-mouse-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
}

body.guardian-stage .stage-card {
  width: 264px;
  min-width: 264px;
  max-width: 264px;
  height: 190px;
  min-height: 190px;
  max-height: 190px;
  overflow: hidden;
}

/* Battle artwork can expand, but persistent HUD and commands keep fixed geometry. */
body.guardian-playing .hud-row,
body.guardian-playing .command-row {
  width: 366px;
  max-width: 100%;
  justify-self: center;
}

body.guardian-playing .hud-row {
  grid-template-columns: 48px repeat(4, 62px) 48px;
}

body.guardian-playing .command-row {
  grid-template-columns: 110px repeat(3, 77px);
}

/* Keep the scene-first defense board dominant over the shared compound-game auto track. */
html body.wp-logical-battle-active.guardian-playing #gamePanel .battle-layout {
  grid-template-rows: 350px minmax(0, 1fr) !important;
}

html body.wp-logical-battle-active.guardian-playing #gamePanel .battle-layout > .canvas-shell {
  width: 100% !important;
  height: 350px !important;
  aspect-ratio: auto !important;
  align-self: stretch !important;
}
