:root {
  --primary-color: #2e7d32;
  --primary-dark: #1b5e20;
  --background-color: #f5f7fa;
  --card-background: #ffffff;
  --text-color: #2c3e50;
  --border-color: #e5e9f0;
  --win-color: #4caf50;
  --draw-color: #ff9800;
  --loss-color: #f44336;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.5;
  width: min-content;
  min-width: 100%;
  overflow-x: auto;
}

.app {
  width: min-content;
  min-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
}

.header {
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  padding: 0.75rem 2rem;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: min-content;
  min-width: 100%;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: white;
}

.trophy-icon {
  font-size: 1.5rem;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.header nav {
  display: flex;
  gap: 1.5rem;
}

.header nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.header nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 2rem;
}

.content {
  width: 1200px;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 0.6rem;
}

.league-selector {
  width: 1200px;
  margin-bottom: 0.6rem;
  position: relative;
}

@media (max-width: 1200px) {
  .container {
    padding: 0.6rem;
  }
  
  .content {
    width: 100%;
    max-width: 800px;
    grid-template-columns: 1fr;
  }

  .league-selector {
    width: 100%;
    max-width: 800px;
  }
}

.standings-section, .matches-section {
  background: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 0.6rem;
}

.matches-section > h2 {
  text-align: center;
}

.standings-section > h2 {
  margin-bottom: 1rem;
}

h2 {
  color: var(--text-color);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
}

th {
  background-color: #f8fafc;
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid var(--border-color);
}

td {
  text-align: center;
}

.position {
  font-weight: 600;
  color: #64748b;
  width: 80px;
  min-width: 40px;
}

.team-header, .team-name {
  text-align: left;
}

th:not(.position):not(.team-header),
td:not(.position):not(.team-name-cell):not(.form) {
  min-width: 40px;
  width: 40px;
}

.form {
  min-width: 100px;
  width: 100px;
}

.team-name-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.team-name {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.points {
  font-weight: 600;
  color: var(--primary-dark);
}

.form-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  transition: transform 0.15s ease;
  margin-top: 4px;
  padding: 4px;
  background-clip: content-box;
}

.form-indicator:hover {
  transform: scale(1.2);
}

.form-indicator.W {
  background-color: var(--win-color);
}

.form-indicator.D {
  background-color: var(--draw-color);
}

.form-indicator.L {
  background-color: var(--loss-color);
}

.form-indicator.live {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.matches-section h2 {
  margin-bottom: 1rem;
}

.matches-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.round-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-color);
  font-size: 0.95rem;
}

select, input, textarea {
  background-color: var(--card-background);
  color: var(--text-color);
  -webkit-appearance: none;
  appearance: none;
}

.round-selector select {
  background-color: var(--card-background);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.25rem;
  font-size: 0.9rem;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.3rem center;
  background-size: 1em;
  padding-right: 1.5rem;
  width: 60px;
  text-align: center;
  margin: 0 0.25rem;
}

.total-rounds {
  color: #64748b;
}

.nav-button {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  padding: 0;
  color: var(--text-color);
  transition: all 0.2s;
}

.nav-button:hover:not(:disabled) {
  background: var(--border-color);
}

.nav-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.matches-list {
  display: flex;
  flex-direction: column;
}

.match-card {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  background: white;
}

.match-teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.match-teams .team {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-teams .team.home {
  justify-content: flex-end;
}

.match-teams .team.away {
  justify-content: flex-start;
}

.match-teams .team-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}

.team-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.score {
  font-size: 1rem;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  background: #f8fafc;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.score.live {
  animation: liveScore 2s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes liveScore {
  0% { background-color: rgba(255, 0, 0, 0.1); }
  50% { background-color: rgba(255, 0, 0, 0.2); }
  100% { background-color: rgba(255, 0, 0, 0.1); }
}

.match-datetime {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #64748b;
  margin: 0.1rem 0 0.1rem 0;
}

.match-info {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  color: #64748b;
  font-style: italic;
}

.bullet {
  font-size: 0.5rem;
  opacity: 0.5;
}

.groups-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0 auto;
}

.group-standings {
  background: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 0.3rem;
  margin-bottom: 0.5rem;
}

.group-standings:last-child {
  margin-bottom: 0;
}

.group-standings h3 {
  color: var(--text-color);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  padding-left: 0.5rem;
}

.group-standings table {
  width: 100%;
  border-collapse: collapse;
}

.group-standings th,
.group-standings td {
  padding: 0.5rem 0.1rem;
  text-align: center;
  font-size: 0.9rem;
}

.group-standings th {
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
  padding-top: 0.5rem;
}

.group-standings tr {
  border-bottom: 1px solid var(--border-color);
}

/* Live match badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-left: auto;
  min-width: 2.8rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
  cursor: default;
}

.live-badge.live-W {
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #16a34a;
}

.live-badge.live-D {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

.live-badge.live-L {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
  animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Zone classification indicator */
.group-standings td.zone-indicator {
  position: relative;
  font-weight: 600;
}

.group-standings td.zone-indicator::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: var(--zone-color);
}

/* Zone legend */
.zones-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0.75rem 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.zone-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.zone-legend-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.zone-legend-label {
  white-space: nowrap;
}

/* Team details panel */
.group-standings tbody tr.selected {
  background-color: rgba(0, 0, 0, 0.05);
}

