:root {
  --bg: #0a0d14;
  --bg-2: #131b2c;
  --sunset: #ff7a3b;
  --neon: #52d1ff;
  --gold: #f2c166;
  --ink: #e7f0ff;
  --muted: #92a4c2;
  --accent: #65f5c1;
  --card: #12192a;
  --card-2: #171f33;
  --line: #2b3a5c;
  --glow: rgba(82, 209, 255, 0.35);
  --rose: rgba(255, 122, 59, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(900px 500px at 10% 0%, #1b2240 0%, transparent 60%),
    radial-gradient(800px 450px at 90% 10%, #2a1440 0%, transparent 65%),
    linear-gradient(160deg, #0b0e16, #0b101a 45%, #0a0d14 100%);
  min-height: 100vh;
}

.arena {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  position: relative;
}

.arena::before,
.arena::after {
  content: "";
  position: absolute;
  inset: -40px -20px auto -20px;
  height: 280px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(82, 209, 255, 0.16), transparent);
  filter: blur(1px);
  opacity: 0.6;
}

.arena::after {
  inset: auto -20px -60px -20px;
  height: 240px;
  background: linear-gradient(90deg, transparent, rgba(255, 122, 59, 0.2), transparent);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: linear-gradient(135deg, rgba(82, 209, 255, 0.12), rgba(255, 122, 59, 0.18));
  border: 1px solid rgba(82, 209, 255, 0.3);
  border-radius: 18px;
  padding: 24px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 30px var(--glow);
}

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

.crest {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: 22px;
  background: linear-gradient(145deg, var(--sunset), #ffad7d);
  color: #1a0e04;
  box-shadow: inset 0 0 0 2px rgba(26, 14, 4, 0.25), 0 0 18px var(--rose);
}

.title h1 {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(20px, 3.4vw, 26px);
  margin: 0 0 6px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.title p {
  margin: 0;
  color: var(--muted);
}

.status {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(18, 25, 42, 0.8);
  border: 1px solid rgba(82, 209, 255, 0.2);
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  margin: 28px 0 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tabs-shell {
  position: relative;
}

.tabs-hint {
  display: none;
}

.tab {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(18, 25, 42, 0.9), rgba(18, 25, 42, 0.6));
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border 0.15s ease;
}

.tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.3);
  border-color: rgba(82, 209, 255, 0.45);
}

.tab.active {
  background: linear-gradient(135deg, rgba(82, 209, 255, 0.2), rgba(255, 122, 59, 0.2));
  border-color: rgba(82, 209, 255, 0.7);
  color: var(--neon);
}

.stage {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(82, 209, 255, 0.08);
}

.analytics-panel {
  margin-top: 16px;
}

.analytics-content {
  display: grid;
  gap: 18px;
}

.analytics-section {
  display: grid;
  gap: 10px;
}

.analytics-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.analytics-card {
  background: rgba(18, 25, 42, 0.7);
  border: 1px solid rgba(82, 209, 255, 0.2);
  border-radius: 14px;
  padding: 14px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35);
}

.analytics-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--neon);
}

.info-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.info-button {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(82, 209, 255, 0.35);
  border-radius: 999px;
  background: rgba(82, 209, 255, 0.12);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.info-button:hover {
  border-color: rgba(82, 209, 255, 0.65);
  background: rgba(82, 209, 255, 0.2);
}

.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: none;
  width: min(280px, calc(100vw - 48px));
  padding: 10px 12px;
  border-radius: 10px;
  background: #0d1526;
  border: 1px solid rgba(82, 209, 255, 0.25);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
  z-index: 5;
}

.info-heading.info-open .info-popover {
  display: block;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: auto;
}

.analytics-table th,
.analytics-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
  font-size: 13px;
}

.analytics-table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
}

.analytics-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(82, 209, 255, 0.15);
  color: var(--neon);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 22px;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.cell-mark {
  font-weight: 700;
  text-align: center;
  font-size: 14px;
}

.cell-mark.ok {
  color: #5cff9b;
  text-shadow: 0 0 8px rgba(92, 255, 155, 0.4);
}

.cell-mark.bad {
  color: #ff6b6b;
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 12px;
  border: 1px solid rgba(82, 209, 255, 0.15);
  background: #0f1524;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.round-wrap {
  width: fit-content;
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 640px;
}

.data-table.round-table {
  table-layout: fixed;
  min-width: 0;
}

.data-table.round-table th,
.data-table.round-table td {
  width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 4px 5px;
  font-size: 12px;
  overflow-wrap: normal;
  word-break: normal;
}

