:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe3ea;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --pitch: #0f6b55;
  --pitch-dark: #0b493d;
  --blue: #2563eb;
  --red: #dc2626;
  --gold: #d97706;
  --green: #059669;
  --violet: #7c3aed;
  --shadow: 0 12px 32px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 107, 85, 0.14), rgba(247, 248, 244, 0) 280px),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-root {
  min-height: 100vh;
}

.loading,
.login-wrap {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 8px;
}

.login-panel p,
.muted {
  color: var(--muted);
}

.login-panel p {
  margin: 0 0 22px;
}

.form-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

label {
  color: #334155;
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn,
.tab-btn {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-btn {
  background: var(--pitch);
  color: #fff;
}

.secondary-btn {
  background: #e9f1ee;
  color: var(--pitch-dark);
}

.danger-btn {
  background: #fee2e2;
  color: #991b1b;
}

.ghost-btn,
.tab-btn {
  background: transparent;
  color: #334155;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover,
.ghost-btn:hover,
.tab-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.danger-btn:disabled,
.team-card:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.shell {
  margin: 0 auto;
  max-width: 1260px;
  padding: 20px;
}

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

.brand h1 {
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0;
}

.brand p {
  color: var(--muted);
  margin: 4px 0 0;
}

.user-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.avatar {
  align-items: center;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  overflow: hidden;
  width: 34px;
}

.avatar img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.user-pill,
.owner-pill,
.score-pill,
.stage-pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 7px;
  min-height: 34px;
  padding: 4px 10px 4px 5px;
  white-space: nowrap;
}

.owner-pill {
  background: #fff;
  font-size: 12px;
  min-height: 28px;
  padding: 3px 8px 3px 4px;
}

.score-pill {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 850;
  min-height: 30px;
  padding: 3px 10px;
}

.stage-pill {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  min-height: 26px;
  padding: 3px 8px;
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.tab-btn {
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

.message {
  border-radius: 8px;
  font-weight: 750;
  margin: 0 0 16px;
  padding: 11px 13px;
}

.message.success {
  background: #dcfce7;
  color: #166534;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.panel {
  box-shadow: none;
  padding: 18px;
}

.panel h2,
.panel h3 {
  letter-spacing: 0;
  margin: 0;
}

.panel h2 {
  font-size: 22px;
}

.panel h3 {
  font-size: 17px;
}

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

.current-turn {
  background: linear-gradient(135deg, #0f6b55, #123a55);
  border: 0;
  color: #fff;
}

.current-turn .muted {
  color: rgba(255, 255, 255, 0.78);
}

.turn-name {
  align-items: center;
  display: flex;
  font-size: 28px;
  font-weight: 900;
  gap: 10px;
  margin: 8px 0 4px;
}

.draft-strip {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.draft-token {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: #fff;
  flex: 0 0 auto;
  min-width: 92px;
  padding: 8px;
}

.draft-token.current {
  background: #fff;
  color: var(--pitch-dark);
}

.draft-token strong,
.draft-token span {
  display: block;
}

.draft-token span {
  font-size: 12px;
  opacity: 0.78;
}

.controls {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(200px, 1fr) 130px 160px 150px;
  margin-bottom: 14px;
}

.team-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(182px, 1fr));
}

.team-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  min-height: 104px;
  padding: 12px;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.team-card:hover:not(:disabled) {
  border-color: var(--pitch);
  box-shadow: 0 8px 18px rgba(15, 107, 85, 0.12);
  transform: translateY(-2px);
}

.team-card.drafted {
  background: #f8fafc;
}

.team-main {
  align-items: center;
  display: flex;
  gap: 10px;
}

.flag {
  font-size: 28px;
  line-height: 1;
}

.team-name {
  display: block;
  font-weight: 900;
}

.team-code {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-top: 2px;
}

.owner-line {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 7px;
  margin-top: 13px;
  min-height: 26px;
}

.pick-list {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.order-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
}

.order-token {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 58px;
  padding: 7px;
}

.order-token span,
.order-token strong,
.order-token em {
  display: block;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-token span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.order-token strong {
  font-size: 12px;
}

.order-token em {
  color: var(--pitch);
  font-size: 11px;
  font-weight: 900;
  margin-top: 2px;
}

.order-token.current {
  background: #ecfdf5;
  border-color: var(--pitch);
}

.order-token.picked {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.pick-row,
.leader-row,
.match-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pick-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 44px 1fr auto;
  padding: 10px;
}

.pick-number {
  align-items: center;
  background: #f1f5f9;
  border-radius: 6px;
  display: flex;
  font-weight: 900;
  height: 38px;
  justify-content: center;
}

.empty-state {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  padding: 20px;
}

.leader-list {
  display: grid;
  gap: 11px;
}

.leader-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 54px 1fr auto;
  padding: 14px;
}

.rank {
  align-items: center;
  background: #f1f5f9;
  border-radius: 8px;
  display: flex;
  font-size: 20px;
  font-weight: 950;
  justify-content: center;
}

.leader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.team-chip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.points-block {
  align-self: center;
  text-align: right;
}

.points-block strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.schedule-list {
  display: grid;
  gap: 10px;
}

.match-row {
  padding: 13px;
}

.match-top {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.match-title {
  align-items: center;
  display: grid;
  gap: 4px;
}

.match-title strong {
  font-size: 15px;
}

.match-teams {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.team-side {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 58px;
  min-width: 0;
  padding: 9px;
}

.team-side.away {
  justify-content: flex-end;
  text-align: right;
}

.team-side .flag {
  flex: 0 0 auto;
}

.team-side-text {
  min-width: 0;
}

.team-side-text strong,
.team-side-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.versus,
.scoreline {
  align-items: center;
  background: #172033;
  border-radius: 6px;
  color: #fff;
  display: flex;
  font-weight: 900;
  justify-content: center;
  min-height: 42px;
  min-width: 58px;
  padding: 7px 9px;
}

.scoreline {
  background: #0f6b55;
}

.admin-editor {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.admin-editor summary {
  cursor: pointer;
  font-weight: 850;
}

.admin-grid,
.settings-grid,
.profile-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.admin-grid .wide,
.settings-grid .wide,
.profile-grid .wide {
  grid-column: span 2;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 42px;
}

.checkbox-row input {
  min-height: 18px;
  width: 18px;
}

.admin-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.source-list {
  color: var(--muted);
  margin: 8px 0 0;
  padding-left: 18px;
}

.source-list li {
  margin: 4px 0;
}

.admin-stack {
  display: grid;
  gap: 16px;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.46);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.confirm-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 20px;
  width: 100%;
}

.confirm-dialog h2 {
  font-size: 25px;
  margin: 4px 0 8px;
}

.confirm-dialog p {
  margin: 0;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .panel-head,
  .match-top {
    align-items: stretch;
    flex-direction: column;
  }

  .user-tools {
    justify-content: flex-start;
  }

  .controls,
  .admin-grid,
  .settings-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .admin-grid .wide,
  .settings-grid .wide,
  .profile-grid .wide {
    grid-column: span 1;
  }

  .match-teams {
    grid-template-columns: 1fr;
  }

  .team-side.away {
    justify-content: flex-start;
    text-align: left;
  }

  .versus,
  .scoreline {
    width: 100%;
  }

  .leader-row {
    grid-template-columns: 44px 1fr;
  }

  .points-block {
    grid-column: 1 / -1;
    text-align: left;
  }
}
