:root {
  --bg-main: #060911;
  --bg-card: #0c1220;
  --bg-card-hover: #131b2e;
  --bg-elevated: #1a2338;
  --border-color: #273449;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-red: #e11d48;
  --accent-red-hover: #be123c;
  --accent-crimson: #9f1239;
  --accent-gold: #f59e0b;
  --accent-gold-light: #fbbf24;
  --accent-green: #22c55e;
  --badge-live: #e11d48;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  background: rgba(12, 18, 32, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.75rem 1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.4);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.brand-text span {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: all 0.15s ease;
  background: var(--bg-elevated);
  color: var(--text-main);
  text-decoration: none;
}

.btn:hover {
  background: #243048;
  border-color: #3b4b66;
}

.btn-primary {
  background: #2563eb;
  color: white;
  border: 1px solid #3b82f6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  background: #1d4ed8;
  border-color: #60a5fa;
}

.btn-icon {
  padding: 0.45rem;
  min-width: 34px;
  justify-content: center;
}

.btn.active {
  background: #1e293b;
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

/* Toolbar */
.toolbar {
  max-width: 1400px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}

.filter-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  gap: 0.2rem;
}

.filter-tab {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.filter-tab:hover {
  color: var(--text-main);
}

.filter-tab.active {
  background: var(--bg-elevated);
  color: #ffffff;
  border: 1px solid #3b4b66;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.date-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-select {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.date-select:focus {
  border-color: var(--accent-red);
}

.refresh-indicator {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.refresh-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  display: inline-block;
}

.refresh-indicator.refreshing .dot {
  background: var(--accent-gold);
  animation: pulse 1s infinite;
}

/* Main Container */
.main-content {
  max-width: 1400px;
  margin: 1rem auto;
  padding: 0 1rem;
  flex: 1;
  width: 100%;
}

/* Grid */
.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.25rem;
  margin-top: 0.75rem;
  align-items: start;
}

@media (max-width: 480px) {
  .matches-grid {
    grid-template-columns: 1fr;
  }
}

/* Match Card */
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.match-card:hover {
  border-color: #3b4b66;
}

.match-card.is-live {
  border-color: rgba(225, 29, 72, 0.7);
  box-shadow: 0 0 25px rgba(225, 29, 72, 0.22), var(--card-shadow);
}

.match-card-header {
  padding: 0.75rem 1rem;
  background: rgba(26, 35, 56, 0.6);
  border-bottom: 1px solid rgba(39, 52, 73, 0.7);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 46px;
}

.league-info {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-live {
  background: rgba(225, 29, 72, 0.25);
  color: #fda4af;
  border: 1px solid rgba(225, 29, 72, 0.6);
  box-shadow: 0 0 10px rgba(225, 29, 72, 0.3);
}

.status-live .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
  animation: pulseLive 1.4s infinite;
}

@keyframes pulseLive {
  0% { transform: scale(0.95); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(0.95); opacity: 1; }
}

.status-scheduled {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.status-finished {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Card Score Section */
.match-score-section {
  padding: 1.25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.teams-scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  min-height: 52px;
}

.team-box {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  min-height: 48px;
  justify-content: center;
  transition: background 0.15s ease;
}

.team-box.has-altdorf {
  background: rgba(225, 29, 72, 0.1);
  border: 1px solid rgba(225, 29, 72, 0.3);
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.1);
}

.team-box.home {
  text-align: right;
}

.team-box.away {
  text-align: left;
}

.team-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.team-name.is-altdorf {
  color: #ffffff;
  font-weight: 800;
}

.team-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.score-display {
  background: #040711;
  border: 1px solid #273449;
  border-radius: 10px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 95px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.score-digits {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1;
}

.score-digits.leading {
  color: #22c55e;
  text-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
}

.score-divider {
  font-size: 1.4rem;
  color: var(--text-dim);
  font-weight: 300;
}

.score-sub {
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Live Active Game Highlight */
.live-active-match {
  margin: 0.5rem 1rem 0;
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.15), rgba(15, 23, 42, 0.3));
  border: 1px solid rgba(225, 29, 72, 0.4);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 0 12px rgba(225, 29, 72, 0.12);
}

.active-match-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fda4af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.active-players {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
}

.active-sets-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}

.set-pill {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  background: rgba(26, 35, 56, 0.85);
  border: 1px solid #3b4b66;
  color: var(--text-muted);
}

.set-pill.current {
  background: rgba(225, 29, 72, 0.3);
  border-color: var(--accent-red);
  color: #ffffff;
  font-weight: 800;
  animation: pulseSubtle 2s infinite;
}

@keyframes pulseSubtle {
  0% { opacity: 1; }
  50% { opacity: 0.75; }
  100% { opacity: 1; }
}

/* Card Footer & Accordion Toggle */
.match-card-footer {
  margin-top: auto;
  padding: 0.65rem 1rem;
  border-top: 1px solid rgba(39, 52, 73, 0.7);
  background: rgba(12, 18, 32, 0.7);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}

.venue-info {
  font-size: 0.73rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
}

.toggle-details-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.toggle-details-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  text-decoration: none;
}

/* Match Details Drawer */
.match-details-drawer {
  border-top: 1px solid var(--border-color);
  background: #080c16;
  display: none;
  padding: 0.75rem;
}

.match-details-drawer.open {
  display: block;
}

.games-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.games-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}

.games-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(39, 52, 73, 0.4);
  vertical-align: middle;
}

.game-row:last-child td {
  border-bottom: none;
}

.game-row.is-running {
  background: rgba(225, 29, 72, 0.1);
}

.game-name {
  font-weight: 700;
  color: var(--text-muted);
  width: 38px;
}

.game-players {
  font-weight: 600;
}

.game-sets {
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.game-winner {
  font-family: var(--font-mono);
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.game-winner.won-home {
  color: #4ade80;
}

.game-winner.won-away {
  color: #f87171;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--accent-crimson);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(26, 35, 56, 0.4);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: white;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-red);
}

.form-help {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  background: rgba(12, 18, 32, 0.8);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: #1a2338;
  color: white;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border-left: 4px solid var(--accent-gold);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
  pointer-events: auto;
  animation: slideIn 0.25s ease;
}

.toast.live-alert {
  border-left-color: var(--accent-red);
  background: #2a1017;
}

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