.history-entry-card,
.history-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
  padding: 26px;
  border: 1px solid rgba(100, 126, 255, 0.32);
  border-radius: var(--radius-card);
  background: radial-gradient(circle at 88% 5%, rgba(100, 38, 255, 0.28), transparent 52%), var(--surface-gradient);
  box-shadow: var(--glow), inset 0 1px rgba(255, 255, 255, 0.07);
}

.history-entry-card h2,
.history-entry-card p,
.history-hero p { margin-bottom: 8px; }
.history-entry-card p,
.history-hero > p { max-width: 760px; color: var(--text-secondary); line-height: 1.55; }
.history-entry-card .button { flex: 0 0 auto; }
.history-hero { display: block; padding: 34px; }
.history-hero.compact h1 { max-width: 900px; font-size: clamp(34px, 6vw, 58px); }
.history-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 22px; }
.source-link { padding: 12px 14px; color: #a9bdff; font-weight: 700; }
.source-link:hover { color: white; }

.history-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.history-anchor-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.history-anchor-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.history-anchor-nav a,
.source-badge,
.status-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.history-anchor-nav a:hover { color: white; border-color: rgba(111, 134, 255, 0.48); }
.history-anchor-nav a.active { color: white; border-color: rgba(111, 134, 255, 0.55); background: rgba(69, 115, 255, 0.18); }
.history-toolbar { grid-template-columns: minmax(190px, 1fr) repeat(3, minmax(150px, 0.55fr)); }
.history-table td:nth-child(2) { text-align: left; }
.history-qualification { display: block; margin-top: 3px; color: var(--text-muted); }
.history-section { margin-top: 34px; }
.history-rating-season { margin-bottom: 12px; }
.panel-heading.bare { padding-inline: 0; border: 0; }
.history-tournament-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.history-tournament-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px; }
.history-overview-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); gap: 16px; }
.history-overview-grid .panel-heading a { color: #a9bdff; font-size: 12px; font-weight: 800; }
.history-tournament-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 10px;
  min-height: 170px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-gradient);
  transition: transform 160ms ease, border-color 160ms ease;
}
.history-tournament-card:hover { transform: translateY(-2px); border-color: rgba(111, 134, 255, 0.48); }
.history-tournament-card > strong { font-size: 18px; line-height: 1.25; }
.history-tournament-card > small { color: var(--text-muted); }
.history-tournament-card > span:last-child { color: var(--text-secondary); font-size: 12px; }
.history-card-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.history-card-top > span { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.status-badge.ongoing { color: #72e1c2; border-color: rgba(64, 209, 171, 0.3); background: rgba(64, 209, 171, 0.1); }
.history-hall { margin-top: 34px; }
.history-hall-list { display: grid; }
.history-hall-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 110px; gap: 14px; align-items: center; padding: 15px 22px; border-bottom: 1px solid var(--line); }
.history-hall-row:last-child { border: 0; }
.history-hall-row > div { display: grid; }
.history-hall-row small,
.history-hall-row span { color: var(--text-muted); font-size: 11px; }
.history-hall-row b { color: #a9bdff; font-size: 18px; }
.history-method-note { margin: 22px 4px 0; color: var(--text-muted); font-size: 12px; line-height: 1.55; }
.history-inline-metrics { display: flex; flex-wrap: wrap; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.history-inline-metrics span { color: var(--text-secondary); }
.history-inline-metrics strong { color: white; }
.history-club-links { display: grid; gap: 8px; padding: 18px 22px; }
.history-club-links a { display: grid; gap: 4px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.04); }
.history-club-links a:hover { background: rgba(69,115,255,0.1); }
.history-club-links small { color: var(--text-muted); }
.history-player-panel { margin-bottom: 24px; }
.history-detail-grid { grid-template-columns: minmax(0, 1fr); }
.history-detail-grid > .stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.history-side-list { display: grid; padding: 10px 20px 18px; }
.history-side-list > span { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-side-list > span:last-child { border: 0; }
.history-side-list small { color: var(--text-muted); }

.history-podium-section {
  margin: 30px 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface-gradient);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.055);
}

.history-podium-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.history-podium-heading h2 { margin: 0; }
.history-podium-heading > span {
  padding: 7px 10px;
  border: 1px solid rgba(255, 202, 56, 0.2);
  border-radius: 999px;
  color: #ffe19a;
  background: rgba(255, 202, 56, 0.09);
  font-size: 10px;
  font-weight: 600;
}

.history-podium {
  display: grid;
  grid-template-columns: 1fr 1.18fr 1fr;
  align-items: end;
  gap: 15px;
  max-width: 880px;
  margin: 42px auto 0;
}

.history-podium-card {
  --medal: #bec8e5;
  position: relative;
  isolation: isolate;
  display: flex;
  overflow: hidden;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 286px;
  padding: 24px 14px 26px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  text-align: center;
  background: var(--surface-gradient);
}

.history-podium-card::after {
  position: absolute;
  z-index: -1;
  right: 4px;
  bottom: -35px;
  content: attr(data-rank);
  color: var(--medal);
  opacity: 0.06;
  font-size: 170px;
  font-weight: 800;
  line-height: 1;
}

.history-podium-card.is-rank-1 {
  --medal: #ffca38;
  min-height: 324px;
  padding-top: 26px;
  border-color: rgba(255, 202, 56, 0.48);
  background: linear-gradient(180deg, rgba(96, 70, 12, 0.48), rgba(18, 22, 42, 0.96) 64%);
  box-shadow: 0 22px 55px rgba(255, 185, 34, 0.12);
}

.history-podium-card.is-rank-3 { --medal: #d89669; }
.history-podium-place {
  min-height: 16px;
  color: var(--medal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.history-podium-crown { position: absolute; top: 23px; left: 26px; color: var(--medal); }
.history-podium-avatar {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 25px 0 17px;
  border: 2px solid var(--medal);
  border-radius: 50%;
  outline: 6px solid rgba(255, 255, 255, 0.025);
  color: var(--text);
  background: radial-gradient(circle at 30% 24%, rgba(117, 127, 192, 0.75), rgba(23, 30, 61, 0.92) 68%);
  font-size: 30px;
  font-weight: 800;
}
.history-podium-avatar > img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.history-podium-card.is-rank-1 .history-podium-avatar {
  width: 104px;
  height: 104px;
  margin-top: 27px;
  background: radial-gradient(circle at 30% 24%, rgba(191, 150, 58, 0.84), rgba(49, 40, 37, 0.96) 68%);
  font-size: 36px;
}
.history-podium-card h3 { max-width: 100%; margin: 0 0 7px; overflow-wrap: anywhere; font-size: 20px; }
.history-podium-card h3 a { color: var(--text); }
.history-podium-card h3 a:hover { color: var(--medal); }
.history-podium-score { color: var(--medal); font-size: 35px; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.history-podium-score-label { margin-top: 1px; color: var(--text-muted); font-size: 10px; }
.history-podium-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 7px;
  margin-top: 15px;
}
.history-podium-facts > span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 5px;
  border: 1px solid color-mix(in srgb, var(--medal) 27%, transparent);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}
.history-podium-facts strong { color: var(--text); font-size: 12px; line-height: 1.15; }
.history-podium-facts small { color: var(--text-muted); font-size: 9px; line-height: 1.2; }
.history-podium-last-game { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 0; line-height: 1.25; }
.history-podium-last-game span { color: var(--text-muted); font-size: 10px; }
.history-podium-last-game strong { color: var(--text-secondary); font-size: 11px; font-weight: 600; }
.history-podium-note { margin: 20px 0 0; color: var(--text-muted); font-size: 11px; text-align: center; }
.history-podium-note span { margin-right: 5px; color: var(--green); }

/* Grid children must shrink before their text or scrollable tables can reflow. */
.history-overview-grid > *,
.history-detail-grid > *,
.history-hall-row > *,
.history-entry-card > *,
.history-side-list strong { min-width: 0; }
.history-tournament-card,
.history-hall-row,
.history-side-list,
.history-club-links,
.history-hero,
.history-entry-card { overflow-wrap: anywhere; }
.history-metrics .metric-card { min-width: 0; overflow-wrap: anywhere; }
.history-side-list > span { flex-wrap: wrap; }
.history-toolbar input,
.history-toolbar select { font-size: 16px; }

@media (max-width: 850px) {
  .history-entry-card { align-items: flex-start; flex-direction: column; }
  .history-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-tournament-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-detail-grid,
  .history-detail-grid > .stack,
  .history-overview-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .history-hero { padding: 24px 20px; }
  .history-hero h1 { font-size: clamp(28px, 8vw, 42px); }
  .history-toolbar,
  .history-tournament-grid,
  .history-tournament-grid.compact { grid-template-columns: minmax(0, 1fr); }
  .history-tournament-grid.compact { padding: 14px; }
  .history-tournament-card { min-height: 0; padding: 16px; }
  .history-hall-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; }
  .history-hall-row > div:first-child { grid-column: 1 / -1; gap: 6px; }
  .history-metrics .metric-card { padding: 14px; }
  .history-overview-grid .panel-heading { gap: 12px; padding: 20px 16px; }
  .history-overview-grid .panel-heading a { display: inline-flex; align-items: center; min-height: 44px; }
  .history-entry-card .button { width: 100%; text-align: center; }
  .history-podium-section { padding: 20px 14px; }
  .history-podium-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .history-podium { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 30px; }
  .history-podium-card { min-height: 220px; padding: 18px 6px; border-radius: 17px; }
  .history-podium-card.is-rank-1 { min-height: 250px; }
  .history-podium-crown { display: none; }
  .history-podium-place { font-size: 8px; letter-spacing: 0.03em; }
  .history-podium-avatar,
  .history-podium-card.is-rank-1 .history-podium-avatar { width: 57px; height: 57px; margin: 20px 0 14px; outline-width: 3px; font-size: 21px; }
  .history-podium-card.is-rank-1 .history-podium-avatar { width: 69px; height: 69px; font-size: 25px; }
  .history-podium-card h3 { font-size: 14px; }
  .history-podium-score { font-size: 25px; }
  .history-podium-facts { grid-template-columns: 1fr; gap: 4px; margin-top: 9px; }
  .history-podium-facts > span { gap: 1px; padding: 5px 2px; }
  .history-podium-facts strong { font-size: 10px; }
  .history-podium-facts small { font-size: 8px; }
  .history-podium-last-game { margin-top: 7px; }
  .history-podium-last-game span { font-size: 8px; }
  .history-podium-last-game strong { font-size: 9px; }
}

.rating-hierarchy-table .identity { gap:10px; }
.rating-hierarchy-table .identity .avatar { flex:0 0 38px; }
