:root {
  color-scheme: light;
  --background: #f4f5f9;
  --surface: #fff;
  --text: #18213a;
  --secondary: #54617d;
  --border: #e1e5ef;
  --accent: #374bcc;
  --accent-soft: #edf0ff;
  --accent-text: #263bbd;
  --green: #146344;
  --green-soft: #e4f5ed;
  --header: #192441;
  --header-text: #ecf0ff;
  --focus: #5369ec;
  --radius: 16px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #111725;
  --surface: #1a2234;
  --text: #f2f4fb;
  --secondary: #adb8d0;
  --border: #303b55;
  --accent: #8999ff;
  --accent-soft: #293456;
  --accent-text: #c3ccff;
  --green: #a2e7c6;
  --green-soft: #1b423a;
  --header: #17213c;
  --focus: #a6b2ff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 0;
  background: var(--background);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.5;
}

button, select { font: inherit; }
button, select, summary, a { -webkit-tap-highlight-color: transparent; }
button, summary { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }

.shell {
  width: min(1040px, 100%);
  margin-inline: auto;
  padding-inline: clamp(16px, 5vw, 52px);
}

.masthead { background: var(--header); color: var(--header-text); }
.masthead-inner {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: env(safe-area-inset-top, 0px);
}
.brand { display: inline-flex; gap: 9px; align-items: center; font-weight: 700; white-space: nowrap; }
.brand-mark {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 8px;
  background: #7283ff;
  color: #111936;
  font-weight: 800;
}
.updated { color: #c9d3ef; font-size: .75rem; text-align: right; }

main.shell { padding-block: clamp(24px, 5vw, 48px) max(32px, env(safe-area-inset-bottom, 0px)); }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
h1 { font-size: clamp(1.75rem, 6vw, 2.85rem); letter-spacing: -.05em; line-height: 1.09; }
.intro p { margin-top: 7px; color: var(--secondary); }
.refresh {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent-text);
  font-size: .8125rem;
  font-weight: 700;
}
.refresh:hover:not(:disabled) { background: var(--accent-soft); }

.notice, .panel, .metric, .game-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.notice { margin-bottom: 16px; padding: 14px 16px; }
.notice strong { font-size: .9375rem; }
.notice p { color: var(--secondary); font-size: .875rem; }
.notice p:not(:empty) { margin-top: 3px; }
.bot-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; color: var(--accent-text); font-weight: 700; }

.filters {
  display: flex;
  justify-content: space-between;
  gap: 10px 16px;
  align-items: end;
  margin-bottom: 18px;
}
.game-filter { display: grid; flex: 1; gap: 4px; max-width: 260px; }
.game-filter > span, .range-filter legend { color: var(--secondary); font-weight: 650; font-size: .75rem; }
select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface);
  font-size: .8125rem;
  font-weight: 650;
}
.range-filter { padding: 0; margin: 0; min-width: 0; border: 0; }
.range-filter legend { margin-bottom: 4px; padding: 0; }
.segments {
  display: flex;
  gap: 2px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  white-space: nowrap;
}
.segments label { position: relative; cursor: pointer; }
.segments input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.segments label span {
  display: grid;
  min-width: 50px;
  min-height: 44px;
  place-items: center;
  padding-inline: 6px;
  border-radius: 8px;
  color: var(--secondary);
  font-size: .8125rem;
  font-weight: 700;
}
.segments input:checked + span { background: var(--accent-soft); color: var(--accent-text); }
.segments input:focus-visible + span { outline: 2px solid var(--focus); }

