.stats-layout {
  display: grid;
  gap: 1.25rem;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
}

.stats-layout > *,
.bot-breakdown-grid > * {
  min-width: 0;
}

.bot-profile-panel {
  border-color: rgba(95, 74, 254, 0.32);
  background:
    radial-gradient(circle at 92% 0%, rgba(95, 74, 254, 0.11), transparent 36%),
    var(--panel);
}

.bot-profile-status {
  max-width: 34rem;
  text-align: right;
}

.bot-profile-status.is-error {
  color: #ff9ca7;
}

.bot-profile-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}

.bot-profile-personality {
  display: grid;
  gap: 0.45rem;
  font-weight: 700;
}

.bot-profile-personality textarea {
  width: 100%;
  min-height: 11rem;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  padding: 0.8rem 0.9rem;
  color: var(--text);
  background: #19191b;
  font: inherit;
  line-height: 1.5;
}

.bot-profile-personality textarea:focus {
  border-color: var(--app-shell-primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(95, 74, 254, 0.16);
}

.bot-profile-personality textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.bot-profile-actions {
  display: flex;
  justify-content: flex-end;
}

.bot-profile-save {
  border: 1px solid var(--app-shell-primary);
  border-radius: 0.5rem;
  padding: 0.65rem 1.2rem;
  color: white;
  background: var(--app-shell-primary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.bot-profile-save:disabled {
  cursor: wait;
  opacity: 0.55;
}

.stats-chart-wrap {
  position: relative;
  min-height: 420px;
}

.stats-chart-wrap canvas {
  cursor: grab;
  touch-action: none;
}

.stats-chart-wrap canvas:active {
  cursor: grabbing;
}

.stats-chart-wrap canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.elo-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
}

.elo-chart-toolbar p {
  margin: 0;
}

.elo-chart-toolbar button {
  flex: 0 0 auto;
}

.elo-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  min-height: 1.75rem;
  margin-top: 0.8rem;
}

.elo-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.elo-chart-legend-item img {
  width: 1.6rem;
  height: 1.6rem;
  object-fit: contain;
}

.elo-chart-legend-marker {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
}

.stats-date-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.stats-date-range label {
  display: grid;
  gap: 0.3rem;
  min-width: 10rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-date-range input {
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.7rem;
  background: #19191b;
  color: var(--text);
  color-scheme: dark;
  font: inherit;
  letter-spacing: normal;
}

.stats-chart-wrap canvas {
  width: 100% !important;
  height: 420px !important;
}

.stats-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.stats-table-wrap:focus-visible {
  outline: 2px solid #a995ff;
  outline-offset: 3px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
}

.stats-table th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-table tbody tr:hover {
  background: rgba(95, 74, 254, 0.055);
}

.stats-rank {
  width: 3rem;
  color: var(--muted);
}

.stats-value,
.matchmaking-probability {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.stats-empty {
  padding: 2rem 1rem !important;
  color: var(--muted);
  text-align: center !important;
}

.bot-statistics-status {
  max-width: 32rem;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.bot-statistics-status.is-error {
  color: #ff9f9f;
}

.bot-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.bot-stat {
  min-width: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.65rem;
  background: #19191b;
}

.bot-stat dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bot-stat dd {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: clamp(1.15rem, 2.2vw, 1.65rem);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.bot-stat--featured dd,
.bot-stat--win dd {
  color: var(--win);
}

.bot-stat--loss dd {
  color: #ff9f9f;
}

.bot-stat--date {
  grid-column: span 2;
}

.bot-stat--date dd {
  font-size: 1rem;
}

.bot-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.bot-details-table {
  min-width: 34rem;
}

.bot-recent-table {
  min-width: 46rem;
}

.bot-character-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}

.bot-character-icon {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  image-rendering: pixelated;
}

.bot-result {
  display: inline-flex;
  min-width: 3.5rem;
  justify-content: center;
  border: 1px solid var(--panel-border);
  border-radius: 0.4rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bot-result--win {
  border-color: rgba(125, 255, 179, 0.45);
  color: var(--win);
  background: rgba(125, 255, 179, 0.08);
}

.bot-result--loss,
.bot-result--dnf {
  border-color: rgba(255, 159, 159, 0.45);
  color: #ff9f9f;
  background: rgba(255, 159, 159, 0.08);
}

.bot-result--unknown {
  color: var(--muted);
}

.bot-match-date {
  white-space: nowrap;
}

.matchmaking-picker {
  display: grid;
  gap: 0.5rem;
  max-width: 28rem;
}

.matchmaking-picker span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.matchmaking-picker select {
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  padding: 0.72rem 0.9rem;
  background: #19191b;
  color: var(--text);
  font: inherit;
}

.matchmaking-bot-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.matchmaking-bot-icon {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.45rem;
  background: rgba(8, 10, 18, 0.82);
  object-fit: contain;
  image-rendering: pixelated;
}

.matchmaking-bot-icon--fallback {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.character-popularity-list {
  display: grid;
  gap: 0.75rem;
}

.character-popularity-row {
  display: grid;
  grid-template-columns: 3rem minmax(10rem, 0.8fr) minmax(12rem, 2fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 0.65rem;
  background: #19191b;
}

.character-popularity-icon {
  width: 3rem;
  height: 3rem;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.character-popularity-copy {
  display: grid;
  gap: 0.15rem;
}

.character-popularity-copy span,
.character-popularity-record {
  color: var(--muted);
  font-size: 0.78rem;
}

.character-popularity-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.character-popularity-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--app-shell-primary), #9d89ff);
}

.character-popularity-record {
  min-width: 8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .elo-chart-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .bot-profile-panel .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .bot-profile-status {
    max-width: none;
    text-align: left;
  }

  #bot-statistics .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .bot-statistics-status {
    text-align: left;
  }

  .bot-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bot-stat--date {
    grid-column: 1 / -1;
  }

  .bot-breakdown-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-chart-wrap,
  .stats-chart-wrap canvas {
    min-height: 320px;
    height: 320px !important;
  }

  .character-popularity-row {
    grid-template-columns: 2.5rem minmax(0, 1fr) auto;
  }

  .character-popularity-icon {
    width: 2.5rem;
    height: 2.5rem;
  }

  .character-popularity-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .character-popularity-record {
    grid-column: 3;
    grid-row: 1;
  }
}

@media (max-width: 560px) {
  .stats-date-range,
  .stats-date-range label {
    width: 100%;
  }

  .stats-date-range {
    justify-content: stretch;
  }

  .stats-date-range label {
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .bot-stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .bot-stat--date {
    grid-column: auto;
  }
}
