:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --panel-2: #eef4ef;
  --ink: #17211e;
  --muted: #66736e;
  --line: #dfe6df;
  --brand: #0b6b57;
  --brand-2: #c52f36;
  --gold: #d59c2a;
  --blue: #2168a6;
  --shadow: 0 18px 50px rgba(23, 33, 30, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(11, 107, 87, 0.1), transparent 26rem),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.72fr);
  gap: 28px;
  padding: 32px 0;
}

.brand-panel {
  align-self: center;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background: #0b3d2c;
  box-shadow: var(--shadow);
}

.brand-hero-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: contain;
}

.login-card,
.panel,
.match-card,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 33, 30, 0.08);
}

.login-card {
  padding: 24px;
}

.login-card h2,
.panel h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.field label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.score-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.field input:focus,
.field select:focus,
.score-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 107, 87, 0.16);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  font-weight: 800;
}

.button.secondary {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.warn {
  background: var(--brand-2);
}

.button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.money-toggle {
  font-size: 1.06rem;
}

.money-toggle.active,
.money-badge {
  border-color: var(--gold);
  background: rgba(213, 156, 42, 0.18);
  color: #8a5a00;
}

.icon-button .btn-icon svg {
  width: 19px;
  height: 19px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  background: rgba(246, 247, 242, 0.9);
  backdrop-filter: blur(16px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.wordmark h1 {
  margin: 0;
  font-size: 1.05rem;
}

.wordmark span,
.user-pill {
  color: var(--muted);
  font-size: 0.86rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0 18px;
}

.summary-card {
  min-height: 96px;
  padding: 15px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.nav-tabs,
.group-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar,
.group-tabs::-webkit-scrollbar {
  display: none;
}

.tab,
.chip {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active,
.chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}

.toolbar .field {
  min-width: 180px;
}

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

.match-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.match-meta,
.result-row,
.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.78rem;
}

.badge.good {
  background: rgba(11, 107, 87, 0.12);
  color: var(--brand);
}

.badge.gold {
  background: rgba(213, 156, 42, 0.15);
  color: #8a5a00;
}

.teams {
  display: grid;
  gap: 10px;
}

.team-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
}

.team-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.score-input {
  text-align: center;
  font-weight: 900;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions .button {
  flex: 1;
  min-width: 0;
}

.panel {
  padding: 16px;
}

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

.standings-toolbar h2 {
  margin: 0;
}

.segment-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.segment-control button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-weight: 850;
}

.segment-control button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23, 33, 30, 0.08);
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.money-badge {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 900;
}

.admin-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
}

.admin-card {
  padding: 14px;
}

.admin-results {
  display: grid;
  gap: 10px;
}

.admin-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 64px 64px auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  transform: translateX(-50%) translateY(120%);
  width: min(420px, calc(100% - 32px));
  border-radius: 8px;
  background: #17211e;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal {
  width: min(560px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 33, 30, 0.42);
}

.modal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#picksBody {
  padding: 14px;
}

.pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.pick-row:last-child {
  border-bottom: 0;
}

.pick-score {
  font-weight: 900;
}

@media (max-width: 860px) {
  .login-screen {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .login-card {
    order: -1;
  }

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

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

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

  .topbar {
    align-items: center;
  }

  .top-actions {
    align-items: center;
  }

  .user-pill {
    max-width: 140px;
  }

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

  .card-actions .button[data-action="random-score"] {
    grid-column: 1 / -1;
  }

  .standings-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segment-control {
    width: 100%;
  }

  .segment-control button {
    flex: 1;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-result-row {
    grid-template-columns: 1fr 58px 58px;
  }

  .admin-result-row .button {
    grid-column: 1 / -1;
  }
}
