.past-games { max-width: 900px; margin: auto; padding: 30px 0 48px; }
.history-detail .past-games { max-width: 1080px; }
.past-games h1 {
  margin: 0;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.past-games h2 { font-size: 19px; letter-spacing: -.025em; }
.past-empty { margin: 0; padding: 22px 0; color: var(--muted); font-size: 14px; }

.past-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 12px; }
.past-filters :is(select, .past-favorite-filter, .past-search) {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--ink);
}
.past-search { display: flex; align-items: center; flex: 1 1 250px; min-width: 0; padding: 3px; }
.past-search svg { width: 18px; height: 18px; flex: none; margin: 0 5px 0 8px; }
.past-search svg, .past-favorite svg, .past-favorite-filter svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.past-search input { min-width: 0; width: 100%; padding: 6px; border: 0; background: transparent; color: var(--ink); }
.past-search .button { min-height: 36px; padding: 4px 13px; }
.past-order select { font: inherit; font-size: 13px; padding: 0 9px; cursor: pointer; }
.past-favorite-filter { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; cursor: pointer; font-size: 13px; }
.past-favorite-filter input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.past-favorite-filter:has(input:focus-visible) { outline: 2px solid var(--lime); outline-offset: 3px; }
.past-favorite-filter:has(input:checked) { border-color: #f5d88766; color: #f5d887; }
.past-favorite-filter input:checked + svg { fill: currentColor; }
.past-favorite-filter svg { width: 16px; height: 16px; }
.past-favorite-form { display: inline-flex; flex: none; margin: 0; }
.past-favorite {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}
.past-favorite svg { width: 19px; height: 19px; }
.past-favorite:hover, .past-favorite[aria-pressed="true"] { color: #f5d887; background: #f5d88713; }
.past-favorite[aria-pressed="true"] svg { fill: currentColor; }

.past-game-list { display: grid; gap: 8px; }
.past-game-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding-inline-end: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}
.past-game-card:hover, .past-game-card:focus-within { border-color: var(--muted); }
.past-game-actions { display: flex; align-items: center; }
.past-remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.past-remove svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.past-remove:is(:hover, :focus-visible) { color: var(--red); background: #ff9a8d18; }
@media (hover: hover) and (pointer: fine) {
  .past-game-card:not(:hover) .past-remove:not(:focus-visible) { opacity: 0; }
}
.past-remove-dialog { width: min(420px, calc(100% - 32px)); }
.past-remove-dialog p { color: var(--muted); overflow-wrap: anywhere; }
.past-remove-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.past-remove-actions form { margin: 0; }
.past-remove-actions .past-remove-confirm { background: var(--red); border-color: var(--red); color: #291411; }
.past-game-link {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, .42fr) minmax(105px, .4fr);
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink);
}
.past-game-link:hover { color: var(--ink); }
.past-game-cover {
  display: grid;
  place-items: center;
  position: relative;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 7px;
  background: #c3b0ed17;
  color: var(--purple);
  font-size: 22px;
}
.past-game-cover img { position: absolute; inset: 0; object-fit: cover; }
.past-game-info, .past-game-result, .past-game-date { display: grid; min-width: 0; gap: 3px; }
.past-game-info strong { font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.past-game-players, .past-game-result, .past-game-date time {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.past-game-winner { color: var(--ink); }
.past-game-date { justify-items: end; text-align: right; }
.past-game-pill {
  width: max-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #c3b0ed20;
  color: #d5c7ee;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.past-game-pill-finished { background: #d1fa641a; color: var(--lime); }
.past-game-pill-closed { background: #ffc3971a; color: #ffc397; }
.past-game-next { justify-self: center; padding: 12px; }
.past-game-load-status { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.past-game-load-status:empty { display: none; }

.past-back { display: inline-flex; align-items: center; min-height: 30px; }
.past-detail-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 6px 0 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.past-detail-heading > div { flex: 1 1 205px; min-width: 0; }
.past-detail-cover { flex: none; object-fit: cover; border-radius: 8px; }
.past-detail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 9px; margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.past-detail-heading .button { min-height: 42px; padding: 8px 13px; }

.past-overview { display: grid; gap: 10px; }
.past-roster, .past-rules { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.past-section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 10px; }
.past-section-heading p { margin: 0; }
.past-winner { display: inline-flex; align-items: center; gap: 5px; color: var(--lime); font-size: 13px; font-weight: 700; }
.past-winner svg { width: 18px; height: 14px; fill: #f5d887; }
.past-players { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0 0; padding: 0; list-style: none; }
.past-players li {
  --avatar-color: #d1fa64;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 50px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.past-players li:nth-child(4n + 2) { --avatar-color: #99cafa; }
.past-players li:nth-child(4n + 3) { --avatar-color: #d2a6f3; }
.past-players li:nth-child(4n + 4) { --avatar-color: #f2b7a7; }
.past-avatar { position: relative; display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--avatar-color); color: #20211e; }
.past-avatar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.past-player-out .past-avatar { opacity: .6; }
.past-players strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.past-life-letters { display: flex; gap: 2px; margin-top: 3px; }
.past-life-letters span { display: grid; place-items: center; width: 10px; height: 13px; border-radius: 3px; background: #ffffff08; color: #aaa8a0; font: 700 9px 'Space Grotesk', sans-serif; opacity: .44; }
.past-life-letters .lost { background: #c3b0ed24; color: #e0cdfc; opacity: 1; }
.past-rules .summary-rules { display: flex; gap: 8px 18px; }
.past-rules .summary-rules > div { display: flex; align-items: baseline; gap: 5px; }
.past-rules .summary-rules dd { margin: 0; font-size: 13px; }

.past-highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(255px, 100%), 1fr)); gap: 12px; margin-top: 10px; }
.past-highlight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  border: 1px solid #d1fa6429;
  border-radius: 10px;
  background: #d1fa6408;
}
.past-highlight h2 { font: 650 12px/1.3 'DM Sans', sans-serif; letter-spacing: 0; color: var(--muted); }
.past-highlight p { margin: 3px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.past-highlight > span { color: var(--lime); white-space: nowrap; font: 700 20px/1.15 'Space Grotesk', sans-serif; }
.past-highlight small { font: 600 11px 'DM Sans', sans-serif; }

.past-rounds { margin-top: 17px; }
.past-rounds .game-statistics { margin: 6px 0 0; padding: 0; }
.past-rounds .statistics-scroll { margin: 0; border-radius: inherit; }
.past-rounds .statistics-scroll:focus-visible { outline-offset: 2px; }
.past-rounds .history-song button { flex: none; margin-top: 0; }
.past-rounds .history-song span { overflow-wrap: anywhere; }
.past-rounds th:first-child { position: sticky; left: 0; z-index: 1; min-width: 145px; background: var(--panel); }
.past-rounds :is(th, td) { padding: 8px 12px; }
.past-rounds .history-score { min-height: 32px; }
.past-rounds .history-player { bottom: 10px; z-index: 2; }
.past-rounds .history-player[hidden] { display: none; }
.history-detail .table-dialog::backdrop { background: #0a0912d4; }

.game-ai-review { margin: 24px 0; }
.game-ai-review [data-ai-review-status] { margin: 10px 0 0; }
.game-ai-review dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; font-size: 14px; }
.game-ai-review dt { color: var(--muted); }
.game-ai-review dd { margin: 0; }
.game-ai-review [data-ai-review-entries] p { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 730px) {
  .past-games { padding-block: 20px 36px; }
  .past-game-link { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px 8px; padding: 8px; }
  .past-game-cover { width: 40px; height: 40px; grid-row: 1 / span 2; align-self: start; }
  .past-game-cover img { width: 100%; height: 100%; }
  .past-game-info, .past-game-result { grid-column: 2; }
  .past-game-info strong { font-size: 14px; }
  .past-game-result { display: flex; flex-wrap: wrap; gap: 2px 8px; }
  .past-game-date { grid-column: 3; grid-row: 1 / span 2; }
  .past-game-date time { font-size: 11px; }
  .past-game-actions { flex-direction: column; }
  .past-game-actions :is(.past-favorite, .past-remove) { height: 38px; }
}
@media (max-width: 460px) {
  .past-search { flex-basis: 100%; }
  .past-game-link { grid-template-columns: 36px minmax(0, 1fr); }
  .past-game-cover { width: 36px; height: 36px; grid-row: 1 / span 3; }
  .past-game-date { display: flex; flex-wrap: wrap; grid-column: 2; grid-row: 3; align-items: center; gap: 3px 6px; text-align: left; }
  .past-game-card { padding-inline-end: 3px; }
  .past-highlight { padding-block: 7px; }
  .past-rounds :is(th, td) { padding-inline: 8px; }
}
