body {
  min-height: 100vh;
  margin: 0;
}

.recap-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 0 60px;
}

/* ---------------- Header ---------------- */

.recap-header {
  padding: 22px 28px 18px;
  position: relative;
  border-bottom: 1px solid var(--border-soft);
}
.back-btn {
  position: absolute;
  left: 28px;
  top: 24px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.back-btn:hover { border-color: var(--gold-dim); }
#downloadRecapBtn {
  left: auto;
  right: 28px;
  cursor: pointer;
}
.header-row { display: flex; align-items: center; justify-content: center; gap: 12px; }
.title-icon { display: flex; line-height: 0; }
.recap-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text);
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.25);
  text-align: center;
}

.recap-main { padding: 28px; display: flex; flex-direction: column; gap: 28px; }

/* ---------------- Stat tiles ---------------- */

.stat-tiles {
  display: grid;
  /* Fixed 5 equal columns, not auto-fit -- auto-fit's minmax(180px,1fr)
     meant that at a lot of realistic widths, only 4 tiles fit per row
     and the 5th got shoved onto its own row, stretched to the full
     container width by itself. There are always exactly 5 of these,
     so keep them on one row and let them get narrower together
     instead. See the 640px breakpoint below for phone-width screens. */
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.stat-tile {
  background: var(--panel-grad);
  box-shadow: var(--panel-sheen);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-tile .stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); }
.stat-tile .stat-value { font-size: 30px; font-weight: 800; color: var(--gold-bright); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-tile .stat-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

/* ---------------- Chart cards ---------------- */

/* Masonry via CSS multi-column layout instead of grid -- with a grid,
   uneven card heights (a tall box-whisker chart next to a short waffle)
   leave big empty gaps because every card in a row is boxed to the
   tallest row member. Columns let shorter cards below pack up tight
   against whatever's above them instead. */
.chart-grid {
  column-width: 420px;
  column-gap: 20px;
}
.chart-card {
  background: var(--panel-grad);
  box-shadow: var(--panel-sheen);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 22px;
  break-inside: avoid;
  margin-bottom: 20px;
  display: inline-block;
  width: 100%;
}
.chart-card h2 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text);
}
.chart-card.wide { column-span: all; }
.chart-note { margin: -10px 0 14px; font-size: 12px; color: var(--text-faint); line-height: 1.4; }
.chart-body { display: flex; flex-direction: column; gap: 10px; }
.chart-empty { font-size: 13px; color: var(--text-faint); padding: 12px 0; }

