.games-history-page {
  padding-bottom: 8px;
}

.games-history-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 24px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.games-history-nav a {
  min-width: 0;
  padding: 11px 14px;
  border-left: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: center;
  text-decoration: none;
}

.games-history-nav a:first-child {
  border-left: 0;
}

.games-history-nav a:hover,
.games-history-nav a:focus-visible {
  background: var(--accent-soft);
  color: var(--ink);
}

.games-history-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.game-history-status {
  min-height: 92px;
  margin-top: 24px;
  padding: 22px 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
}

.game-history-status.is-error {
  min-height: 0;
  border-color: color-mix(in srgb, var(--miss) 55%, var(--line));
  background: color-mix(in srgb, var(--miss) 7%, var(--surface));
  color: var(--miss);
}

.game-history-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-top: 24px;
  padding: 26px 24px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.game-history-empty h2,
.game-history-empty p,
.history-notice h2,
.history-notice p {
  margin: 0;
}

.game-history-empty h2,
.history-notice h2 {
  font-size: 17px;
  line-height: 1.45;
}

.game-history-empty > p:not(.history-label),
.history-notice > div > p:not(.history-label):not(.history-action-status) {
  color: var(--ink-2);
  font-size: 13.5px;
}

.game-history-empty .t-btn {
  margin-top: 8px;
  text-decoration: none;
}

.game-history-stack {
  display: grid;
  min-width: 0;
  gap: 0;
}

.history-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 24px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.history-metric {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 15px 16px 14px;
  border-left: 1px solid var(--line);
}

.history-metric:first-child {
  border-left: 0;
}

.history-metric span,
.history-label {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.history-label span {
  color: var(--accent);
}

.history-metric strong {
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.history-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.history-notice > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-action-buttons .t-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
  white-space: nowrap;
}

.history-action-status {
  min-height: 1.35em;
  color: var(--ink-3);
  font-size: 12px;
}

.history-action-status.is-error {
  color: var(--miss);
}

.history-section {
  min-width: 0;
  margin-top: 42px;
}

.history-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.history-section-header::after {
  content: "";
  order: 1;
  flex: 1;
  height: 7px;
  transform: translateY(3px);
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.history-section-header h2 {
  flex: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.history-section-header .t-btn {
  order: 2;
  flex: none;
  min-height: 0;
  color: var(--ink);
  text-decoration: none;
}

.history-calendar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.history-calendar li,
.history-scale i {
  border: 1px solid var(--line);
  background: var(--surface);
}

.history-calendar li {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  aspect-ratio: 1;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.history-calendar li[data-level="1"],
.history-scale i[data-level="1"] {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--ink);
}

.history-calendar li[data-level="2"],
.history-scale i[data-level="2"] {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: color-mix(in srgb, var(--accent) 35%, var(--surface));
  color: var(--ink);
}

.history-calendar li[data-level="3"],
.history-scale i[data-level="3"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.history-scale {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.history-scale i {
  display: block;
  width: 11px;
  height: 11px;
}

.history-list {
  display: grid;
  margin-top: 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.history-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
}

.history-list-row:first-child {
  border-top: 0;
}

a.history-list-row {
  color: inherit;
  text-decoration: none;
}

a.history-list-row:hover,
a.history-list-row:focus-visible {
  background: var(--accent-soft);
}

a.history-list-row:hover .history-list-title,
a.history-list-row:focus-visible .history-list-title {
  color: var(--accent);
}

.history-list-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.history-list-title {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
}

.history-list-meta {
  color: var(--ink-3);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.history-list-value {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-list-empty,
.history-table-empty {
  padding: 22px 16px;
  color: var(--ink-3);
  font-size: 13px;
}

.history-table-wrap {
  margin-top: 18px;
}

.history-table {
  min-width: 580px;
}

.history-table th:nth-child(n + 2),
.history-table td:nth-child(n + 2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-table-empty {
  background: var(--surface);
}

@media (max-width: 640px) {
  .history-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-metric:nth-child(odd) {
    border-left: 0;
  }

  .history-metric:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .history-notice {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .history-action-buttons .t-btn {
    flex: 1;
  }

  .history-calendar {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .history-calendar li {
    min-height: 38px;
    aspect-ratio: auto;
  }

  .history-section-header {
    flex-wrap: wrap;
  }

  .history-section-header .t-btn {
    margin-left: auto;
  }

  .history-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 12px;
  }

  .history-table th,
  .history-table td {
    padding: 9px 6px;
  }

  .history-table th:first-child,
  .history-table td:first-child {
    width: 26%;
    overflow-wrap: anywhere;
  }

  .history-table th:nth-child(2),
  .history-table td:nth-child(2) {
    width: 18%;
  }

  .history-table th:nth-child(3),
  .history-table td:nth-child(3) {
    width: 36%;
  }

  .history-table th:nth-child(4),
  .history-table td:nth-child(4) {
    width: 20%;
  }
}

@media (max-width: 420px) {
  .games-history-nav a {
    padding-inline: 9px;
    font-size: 12.5px;
  }

  .game-history-empty {
    padding: 22px 18px;
  }

  .history-metric {
    padding-inline: 13px;
  }

  .history-calendar {
    gap: 4px;
  }

  .history-calendar li {
    min-height: 34px;
  }

  .history-list-row {
    gap: 10px;
    padding-inline: 13px;
  }
}
