:root {
  color-scheme: dark;
  --bg: #0f0c15;
  --bg-elevated: rgba(24, 20, 34, 0.92);
  --bg-soft: rgba(255, 255, 255, 0.05);
  --text: #f7f2ff;
  --muted: #b8afcd;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #a978ff;
  --danger: #ff6aa2;
  --warning: #ffc861;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --font-display: "Space Grotesk", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI Variable Text", "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3eefc;
  --bg-elevated: rgba(255, 255, 255, 0.92);
  --bg-soft: rgba(98, 72, 156, 0.08);
  --text: #21182f;
  --muted: #695a88;
  --line: rgba(58, 37, 101, 0.12);
  --accent: #7d58ff;
  --danger: #d63b7b;
  --warning: #b97200;
  --shadow: 0 18px 48px rgba(120, 86, 182, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(169, 120, 255, 0.24), transparent 28%),
    radial-gradient(circle at top right, rgba(210, 110, 255, 0.18), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

img {
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  background: rgba(10, 9, 14, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(58, 37, 101, 0.14);
}

.topbar-inner,
.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  min-height: 72px;
}

.topbar-left {
  display: flex;
  justify-content: flex-start;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

.topbar-center {
  display: flex;
  justify-content: center;
}

.players-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(169, 120, 255, 0.12);
  border: 1px solid rgba(169, 120, 255, 0.24);
  white-space: nowrap;
}

.players-chip span {
  color: var(--muted);
  font-size: 13px;
}

.players-chip strong {
  font-family: var(--font-display);
  font-size: 22px;
}

.topbar-actions,
.chart-range-pills,
.flag-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-actions {
  justify-content: flex-end;
}

.app-shell {
  padding: 28px 0 64px;
}

.layout {
  display: grid;
  gap: 24px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

h2 {
  font-size: clamp(24px, 2vw, 30px);
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.section-title-accent {
  color: var(--accent);
}

.ghost-button,
.soft-pill,
.back-button,
.order-button {
  border-radius: 999px;
  color: var(--text);
}

.ghost-button,
.soft-pill {
  padding: 11px 15px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.order-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid rgba(169, 120, 255, 0.24);
  background: rgba(169, 120, 255, 0.12);
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.order-button-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
}

.soft-pill.active {
  border-color: rgba(169, 120, 255, 0.48);
  background: rgba(169, 120, 255, 0.14);
}

.ghost-button:hover,
.soft-pill:hover,
.order-button:hover,
.back-button:hover {
  transform: translateY(-1px);
  border-color: rgba(169, 120, 255, 0.38);
  background: rgba(169, 120, 255, 0.16);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 10px 16px;
  background: rgba(169, 120, 255, 0.12);
  border: 1px solid rgba(169, 120, 255, 0.24);
  color: var(--text);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.lang-switch {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  height: 44px;
}

.lang-switch-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  width: 92px;
  height: 44px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.lang-switch-option {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.lang-switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: rgba(169, 120, 255, 0.22);
  transition: transform 0.18s ease;
}

.lang-switch[data-language="en"] .lang-switch-thumb {
  transform: translateX(100%);
}

.lang-switch:hover .lang-switch-track {
  border-color: rgba(169, 120, 255, 0.34);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.sort-button.active {
  color: var(--accent);
}

.sort-arrow {
  display: inline-block;
  width: 12px;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
}

thead th {
  padding: 0 14px 16px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

tbody td {
  padding: 15px 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

.table-row {
  cursor: pointer;
  transition: background 0.16s ease;
}

.table-row:hover {
  background: rgba(169, 120, 255, 0.08);
}

.game-cell {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 280px;
}

.game-cell > div:last-child {
  min-width: 0;
}

.game-cell strong {
  display: block;
  overflow-wrap: anywhere;
}

.game-icon,
.game-cover {
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(169, 120, 255, 0.28), rgba(210, 110, 255, 0.14));
}

.game-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  flex: 0 0 56px;
}

.game-icon img,
.game-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nowrap-cell {
  white-space: nowrap;
}

.flags-column,
.flags-cell {
  width: 148px;
  min-width: 148px;
}

.flag-wrap {
  width: 100%;
}

.flag {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.flag-danger {
  color: white;
  background: rgba(255, 106, 162, 0.18);
  border: 1px solid rgba(255, 106, 162, 0.45);
}

.flag-warning {
  background: rgba(255, 200, 97, 0.16);
  border: 1px solid rgba(255, 200, 97, 0.32);
}

.game-hero-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: start;
}

.game-cover {
  width: 180px;
  height: 180px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 42px;
}

.game-summary {
  display: grid;
  gap: 18px;
}

.game-meta-inline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.meta-stat {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.meta-stat span,
.meta-stat small,
.empty,
.empty-cell {
  display: block;
  color: var(--muted);
}

.meta-stat span {
  margin-bottom: 6px;
  font-size: 13px;
  text-align: left;
}

.meta-stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.1;
  text-align: left;
}

.meta-stat small {
  margin-top: 8px;
  font-size: 12px;
}

.meta-stat-primary strong {
  font-size: 36px;
}

.chart-toolbar {
  margin-bottom: 16px;
}

.chart-root {
  position: relative;
  min-height: 340px;
  color: var(--accent);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid line {
  stroke: rgba(255, 255, 255, 0.08);
}

.chart-point {
  fill: currentColor;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 8px));
  min-width: 118px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(12, 11, 18, 0.96);
  border: 1px solid rgba(169, 120, 255, 0.35);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-cell {
  text-align: center;
  padding: 24px 12px;
}

@media (max-width: 980px) {
  .topbar-inner,
  .app-shell {
    width: min(100% - 20px, 1480px);
  }

  .topbar-inner {
    grid-template-columns: 1fr;
    justify-items: start;
    padding: 10px 0;
  }

  .topbar-left,
  .topbar-center {
    justify-content: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .game-hero-grid {
    grid-template-columns: 1fr;
  }

  .game-cover {
    width: 120px;
    height: 120px;
    border-radius: 20px;
  }

  .game-meta-inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .card {
    padding: 18px;
    border-radius: 22px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tbody tr,
  tbody td {
    display: block;
    width: 100%;
  }

  tbody tr {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
  }

  tbody tr + tr {
    margin-top: 14px;
  }

  tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    text-align: right;
  }

  tbody td:first-child {
    padding-top: 0;
    border-top: 0;
  }

  tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
  }

  .table-row:hover {
    background: rgba(169, 120, 255, 0.12);
  }

  .game-cell {
    min-width: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .game-cell > div:last-child {
    text-align: right;
  }

  .flags-column,
  .flags-cell {
    width: 100%;
    min-width: 0;
  }

  .flags-cell {
    align-items: stretch;
  }

  .flags-cell::before {
    margin-top: 6px;
  }

  .flag-wrap {
    justify-content: flex-end;
  }

  .flag {
    max-width: 180px;
  }

  .nowrap-cell {
    white-space: nowrap;
  }

  .chart-range-pills {
    flex-wrap: wrap;
  }

  .back-button,
  .order-button,
  .ghost-button,
  .lang-switch-track {
    min-height: 44px;
  }
}
