/* =========================
   COMBAT MODE
========================= */
body.combat-mode #gameWorld,
body.combat-mode #player,
body.combat-mode .monsterEntity,
body.combat-mode .remotePlayer {
  pointer-events: none;
}

body.combat-mode #mapContainer {
  align-items: stretch;
  justify-content: stretch;
  background: #0b0907;
  overflow: hidden;
}

.combatScene {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border: none;
  border-radius: 0;
  background: var(--window-bg, radial-gradient(circle at 50% 30%, rgba(20, 24, 38, 0.98) 0%, rgba(10, 12, 20, 0.99) 100%));
  backdrop-filter: none;
  box-shadow: none;
}

.combatSceneBoardPanel {
  order: 2;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.combatSceneHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--window-border, rgba(245, 158, 11, 0.35));
  background: var(--window-surface, linear-gradient(180deg, rgba(20, 24, 38, 0.95) 0%, rgba(11, 14, 23, 0.98) 100%));
  box-shadow: var(--window-shadow, 0 4px 16px rgba(0, 0, 0, 0.4));
}

.combatSceneHeader h2 {
  margin: 0;
  color: var(--window-accent, #f59e0b);
}

.combatSceneHeader p {
  margin: 6px 0 0;
  color: var(--window-text, #efe6d2);
}

.combatSceneSidebar {
  order: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-right: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  align-items: start;
}

/* Combat Grid */
.combatGrid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 14px;
  padding: 0 18px 14px;
}

.combatSection {
  padding: 0 18px 14px;
}

.combatSceneSidebar .combatSection {
  padding: 0;
  min-width: 220px;
}

.combatSceneSidebar .combatMonsterList,
.combatSceneSidebar .combatInitiativeList,
.combatSceneSidebar .combatLog {
  max-height: 180px;
  overflow: auto;
}

.combatSection h3 {
  margin: 0 0 10px;
  color: var(--window-accent, #f59e0b);
}

.combatActorCard,
.combatMonsterCard,
.combatInitiativeList,
.combatLog {
  border: 1px solid var(--window-border, rgba(245, 158, 11, 0.35));
  border-radius: 14px;
  background: var(--window-surface, linear-gradient(180deg, rgba(20, 24, 38, 0.95) 0%, rgba(11, 14, 23, 0.98) 100%));
  box-shadow: var(--window-shadow, 0 4px 14px rgba(0, 0, 0, 0.4));
}

.combatActorCard {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.combatActorName {
  font-size: 1rem;
  font-weight: bold;
  color: #fff1cd;
}

.combatActorMeta,
.combatActorResources,
.combatActorStats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.92rem;
  color: #dfd1b3;
}

.combatPill {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.combatStatInline,
.combatStatIcon,
.combatStatIcon--res {
  display: inline-flex;
  align-items: center;
}

.combatStatInline,
.combatStatIcon--res {
  gap: 4px;
}

.combatStatIcon--res {
  margin-right: 2px;
}

.combatActionRow {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.combatActionRow button {
  min-height: 44px;
  width: 100%;
}

#combatTimer {
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: linear-gradient(180deg, rgba(27, 20, 15, 0.96), rgba(48, 37, 26, 0.92));
  color: #ffffff !important;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: center;
}

.combatMapSummary {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(216, 180, 106, 0.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(23, 17, 13, 0.9), rgba(16, 11, 9, 0.82));
  color: #e7dbc1;
  font-size: 0.92rem;
  line-height: 1.4;
}

.combatMonsterCastState {
  margin-top: 4px;
}

.combatRangeBadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(216, 180, 106, 0.24);
}

.combatRangeBadge--in {
  color: #dff7bf;
  background: rgba(112, 179, 72, 0.18);
  border-color: rgba(156, 214, 91, 0.35);
}

.combatRangeBadge--out {
  color: #e7d6b8;
  background: rgba(255, 255, 255, 0.05);
}

.combatTargetEstimate {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.combatTargetEstimateLine {
  font-size: 0.86rem;
  line-height: 1.35;
  color: #f0e1c2;
}

.combatTargetEstimateLine--outcome {
  margin-top: 4px;
  color: #d8c6a3;
}

/* Timeline Custom Styles */
.combatInitiativeList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
  color: #dfd1b3;
  transition: all 0.2s ease-in-out;
}

.timeline-item.active {
  background: linear-gradient(90deg, rgba(216, 180, 106, 0.25) 0%, rgba(216, 180, 106, 0.05) 100%);
  border-color: rgba(216, 180, 106, 0.6);
  color: #fff1cd;
  font-weight: bold;
  box-shadow: inset 0 0 8px rgba(216, 180, 106, 0.15);
}

.timeline-item.monster {
  border-left: 4px solid #f66666;
}

.timeline-item.player {
  border-left: 4px solid #66ccff;
}

.timeline-item.active.monster {
  border-left-width: 6px;
  border-left-color: #ff3333;
}

.timeline-item.active.player {
  border-left-width: 6px;
  border-left-color: #33aaff;
}

.timeline-item.ko {
  opacity: 0.4;
  text-decoration: line-through;
}

.timeline-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.1);
}

.timeline-item.player .timeline-badge {
  color: #66ccff;
  background: rgba(102, 204, 255, 0.15);
}

.timeline-item.monster .timeline-badge {
  color: #f66666;
  background: rgba(246, 102, 102, 0.15);
}

.timeline-item.active .timeline-badge {
  background: #d8b46a;
  color: #17110d;
}

/* =========================
   COMBAT CHAT LAYOUT
   ========================= */

/* Hide sidebar during combat */
body.combat-mode .combatSceneSidebar {
  display: none !important;
}

@media (min-width: 769px) {
  /* Restructure combat scene into 2 columns: board (left) + chat (right) */
  body.combat-mode .combatScene {
    display: grid !important;
    grid-template-columns: 1fr 380px !important;
    grid-template-rows: 1fr !important;
    gap: 16px !important;
  }

  body.combat-mode .combatSceneBoardPanel {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  /* Style chatSection and chatBox inside combat scene */
  body.combat-mode #chatSection {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100% !important;
    box-sizing: border-box;
    display: flex !important;
    min-height: 0 !important;
    background: linear-gradient(180deg, rgba(28, 21, 17, 0.94) 0%, rgba(18, 14, 11, 0.92) 100%) !important;
    border: 1px solid rgba(216, 180, 106, 0.22) !important;
    border-radius: 16px !important;
    padding: 16px !important;
  }

  body.combat-mode #chatBox {
    flex: 1 !important;
    max-height: none !important;
  }

  body.combat-mode #chatControls {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: 8px !important;
  }

  body.combat-mode #chatControls select {
    width: 110px !important;
    box-sizing: border-box !important;
    padding: 8px !important;
  }

  body.combat-mode #chatControls input#chatInput {
    flex: 1 1 150px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 8px !important;
  }

  body.combat-mode #chatControls input#chatPrivateTo {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px !important;
    margin-bottom: 4px !important;
  }

  body.combat-mode #chatControls button {
    flex: 1 1 calc(50% - 4px) !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 38px !important;
    box-sizing: border-box !important;
    padding: 8px !important;
    margin: 0 !important;
  }
}