:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #1e293b;
  --accent: #22d3ee;
  --accent-muted: rgba(34, 211, 238, 0.15);
  --text: #e2e8f0;
  --subtle: #94a3b8;
  --error: #f87171;
  --success: #4ade80;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  max-width: 960px;
  margin: 0 auto 24px auto;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2.4rem;
  color: var(--accent);
}

h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

h3 {
  margin: 20px 0 8px 0;
  font-size: 1.15rem;
}

.tagline {
  margin-top: 8px;
  color: var(--subtle);
}

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
}

.hint {
  margin: 0 0 16px 0;
  color: var(--subtle);
  font-size: 0.95rem;
}

.hint.status {
  color: var(--text);
}

.hint.error {
  color: var(--error);
}

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

.file-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--accent-muted);
  border-radius: 10px;
}

.file-input input[type="file"] {
  width: 100%;
  color: var(--text);
}

.input-title {
  font-weight: 600;
}

.input-desc {
  font-size: 0.85rem;
  color: var(--subtle);
}

.auto-fetch {
  margin-top: 20px;
  padding: 16px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.12);
}

.auto-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.auto-controls label {
  font-size: 0.95rem;
  color: var(--subtle);
}

.auto-controls input[type="text"] {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
}

button {
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #0f172a;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.4);
}

.outputs {
  overflow-x: auto;
}

.status {
  color: var(--text);
}

.error {
  color: var(--error);
}

.status.meta {
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.95rem;
}

.data-table thead {
  background: rgba(148, 163, 184, 0.12);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.08);
}

.data-table tbody tr:hover {
  background: rgba(34, 211, 238, 0.08);
}

footer {
  margin-top: 32px;
  text-align: center;
  color: var(--subtle);
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  body {
    padding: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  button {
    width: 100%;
  }

  .auto-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .auto-controls button {
    width: 100%;
  }
}

.collapsible {
  margin-bottom: 24px;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 600;
  background: rgba(34, 211, 238, 0.08);
  padding: 12px 16px;
  border-radius: 10px;
  user-select: none;
}

.collapsible-header::after {
  content: '>';
  display: inline-block;
  transition: transform 0.2s ease;
  transform: rotate(90deg);
}

.collapsible-header[aria-expanded="false"]::after {
  transform: rotate(0deg);
}

.collapsible-body {
  margin-top: 14px;
}

.data-table th[data-sort-key] {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.data-table th[data-sort-key]::after {
  content: '';
  border: solid transparent;
  border-width: 5px 5px 0 5px;
  border-top-color: rgba(148, 163, 184, 0.6);
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s ease;
}

.data-table th[data-sort-direction="desc"]::after {
  transform: translateY(-50%) rotate(180deg);
}

.data-table th[data-sort-direction] {
  color: var(--accent);
}

.data-table tbody td {
  white-space: nowrap;
}

.collapsible-body[hidden] {
  display: none;
}

.explanation {
  color: var(--subtle);
  margin-bottom: 16px;
}


.tab-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 0 auto 24px auto;
  max-width: 960px;
}

.tab-button {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.tab-button.active {
  background: var(--accent);
  color: #0f172a;
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-section {
  display: none;
}

.tab-section.active {
  display: block;
}

.api-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.api-controls input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
}

.ev-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.ev-select-label {
  font-size: 0.9rem;
  color: var(--subtle);
}

.ev-controls select {
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
}

.hint.ev-warning {
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--subtle);
  margin-bottom: 16px;
}

.ev-game {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 18px 18px 20px 18px;
  margin-bottom: 18px;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.85));
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.15);
}

.ev-game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.ev-matchup {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 600;
}

.ev-team {
  color: var(--text);
  letter-spacing: 0.02em;
}

.ev-team.ev-home {
  color: var(--accent);
}

.ev-vs {
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--subtle);
  letter-spacing: 0.12em;
}

.ev-game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
}

.ev-meta-item {
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ev-meta-item.ev-date {
  background: rgba(34, 211, 238, 0.14);
  color: var(--accent);
}

.ev-meta-item strong {
  color: var(--text);
}

.ev-board {
  margin-top: 18px;
  display: grid;
  gap: 18px;
}

.ev-group {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ev-group-title {
  font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

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

.ev-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.1);
}

.ev-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.ev-card-team {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.ev-tag {
  background: rgba(34, 211, 238, 0.18);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.ev-card-details {
  display: grid;
  gap: 6px;
}

.ev-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 8px;
  font-size: 0.85rem;
}

.ev-detail-label {
  color: var(--subtle);
  font-weight: 500;
}

.ev-detail-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.ev-inputs {
  display: grid;
  gap: 8px;
}

.ev-inputs label {
  font-size: 0.8rem;
  color: var(--subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ev-inputs input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
}

.ev-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ev-input-wrapper input {
  flex: 1;
}

.ev-sign-toggle {
  flex-shrink: 0;
  padding: 0 10px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(30, 41, 59, 0.95);
  color: var(--text);
  font-weight: 600;
}

.ev-sign-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ev-input-row {
  display: flex;
  gap: 8px;
}

.ev-input-row label {
  flex: 1;
}

.ev-input-row input {
  flex: 1;
}

.ev-results {
  font-size: 0.85rem;
  color: var(--subtle);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.ev-metric {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(34, 211, 238, 0.08);
  border-radius: 8px;
}

.ev-metric-label {
  color: var(--subtle);
  font-weight: 500;
}

.ev-metric-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.custom-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.custom-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.custom-form input,
.custom-form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
}

.custom-form button {
  padding: 10px 18px;
}

@media (max-width: 768px) {
  .tab-nav {
    flex-direction: column;
  }

  .ev-board-grid {
    grid-template-columns: 1fr;
  }

  .ev-results {
    grid-template-columns: 1fr;
  }

  .ev-game-header {
    align-items: flex-start;
  }
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
}
