:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-row: #1c2128;
  --bg-row-hover: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2ea043;
  --accent-blue: #388bfd;
  --accent-gold: #d4a017;
  --prob-high: #3fb950;
  --prob-mid: #d29922;
  --prob-low: #484f58;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  margin: 0;
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-wrap: break-word;
}

html[lang="ko"] body {
  word-break: keep-all;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.header {
  background: linear-gradient(135deg, #1a2332 0%, #0d1117 60%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.header-inner h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 36rem;
}

.header-status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.85rem;
}

.refresh-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
  background: rgba(212, 160, 23, 0.12);
  border: 1px solid rgba(212, 160, 23, 0.35);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--accent-blue);
  color: #fff;
}

.btn-refresh {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s, transform 0.15s;
}

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

.btn-refresh:active {
  transform: rotate(90deg);
}

.refresh-cycle {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.85;
  white-space: nowrap;
}

.view-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
  display: flex;
  gap: 0.5rem;
}

.view-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn:hover {
  border-color: var(--accent-blue);
  color: var(--text);
}

.view-btn.active {
  background: var(--bg-row);
  border-color: var(--accent-blue);
  color: var(--text);
}

.results-container {
  display: grid;
  gap: 1.25rem;
}

.results-container.all-view {
  /* same grid as groups */
}

.schedule-container {
  display: grid;
  gap: 1.25rem;
}

.schedule-day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.schedule-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-row);
}

.schedule-date {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.schedule-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.schedule-list {
  background: var(--bg-card);
}

.schedule-match {
  padding: 0.75rem 1rem;
}

.schedule-match-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.schedule-time {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.schedule-phase {
  color: var(--text-muted);
}

.schedule-scoreboard {
  margin-bottom: 0.25rem;
}

.schedule-stadium {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-top: 0.15rem;
}

.filtered-out {
  display: none !important;
}

.match-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.match-row {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
  background: var(--bg-row);
}

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

.match-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.match-date {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}

.match-round {
  font-weight: 600;
  color: var(--text);
}

.match-time {
  white-space: nowrap;
}

.match-time-sep {
  opacity: 0.5;
}

.match-status {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.match-status.finished {
  background: rgba(46, 160, 67, 0.15);
  color: var(--prob-high);
}

.match-status.live {
  background: rgba(248, 81, 73, 0.15);
  color: #ff7b72;
}

.match-status.scheduled {
  background: rgba(139, 148, 158, 0.12);
  color: var(--text-muted);
}

.match-scoreboard {
  display: grid;
  gap: 0.35rem;
}

.match-team {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.match-team img {
  object-fit: contain;
}

.match-team-name {
  font-weight: 500;
  min-width: 0;
}

.match-team-score {
  font-weight: 700;
  font-size: 1rem;
  min-width: 1.5rem;
  text-align: right;
}

.match-team.winner .match-team-score {
  color: var(--prob-high);
}

.match-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.group-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.group-nav button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.group-nav button:hover {
  border-color: var(--accent-blue);
  color: var(--text);
}

.group-nav button.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.loading {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid #f85149;
  color: #ff7b72;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.groups-container {
  display: grid;
  gap: 1.25rem;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.group-card.filtered-out {
  display: none;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.group-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.group-progress {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-wrap {
  overflow-x: auto;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.standings-table th {
  text-align: left;
  padding: 0.6rem 0.5rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.standings-table th.num,
.standings-table td.num {
  text-align: center;
}

.standings-table th.prob {
  min-width: 90px;
}

.standings-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
  vertical-align: middle;
}

.standings-table tbody tr {
  background: var(--bg-row);
  transition: background 0.12s;
}

.standings-table tbody tr:hover {
  background: var(--bg-row-hover);
}

.team-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 140px;
}

.team-emblem {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.team-name {
  font-weight: 600;
  white-space: nowrap;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
}

.rank-badge.top {
  background: rgba(46, 160, 67, 0.25);
  color: var(--prob-high);
}

.rank-badge.third {
  background: rgba(210, 153, 34, 0.2);
  color: var(--prob-mid);
}

.prob-cell {
  min-width: 100px;
}

.prob-value {
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.prob-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.prob-bar-fill.high {
  background: linear-gradient(90deg, #238636, var(--prob-high));
}

.prob-bar-fill.mid {
  background: linear-gradient(90deg, #9e6a03, var(--prob-mid));
}

.prob-bar-fill.low {
  background: var(--prob-low);
}

.remaining-matches {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.remaining-matches strong {
  color: var(--text);
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer p {
  margin: 0.25rem 0;
}

.footer-note {
  font-size: 0.75rem;
}

.site-intro {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  padding: 1rem;
}

.site-intro-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.site-disclaimer {
  margin: 0 0 0.85rem;
  line-height: 1.55;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.prob-method {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-row);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
}

.prob-method summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.prob-method p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.prob-method ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.prob-method ol {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.prob-method li {
  margin: 0.25rem 0;
}

@media (max-width: 768px) {
  .header-inner h1 {
    font-size: 1.25rem;
  }

  .standings-table {
    font-size: 0.78rem;
  }

  .standings-table th.prob,
  .prob-cell {
    min-width: 72px;
  }

  .team-name {
    font-size: 0.82rem;
  }
}

@media (min-width: 900px) {
  .groups-container.all-view,
  .results-container.all-view {
    grid-template-columns: repeat(2, 1fr);
  }
}
