/* === Commander Detail Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 860px;
  width: 100%;
  padding: 2rem;
  position: relative;
  animation: fadeUp 0.25s ease both;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.modal-header {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-art {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.modal-name {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.modal-faction {
  display: inline-block;
  margin-bottom: 0.5rem;
}

.modal-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-body {
  padding-top: 0;
}

.modal-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}

.modal-chart-wide {
  margin-bottom: 1.5rem;
}

.modal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.modal-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
}

.modal-kpi-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-kpi-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.25rem;
}

.modal-top-cards-wrapper {
  margin-top: 0.25rem;
}

.modal-top-cards-table td:nth-child(2),
.modal-top-cards-table td:nth-child(3),
.modal-top-cards-table td:nth-child(4),
.modal-top-cards-table th:nth-child(2),
.modal-top-cards-table th:nth-child(3),
.modal-top-cards-table th:nth-child(4) {
  text-align: right;
}

/* Clickable chart bars */
.chart-container canvas.clickable {
  cursor: pointer;
}

/* === Matchup Detail Modal === */

.matchup-modal-content {
  max-width: 720px;
}

.matchup-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.matchup-modal-commander {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
}

.matchup-modal-art {
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-elevated);
  margin-bottom: 0.5rem;
}

.matchup-modal-cmd-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.matchup-modal-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.matchup-modal-vs-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Stats section */
.matchup-modal-stats {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
}

/* Card lists */
.matchup-modal-cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.matchup-cards-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.matchup-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--bg-elevated);
  gap: 0.5rem;
}

.matchup-card-name {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.matchup-card-stats {
  display: flex;
  gap: 0.625rem;
  align-items: baseline;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Card list column headers */
.matchup-card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  margin-bottom: 0.125rem;
}

.matchup-card-header .matchup-card-stats {
  font-weight: 400;
}

.matchup-col-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.matchup-card-stats > span {
  min-width: 3.5rem;
  text-align: right;
}

.matchup-card-games {
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 400;
  min-width: 2.5rem !important;
  text-align: right;
}

/* First-turn table */
.ft-table {
  width: 100%;
  font-size: 0.8125rem;
  border-collapse: collapse;
}

.ft-table th {
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
}

.ft-table th:first-child {
  text-align: left;
}

.ft-table td {
  text-align: center;
  padding: 0.375rem 0.5rem;
  color: var(--text);
}

.ft-label {
  text-align: left !important;
  font-weight: 500;
  color: var(--text-secondary);
}

.ft-games {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-muted);
}

.ft-headline-row td {
  padding-top: 0.5rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}

.ft-headline {
  font-size: 1.375rem;
  font-weight: 700;
}

.ft-wr-high { color: #3fb950; }
.ft-wr-low { color: #f0834a; }
.ft-wr-even { color: var(--text); }

.ft-total {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.625rem;
}

.matchup-wr-high { color: var(--positive); }
.matchup-wr-low { color: #f0834a; }
.matchup-wr-even { color: var(--text); }

.matchup-cards-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

/* Heatmap cell hover outline for clickable cells */
.matchup-cell[data-type="data"]:hover {
  outline: 2px solid #58a6ff;
  outline-offset: -2px;
}

/* === Modal Filter Bar === */
.modal-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  padding: 0.625rem 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* === Modal-open state === */
body.modal-open .time-filter-bar {
  pointer-events: none;
}
