html {
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.admin-date-trigger {
  position: fixed;
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  opacity: 0;
  border: none;
  background: transparent;
  cursor: default;
  z-index: 100;
  padding: 0;
}

.admin-dialog {
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 0;
  background: #1e293b;
  color: #e2e8f0;
  max-width: calc(100vw - 2rem);
}

.admin-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

.admin-dialog form {
  margin: 0;
  padding: 1.25rem;
  min-width: 280px;
}

.admin-dialog h2 {
  margin: 0;
  font-size: 1.1rem;
  color: #f8fafc;
}

.admin-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-dialog-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: -0.25rem -0.25rem 0 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.admin-dialog-close:hover {
  background: #334155;
  color: #f8fafc;
}

.admin-section {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid #475569;
}

.admin-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.admin-section-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #e2e8f0;
  font-weight: 600;
}

.admin-date-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 1rem 0 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.admin-date-field input {
  background: #0f172a;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
}

.admin-date-status {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: #93c5fd;
}

.admin-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.admin-btn {
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid #475569;
}

.admin-btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.admin-btn.secondary {
  background: transparent;
  color: #cbd5e1;
}

header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
  border-bottom: 1px solid #334155;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  color: #f8fafc;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: #1e293b;
}

.tab {
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5e1;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

.tab:hover {
  background: #334155;
}

.tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

main:has(#standings.active) {
  max-width: 1260px;
}

body.bracket-view {
  overflow: hidden;
}

body.bracket-view main {
  max-width: none;
  padding: 0;
}

body.bracket-view .bracket-scroll {
  height: calc(100dvh - var(--app-chrome-height, 9.5rem));
  max-height: calc(100dvh - var(--app-chrome-height, 9.5rem));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.hint {
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 0;
}

#standings .hint {
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.toolbar label {
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar select {
  background: #1e293b;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
}

.progress {
  color: #93c5fd;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

/* Fixtures */
.fixture-group {
  margin-bottom: 1.5rem;
}

.fixture-group h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #93c5fd;
}

.fixture-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #334155;
}

.fixture-section > h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: #f8fafc;
}

.fixture {
  display: grid;
  grid-template-columns: 1fr auto auto auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #1e293b;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.fixture .team {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  min-width: 0;
}

.team-label.align-right {
  flex-direction: row-reverse;
  margin-left: auto;
}

.team-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-flag {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.standings-table .team-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.fixture .date {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-bottom: 0.15rem;
  line-height: 1.35;
}

.fixture .score-input {
  width: 3.5rem;
  text-align: center;
  background: #0f172a;
  border: 1px solid #475569;
  color: #f8fafc;
  border-radius: 4px;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem;
  -moz-appearance: textfield;
  appearance: textfield;
}

.fixture .score-input::-webkit-outer-spin-button,
.fixture .score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.fixture.past-played .score-input {
  background: #334155;
  border-color: #94a3b8;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.played-indicator {
  color: #94a3b8;
  font-size: 0.55rem;
  vertical-align: middle;
}

.fixture .vs {
  color: #cbd5e1;
  font-size: 0.8rem;
}

/* Standings */
.standings-grid {
  --standings-team-col: 8.75rem;
  --standings-stat-col: calc(2.25rem - 1px - 0.2rem);
  --standings-stat-padding-x: 0.25rem;
  --standings-card-width: calc(var(--standings-team-col) + 6 * var(--standings-stat-col) + 1rem);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(1rem + 4px);
}

.standings-table {
  width: 100%;
  min-width: 0;
  background: #1e293b;
  border-radius: 8px;
  overflow: hidden;
}

.standings-table h3 {
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: #334155;
  font-size: 0.9rem;
}

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

.standings-table th,
.standings-table td {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  text-align: center;
}

.standings-table th:first-child,
.standings-table td:first-child {
  width: var(--standings-team-col);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-align: left;
}

.standings-table th:not(:first-child),
.standings-table td:not(:first-child) {
  width: var(--standings-stat-col);
  padding-left: var(--standings-stat-padding-x);
  padding-right: var(--standings-stat-padding-x);
}

.standings-table th {
  color: #94a3b8;
  font-weight: 500;
  border-bottom: 1px solid #334155;
}

.standings-table tr.qualified td:first-child {
  color: #4ade80;
}

.standings-table tr.third-candidate td:first-child {
  color: #fbbf24;
}

/* Bracket — see bracket.css for ESPN-style tree */

@media (max-width: 1000px) {
  main:has(#standings.active) {
    max-width: 960px;
  }

  .standings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .tabs {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    gap: 0.4rem;
  }

  .tab {
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .fixture {
    grid-template-columns: 1fr auto auto auto 1fr;
    font-size: 0.8rem;
  }

  .standings-grid {
    grid-template-columns: 1fr;
  }

  .standings-table {
    width: 100%;
  }
}
