* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(255, 122, 69, 0.06), transparent),
    radial-gradient(900px 500px at 110% 110%, rgba(127, 184, 240, 0.04), transparent);
  background-attachment: fixed;
  color: var(--text);
  font: var(--fs-body) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

canvas { display: block; }

h1, h2, h3, .pixel-title {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
}

h1 {
  font-size: var(--fs-hero);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

h2 {
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

h3, .pixel-title {
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

a {
  color: var(--steel);
  text-decoration: none;
}

a:hover { color: color-mix(in srgb, var(--steel) 84%, white); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 36px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font: 600 var(--fs-sm) / 1 var(--font);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
  transition-duration: 0.06s;
}

.btn.primary {
  background: var(--gold);
  color: #1a1408;
  border-color: transparent;
}

.btn.primary:hover { background: color-mix(in srgb, var(--gold) 88%, white); }

.btn.danger {
  background: rgba(255, 90, 82, 0.08);
  color: var(--bad);
  border-color: rgba(255, 90, 82, 0.4);
}

.btn.danger:hover {
  background: rgba(255, 90, 82, 0.14);
  border-color: rgba(255, 90, 82, 0.58);
  color: color-mix(in srgb, var(--bad) 82%, white);
}

.btn.good {
  background: var(--good);
  color: #08130d;
  border-color: transparent;
}

.btn.good:hover { background: color-mix(in srgb, var(--good) 88%, white); }

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

select, input {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  padding: 8px 12px;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

select:hover, input:hover { border-color: rgba(227, 183, 101, 0.32); }

select:focus, input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(227, 183, 101, 0.16);
  outline: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--text-3);
  font-size: var(--fs-cap);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.me { background: rgba(227, 183, 101, 0.07); }

tr.clickable { cursor: pointer; }

tr.clickable:hover { background: var(--surface-2); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.card .meta {
  flex: 1;
  min-width: 0;
}

.card .name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card .sub {
  color: var(--text-2);
  font-size: var(--fs-cap);
}

.card.injured {
  border-color: rgba(255, 90, 82, 0.38);
  background: rgba(255, 90, 82, 0.06);
  opacity: 0.9;
}

.attr {
  display: grid;
  grid-template-columns: 86px 1fr 30px;
  gap: 6px;
  align-items: center;
  margin: 2px 0;
  font-size: var(--fs-cap);
}

.attr .track {
  height: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: var(--r-pill);
}

.attr .fill {
  height: 100%;
  border-radius: inherit;
}

.stars { color: var(--gold); letter-spacing: 1px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal {
  width: 100%;
  max-width: 660px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.modal h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Match-result rows in the round / tick result modals.
   Deliberately NOT .event — that class carries the match-page timeline
   grid (58px 28px 1fr), which crushes the team/score into the 28px column. */
.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.result-row + .result-row {
  margin-top: 8px;
}

.result-row:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.result-row.mine {
  background: color-mix(in srgb, var(--good) 12%, transparent);
  border-color: color-mix(in srgb, var(--good) 28%, transparent);
}

.result-row .icon {
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.03);
}

.result-row .teams {
  flex: 1 1 auto;
  min-width: 0;
}

.result-row .result-watch {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 2px;
  padding: 1px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-2);
  font-size: var(--fs-cap);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.muted { color: var(--text-2); }

.right { text-align: right; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: var(--fs-cap);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag.good {
  color: var(--good);
  border-color: rgba(67, 209, 124, 0.38);
}

.tag.bad {
  color: var(--bad);
  border-color: rgba(255, 90, 82, 0.4);
}

.tag.warn {
  color: var(--gold);
  border-color: rgba(227, 183, 101, 0.4);
}

.form-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.form-pip.W { background: var(--good); color: #08130d; }

.form-pip.D { background: rgba(245, 245, 247, 0.2); color: var(--text); }

.form-pip.L { background: var(--bad); color: #170808; }

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.03);
  width: fit-content;
}

.tabbar button {
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font: 600 var(--fs-cap) / 1 var(--font);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tabbar button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transform: translateY(-1px);
}

.tabbar button.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  min-width: min(92vw, 320px);
  padding: 12px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--glass);
  color: var(--text);
  box-shadow: var(--shadow-2);
  transform: translateX(-50%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: toast-in 0.24s ease-out;
}

.empty {
  padding: 40px;
  color: var(--text-2);
  text-align: center;
}

@media (max-width: 860px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

.stat-tip { cursor: help; }

.stat-tip { position: relative; }

.stat-tip > abbr, .stat-tip {
  text-decoration: underline dotted rgba(245, 245, 247, 0.34);
  text-underline-offset: 3px;
}

.stat-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 80;
  width: 290px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--glass);
  color: var(--text);
  box-shadow: var(--shadow-2);
  transform: translateX(-50%);
  white-space: pre-line;
  font-size: var(--fs-cap);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  pointer-events: none;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

th.stat-tip:hover::after {
  left: auto;
  right: 0;
  transform: none;
}

td.stat-tip:hover::after {
  left: auto;
  right: 0;
  width: 210px;
  transform: none;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid transparent;
  border-radius: var(--r-pill);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