/* Horizontal bar rows (avg price / team spend) */
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row .bar-label {
  flex: none;
  width: 108px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar-track {
  flex: 1;
  height: 16px;
  background: var(--panel-alt);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-row .bar-fill {
  /* It's a <span> -- display:inline by default, which silently ignores
     any width set on it. That's why the numbers rendered correctly but
     no visible bar ever appeared. */
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}
.bar-row .bar-value {
  flex: none;
  width: 58px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Stacked position-mix bar per team */
.mix-row { display: flex; align-items: center; gap: 10px; }
.mix-row .mix-label {
  flex: none;
  width: 108px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mix-row .mix-track {
  flex: 1;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--panel-alt);
}
.mix-row .mix-seg { height: 100%; display: flex; align-items: center; justify-content: center; }
.mix-row .mix-seg + .mix-seg { border-left: 2px solid var(--panel); }
.mix-row .mix-seg-label { font-size: 10px; font-weight: 800; color: rgba(0, 0, 0, 0.65); text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.legend-item .legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------------- Trend chart (SVG) ---------------- */

/* No width:100% here on purpose -- the SVG's width/viewBox are set in JS
   to match the container's measured pixel width 1:1, so dots stay
   perfectly circular and the tooltip's cx/cy-based positioning lines up
   exactly. Forcing a CSS width would let the two disagree and stretch
   the marks. */
.trend-svg { height: 220px; display: block; }
.trend-axis-label { font-size: 10px; fill: var(--text-faint); }
.trend-gridline { stroke: var(--border-soft); stroke-width: 1; }
.trend-line { fill: none; stroke: var(--text-faint); stroke-width: 2; }
.trend-dot { stroke: var(--bg); stroke-width: 1; cursor: pointer; }
.trend-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-alt);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 5;
}
.trend-wrap { position: relative; }

/* ---------------- Advanced: position matrix ---------------- */

.matrix-wrap { overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.matrix-table th, .matrix-table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.matrix-table th { color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; font-size: 10.5px; }
.matrix-table td.team-name-cell { text-align: left; font-weight: 700; color: var(--text); }
.matrix-table td.matrix-cell { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.matrix-table td.matrix-cell.empty { color: var(--text-faint); }

/* ---------------- Advanced: box & whisker ---------------- */

.bw-svg { display: block; }
.bw-axis-label { font-size: 10px; fill: var(--text-faint); }
.bw-gridline { stroke: var(--border-soft); stroke-width: 1; }
.bw-whisker { stroke: var(--text-faint); stroke-width: 1.5; }
.bw-box { stroke-width: 1.5; fill-opacity: 0.28; }
.bw-median { stroke-width: 2; }
.bw-pos-label { font-size: 11px; font-weight: 700; fill: var(--text-dim); text-anchor: middle; }

/* ---------------- Spending Race ---------------- */

.race-svg { display: block; }
.race-axis-label { font-size: 10px; fill: var(--text-faint); }
.race-gridline { stroke: var(--border-soft); stroke-width: 1; }
.race-line { fill: none; stroke-width: 2; opacity: 0.9; }

/* ---------------- Draft Pace ---------------- */

.pace-svg { display: block; }
.pace-axis-label { font-size: 10px; fill: var(--text-faint); }
.pace-gridline { stroke: var(--border-soft); stroke-width: 1; }
.pace-bar { fill: rgba(212, 175, 55, 0.55); cursor: pointer; }
.pace-bar.long-break { fill: rgba(197, 61, 61, 0.75); }
.longest-breaks { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.longest-breaks .lb-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); }
.longest-breaks .lb-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dim); padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.longest-breaks .lb-row .lb-gap { font-weight: 800; color: var(--gold-bright); }

/* ---------------- Steals & Reaches ---------------- */

.value-list { display: flex; flex-direction: column; gap: 8px; }
.value-list-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); margin-top: 4px; }
.value-list-heading:first-child { margin-top: 0; }
.value-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  border: 1px solid var(--border-soft);
}
.value-row .vr-pos-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.value-row .vr-name { flex: 1; font-size: 13px; font-weight: 700; color: var(--text); }
.value-row .vr-team { font-size: 11.5px; color: var(--text-faint); margin-left: 6px; }
.value-row .vr-price { font-size: 14px; font-weight: 800; color: var(--gold-bright); }
.value-row.steal { border-color: rgba(76, 175, 80, 0.4); }
.value-row.reach { border-color: rgba(197, 61, 61, 0.4); }

/* ---------------- Roast ---------------- */

.roast-section {
  background: linear-gradient(155deg, #241414 0%, var(--panel) 60%);
  border: 1px solid rgba(197, 61, 61, 0.35);
  border-radius: var(--radius-lg);
  padding: 22px 24px 26px;
  box-shadow: 0 0 30px -12px rgba(197, 61, 61, 0.4);
}
.roast-heading {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #f2a541;
  text-align: center;
  margin-bottom: 18px;
  text-shadow: 0 0 14px rgba(242, 165, 65, 0.4);
}
.roast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.roast-card {
  background: var(--panel-alt-grad);
  box-shadow: var(--panel-sheen);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-dim);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.roast-card .roast-team-name { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.roast-card .roast-team-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.roast-card .roast-line { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-top: 6px; }
.roast-card .roast-line:first-of-type { margin-top: 0; }

@media (max-width: 640px) {
  .recap-main { padding: 18px; }
  .recap-title { font-size: 19px; }
  .back-btn { left: 16px; top: 18px; }
  #downloadRecapBtn { left: auto; right: 16px; top: 18px; }
  .recap-header { padding: 18px 16px 14px; }
  /* 5 equal columns get too narrow to read on a phone-width screen --
     2 columns (3 rows for 5 tiles) instead. */
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
}
