:root {
  --primary: #667eea;
  --secondary: #764ba2;
  --bg: #0b0f16;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.12);
  --muted: rgba(255, 255, 255, 0.78);
  --muted-2: rgba(255, 255, 255, 0.56);
  --shadow: 0 14px 46px rgba(0, 0, 0, 0.36);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body.matches-theme {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: #fff;
  background-image:
    radial-gradient(1100px 700px at 25% 0%, rgba(102, 126, 234, 0.3), transparent 68%),
    radial-gradient(1000px 650px at 105% 45%, rgba(118, 75, 162, 0.22), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
  background-attachment: fixed;
}

body.matches-theme header {
  position: sticky;
  top: 0;
  z-index: 24;
  margin: 10px auto 0;
  width: min(1200px, calc(100% - 28px));
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: rgba(8, 12, 20, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.matches-theme header h1 {
  margin: 0;
  color: #fff;
  letter-spacing: -0.35px;
  font-size: 20px;
  font-weight: 850;
}

body.matches-theme .back-btn,
body.matches-theme .back-button {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s ease;
}

body.matches-theme .back-btn:hover,
body.matches-theme .back-button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

body.matches-theme main.main-container {
  width: min(1200px, calc(100% - 28px));
  margin: 14px auto 24px;
  padding: 0;
}

body.matches-theme footer {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto 20px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: rgba(8, 12, 20, 0.8);
  color: var(--muted);
  text-align: center;
}

body.matches-theme .card,
body.matches-theme .admin-panel,
body.matches-theme .classifica-wrapper,
body.matches-theme .legenda,
body.matches-theme .stats-card,
body.matches-theme .top-team-card,
body.matches-theme .criteri-classifica,
body.matches-theme .stats-table,
body.matches-theme .player-photo-container,
body.matches-theme .mvp-voting,
body.matches-theme .penalty-modal,
body.matches-theme .modal {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  color: #fff;
}

body.matches-theme .tab-button,
body.matches-theme .sub-tab,
body.matches-theme .match-tab,
body.matches-theme .lineup-control-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

body.matches-theme .tab-button.active,
body.matches-theme .sub-tab.active,
body.matches-theme .match-tab.active,
body.matches-theme .lineup-control-btn.active {
  border-color: rgba(147, 160, 255, 0.9);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.45), rgba(118, 75, 162, 0.45));
  color: #fff;
}

body.matches-theme .stats-table th,
body.matches-theme .classifica-table th,
body.matches-theme .standings-table th {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

body.matches-theme .stats-table td,
body.matches-theme .classifica-table td,
body.matches-theme .standings-table td {
  color: var(--muted);
  border-bottom-color: rgba(255, 255, 255, 0.09);
}

body.matches-theme .stats-table tbody tr:hover,
body.matches-theme .classifica-table tbody tr:hover,
body.matches-theme .standings-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06) !important;
}

body.matches-theme input[type="text"],
body.matches-theme input[type="number"],
body.matches-theme select,
body.matches-theme textarea {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

body.matches-theme input::placeholder,
body.matches-theme textarea::placeholder {
  color: var(--muted-2);
}

body.matches-theme .hidden {
  display: none !important;
}

/* Dettaglio partita */
body.match-detail-page {
  overscroll-behavior-y: none;
}

body.match-detail-page header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

body.match-detail-page .back-button {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

body.match-detail-page main.main-container {
  width: min(920px, calc(100% - 28px));
}

body.match-detail-page .teams .team .team-name,
body.match-detail-page .score,
body.match-detail-page .event-player,
body.match-detail-page .timeline-event .event-time,
body.match-detail-page .standings-team-link,
body.match-detail-page .lineup-team-name,
body.match-detail-page .top-team-name,
body.match-detail-page .photo-player-name {
  color: #fff;
}

body.match-detail-page .event-team,
body.match-detail-page .lineup-placeholder-note,
body.match-detail-page .lineup-empty,
body.match-detail-page .media-placeholder,
body.match-detail-page .standings-live-note,
body.match-detail-page .mvp-result-team,
body.match-detail-page .photo-player-team {
  color: var(--muted);
}

body.match-detail-page .teams .team img {
  border-color: rgba(130, 149, 255, 0.9);
  box-shadow: 0 8px 22px rgba(102, 126, 234, 0.3);
}

body.match-detail-page .match-meta-pill,
body.match-detail-page .additional-time-badge,
body.match-detail-page .lineup-module,
body.match-detail-page .event-score-pill {
  border: 1px solid rgba(130, 149, 255, 0.45);
  background: rgba(102, 126, 234, 0.2);
  color: #dbe4ff;
}

body.match-detail-page .match-status-indicator.not-started {
  background: rgba(148, 163, 184, 0.24);
  color: #cbd5e1;
}

body.match-detail-page .match-status-indicator.in-progress {
  background: rgba(250, 204, 21, 0.2);
  color: #fde68a;
}

body.match-detail-page .match-status-indicator.completed {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

body.match-detail-page .timeline::before,
body.match-detail-page .timeline-event::before {
  background: rgba(255, 255, 255, 0.18);
}

body.match-detail-page .timeline-event {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

body.match-detail-page .timeline-event.team1 {
  background: rgba(102, 126, 234, 0.18);
  border-left-color: #8295ff;
}

body.match-detail-page .timeline-event.team2 {
  background: rgba(244, 114, 182, 0.14);
  border-left-color: #fb7185;
}

body.match-detail-page .timeline-event .event-minute {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}

body.match-detail-page .match-control-btn.start {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

body.match-detail-page .match-control-btn.end {
  background: linear-gradient(135deg, #dc2626, #ef4444);
}

body.match-detail-page .match-control-btn.penalties {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}

body.match-detail-page .playoff-advance-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

body.match-detail-page .match-status-text,
body.match-detail-page .lineup-module,
body.match-detail-page .mvp-player-team {
  color: var(--muted);
}

body.match-detail-page .mvp-section {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.55), rgba(118, 75, 162, 0.52));
  border: 1px solid rgba(255, 255, 255, 0.2);
}

body.match-detail-page .mvp-player,
body.match-detail-page .mvp-result-item,
body.match-detail-page .mvp-photo-upload,
body.match-detail-page .penalty-team,
body.match-detail-page .penalty-player,
body.match-detail-page .penalty-score-team {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
}

body.match-detail-page .mvp-player-name,
body.match-detail-page .mvp-candidate-name,
body.match-detail-page .mvp-result-name,
body.match-detail-page .penalty-player-name,
body.match-detail-page .penalty-modal h3 {
  color: #fff;
}

body.match-detail-page .mvp-candidate-team,
body.match-detail-page .penalty-team-header,
body.match-detail-page .mvp-result-votes,
body.match-detail-page .mvp-votes {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

body.match-detail-page .mvp-candidate:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.match-detail-page .mvp-candidate.selected {
  border-color: rgba(130, 149, 255, 0.85);
  background: rgba(102, 126, 234, 0.18);
}

body.match-detail-page .vote-success {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

body.match-detail-page .modal-overlay {
  background: rgba(1, 4, 10, 0.7);
}

body.match-detail-page .loading-overlay {
  background: rgba(1, 4, 10, 0.72);
}

body.match-detail-page .loading-spinner {
  border-color: rgba(255, 255, 255, 0.18);
  border-top-color: #8ea1ff;
}

body.match-detail-page .toast {
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
}

body.match-detail-page .standings-table thead th {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

body.match-detail-page .lineup-team-card,
body.match-detail-page .standings-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--stroke);
}

body.match-detail-page .lineup-team-header {
  background: rgba(255, 255, 255, 0.08);
  border-bottom-color: var(--stroke);
}

body.match-detail-page .lineup-avatar {
  border-color: rgba(255, 255, 255, 0.55);
}

body.match-detail-page .bg-white,
body.match-detail-page .text-gray-600,
body.match-detail-page .text-gray-500,
body.match-detail-page .text-gray-700 {
  color: var(--muted) !important;
}

body.match-detail-page .bg-white {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Partite / classifica */
body.matches-overview-page header {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

body.matches-overview-page .tabs-container {
  position: sticky;
  top: 84px;
  z-index: 18;
  width: min(1200px, calc(100% - 28px));
  margin: 10px auto 0;
  padding: 8px;
  display: flex;
  gap: 8px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  background: rgba(8, 12, 20, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.matches-overview-page .tab-button {
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
  padding: 8px 10px;
}

body.matches-overview-page .main-container {
  margin-top: 14px;
}

body.matches-overview-page .classifica-header {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.48), rgba(118, 75, 162, 0.48));
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
}

body.matches-overview-page .classifica-description,
body.matches-overview-page .stats-label,
body.matches-overview-page .top-stat-label,
body.matches-overview-page .criteri-list,
body.matches-overview-page .provisional-note,
body.matches-overview-page .waiting-message p {
  color: var(--muted);
}

body.matches-overview-page .legenda-item {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

body.matches-overview-page .stats-card .stats-value,
body.matches-overview-page .highlight-cell,
body.matches-overview-page .top-stat-value {
  color: #dbe4ff;
}

body.matches-overview-page .classifica-wrapper,
body.matches-overview-page .classifica-table {
  background: transparent;
}

body.matches-overview-page .classifica-table th {
  background: rgba(255, 255, 255, 0.11);
}

body.matches-overview-page .points-column,
body.matches-overview-page .diff-column {
  background-color: rgba(102, 126, 234, 0.36) !important;
}

body.matches-overview-page .classifica-table tr:nth-child(odd) td,
body.matches-overview-page .classifica-table tr:nth-child(even) td {
  background: transparent;
}

body.matches-overview-page .team-name-container,
body.matches-overview-page .top-team-name,
body.matches-overview-page .criteri-header,
body.matches-overview-page .waiting-message h3,
body.matches-overview-page .photo-player-name {
  color: #fff;
}

body.matches-overview-page .admin-panel button {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.65), rgba(118, 75, 162, 0.65));
}

body.matches-overview-page .admin-panel button.confirm-btn {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.75), rgba(16, 185, 129, 0.75));
}

body.matches-overview-page .sub-tabs {
  padding: 8px 0;
}

body.matches-overview-page .stats-table th {
  background: rgba(255, 255, 255, 0.11);
}

body.matches-overview-page .stats-table tbody tr:nth-child(even),
body.matches-overview-page .stats-table tbody tr:nth-child(odd) {
  background: transparent;
}

body.matches-overview-page .waiting-message,
body.matches-overview-page #waiting-playoff-message {
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: #fff;
}

body.matches-overview-page .logo-container img {
  background: rgba(8, 12, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

body.matches-overview-page .player-photo-info {
  background: transparent;
}

body.matches-overview-page .photo-player-team {
  color: var(--muted);
}

/* Override tema del bracket avanzato iniettato da JS */
body.matches-overview-page .enhanced-bracket {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

body.matches-overview-page .bracket-header {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

body.matches-overview-page .phase-container,
body.matches-overview-page .placement-section,
body.matches-overview-page .enhanced-legend,
body.matches-overview-page .flow-text {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}

body.matches-overview-page .match-card.enhanced,
body.matches-overview-page .placement-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.16);
}

body.matches-overview-page .match-card.enhanced .match-label,
body.matches-overview-page .placement-info h4,
body.matches-overview-page .placement-name,
body.matches-overview-page .legend-title {
  color: #fff;
}

body.matches-overview-page .match-status,
body.matches-overview-page .match-time,
body.matches-overview-page .team-record,
body.matches-overview-page .flow-text,
body.matches-overview-page .placement-info p,
body.matches-overview-page .placement-details span,
body.matches-overview-page .legend-item {
  color: var(--muted);
}

body.matches-overview-page .team-name {
  color: #fff;
}

body.matches-overview-page .team-logo,
body.matches-overview-page .placement-logo {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(7, 11, 20, 0.72);
}

body.matches-overview-page .bg-white {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
}

body.matches-overview-page .text-gray-500,
body.matches-overview-page .text-gray-600,
body.matches-overview-page .text-gray-700,
body.matches-overview-page .text-indigo-800,
body.matches-overview-page .text-blue-800,
body.matches-overview-page .text-green-800,
body.matches-overview-page .text-yellow-800 {
  color: var(--muted) !important;
}

body.matches-overview-page .bg-blue-100,
body.matches-overview-page .bg-green-100,
body.matches-overview-page .bg-yellow-400,
body.matches-overview-page .bg-red-500,
body.matches-overview-page .bg-gray-50,
body.matches-overview-page .from-blue-100,
body.matches-overview-page .to-indigo-100,
body.matches-overview-page .from-green-100,
body.matches-overview-page .to-teal-100 {
  background: rgba(255, 255, 255, 0.12) !important;
}

@media (max-width: 768px) {
  body.matches-theme header {
    width: calc(100% - 20px);
    margin-top: 8px;
  }

  body.matches-theme main.main-container,
  body.matches-theme footer,
  body.matches-overview-page .tabs-container {
    width: calc(100% - 20px);
  }

  body.matches-overview-page .tabs-container {
    top: 76px;
  }
}
