* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --secondary: #7c3aed;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 25px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 40px -12px rgb(0 0 0 / 0.15);
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 3rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.4;
}

.header-content {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
}

.app-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: block;
}

.header h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.header p {
  font-size: clamp(1rem, 3vw, 1.25rem);
  opacity: 0.95;
  font-weight: 500;
}

.main-content-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  align-items: start;
}

.container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar {
  position: sticky;
  top: 2rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.sidebar-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.leaderboard-wrapper {
  padding: 1.25rem;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

.leaderboard-wrapper::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-wrapper::-webkit-scrollbar-track {
  background: var(--bg-main);
}

.leaderboard-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

#leaderboard table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

#leaderboard thead th {
  position: sticky;
  top: 0;
  background: var(--bg-main);
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}

#leaderboard thead th:first-child {
  text-align: center;
  width: 50px;
}

#leaderboard thead th:nth-child(3),
#leaderboard thead th:nth-child(4),
#leaderboard thead th:nth-child(5),
#leaderboard thead th:nth-child(6),
#leaderboard thead th:nth-child(7) {
  text-align: center;
}

#leaderboard tbody td {
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

#leaderboard tbody tr:last-child td {
  border-bottom: none;
}

#leaderboard tbody tr:hover {
  background: var(--bg-main);
}

#leaderboard tbody td:first-child {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

#leaderboard tbody td:nth-child(3),
#leaderboard tbody td:nth-child(4),
#leaderboard tbody td:nth-child(5),
#leaderboard tbody td:nth-child(6),
#leaderboard tbody td:nth-child(7) {
  text-align: center;
  font-weight: 600;
}

.squadra-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}

.team-logo-leaderboard {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.day-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.day-section:hover {
  box-shadow: var(--shadow-lg);
}

.day-header {
  padding: 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background 0.2s ease;
}

.day-header:hover {
  background: var(--bg-main);
}

.day-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.toggle-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 300;
  transition: all 0.2s ease;
}

.day-header:hover .toggle-icon {
  background: var(--primary);
  color: white;
}

.matches-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.4s ease;
}

.matches-container.open {
  max-height: 80vh;
  overflow-y: auto;
  padding: 0 1.5rem 1.5rem;
}

.matches-container::-webkit-scrollbar {
  width: 6px;
}

.matches-container::-webkit-scrollbar-track {
  background: transparent;
}

.matches-container::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.match-card {
  background: var(--bg-main);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.match-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.teams {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.team-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

.score {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.fantapunti {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.fantallenatori {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 1200px) {
  .main-content-container {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: 0;
  }

  .leaderboard-wrapper {
    max-height: none;
  }
}

@media (max-width: 768px) {
  .main-content-container {
    padding: 1.5rem 1rem 3rem;
    gap: 1.5rem;
  }

  .header {
    padding: 2rem 1rem;
  }

  .app-logo {
    width: 64px;
    height: 64px;
  }

  .day-header {
    padding: 1.25rem;
  }

  .matches-container {
    grid-template-columns: 1fr;
  }

  .matches-container.open {
    padding: 0 1.25rem 1.25rem;
  }

  .sidebar-header {
    padding: 1.25rem;
    font-size: 1.125rem;
  }

  .leaderboard-wrapper {
    padding: 1rem;
  }

  #leaderboard thead th {
    padding: 0.625rem 0.375rem;
    font-size: 0.7rem;
  }

  #leaderboard tbody td {
    padding: 0.875rem 0.375rem;
    font-size: 0.85rem;
  }

  .team-logo-leaderboard {
    width: 28px;
    height: 28px;
  }

  .squadra-cell {
    gap: 0.5rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .match-card {
    padding: 1.25rem;
  }

  .score {
    font-size: 2rem;
  }

  .team-logo {
    width: 36px;
    height: 36px;
  }
}
