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

:root {
  --green: #1a7a3c;
  --green-dark: #145e2e;
  --green-light: #e8f5ee;
  --gold: #e8a020;
  --gold-light: #fff8ec;
  --bg: #f4f5f7;
  --card-bg: #fff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.header-title h1 {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.header-title .subtitle {
  font-size: 0.68rem;
  opacity: 0.7;
  letter-spacing: 0.03em;
}

.sport-filter {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  background: rgba(0,0,0,0.15);
  border-radius: 24px;
  padding: 0.2rem;
}

.sport-btn {
  background: transparent;
  border: none;
  border-radius: 20px;
  padding: 0.28rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: rgba(255,255,255,0.75);
  transition: all 0.15s;
}

.sport-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }

.sport-btn.active {
  background: #fff;
  color: var(--green-dark);
  font-weight: 700;
}

.my-teams-btn {
  margin-left: 0.4rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25) !important;
  border-radius: 20px;
  padding: 0.28rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  transition: all 0.15s;
}

.my-teams-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.my-teams-btn.active { background: var(--gold); border-color: var(--gold) !important; color: #1a1a2e; font-weight: 700; }

.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 0.28rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ---- Body layout ---- */
.body-layout {
  display: flex;
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  align-items: flex-start;
  padding: 1rem 1rem 1rem 0;
  gap: 1rem;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
}

.sidebar-inner {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 0;
  overflow: hidden;
}

.watchlist-section {
  padding: 0 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.watchlist-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
}

.watchlist-heading {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.45rem;
  padding-top: 0.25rem;
}

.watchlist-list {
  list-style: none;
}

.watchlist-list li {
  margin-bottom: 1px;
}

/* Sport group header */
.sport-group { list-style: none; }

.sport-group-btn {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
}

.sport-group-btn:hover { background: var(--bg); }
.sport-group-btn.has-active { color: var(--green); }
.sport-group-btn.has-partial { color: var(--green); }

.sport-group-arrow {
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.15s;
  color: var(--muted);
}

.sport-group-arrow.open { transform: rotate(90deg); }

/* Collapsible competition list */
.sport-group-list {
  list-style: none;
  display: none;
  padding-left: 0.7rem;
}

.sport-group-list.open { display: block; }

/* Competition and team buttons */
.watchlist-btn {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s, color 0.12s;
  line-height: 1.3;
}

.watchlist-btn:hover { background: var(--bg); }

.watchlist-btn.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
}

.watchlist-empty {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.2rem 0.45rem;
  font-style: italic;
}

.team-add-form {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.team-input {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0.27rem 0.45rem;
  font-size: 0.78rem;
  outline: none;
  min-width: 0;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}

.team-input:focus { border-color: var(--green); background: #fff; }

.team-add-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 5px;
  width: 26px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s;
}

.team-add-btn:hover { background: var(--green-dark); }

.team-fav-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.team-fav-item .watchlist-btn {
  flex: 1;
  padding: 0.25rem 0.45rem;
}

.team-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}

.team-remove-btn:hover { color: #dc2626; background: #fee2e2; }

.clear-watchlist {
  display: block;
  width: calc(100% - 1.5rem);
  margin: 0.5rem 0.75rem 0.25rem;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 0.3rem;
  font-size: 0.73rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.clear-watchlist:hover { border-color: #dc2626; color: #dc2626; background: #fee2e2; }

/* ---- Main content ---- */
main {
  flex: 1;
  min-width: 0;
}

.loading, .empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  padding: 0 0.1rem;
}

.section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-count {
  background: var(--border);
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  letter-spacing: 0;
}

.toggle-btn {
  background: none;
  border: none;
  font-size: 0.72rem;
  color: var(--green);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.older-results-bar {
  margin: 0.4rem 0 0.9rem;
}

.show-results-btn {
  background: none;
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.show-results-btn:hover { background: var(--green); color: #fff; }

/* ---- Match rows ---- */
.match-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-bg);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

/* [badge comp date] | [home score away] | [venue] */
.match-card {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  gap: 0.5rem;
  padding: 0.48rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  transition: background 0.1s;
}

.match-card:hover { background: #fafafa; }

.match-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

/* Inner grid — score is the exact midpoint */
.match-teams {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  gap: 0.5rem;
  min-width: 280px;
}

.match-right {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.match-card:last-child { border-bottom: none; }

.match-card.status-live {
  border-left: 3px solid var(--gold);
  background: var(--gold-light);
}

.match-card.status-live:hover { background: #fff3dc; }

.match-card.watchlist-match { background: var(--green-light); }
.match-card.watchlist-match:hover { background: #ddf0e6; }

.match-card.status-live.watchlist-match {
  background: #fef6e4;
  border-left-color: var(--gold);
}

.sport-badge {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.comp {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-date {
  font-size: 0.71rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.team {
  font-weight: 600;
  font-size: 0.87rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team.home { text-align: right; }
.team.away { text-align: left; }
.team.fav  { color: var(--green); }

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}

.score {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  text-align: center;
  width: 100px;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.match-time {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  width: 44px;
  font-size: 0.87rem;
}

.match-venue {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-badge {
  display: inline-block;
  background: var(--gold);
  color: #7a4400;
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  animation: livepulse 1.8s ease-in-out infinite;
}

@keyframes livepulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---- Footer ---- */
footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .sidebar-toggle { display: block; }
  .sport-filter { margin-left: auto; }

  .body-layout { padding: 0.5rem; gap: 0; }

  .sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 100%;
    z-index: 200;
    background: rgba(0,0,0,0.45);
    padding: 3.5rem 1rem 1rem;
  }

  .sidebar.open { display: block; }

  .sidebar-inner {
    max-height: 100%;
    overflow-y: auto;
  }

  .match-card {
    grid-template-columns: auto auto;
    gap: 0.3rem;
    padding: 0.42rem 0.55rem;
  }

  .match-left, .match-right { display: none; }
  .match-teams { min-width: 0; }
  .score { width: 80px; }
  .match-time { width: 36px; }
}
