/* ===== 全局重置 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

body {
  background: #1a1e2c;
  color: #e8edf5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.app {
  max-width: 1440px;
  width: 100%;
  background: #232837;
  border-radius: 24px;
  padding: 24px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 40px);
}

/* ===== 顶部栏 ===== */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  border-bottom: 1px solid #3a4055;
  padding-bottom: 14px;
}

.header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f0c27f, #fc5c7d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.header-center {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  flex: 1;
}

.enemy-clan {
  font-size: 15px;
  color: #c8d0e6;
  font-weight: 500;
  white-space: nowrap;
}
.enemy-clan #clanName {
  color: #f0c27f;
}

.tabs {
  display: flex;
  gap: 4px;
  background: #2e3448;
  padding: 4px;
  border-radius: 40px;
}
.tabs .tab {
  padding: 6px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  color: #8892b0;
  cursor: pointer;
  transition: 0.2s;
  user-select: none;
}
.tabs .tab:hover {
  color: #e8edf5;
}
.tabs .tab.active {
  background: #4a526b;
  color: #fff;
}

.filters {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
  color: #b0b9d4;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}
.filters input[type="checkbox"] {
  accent-color: #fc5c7d;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.header-right button {
  padding: 5px 14px;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
}
.btn-history {
  background: #4a526b;
  color: #e8edf5;
}
.btn-history:hover {
  background: #5a6a8b;
}
.btn-placeholder {
  background: #2e3448;
  color: #8892b0;
}
.btn-placeholder:hover {
  background: #3a4055;
  color: #b0b9d4;
}

/* ===== 主体：左右分栏 ===== */
.main {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 500px;
}

/* ===== 左侧：大据点列表 ===== */
.left-panel {
  width: 200px;
  flex-shrink: 0;
  background: #1e2436;
  border-radius: 16px;
  padding: 8px 0;
  max-height: 600px;
  overflow-y: auto;
}
.left-panel .loading-placeholder {
  padding: 20px;
  text-align: center;
  color: #4a526b;
  font-size: 14px;
}

.left-panel .slot-item {
  padding: 10px 16px;
  font-size: 14px;
  color: #a8b2d0;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.left-panel .slot-item:hover {
  background: #282f44;
}
.left-panel .slot-item.active {
  background: #2e3448;
  border-left-color: #fc5c7d;
  color: #fff;
  font-weight: 500;
}
.left-panel .slot-item .badge {
  font-size: 10px;
  background: #3a4055;
  color: #b0b9d4;
  border-radius: 20px;
  padding: 0 8px;
  line-height: 18px;
  margin-left: auto;
  flex-shrink: 0;
}
.left-panel .slot-item .buff-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.buff-dot.high { background: #fc5c7d; }
.buff-dot.low  { background: #f0c27f; }
.buff-dot.none { background: #3a4055; }

/* ===== 右侧：详情区域 ===== */
.right-panel {
  flex: 1;
  background: #1e2436;
  border-radius: 16px;
  padding: 18px 22px;
  overflow-y: auto;
  max-height: 600px;
  min-width: 0;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #e8edf5;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title small {
  font-size: 13px;
  font-weight: 400;
  color: #8892b0;
}
.section-title .buff-tag {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 12px;
  border-radius: 20px;
  background: #2e3448;
  color: #b0b9d4;
}
.buff-tag.high { border-left: 3px solid #fc5c7d; }
.buff-tag.low  { border-left: 3px solid #f0c27f; }

.empty-state {
  color: #4a526b;
  text-align: center;
  padding: 40px 0;
  font-size: 15px;
}

/* ===== 每个小据点 Panel ===== */
.slot-panel {
  background: #141a28;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: stretch;
  gap: 14px;
  border: 1px solid #2e3448;
  transition: 0.1s;
}
.slot-panel:last-child {
  margin-bottom: 0;
}

/* ===== 防守方 ===== */
.defense-side {
  flex: 0 0 auto;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 14px;
  border-right: 1px solid #2e3448;
  justify-content: center;
}
.defense-side .full-row {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}

/* 英雄卡片 - 64px */
.hero-unit {
  position: relative;
  width: 64px;
  height: 64px;
  background: #2e3448;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #3a4055;
  overflow: hidden;
}
.hero-unit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-unit .fallback-id {
  display: none;
  font-size: 14px;
  font-weight: 600;
  color: #c8d0e6;
}
.hero-unit img.error,
.hero-unit img[src=""],
.hero-unit img:not([src]) {
  display: none;
}
.hero-unit img.error + .fallback-id,
.hero-unit img[src=""] + .fallback-id,
.hero-unit img:not([src]) + .fallback-id {
  display: flex;
}

/* 庇佑宠物 - 暂不显示（数据缺失） */
.hero-unit .bless-pet {
  display: none;
}

/* 战场宠物 */
.battle-pet {
  width: 64px;
  height: 64px;
  background: #2e3448;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #3a4055;
  overflow: hidden;
  margin-left: 0;
}
.battle-pet img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.battle-pet .fallback-id {
  display: none;
  font-size: 14px;
  font-weight: 600;
  color: #c8d0e6;
}
.battle-pet img.error,
.battle-pet img[src=""],
.battle-pet img:not([src]) {
  display: none;
}
.battle-pet img.error + .fallback-id,
.battle-pet img[src=""] + .fallback-id,
.battle-pet img:not([src]) + .fallback-id {
  display: flex;
}

/* 战旗（左侧） */
.banner-compact {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #1e2436;
  padding: 2px 10px;
  border-radius: 0 6px 6px 0;
  border-left: 2px solid #fc5c7d;
  min-width: 40px;
  height: 64px;
  margin-left: 0;
}
.banner-compact span {
  font-size: 10px;
  color: #b0b9d4;
  line-height: 1.5;
  white-space: nowrap;
  font-weight: 500;
  text-align: center;
}

/* ===== 对策区 ===== */
.counter-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  min-width: 0;
}
.counter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1a1f30;
  padding: 3px 10px 3px 4px;
  border-radius: 8px;
  border-left: 3px solid #4a526b;
  flex-wrap: nowrap;
}
.counter-row .winrate {
  font-weight: 700;
  font-size: 14px;
  min-width: 44px;
  flex-shrink: 0;
  text-align: center;
}
.counter-row .winrate.gold { color: #f7d44a; }
.counter-row .winrate.silver { color: #b0bec5; }
.counter-row .winrate.bronze { color: #d4a373; }

/* 标记 */
.counter-row .marks {
  font-size: 10px;
  color: #8892b0;
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  min-width: 30px;
}
.counter-row .marks .mark {
  background: #2e3448;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9px;
  color: #b0b9d4;
}
.counter-row .marks .mark.buff-plus { color: #6fcf97; }
.counter-row .marks .mark.buff-minus { color: #f28b82; }

/* 攻击方阵容 */
.counter-row .attack-full {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}

/* 攻击方英雄 - 40px */
.mini-hero {
  position: relative;
  width: 40px;
  height: 40px;
  background: #2e3448;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #b0b9d4;
  border: 1px solid #3a4055;
  flex-shrink: 0;
  overflow: hidden;
}
.mini-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mini-hero .fallback-id {
  display: none;
  font-size: 9px;
  font-weight: 600;
  color: #b0b9d4;
}
.mini-hero img.error,
.mini-hero img[src=""],
.mini-hero img:not([src]) {
  display: none;
}
.mini-hero img.error + .fallback-id,
.mini-hero img[src=""] + .fallback-id,
.mini-hero img:not([src]) + .fallback-id {
  display: flex;
}

/* 攻击方庇佑宠物 - 暂不显示（数据缺失） */
.mini-hero .mini-bless {
  display: none;
}

/* 攻击方战场宠物 - 32x40 */
.mini-pet {
  width: 32px;
  height: 40px;
  background: #1e2436;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #8892b0;
  border: 1px solid #3a4055;
  flex-shrink: 0;
  overflow: hidden;
}
.mini-pet img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mini-pet .fallback-id {
  display: none;
  font-size: 8px;
  font-weight: 600;
  color: #8892b0;
}
.mini-pet img.error,
.mini-pet img[src=""],
.mini-pet img:not([src]) {
  display: none;
}
.mini-pet img.error + .fallback-id,
.mini-pet img[src=""] + .fallback-id,
.mini-pet img:not([src]) + .fallback-id {
  display: flex;
}

/* 攻击方战旗 - 右侧显示三行数字 */
.mini-banner {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  background: #141a28;
  padding: 0 6px;
  border-radius: 0 4px 4px 0;
  border-left: 1px solid #3a4055;
  height: 40px;
  min-width: 18px;
}
.mini-banner span {
  font-size: 9px;
  font-weight: 700;
  color: #f0c27f;
  line-height: 1.3;
  white-space: nowrap;
  text-align: center;
}

/* 对策区 Buff 值 */
.counter-row .buff-value {
  font-size: 10px;
  color: #8892b0;
  flex-shrink: 0;
  padding-left: 4px;
}
.counter-row .buff-value span {
  background: #2e3448;
  padding: 0 6px;
  border-radius: 3px;
}

/* 显示更多按钮 */
.btn-show-more {
  background: transparent;
  border: 1px solid #3a4055;
  color: #8892b0;
  padding: 4px 16px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s;
  margin-top: 4px;
  align-self: flex-start;
}
.btn-show-more:hover {
  background: #2e3448;
  color: #e8edf5;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #1a1e2c;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: #4a526b;
  border-radius: 10px;
}

/* ===== 底部 TODO ===== */
.footer {
  border-top: 1px solid #2e3448;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footer-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #4a526b;
}
.todo-toggle {
  font-size: 13px;
  color: #8892b0;
  cursor: pointer;
  user-select: none;
}
.todo-toggle:hover {
  color: #b0b9d4;
}
.todo-toggle .toggle-arrow {
  display: inline-block;
  transition: 0.2s;
}
.todo-toggle .toggle-arrow.open {
  transform: rotate(90deg);
}
.todo-table {
  overflow-x: auto;
}
.todo-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: #b0b9d4;
}
.todo-table th,
.todo-table td {
  padding: 6px 12px;
  border: 1px solid #2e3448;
  text-align: left;
}
.todo-table th {
  background: #1a1e2c;
  color: #8892b0;
  font-weight: 500;
}
.todo-table td:first-child {
  width: 60px;
  text-align: center;
}
.todo-table tr:hover td {
  background: #1e2436;
}

/* ===== 历史记录滑出面板 ===== */
.history-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 998;
}
.history-overlay.open {
  display: block;
}

.history-panel {
  position: fixed;
  top: 0;
  right: -810px;
  width: 790px;
  height: 100%;
  background: #232837;
  z-index: 999;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}
.history-panel.open {
  right: 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid #3a4055;
  flex-shrink: 0;
}
.history-header h2 {
  font-size: 18px;
  color: #e8edf5;
}
.btn-close-history {
  background: none;
  border: none;
  color: #8892b0;
  font-size: 22px;
  cursor: pointer;
}
.btn-close-history:hover {
  color: #e8edf5;
}

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}
.history-body .empty-state {
  color: #4a526b;
  text-align: center;
  padding: 40px 0;
  font-size: 15px;
}

/* 筛选栏 */
.history-filter-bar {
  padding: 10px 18px;
  background: #1a1e2c;
  border-bottom: 1px solid #2e3448;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  flex-shrink: 0;
}

.history-filter-bar .history-type-tabs {
  display: flex;
  gap: 4px;
  background: #2e3448;
  border-radius: 20px;
  padding: 2px;
}
.history-filter-bar .history-type-tabs .type-tab {
  padding: 4px 14px;
  border-radius: 18px;
  font-size: 12px;
  color: #8892b0;
  cursor: pointer;
  transition: 0.2s;
}
.history-filter-bar .history-type-tabs .type-tab.active {
  background: #4a526b;
  color: #fff;
}
.history-filter-bar .history-type-tabs .type-tab:hover:not(.active) {
  color: #e8edf5;
}

.history-filter-bar .history-group-select select {
  background: #2e3448;
  color: #e8edf5;
  border: 1px solid #3a4055;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
}
.history-filter-bar .history-count {
  font-size: 12px;
  color: #4a526b;
  margin-left: auto;
}

/* 历史记录行 */
.history-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 8px 12px;
  background: #1a1f30;
  border-radius: 8px;
  margin-bottom: 6px;
  border-left: 3px solid #4a526b;
}

/* 左侧元数据：三行 */
.history-row .h-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 80px;
  flex-shrink: 0;
  gap: 2px;
}
.history-row .h-meta .h-group {
  color: #f0c27f;
  font-weight: 500;
  font-size: 14px;
}
.history-row .h-meta .h-buff {
  color: #b0b9d4;
  font-size: 13px;
}
.history-row .h-meta .h-date {
  color: #4a526b;
  font-size: 12px;
}

/* 中间队伍：攻左防右 */
.history-row .h-teams {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.history-row .h-teams .h-team-attack,
.history-row .h-teams .h-team-defense {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}
.history-row .h-teams .vs {
  color: #4a526b;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  padding: 0 6px;
}
.history-row .h-teams .h-mini-hero {
  width: 32px;
  height: 32px;
  background: #2e3448;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #3a4055;
  overflow: hidden;
}
.history-row .h-teams .h-mini-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-row .h-teams .h-mini-hero .fallback-id {
  font-size: 8px;
  font-weight: 600;
  color: #b0b9d4;
}
.history-row .h-teams .h-mini-hero img.error,
.history-row .h-teams .h-mini-hero img[src=""],
.history-row .h-teams .h-mini-hero img:not([src]) {
  display: none;
}
.history-row .h-teams .h-mini-hero img.error + .fallback-id,
.history-row .h-teams .h-mini-hero img[src=""] + .fallback-id,
.history-row .h-teams .h-mini-hero img:not([src]) + .fallback-id {
  display: flex;
}
.history-row .h-teams .h-mini-pet {
  width: 26px;
  height: 32px;
  background: #1e2436;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #3a4055;
  overflow: hidden;
}
.history-row .h-teams .h-mini-pet img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-row .h-teams .h-mini-pet .fallback-id {
  font-size: 7px;
  font-weight: 600;
  color: #8892b0;
}
.history-row .h-teams .h-mini-pet img.error,
.history-row .h-teams .h-mini-pet img[src=""],
.history-row .h-teams .h-mini-pet img:not([src]) {
  display: none;
}
.history-row .h-teams .h-mini-pet img.error + .fallback-id,
.history-row .h-teams .h-mini-pet img[src=""] + .fallback-id,
.history-row .h-teams .h-mini-pet img:not([src]) + .fallback-id {
  display: flex;
}

/* 胜率 */
.history-row .h-winrate {
  font-weight: 700;
  font-size: 14px;
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.history-row .h-winrate.win { color: #6fcf97; }
.history-row .h-winrate.lose { color: #f28b82; }

/* 分页 */
.history-pagination-container {
  padding: 10px 18px;
  border-top: 1px solid #2e3448;
  flex-shrink: 0;
}
.history-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.history-pagination .page-btn {
  background: #2e3448;
  border: none;
  color: #b0b9d4;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.2s;
}
.history-pagination .page-btn:hover:not(:disabled) {
  background: #4a526b;
  color: #fff;
}
.history-pagination .page-btn.active {
  background: #fc5c7d;
  color: #fff;
}
.history-pagination .page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.history-pagination .page-info {
  color: #4a526b;
  font-size: 12px;
  margin-left: 8px;
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .defense-side {
    min-width: 280px;
  }
  .hero-unit,
  .battle-pet {
    width: 52px;
    height: 52px;
  }
  .banner-compact {
    height: 52px;
    padding: 2px 6px;
    min-width: 30px;
  }
  .banner-compact span {
    font-size: 9px;
  }
  .mini-hero {
    width: 34px;
    height: 34px;
  }
  .mini-pet {
    width: 28px;
    height: 34px;
  }
  .mini-banner {
    height: 34px;
    padding: 0 4px;
  }
  .mini-banner span {
    font-size: 8px;
  }
}

@media (max-width: 800px) {
  .app {
    padding: 16px;
  }
  .main {
    flex-direction: column;
  }
  .left-panel {
    width: 100%;
    max-height: 160px;
    display: flex;
    flex-wrap: wrap;
    padding: 6px;
    gap: 4px;
    overflow-y: auto;
  }
  .left-panel .slot-item {
    padding: 5px 10px;
    border-left: none;
    border-bottom: 2px solid transparent;
    flex: 0 0 auto;
    font-size: 12px;
  }
  .left-panel .slot-item.active {
    border-left: none;
    border-bottom-color: #fc5c7d;
  }
  .left-panel .slot-item .badge {
    display: none;
  }
  .slot-panel {
    flex-direction: column;
  }
  .defense-side {
    border-right: none;
    border-bottom: 1px solid #2e3448;
    padding-bottom: 10px;
    min-width: unset;
  }
  .defense-side .full-row {
    flex-wrap: wrap;
    gap: 2px;
  }
  .right-panel {
    max-height: none;
    padding: 14px 16px;
  }
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .header-center {
    flex-wrap: wrap;
  }
  .header-right {
    margin-left: 0;
    justify-content: flex-start;
  }
  .history-panel {
    width: 100%;
    right: -100%;
  }
  .history-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .history-row .h-meta {
    min-width: 100px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 12px;
  }
  .history-row .h-teams {
    flex-wrap: wrap;
  }
  .history-row .h-winrate {
    text-align: left;
    min-width: auto;
  }
  .history-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .history-filter-bar .history-count {
    margin-left: 0;
  }
  .counter-row {
    flex-wrap: wrap;
    gap: 4px;
  }
  .counter-row .attack-full {
    flex-wrap: wrap;
    gap: 2px;
  }
}