/* TerraNigra structured turn-based combat overlay */

#structuredCombatOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(4, 3, 2, 0.92);
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

#structuredCombatOverlay.is-open {
  display: flex;
}

.structured-combat-screen {
  width: min(1140px, 100%);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid #6b5228;
  background:
    linear-gradient(180deg, rgba(28, 20, 12, 0.98), rgba(10, 8, 5, 0.99)),
    radial-gradient(ellipse at top, rgba(120, 90, 40, 0.12), transparent 60%);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.65);
  padding: 16px;
  box-sizing: border-box;
}

.structured-combat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(107, 82, 40, 0.5);
  padding-bottom: 10px;
}

.structured-combat-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #e8d6a8;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.structured-combat-turn {
  font-size: 0.9rem;
  color: #c9a24d;
}

.structured-combat-turn.is-wait {
  color: #9a8b6a;
  font-style: italic;
}

.structured-combat-arena {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1.15fr) minmax(240px, 1fr);
  gap: 16px;
  align-items: start;
  min-height: 360px;
}

.structured-combat-fighter {
  border: 1px solid rgba(107, 82, 40, 0.55);
  background: linear-gradient(180deg, rgba(22, 16, 10, 0.95), rgba(8, 6, 4, 0.98));
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.structured-combat-fighter.is-enemy {
  border-color: rgba(120, 48, 48, 0.6);
}

/* Portrait frame matches avatar1.png aspect (945×1299), scaled up for combat. */
.structured-combat-portrait {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  aspect-ratio: 945 / 1299;
  border: 1px solid #6b5228;
  background:
    linear-gradient(180deg, rgba(22, 16, 11, 0.98), rgba(8, 6, 4, 0.98)),
    radial-gradient(circle at top, rgba(93, 70, 28, 0.2), transparent 58%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(245, 214, 137, 0.06);
}

.structured-combat-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  filter: saturate(0.9) contrast(1.04);
}

.structured-combat-name {
  font-weight: 700;
  color: #eadcad;
  font-size: 1rem;
}

.structured-combat-meta {
  font-size: 0.8rem;
  color: #9a8b6a;
}

.structured-combat-hp-bar {
  height: 14px;
  border: 1px solid #4a3820;
  background: #1a1208;
  position: relative;
  overflow: hidden;
}

.structured-combat-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #5a2018, #8b3028, #c44);
  transition: width 0.35s ease;
}

.structured-combat-fighter.is-player-side .structured-combat-hp-fill {
  background: linear-gradient(90deg, #1a4020, #2d6b32, #4a9);
}

.structured-combat-hp-text {
  font-size: 0.75rem;
  color: #b8a888;
  text-align: right;
}

.structured-combat-mana-wrap {
  margin-top: 4px;
}

.structured-combat-mana-bar {
  height: 10px;
  border: 1px solid #2a4470;
  background: #101828;
  position: relative;
  overflow: hidden;
}

.structured-combat-mana-fill {
  height: 100%;
  background: linear-gradient(90deg, #14204a, #2a4a9f, #5b8fd7);
  transition: width 0.35s ease;
}

.structured-combat-mana-text {
  font-size: 0.7rem;
  color: #8aa8d8;
  text-align: right;
}

.structured-combat-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}

.structured-combat-status-pill {
  font-size: 0.68rem;
  padding: 2px 6px;
  border: 1px solid rgba(107, 82, 40, 0.6);
  background: rgba(40, 30, 18, 0.9);
  color: #d4c4a0;
  border-radius: 3px;
}

.structured-combat-log-panel {
  border: 1px solid rgba(107, 82, 40, 0.45);
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  overflow-y: auto;
  max-height: 180px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #c4b896;
}

.structured-combat-log-panel .log-line {
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(60, 48, 28, 0.25);
  padding-bottom: 3px;
}

.structured-combat-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.structured-combat-actions button {
  padding: 10px 8px;
  border: 1px solid #6b5228;
  background: linear-gradient(180deg, rgba(62, 47, 22, 0.94), rgba(20, 15, 9, 0.98));
  color: #e8d6a8;
  font-size: 0.78rem;
  cursor: pointer;
  letter-spacing: 0.03em;
}

.structured-combat-actions button:hover:not(:disabled) {
  border-color: #c9a24d;
  color: #fff8e8;
}

.structured-combat-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.structured-combat-actions button.is-cooldown::after {
  content: attr(data-cd);
  display: block;
  font-size: 0.65rem;
  color: #9a7060;
}

.structured-combat-actions .btn-flee {
  border-color: rgba(120, 48, 48, 0.7);
  color: #e8b0a8;
}

.structured-combat-sidebar-panel .combat-class-row,
.arena-combat-panel .combat-class-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.structured-combat-sidebar-panel button.combat-mini-btn,
.arena-combat-panel button.combat-mini-btn {
  font-size: 0.72rem;
  padding: 6px 8px;
  border: 1px solid #6b5228;
  background: rgba(30, 22, 12, 0.95);
  color: #c9b483;
  cursor: pointer;
}

.structured-combat-sidebar-panel select,
.arena-combat-panel select {
  width: 100%;
  margin-top: 6px;
  background: #1a1208;
  color: #e8d6a8;
  border: 1px solid #6b5228;
}

.arena-combat-panel {
  margin-top: 4px;
  max-width: 920px;
  border: 1px solid rgba(112, 87, 41, 0.55);
  background: rgba(12, 10, 8, 0.55);
  padding: 14px 16px 16px;
}

.arena-combat-heading {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #e8c56a;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.arena-combat-note {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: #cfc3a0;
}

.arena-combat-field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a59369;
  margin-bottom: 4px;
}

.arena-combat-active-row {
  margin-bottom: 8px;
}

.arena-pvp-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(112, 87, 41, 0.45);
}

.arena-pvp-input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 6px;
  background: #1a1208;
  color: #e8d6a8;
  border: 1px solid #6b5228;
  padding: 8px 10px;
  font: inherit;
}

.arena-pvp-challenge-list {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #b8a888;
}

.arena-pvp-send-btn {
  width: 100%;
}