.team-details-cell {
  padding: 0 !important;
  background-color: #f8fafc;
}

.team-details-panel {
  padding: 0.75rem;
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
  cursor: default;
}

.team-details-panel h4 {
  margin: 0 0 1rem 0;
  color: var(--text-color);
  font-size: 1.1rem;
}

.team-details-panel .position-history {
  margin-bottom: 0.75rem;
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.team-details-panel .matches-history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.team-details-panel .past-matches,
.team-details-panel .upcoming-matches {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.team-details-panel .matches-list {
  display: flex;
  flex-direction: column;
}

.team-details-panel .match-card {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.team-details-panel .match-teams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.team-details-panel .match-teams .team {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 120px;
}

.team-details-panel .match-teams .team.home {
  justify-content: flex-end;
}

.team-details-panel .match-teams .team.away {
  justify-content: flex-start;
}

.team-details-panel .match-teams .team.highlight {
  font-weight: 600;
}

.team-details-panel .past-matches .match-teams .team.highlight {
  font-weight: 600;
}

.team-details-panel .upcoming-matches .match-teams .team.highlight {
  font-weight: normal;
}

.team-details-panel .match-teams .team-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}

.team-details-panel .score {
  font-size: 1rem;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
  background: #f8fafc;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.team-details-panel .match-datetime {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #64748b;
  margin: 0.1rem 0 0.1rem 0;
}

.team-details-panel .match-teams .team.win {
  color: #16a34a;
  font-weight: 600;
}

.team-details-panel .match-teams .team.loss {
  color: #dc2626;
  font-weight: 600;
}

/* Make team rows clickable */
.group-standings tbody tr:not(.team-details-cell) {
  cursor: pointer;
}

.group-standings tbody tr:hover:not(.team-details-cell) {
  background-color: rgba(0, 0, 0, 0.03);
}

@media (max-width: 768px) {
  .team-details-panel .matches-history {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .team-details-panel .match-teams .team-name {
    font-size: 0.85rem;
  }

  .team-details-panel,
  .team-details-panel .position-history,
  .team-details-panel .past-matches,
  .team-details-panel .upcoming-matches {
    padding: 1rem;
  }
}

/* Position history tooltip */
.position-tooltip {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.position-tooltip p {
  margin: 0;
  font-size: 0.9rem;
  color: #64748b;
}

.position-tooltip .position {
  color: #0f172a;
  margin-top: 0.25rem;
}

.position-tooltip .position span {
  font-weight: 600;
  font-size: 1.1rem;
  color: #2563eb;
}

.league-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  cursor: pointer;
  margin: 0;
  font-size: 1.25rem;
}

.league-title:hover {
  background-color: #f9fafb;
}

.league-name {
  flex: 1;
}

.league-icon {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}

.dropdown-arrow {
  font-size: 0.875rem;
  transition: transform 0.2s ease;
}

.dropdown-arrow.open {
  transform: rotate(180deg);
}

.league-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background-color: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  z-index: 50;
}

.league-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  color: #374151;
  font-size: 1rem;
}

.league-option:hover {
  background-color: #f9fafb;
}

.league-option.active {
  background-color: #f3f4f6;
  font-weight: 500;
}

.league-option:first-child {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.league-option:last-child {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

/* Tab Panel Styles */
.tab-panel {
  margin-top: 1rem;
}

.tab-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.tab-button {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-size: 1rem;
  color: #6b7280;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
}

.tab-button:hover {
  color: #2563eb;
  background-color: #f3f4f6;
}

.tab-button.active {
  color: #2563eb;
  font-weight: 600;
  position: relative;
}

.tab-button.active::after {
  content: '';
  position: absolute;
  bottom: -0.5rem;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: #2563eb;
}

.tab-content {
  padding: 1rem 0;
}

/* ── About & Contact pages ── */

.page-container {
  width: 100%;
  min-height: calc(100vh - 60px);
  padding: 2rem;
  background-color: var(--background-color);
  display: flex;
  justify-content: center;
}

.page-content {
  max-width: 800px;
  width: 100%;
  background: var(--card-background);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.page-content h1 {
  color: var(--text-color);
  font-size: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.about-section, .contact-section {
  margin-bottom: 2.5rem;
}

.about-section h2, .contact-section h2 {
  color: var(--text-color);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.about-section p, .contact-section p {
  line-height: 1.6;
  color: var(--text-color);
  margin-bottom: 1rem;
}

.about-section ul {
  list-style-type: none;
  padding: 0;
}

.about-section li {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  position: relative;
}

.about-section li::before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
  position: absolute;
  left: 0;
}

.contact-form {
  margin-top: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.submit-button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.submit-button:hover {
  background-color: var(--primary-dark);
}

.submit-status {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 4px;
  text-align: center;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

.submit-status.success {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.submit-status.error {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .page-container {
    padding: 1rem;
  }

  .page-content {
    padding: 1.5rem;
  }
}

/* ── Footer ── */

.site-footer {
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: rgba(255, 255, 255, 0.9);
  padding: 2rem;
  margin-top: auto;
  width: 100%;
  min-width: 100%;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}

.footer-section h3 {
  color: white;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.footer-section p {
  font-size: 0.875rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.75);
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: white;
}

.footer-bottom {
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}
