/* === Reset & Basis === */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, .card-title, .season-name {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('../img/logo-bg.png') repeat;
  z-index: -1;
  opacity: var(--bg-pattern-opacity, 0.1);
  filter: var(--bg-pattern-filter, none);
  transition: opacity 0.4s, filter 0.4s;
}

a {
  color: var(--link, var(--primary));
  text-decoration: underline;
  cursor: pointer;
}

a:visited {
  color: var(--link, var(--primary));
}

a:hover {
  text-decoration: none;
  opacity: .8;
}

h2 {
  margin-bottom: 1.5rem;
}


/* === Header === */
header {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-alt) 100%);
  border-bottom: 2px solid var(--primary);
  box-shadow: 0 2px 20px color-mix(in srgb, var(--primary) 8%, transparent);
  padding: 1rem 2rem;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 769px) {
  header {
    position: sticky;
    top: 0;
  }
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

header p {
  margin: .25rem 0 0;
  color: var(--muted);
}


/* === Burger Menu === */
.burger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
}

.burger-btn span {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: all .3s;
}

.burger-btn.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.burger-btn.open span:nth-child(2) {
  opacity: 0;
}

.burger-btn.open span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}


/* === Dark Mode Toggle === */
.dark-mode-toggle {
  appearance: none;
  cursor: pointer;
  width: 50px;
  height: 28px;
  background: var(--border);
  border: none;
  border-radius: 14px;
  position: relative;
  transition: background .3s;
}

.dark-mode-toggle::before {
  content: "☀️";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  transition: left .3s;
}

.dark-mode-toggle::after {
  content: "🌙";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0;
  transition: opacity .3s;
}

.dark-mode-toggle:checked {
  background: var(--primary);
}

.dark-mode-toggle:checked::before {
  opacity: 0;
}

.dark-mode-toggle:checked::after {
  opacity: 1;
}


/* === Menu Overlay & Nav Panel === */
.menu-overlay {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, .5);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}

.menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

nav {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100vh;
  background: var(--card);
  z-index: 100;
  transition: right .3s;
  padding: 5rem 2rem 2rem;
  box-shadow: -4px 0 24px rgba(0, 0, 0, .1);
  overflow-y: auto;
}

nav.open {
  right: 0;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

nav a {
  text-decoration: none;
  color: var(--text);
  padding: .75rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  display: block;
  transition: background .2s;
}

nav a:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
}

nav a.active {
  background: color-mix(in srgb, var(--primary) 15%, var(--card));
  color: var(--primary);
  font-weight: 700;
}


/* === Layout === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}


/* === Cards === */
.card {
  background: linear-gradient(145deg, var(--card) 0%, var(--card-alt) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-top: 2px solid var(--primary);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .10), 0 4px 16px rgba(0, 0, 0, .10), inset 0 1px 0 color-mix(in srgb, var(--primary) 15%, transparent);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .75rem;
}

.card-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.card-sub {
  color: var(--muted);
  font-size: .9rem;
}

.card h2 {
  padding-bottom: .5rem;
  border-bottom: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  margin-bottom: 1rem;
}


/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: .75rem;
  font-size: .85rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: .5rem .6rem;
  border-bottom: 2px solid var(--border);
}

td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

tr:hover td {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

tr.leader {
  font-weight: 700;
  color: var(--primary);
}

tr.leader td {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}


/* === Match Score === */
.match-score {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: 0.05em;
  padding: .2rem .6rem;
  border-radius: 6px;
  background: var(--primary);
  color: var(--bg);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent);
}


/* === Utilities === */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}


/* === Season Items === */
.season-item {
  padding: .5rem 1rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all .2s;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: .9rem;
  white-space: nowrap;
}

.season-item:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.season-item.active {
  background: color-mix(in srgb, var(--primary) 15%, var(--card));
  color: var(--primary);
  font-weight: 600;
  border-color: var(--primary);
}


/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  opacity: .85;
}

.btn-danger {
  background: var(--danger, #dc2626);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  opacity: .85;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--card-alt);
}


/* === Footer === */
footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  margin-top: 3rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
}

.footer-left {
  text-align: left;
}

.footer-center {
  text-align: center;
}

.footer-right {
  text-align: right;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer a:visited {
  color: var(--primary);
}

.backend-status {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: #3fb950;
}

.status-dot.offline {
  background: #dc2626;
}

#theme-select {
  padding: .35rem .6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: .8rem;
  cursor: pointer;
}

#theme-select:focus {
  outline: none;
  border-color: var(--primary);
}

@media (max-width: 768px) {
  footer {
    grid-template-columns: 1fr;
    gap: 1rem;
    text-align: center;
  }

  .footer-left, .footer-right {
    text-align: center;
  }
}
