/* styles.css v2.1 (Single Column Layout) */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  color: #111;
  background-color: #f4f6f8;
}

/* --- 頁首與導航 --- */
.top-nav {
  background: #333;
  color: #fff;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: bold;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sync {
  background: #007bff;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-sync:hover { background: #0056b3; }

.page-head {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.controls {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 15px;
}

.badge {
  background: #e9ecef;
  color: #495057;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}
.badge.info { background: #e3f2fd; color: #0d47a1; }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  background: #fff;
  border: 1px solid #ced4da;
  color: #495057;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn:hover { background: #f8f9fa; }
.tab-btn.active {
  background: #343a40;
  color: #fff;
  border-color: #343a40;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* --- 主內容區 --- */
main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 15px;
  margin-bottom: 20px;
  overflow: hidden;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 18px;
  color: #333;
  border-left: 4px solid #007bff;
  padding-left: 10px;
}

.hint {
  color: #6c757d;
  font-size: 0.9em;
  margin-bottom: 10px;
}

.err { color: #dc3545; border-left-color: #dc3545; }

/* --- [B5] Sticky Table (固定首欄/首列) --- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #eee;
  border-radius: 4px;
}

.sticky-table {
  max-height: 80vh;
  position: relative;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.table th, .table td {
  padding: 10px;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
  text-align: center;
  white-space: nowrap;
}

/* Sticky Header */
.sticky-table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #f8f9fa;
  border-bottom: 2px solid #ddd;
}

/* Sticky First Column */
.sticky-table tbody th, 
.sticky-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background-color: #fff;
  border-right: 2px solid #ddd;
  font-weight: 600;
  color: #333;
}

/* 左上角重疊處 */
.sticky-table thead th:first-child {
  z-index: 30;
  left: 0;
  background-color: #f8f9fa;
  border-right: 2px solid #ddd;
}

/* --- [Modified] Flexbox Scoreboard (單排模式) --- */
.grid-matchups {
  display: grid;
  /* [修改] 改為 1fr 強制單欄，不並排 */
  grid-template-columns: 1fr;
  gap: 15px;
}

.matchup-row {
  display: flex;
  align-items: stretch;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.team-block {
  flex: 0 0 120px; /* [微調] 稍微加寬隊名區塊 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 5px;
  background: #f8f9fa;
  text-align: center;
  font-size: 14px;
}

.team-block.winner {
  background: #e3f2fd;
  font-weight: bold;
  color: #007bff;
}

.team-block .total-score {
  font-size: 24px; /* [微調] 分數放大 */
  font-weight: bold;
  margin-top: 5px;
}

.stats-block {
  flex: 1;
  display: flex;
  /* 仍保留 auto 以防手機版炸裂，但電腦版會因為 width 夠寬而不出現卷軸 */
  overflow-x: auto; 
  border-left: 1px solid #eee;
  border-right: 1px solid #eee;
}

.stat-col {
  /* [修改] flex: 1 讓它自動伸展填滿剩餘空間，min-width 保持最小可讀性 */
  flex: 1 0 50px; 
  display: flex;
  flex-direction: column;
  border-right: 1px solid #f0f0f0;
}

.stat-header {
  background: #fafafa;
  font-size: 11px;
  color: #888;
  text-align: center;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

.stat-val {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px; /* [微調] 字體加大好閱讀 */
  padding: 6px 0;
}
.stat-val:first-of-type { border-bottom: 1px dashed #eee; }

.win-bg {
  background-color: #d4edda;
  color: #155724;
  font-weight: bold;
}

/* --- Stats Table Enhancements --- */
.sort-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sort-trigger:hover { color: #007bff; }
.sort-asc::after { content: '▲'; font-size: 0.8em; }
.sort-desc::after { content: '▼'; font-size: 0.8em; }

/* Z-Score Colors */
.win-text { color: #28a745; }
.lose-text { color: #dc3545; }

/* Heatmap Colors */
.heat-1 { background: #ffebee; color: #c62828; }
.heat-2 { background: #ffccbc; }
.heat-3 { background: #fff9c4; }
.heat-4 { background: #dcedc8; }
.heat-5 { background: #c8e6c9; color: #2e7d32; font-weight:bold; }

/* --- [A1] Schedule Styles --- */
.loading-state {
  text-align: center;
  padding: 40px;
  color: #666;
  font-style: italic;
}

/* --- [B4] Radar Chart Styles --- */
.radar-grid {
  margin-bottom: 20px;
}

/* --- [Waiver] Ranks Badges --- */
.rank-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.8em;
  margin-right: 4px;
}

/* Streak Box for History */
.streak-box {
  border: 2px solid;
  border-radius: 4px;
  padding: 2px 6px;
}
.streak-box.win { border-color: #28a745; color: #28a745; }
.streak-box.lose { border-color: #dc3545; color: #dc3545; }
.streak-box.tie { border-color: #6c757d; color: #6c757d; }

/* Pill styles */
.pill { padding: 2px 8px; border-radius: 12px; font-size: 12px; display: inline-block; }
.pill.win { background: #d4edda; color: #155724; }
.pill.lose { background: #f8d7da; color: #721c24; }
.pill.tie { background: #e2e3e5; color: #383d41; }