:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(7, 18, 32, 0.78);
  --panel-strong: rgba(9, 24, 42, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f7fbff;
  --muted: rgba(247, 251, 255, 0.68);
  --soft: rgba(247, 251, 255, 0.48);
  --green: #30d987;
  --blue: #4aa3ff;
  --gold: #f7c948;
  --red: #ff5b68;
  --orange: #ff9b54;
  --magenta: #df70ff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
  overflow: hidden;
  padding: 22px;
}

.app-shell::before {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";
  background:
    linear-gradient(180deg, rgba(7, 17, 31, 0.2), rgba(7, 17, 31, 0.96) 80%),
    radial-gradient(circle at 74% 16%, rgba(74, 163, 255, 0.26), transparent 36%),
    radial-gradient(circle at 12% 78%, rgba(48, 217, 135, 0.18), transparent 34%),
    #07111f;
}

#pitchCanvas {
  position: fixed;
  inset: 0;
  z-index: -4;
  width: 100vw;
  height: 100vh;
  opacity: 0.72;
}

.topbar,
.match-center,
.tabbar,
.view-panel {
  width: min(1180px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 800;
}

.brand-mark {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.brand-mark::after {
  position: absolute;
  right: -8px;
  bottom: -10px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  content: "";
}

.mark-dot,
.mark-i,
.mark-l {
  position: absolute;
  display: block;
}

.mark-dot {
  top: 8px;
  left: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.mark-i {
  top: 20px;
  left: 11px;
  width: 7px;
  height: 15px;
  border-radius: 999px;
  background: var(--text);
}

.mark-l {
  right: 8px;
  bottom: 8px;
  width: 17px;
  height: 24px;
  border-left: 7px solid var(--green);
  border-bottom: 7px solid var(--blue);
  border-radius: 0 0 2px 6px;
}

.brand-word {
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.select-label {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.matchday-select,
.player-select,
.search-input {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}

.player-select {
  width: min(360px, 100%);
}

.search-input {
  width: min(240px, 100%);
}

.sync-pill,
.panel-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.sync-pill.is-success,
.status-pill.is-in {
  border-color: rgba(48, 217, 135, 0.42);
  background: rgba(48, 217, 135, 0.12);
  color: #8ff0c0;
}

.sync-pill.is-warning,
.status-pill.is-wait {
  border-color: rgba(247, 201, 72, 0.42);
  background: rgba(247, 201, 72, 0.12);
  color: #f9dc7b;
}

.sync-pill.is-error,
.status-pill.is-out {
  border-color: rgba(255, 91, 104, 0.42);
  background: rgba(255, 91, 104, 0.12);
  color: #ff9aa3;
}

.match-center {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: end;
  padding: 44px 0 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 14px;
  font-size: clamp(3.2rem, 10vw, 7.8rem);
  line-height: 0.92;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

h3 {
  margin-bottom: 8px;
  font-size: clamp(1.55rem, 3vw, 2.4rem);
  line-height: 1;
}

.match-copy p:last-child,
.quiet-note,
.status-card p,
.score-card p {
  max-width: 700px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 700;
}

.metric-grid,
.mini-metrics,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-grid article,
.mini-metrics article,
.admin-card {
  min-height: 92px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 14px;
  background: rgba(9, 24, 42, 0.82);
}

.metric-grid span,
.mini-metrics span,
.admin-card span,
.card-title-row > span,
.team-card-head > span,
.queue-row > div > span,
.match-card > div > span {
  display: block;
  margin-bottom: 12px;
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-grid strong,
.mini-metrics strong,
.admin-card strong {
  display: block;
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(6, 16, 29, 0.78);
  backdrop-filter: blur(20px);
  overflow-x: auto;
}

.tab-btn,
.filter-chip {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-btn {
  flex: 1 0 auto;
  min-height: 38px;
  padding: 0 14px;
}

.tab-btn.is-active,
.filter-chip.is-active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
}

.view-panel {
  display: none;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(24px);
}

.view-panel.is-active {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.week-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
}

.status-card,
.score-card {
  min-height: 280px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-strong);
}

.status-card .status-pill {
  margin-bottom: 22px;
}

.mini-metrics {
  margin-top: 18px;
}

.code-field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.code-field span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.code-field input {
  min-height: 48px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
  outline: none;
}

.code-field input:focus {
  border-color: rgba(48, 217, 135, 0.58);
  box-shadow: 0 0 0 4px rgba(48, 217, 135, 0.1);
}

.code-field input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.checkin-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 800;
}

.primary-action {
  background: rgba(48, 217, 135, 0.16);
}

.secondary-action {
  background: rgba(255, 255, 255, 0.07);
}

.primary-action.is-active {
  border-color: rgba(48, 217, 135, 0.7);
  background: var(--green);
  color: #06101b;
}

.secondary-action.is-active {
  border-color: rgba(255, 91, 104, 0.7);
  background: rgba(255, 91, 104, 0.22);
  color: #ffd8dc;
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.action-note {
  margin: 12px 0 0;
  color: var(--soft);
  font-size: 0.9rem;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row strong {
  color: var(--text);
  text-align: right;
}

.score-list,
.match-list,
.queue-list,
.teams-grid {
  display: grid;
  gap: 10px;
}

.scoreline,
.match-card,
.queue-row,
.team-card,
.empty-state {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.scoreline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px;
}

.scoreline strong {
  font-size: 1.2rem;
}

.away {
  text-align: right;
}

.team-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}

.team-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.team-blue { background: var(--blue); }
.team-green { background: var(--green); }
.team-orange { background: var(--orange); }
.team-magenta { background: var(--magenta); }

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

.team-card {
  padding: 14px;
}

.team-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.team-card-head strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
}

.player-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 0;
}

.player-line:first-child {
  border-top: 0;
}

.player-line strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-line small,
.queue-row small,
.match-card small {
  color: var(--soft);
  font-weight: 700;
}

.tier-chip {
  border-radius: 999px;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.tier-core {
  background: rgba(247, 201, 72, 0.14);
  color: #f9dc7b;
}

.tier-flex {
  background: rgba(48, 217, 135, 0.12);
  color: #8ff0c0;
}

.tier-sub {
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.queue-row,
.match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 14px;
}

.queue-rank {
  font-size: 1.3rem;
  font-weight: 800;
}

.filter-row,
.table-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.filter-chip {
  min-height: 34px;
  padding: 0 11px;
}

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

.standings-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.standings-table th,
.standings-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

.standings-table th {
  color: var(--soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.standings-table td {
  font-weight: 800;
}

.standings-table td:not(:nth-child(2)),
.standings-table th:not(:nth-child(2)) {
  text-align: center;
}

.match-card strong {
  font-size: 1.25rem;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
}

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

.builder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.builder-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-strong);
}

.builder-card-wide {
  grid-column: 1 / -1;
}

.builder-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.publish-action {
  grid-column: 1 / -1;
}

.admin-list,
.admin-roster-lists,
.admin-team-preview {
  display: grid;
  gap: 10px;
}

.admin-list-row,
.admin-list-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.admin-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px;
}

.admin-list-row span,
.admin-team-meta span {
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-list-row strong {
  font-size: 1.25rem;
}

.admin-team-preview,
.admin-roster-lists {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-team-card,
.admin-list-card {
  padding: 14px;
}

.admin-team-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-team-meta span {
  border-radius: 999px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.07);
}

.admin-player-line small {
  display: block;
  margin-top: 3px;
}

.admin-edit-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.admin-edit-controls label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-edit-controls label span {
  color: var(--soft);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-edit-controls select {
  min-height: 34px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  outline: none;
}

.admin-edit-controls select:focus {
  border-color: rgba(74, 163, 255, 0.58);
  box-shadow: 0 0 0 3px rgba(74, 163, 255, 0.1);
}

.admin-edit-controls select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .match-center,
  .week-grid,
  .section-head {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .player-select,
  .search-input {
    width: 100%;
  }

  .filter-row,
  .table-tools {
    justify-content: flex-start;
  }

  .admin-grid,
  .builder-grid,
  .admin-team-preview,
  .admin-roster-lists {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    display: grid;
  }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .tab-btn {
    min-width: 0;
    padding: 0 8px;
  }

  .match-center {
    padding-top: 26px;
  }

  .metric-grid,
  .mini-metrics,
  .teams-grid,
  .admin-grid,
  .builder-grid,
  .admin-team-preview,
  .admin-roster-lists,
  .builder-actions {
    grid-template-columns: 1fr;
  }

  .checkin-actions {
    grid-template-columns: 1fr;
  }

  .view-panel {
    padding: 14px;
  }

  .status-card,
  .score-card {
    min-height: 0;
    padding: 14px;
  }

  .scoreline {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .away {
    text-align: left;
  }

  .admin-player-line {
    align-items: flex-start;
  }

  .admin-edit-controls {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(3rem, 19vw, 4.4rem);
  }
}