.report-range, .report-note { color: var(--secondary); font-size: .8125rem; }
.report-range { margin: -3px 0 10px; font-weight: 650; }
.report-note { margin: -4px 0 16px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.metric { display: flex; flex-direction: column; padding: 12px 14px; }
.metric.primary { background: var(--accent-soft); border-color: transparent; }
.metric-label { color: var(--secondary); font-size: .75rem; font-weight: 650; }
.metric-value {
  margin-top: auto;
  padding-top: 5px;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 750;
  line-height: 1.17;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
}
.metric.primary .metric-value { color: var(--accent-text); }
.metric-value.unavailable { font-size: .95rem; font-weight: 650; color: var(--secondary); letter-spacing: 0; }

.panel { padding: clamp(13px, 3vw, 24px); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h2 { font-size: clamp(1.1rem, 3.3vw, 1.32rem); line-height: 1.2; letter-spacing: -.028em; }
.section-head p { margin-top: 3px; color: var(--secondary); font-size: .75rem; }
.chart-control { width: min(45%, 170px); }
.chart-empty { padding: 25px 0 10px; text-align: center; color: var(--secondary); font-size: .875rem; }
.chart {
  --columns: 7;
  --chart-height: clamp(108px, 27vw, 172px);
  margin: 24px 0 5px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 9px;
}
.chart-axis {
  display: flex;
  height: var(--chart-height);
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  color: var(--secondary);
  font-size: .65rem;
  line-height: 1;
}
.chart-bars {
  height: var(--chart-height);
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  align-items: end;
  justify-items: center;
  background:
    linear-gradient(var(--border), var(--border)) center top / 100% 1px no-repeat,
    linear-gradient(var(--border), var(--border)) center center / 100% 1px no-repeat,
    linear-gradient(var(--border), var(--border)) center bottom / 100% 1px no-repeat;
}
.chart-bar { display: block; width: 67%; max-width: 50px; min-width: 1px; border-radius: 4px 4px 0 0; background: var(--accent); }
.chart-bar[data-zero] { opacity: .22; }
.chart-dates {
  display: flex;
  grid-column: 2;
  justify-content: space-between;
  color: var(--secondary);
  font-size: .65rem;
  white-space: nowrap;
}
.chart-data { margin-top: 10px; color: var(--secondary); font-size: .8125rem; }
.chart-data summary { display: list-item; width: fit-content; padding-block: 7px; color: var(--accent-text); font-weight: 700; }
.chart-data table { width: 100%; margin-top: 6px; border-collapse: collapse; }
.chart-data th { color: var(--text); }
.chart-data th, .chart-data td { text-align: left; border-bottom: 1px solid var(--border); padding: 6px; }
.chart-data th:last-child, .chart-data td:last-child { text-align: right; }

.games-section { margin-top: 24px; }
.game-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.game-card { padding: 14px; }
.game-heading { display: flex; align-items: start; justify-content: space-between; gap: 7px; }
h3 { font-size: 1rem; line-height: 1.3; }
.platform { margin-top: 1px; color: var(--secondary); font-size: .75rem; }
.game-status {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--secondary);
  background: var(--background);
  font-size: .6875rem;
  font-weight: 700;
}
.game-status.live { color: var(--green); background: var(--green-soft); }
.game-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; margin-block: 11px; }
.game-figures dt { color: var(--secondary); font-size: .75rem; }
.game-figures dd { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.game-activity { margin-top: 9px; color: var(--secondary); font-size: .75rem; }
.game-history { margin-top: 10px; padding: 9px 11px; border-radius: 10px; background: var(--background); }
.game-history p { color: var(--secondary); font-size: .75rem; }
.game-history a { color: var(--accent-text); }
.game-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 13px; margin-top: 7px; }
.game-actions a, .game-actions button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--accent-text);
  background: transparent;
  font-size: .8125rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.game-actions button[aria-pressed="true"] { font-weight: 750; text-decoration: none; }

.players-section { margin-top: 24px; }
.players-section summary { width: fit-content; min-height: 34px; padding-block: 5px; color: var(--accent-text); font-weight: 700; }
.players-notice { margin-top: 12px; color: var(--secondary); font-size: .875rem; }
.players-sort { display: grid; gap: 4px; width: min(100%, 215px); margin-top: 12px; color: var(--secondary); font-size: .75rem; font-weight: 650; }
.players-table { width: 100%; margin-top: 8px; table-layout: fixed; border-collapse: collapse; font-size: .8125rem; }
.players-table th, .players-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.players-table th:first-child { text-align: left; overflow-wrap: anywhere; }
.players-table th:not(:first-child), .players-table td { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.players-table :is(th, td):nth-child(2) { width: 17%; }
.players-table :is(th, td):nth-child(3) { width: 24%; }
.players-table :is(th, td):nth-child(4) { width: 29%; }
.player-dates { display: block; margin-top: 3px; color: var(--secondary); font-size: .69rem; font-weight: 400; }
.more-players { margin-top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 620px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .filters { display: grid; grid-template-columns: minmax(0, 1fr); }
  .game-filter { max-width: none; }
  .segments { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .segments label span { min-width: 0; }
  .game-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 365px) {
  .intro { align-items: flex-start; flex-direction: column; }
  .refresh { min-height: 44px; }
  .segments { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
