:root {
  color-scheme: light;
  --ink: #172234;
  --muted: #667085;
  --line: #e2e7ee;
  --paper: #ffffff;
  --wash: #f4f6f8;
  --brand: #326fd1;
  --brand-soft: #eaf1fc;
  --success: #17805c;
  --success-soft: #e8f6f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--wash); }
a { color: inherit; }
.history-shell { width: min(760px, 100%); margin: 0 auto; padding: 24px 18px 64px; }
.history-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; }
.history-brand { display: inline-flex; gap: 10px; align-items: center; text-decoration: none; font-weight: 750; }
.history-brand img { width: 34px; height: 34px; border-radius: 9px; }
.history-back { border: 0; background: transparent; color: var(--brand); text-decoration: none; font-weight: 650; }
.history-header { margin-bottom: 22px; }
.history-header h1 { margin: 0 0 7px; font-size: clamp(2rem, 8vw, 3.25rem); letter-spacing: -.045em; }
.history-header p { margin: 0; color: var(--muted); line-height: 1.55; }
.history-progress { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px rgb(23 34 52 / 5%); }
.history-progress__heading { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.history-progress__heading p { margin: 0 0 3px; color: var(--brand); font-size: .74rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.history-progress__heading h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.015em; }
.history-progress__metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.history-progress__metric { min-width: 0; padding: 17px 16px; }
.history-progress__metric + .history-progress__metric { border-left: 1px solid var(--line); }
.history-progress__metric strong, .history-progress__metric span { display: block; }
.history-progress__metric strong { overflow: hidden; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.history-progress__metric span { margin-top: 4px; color: var(--muted); font-size: .76rem; line-height: 1.25; }
.history-progress__trend { margin: 0; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--brand-soft); color: #294e85; font-size: .82rem; font-weight: 620; line-height: 1.4; }
.history-list, .history-items { display: grid; gap: 12px; }
.history-card { display: grid; grid-template-columns: 58px minmax(0, 1fr) minmax(108px, auto); gap: 16px; align-items: center; min-height: 92px; padding: 17px 18px; color: inherit; text-decoration: none; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px rgb(23 34 52 / 5%); transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
.history-card:hover { border-color: #bdcce2; box-shadow: 0 12px 30px rgb(23 34 52 / 8%); transform: translateY(-1px); }
.history-card:focus-visible { outline: 3px solid rgb(50 111 209 / 28%); outline-offset: 3px; border-color: var(--brand); }
.history-card__visual { position: relative; display: grid; place-items: center; width: 58px; height: 58px; flex: 0 0 auto; }
.history-card__visual--icon { border-radius: 16px; background: var(--brand-soft); }
.history-card__mode-icon { display: block; width: 33px; height: 33px; object-fit: contain; }
.history-card__visual--players { isolation: isolate; }
.history-card__avatars { display: flex; align-items: center; width: 56px; padding-left: 1px; }
.history-avatar { position: relative; display: grid; place-items: center; width: 35px; height: 35px; overflow: hidden; border: 3px solid var(--paper); border-radius: 50%; background: var(--brand); color: #fff; font-size: .66rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; box-shadow: 0 3px 9px rgb(23 34 52 / 14%); }
.history-avatar + .history-avatar { margin-left: -12px; }
.history-avatar--opponent { z-index: 1; background: #dce7f7; color: #274c7f; }
.history-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.history-card__mode-badge { position: absolute; right: -1px; bottom: -1px; z-index: 2; display: grid; place-items: center; width: 24px; height: 24px; border: 3px solid var(--paper); border-radius: 50%; background: var(--brand-soft); box-shadow: 0 2px 7px rgb(23 34 52 / 12%); }
.history-card__mode-badge .history-card__mode-icon { width: 14px; height: 14px; }
.history-card__copy, .history-card__copy strong, .history-card__meta, .history-card__result, .history-card__result small { display: block; }
.history-card__copy { min-width: 0; }
.history-card__copy strong { font-size: 1rem; line-height: 1.25; letter-spacing: -.012em; }
.history-card__meta { color: var(--muted); margin-top: 5px; font-size: .875rem; line-height: 1.4; overflow-wrap: anywhere; }
.history-card__result { max-width: 180px; text-align: right; font-size: 1.03rem; font-variant-numeric: tabular-nums; font-weight: 780; line-height: 1.2; }
.history-card__result small { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; font-weight: 580; line-height: 1.2; }
.history-card[data-outcome="won"] .history-card__result { color: var(--success); }
.history-card[data-outcome="won"] .history-card__result small { color: var(--muted); }
.history-card--ongoing { border-color: rgb(24 166 74 / 38%); box-shadow: 0 10px 28px rgb(24 166 74 / 9%); }
.history-card--ongoing .history-card__result { color: var(--success); }
.history-card--ongoing .history-card__result small { color: var(--muted); }
.history-state { padding: 46px 22px; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; color: var(--muted); }
.history-state strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: 6px; }
.history-pagination { display: grid; justify-items: center; gap: 8px; padding: 10px 0 0; }
.history-load-more { min-width: 180px; min-height: 48px; padding: 11px 20px; border: 1px solid #bfd0ea; border-radius: 14px; background: var(--paper); color: var(--brand); font: inherit; font-weight: 720; cursor: pointer; }
.history-load-more:hover { border-color: var(--brand); background: var(--brand-soft); }
.history-load-more:focus-visible { outline: 3px solid rgb(50 111 209 / 28%); outline-offset: 3px; }
.history-load-status { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.history-load-status--complete { padding-top: 7px; }
.result-hero { padding: 30px 24px; text-align: center; background: linear-gradient(145deg, #fff, #edf3fc); border: 1px solid var(--line); border-radius: 22px; }
.result-kicker { margin: 0 0 8px; color: var(--brand); text-transform: uppercase; letter-spacing: .1em; font-size: .76rem; font-weight: 800; }
.result-hero h1 { margin: 0; font-size: clamp(2rem, 10vw, 3.6rem); letter-spacing: -.05em; }
.result-hero p { margin: 9px 0 0; color: var(--muted); }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.result-stat { padding: 17px; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; }
.result-stat span { display: block; color: var(--muted); font-size: .82rem; margin-bottom: 5px; }
.result-stat strong { font-size: 1.08rem; }
.result-grid .result-stat:first-child:last-child { grid-column: 1 / -1; }
@media (max-width: 520px) {
  .history-shell { padding-top: 16px; }
  .history-list, .history-items { gap: 10px; }
  .history-progress__metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-progress__metric { padding: 15px 16px; }
  .history-progress__metric + .history-progress__metric { border-left: 0; }
  .history-progress__metric:nth-child(even) { border-left: 1px solid var(--line); }
  .history-progress__metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .history-card { grid-template-columns: 54px minmax(0, 1fr); gap: 13px; min-height: 104px; padding: 15px; }
  .history-card__visual { grid-row: 1 / span 2; width: 54px; height: 54px; }
  .history-card__copy { grid-column: 2; }
  .history-card__result { grid-column: 2; display: flex; gap: 8px; align-items: baseline; max-width: none; text-align: left; }
  .history-card__result small { margin-top: 0; }
  .result-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .history-card { transition: none; }
}
