/* ------------------ THEME VARIABLES ------------------ */
:root {
  --bg-color: #061826;
  --card-bg: #0b2236;
  --text-color: #f5f5f5;
  --accent-color: #00b894;
  --border-color: #16344c;
  --row-even: #0f283d;
  --text-muted: #8a9ca8;
}

body.light {
  --bg-color: #f4f6f8;
  --card-bg: #ffffff;
  --text-color: #1e293b;
  --accent-color: #0f9f80;
  --border-color: #cbd5e1;
  --row-even: #f8fafc;
  --text-muted: #64748b;
}

/* ------------------ BASE STYLES ------------------ */
html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px 20px 0 20px;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

h1, h2, h3 {
  color: var(--text-color);
}

/* ------------------ NAVIGATION & THEME TOGGLE ------------------ */
.menu {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.menu a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.menu a:hover {
  opacity: 0.8;
}

.theme-btn {
  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px 8px;
  border-radius: 6px;
  margin-left: auto;
  color: var(--text-color);
}

/* ------------------ UI COMPONENTS ------------------ */
.hero {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.card {
  background: var(--card-bg);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
}

.card .meta {
  font-size: 0.85rem;
  margin: 5px 0;
  color: var(--text-color);
  opacity: 0.8;
}

.card .teams {
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.filter {
  color: var(--accent-color);
  cursor: pointer;
  text-decoration: underline;
}

.no-results {
  text-align: center;
  padding: 20px;
  color: var(--text-color);
  opacity: 0.6;
}

/* ------------------ TABLES & STANDINGS ------------------ */
.table-wrap {
  background: var(--card-bg);
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 25px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
}

tr:nth-child(even) {
  background: var(--row-even);
}

.stage-title, .group-title, .level-title {
  margin-top: 35px;
  margin-bottom: 15px;
  color: var(--accent-color);
}

/* Teams Grid Layout */
#teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

#teams .card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

#teams .card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
}

/* ------------------ FIXED MODAL COMPONENT ------------------ */
.modal {
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow-y: auto; 
  background-color: rgba(0, 0, 0, 0.7); 
  backdrop-filter: blur(4px);
  padding: 40px 10px;
  box-sizing: border-box;
}

.modal-content {
  background-color: var(--card-bg);
  color: var(--text-color);
  margin: 0 auto; 
  padding: 25px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 600px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  box-sizing: border-box;
  /* Prevent content overflow */
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.close-modal {
  color: var(--text-color);
  opacity: 0.6;
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10;
}

.close-modal:hover {
  opacity: 1;
}

.modal-header-block {
  display: flex;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
  margin-bottom: 15px;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  text-align: center;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--row-even);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.stat-box span {
  display: block;
  font-size: 0.8rem;
  opacity: 0.7;
}

.stat-box strong {
  font-size: 1.2rem;
  color: var(--accent-color);
}

.modal-match-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

/* ------------------ GLOBAL FOOTER STYLES ------------------ */
footer {
  margin-top: auto;
  padding: 20px 0;
  text-align: center;
  font-size: 0.9rem;
  border-top: 1px solid var(--border-color);
  opacity: 0.8;
}

footer a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

footer a:hover {
  text-decoration: underline;
}

/* Highlight rows for qualifying positions */
tr.qualify-row {
  background-color: rgba(0, 184, 148, 0.15) !important;
}
body.light tr.qualify-row {
  background-color: rgba(15, 159, 128, 0.12) !important;
}

/* Badge style for the 3rd place section */
.bubble-badge {
  font-size: 0.8rem;
  font-weight: bold;
  color: #fff;
  background-color: #f1c40f;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}