.battle-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
}
.battle-score {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 27px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.battle-score > span:first-child {
  color: #86c9ff;
}
.battle-score > span:nth-child(3) {
  color: #ff9b98;
}
.battle-score time {
  font-size: 15px;
  font-weight: 600;
  border-left: 1px solid #38516a;
  padding-left: 14px;
  color: #dae6f3;
}
.battle-options {
  display: flex;
  align-items: center;
  gap: 8px;
}
.battle-options button,
.battle-options select {
  font-size: 11px;
  padding: 7px 9px;
}
.battle-options label {
  font-size: 11px;
  color: #aebed0;
}
.battle-stage {
  position: relative;
  width: 100%;
  height: 580px;
  max-height: 70vh;
  min-height: 340px;
  overflow: hidden;
  background: #090e12;
  border: 1px solid #45556a;
  border-radius: 9px;
  isolation: isolate;
}
.battle-stage:focus-within {
  border-color: #75cba6;
  box-shadow: 0 0 0 2px #75cba625;
}
#battle-canvas,
#battle-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#battle-canvas {
  outline: none;
  touch-action: none;
  cursor: crosshair;
}
#battle-overlay {
  pointer-events: none;
}
.battle-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: #09141cce;
  color: #d9f0ed;
  font-size: 15px;
  padding: 30px;
  pointer-events: none;
}
#battle-paused {
  inset: auto 0 18px;
  margin: auto;
  width: max-content;
  max-width: 90%;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 12px;
  background: #111c2bdb;
}
.battle-hud {
  display: grid;
  grid-template-columns: minmax(160px, 1.15fr) minmax(260px, 1.5fr) minmax(160px, 1fr);
  gap: 16px;
  align-items: stretch;
  padding: 15px 0;
  border-bottom: 1px solid #334b62;
}
.self-vitals > strong {
  font-size: 14px;
  display: block;
  margin-bottom: 7px;
}
.vital {
  height: 22px;
  position: relative;
  overflow: hidden;
  background: #0b1722;
  border: 1px solid #284c44;
  border-radius: 4px;
  margin-top: 5px;
}
.vital > div {
  height: 100%;
  width: 0;
  transition: width 80ms linear;
}
.vital.hp > div {
  background: #279469;
}
.vital.mp {
  border-color: #264967;
}
.vital.mp > div {
  background: #316cb0;
}
.vital > span {
  position: absolute;
  inset: 0;
  text-align: center;
  line-height: 20px;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
  font-variant-numeric: tabular-nums;
}
.self-vitals > p {
  font-size: 11px;
  color: #b2c6d8;
  margin-top: 5px;
  min-height: 16px;
}
.skill-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.skill-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  padding: 10px;
  min-height: 100px;
  background: #172e39;
  border-color: #447469;
}
.skill-slot:disabled {
  opacity: 0.8;
  cursor: default;
  background: #192638;
  border-color: #3a4c60;
}
.skill-slot.ready {
  border-color: #6cd8aa;
  background: #1b4235;
}
.skill-slot kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: #e5f1ef;
  background: #091a22a8;
  padding: 1px 5px;
  border-radius: 4px;
  position: absolute;
  top: 7px;
  right: 7px;
}
.skill-name {
  font-size: 11px;
  color: #d3e1ed;
  padding-right: 25px;
  min-height: 32px;
  line-height: 1.3;
}
.skill-timer {
  font-size: 18px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: #99ecc3;
}
.skill-slot:disabled .skill-timer {
  color: #ced9e6;
}
.skill-charge {
  font-size: 9px;
  min-height: 15px;
  color: #adc0cf;
  margin-top: 4px;
}
.battle-target {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border-left: 1px solid #334b62;
  padding-left: 14px;
}
.battle-target > span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #92a8bd;
}
.battle-target > strong {
  font-size: 13px;
  color: #f2b5ad;
}
.battle-target > p {
  font-size: 11px;
  color: #aabfce;
}
.input-message {
  font-size: 12px;
  color: #d6e5cf;
  margin-top: 10px;
  min-height: 20px;
}
.battle-controls {
  font-size: 11px;
  line-height: 1.8;
  color: #afc0d1;
  margin-top: 6px;
}
.battle-controls kbd {
  font: inherit;
  color: #e3edf7;
  background: #253c51;
  border: 1px solid #455b70;
  border-radius: 4px;
  padding: 1px 4px;
}
#battle-asset-status {
  font-size: 10px;
  margin-top: 5px;
  color: #8aa4b8;
}
.battle-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #08131df0;
  padding: 28px;
  overflow: auto;
}
.battle-result h3 {
  font-size: 32px;
  margin: 3px 0 8px;
  color: #bcebd1;
}
.battle-result > p:not(.eyebrow) {
  font-size: 13px;
  color: #b9cedd;
}
.battle-result .table-wrap {
  width: min(600px, 100%);
  max-height: 300px;
  margin-bottom: 20px;
}
.battle-result th {
  background: #102535;
}
#battle-panel:fullscreen {
  background: #10151e;
  padding: 12px;
  overflow: auto;
}
#battle-panel:fullscreen .battle-stage {
  height: calc(100vh - 240px);
  max-height: none;
}
#battle-panel:fullscreen .battle-toolbar {
  margin-top: 0;
}
#battle-panel:fullscreen .battle-hud {
  max-width: 1200px;
  margin: auto;
}
@media (max-width: 850px) {
  .battle-hud {
    grid-template-columns: 1fr 1.6fr;
  }
  .battle-target {
    grid-column: 1/-1;
    border-left: 0;
    border-top: 1px solid #334b62;
    padding: 8px 0 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .battle-toolbar {
    align-items: flex-start;
  }
  .battle-options {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .battle-stage {
    height: 480px;
  }
  .skill-slot {
    min-height: 100px;
  }
}
@media (max-width: 560px) {
  .battle-options label {
    display: none;
  }
  .battle-stage {
    height: 380px;
    min-height: 300px;
  }
  .battle-hud {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .battle-target {
    font-size: 10px;
  }
  .skill-bar {
    min-height: 90px;
  }
  .skill-slot {
    min-height: 85px;
  }
  .battle-score {
    font-size: 22px;
    gap: 8px;
  }
  .battle-result {
    padding: 16px;
  }
  .battle-result h3 {
    font-size: 26px;
  }
}

/* M5 team status is separate from the player's skill bar and camera control. */
.battle-team {
  padding: 12px 0;
  border-bottom: 1px solid #334b62;
}
.team-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
}
.team-toolbar h4 {
  font-size: 13px;
  margin: 0;
}
.team-toolbar h4 span {
  font-size: 11px;
  font-weight: 400;
  color: #a8bbcb;
  margin-left: 9px;
}
.team-toolbar button {
  font-size: 11px;
  padding: 6px 10px;
}
.team-roster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.team-card {
  position: relative;
  background: #132431;
  border: 1px solid #344c62;
  border-radius: 7px;
  padding: 10px;
  min-width: 0;
}
.team-card.is-self {
  border-color: #457b63;
}
.team-card.is-dead {
  background: #1a202a;
}
.team-card.is-followed {
  border-color: #efc66d;
  box-shadow: 0 0 0 1px #efc66d55;
}
.team-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.team-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-heading img {
  object-fit: contain;
  flex: 0 0 24px;
}
.team-vital {
  position: relative;
  background: #09131d;
  border-radius: 3px;
  height: 17px;
  overflow: hidden;
  margin: 4px 0;
}
.team-vital-fill {
  height: 100%;
  transition: width 80ms linear;
  background: #287c5c;
}
.team-vital.mp .team-vital-fill {
  background: #2c568c;
}
.team-vital-label {
  position: absolute;
  inset: 0;
  font-size: 10px;
  text-align: center;
  line-height: 17px;
  font-variant-numeric: tabular-nums;
  color: #f1f6ff;
  text-shadow: 0 1px 2px #000;
}
.team-details {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: #bdcde0;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.team-space {
  color: #c8ead7;
}
.team-status {
  font-size: 10px;
  min-height: 15px;
  margin: 6px 0;
  color: #c7b9a8;
}
.team-buffs {
  display: flex;
  gap: 3px;
  min-height: 22px;
  flex-wrap: wrap;
  padding-right: 65px;
}
.team-buff {
  position: relative;
  max-width: 100%;
  font-size: 9px;
}
.team-buff img {
  display: block;
  object-fit: contain;
}
.team-buff-count {
  position: absolute;
  bottom: -1px;
  right: 0;
  background: #07121c;
  color: #fff;
  font-size: 9px;
  padding: 0 2px;
}
.team-watch {
  position: absolute;
  bottom: 9px;
  right: 8px;
  padding: 4px 6px;
  font-size: 9px;
}
.team-watch:disabled {
  opacity: 0.45;
}
.battle-team > p {
  font-size: 10px;
  margin: 7px 0 0;
  min-height: 16px;
}
@media (max-width: 650px) {
  .team-roster {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .team-card {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 1.2fr;
    column-gap: 12px;
  }
  .team-heading {
    grid-row: 1/3;
    margin: 0;
  }
  .team-details {
    grid-column: 2;
  }
  .team-status {
    grid-column: 1/3;
  }
  .team-buffs {
    grid-column: 1/3;
  }
  .team-toolbar {
    align-items: flex-start;
  }
  .team-toolbar h4 span {
    display: block;
    margin: 3px 0 0;
  }
}

/* Independent of RoboHud: caught renderer errors keep explicit recovery controls. */
.m84-battle-recovery {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #071422c9;
  color: #e8f4ff;
  pointer-events: auto;
  font:
    14px/1.5 Tahoma,
    Arial,
    sans-serif;
}
.m84-battle-recovery[hidden] {
  display: none !important;
}
.m84-battle-recovery-card {
  box-sizing: border-box;
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 22px;
  background: #102d45;
  border: 2px solid #8bc5e6;
  border-radius: 8px;
  box-shadow: 0 8px 32px #0008;
}
.m84-battle-recovery-card h2 {
  margin: 0 0 10px;
  font-size: 19px;
  color: #fff;
}
.m84-battle-recovery-card p {
  margin: 10px 0;
}
.m84-battle-recovery-details {
  margin: 14px 0;
  color: #c5ddec;
}
.m84-battle-recovery-details summary {
  cursor: pointer;
}
.m84-battle-recovery-details pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0;
  font: 12px/1.5 monospace;
}
.m84-battle-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.m84-battle-recovery-actions button {
  border: 1px solid #91c9e9;
  border-radius: 4px;
  background: #176795;
  color: #fff;
  padding: 9px 14px;
  font:
    bold 14px Tahoma,
    Arial,
    sans-serif;
  cursor: pointer;
}
.m84-battle-recovery-actions button:hover:not(:disabled) {
  background: #2186bc;
}
.m84-battle-recovery-actions button:focus-visible {
  outline: 3px solid #ffe172;
  outline-offset: 3px;
}
.m84-battle-recovery-actions button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.m84-battle-recovery-status:empty {
  display: none;
}