.data-table.round-table th:first-child,
.data-table.round-table td:first-child {
  width: 152px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.data-table.round-table th.derived-metric,
.data-table.round-table td.derived-metric {
  width: 96px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.data-table.round-table th:nth-last-child(2),
.data-table.round-table td:nth-last-child(2) {
  width: 76px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.data-table.round-table .cell-mark {
  font-size: 12px;
}

.theme-divider {
  border-left: 1px solid rgba(82, 209, 255, 0.22);
}

.data-table.table-compact th,
.data-table.table-compact td {
  padding: 6px 8px;
  font-size: 13px;
}

.data-table thead {
  background: rgba(82, 209, 255, 0.12);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-weight: 600;
  color: var(--neon);
  position: sticky;
  top: 0;
  background: #151c2f;
  z-index: 1;
}

.data-table tbody td:first-child,
.data-table thead th:first-child {
  position: sticky;
  left: 0;
  background: #121a2c;
  z-index: 2;
}

.theme-sticky-overlay {
  position: fixed;
  top: 0;
  z-index: 6;
  display: none;
  overflow: hidden;
  background: #151c2f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.theme-sticky-overlay.visible {
  display: block;
}

.theme-sticky-overlay-inner {
  display: flex;
  width: max-content;
}

.theme-sticky-overlay-cell {
  flex: 0 0 auto;
  padding: 10px 12px;
  min-height: 60px;
  color: var(--neon);
  font-weight: 600;
  border-right: 1px solid rgba(82, 209, 255, 0.2);
  white-space: normal;
  word-break: normal;
  background: #151c2f;
  text-align: left;
  display: flex;
  align-items: flex-start;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  background: #19233b;
}

.data-table th.sortable span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sort-indicator {
  font-size: 12px;
  margin-left: 4px;
  opacity: 0.8;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  color: var(--accent);
}

.sort-indicator .sort-up {
  color: var(--accent);
}

.sort-indicator .sort-down {
  color: #ff6b6b;
}

.sortable[data-sort-direction="desc"] .sort-indicator {
  color: #ff6b6b;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:hover {
  background: rgba(82, 209, 255, 0.08);
}

.data-table tbody td.column-hover {
  background: rgba(82, 209, 255, 0.08);
}

.data-table tbody tr.selected {
  background: rgba(82, 209, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(82, 209, 255, 0.45);
}

.data-table tbody tr.selected td:first-child {
  background: #18253d;
}

.data-table tbody tr.sub-header td {
  background: rgba(255, 122, 59, 0.18);
  color: var(--ink);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr.sub-header td:first-child {
  background: rgba(255, 122, 59, 0.24);
}

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .arena {
    padding: 16px 12px 32px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 16px;
  }

  .brand {
    gap: 12px;
    min-width: 0;
  }

  .crest {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 18px;
  }

  .title h1 {
    letter-spacing: 1px;
  }

  .status {
    padding: 8px 12px;
    font-size: 12px;
  }

  .tabs-shell {
    margin: 18px -12px 14px;
    padding: 0 12px 18px;
  }

  .tabs-shell::before,
  .tabs-shell::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 18px;
    width: 22px;
    pointer-events: none;
    z-index: 2;
  }

  .tabs-shell::before {
    left: 12px;
    background: linear-gradient(90deg, rgba(10, 13, 20, 0.95), rgba(10, 13, 20, 0));
  }

  .tabs-shell::after {
    right: 12px;
    background: linear-gradient(270deg, rgba(10, 13, 20, 0.95), rgba(10, 13, 20, 0));
  }

  .tabs {
    margin: 0;
    padding: 0 12px 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    padding: 9px 13px;
    font-size: 14px;
    scroll-snap-align: start;
  }

  .tabs-hint {
    display: block;
    position: absolute;
    right: 18px;
    bottom: 0;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-header h2 {
    font-size: 18px;
  }

  .table-wrap {
    border-radius: 10px;
  }

  .round-wrap {
    margin-left: 0;
    margin-right: 0;
  }

  .data-table {
    min-width: 520px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 9px;
  }

  .data-table.round-table th,
  .data-table.round-table td {
    width: 30px;
    padding: 3px 4px;
    font-size: 11px;
  }

  .data-table.round-table th:first-child,
  .data-table.round-table td:first-child {
    width: 108px;
  }

  .data-table.round-table th.derived-metric,
  .data-table.round-table td.derived-metric {
    width: 72px;
  }

  .data-table tbody td:first-child,
  .data-table thead th:first-child {
    max-width: 108px;
  }

  .theme-sticky-overlay {
    display: none !important;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-card {
    padding: 12px;
  }

  .analytics-table th,
  .analytics-table td {
    padding: 5px 6px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .arena {
    padding: 12px 8px 24px;
  }

  .hero {
    padding: 14px;
  }

  .title h1 {
    font-size: 18px;
  }

  .panel {
    padding: 10px;
  }

  .tabs-shell {
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .tabs-shell::before {
    left: 8px;
  }

  .tabs-shell::after {
    right: 8px;
  }

  .tabs {
    padding-left: 8px;
    padding-right: 8px;
  }

  .tab {
    padding: 8px 11px;
    font-size: 13px;
  }

  .data-table {
    min-width: 470px;
  }

  .data-table.round-table th,
  .data-table.round-table td {
    width: 27px;
    font-size: 10px;
  }

  .data-table.round-table th:first-child,
  .data-table.round-table td:first-child {
    width: 96px;
  }

  .data-table.round-table th.derived-metric,
  .data-table.round-table td.derived-metric {
    width: 64px;
  }
}
