:root {
  color-scheme: light;

  --bg: #f4f6f2;
  --ink: #1b1f1e;
  --muted: #5c6b66;
  --card: #ffffff;
  --surface-2: #f8faf7;
  --surface-3: #eef3ee;
  --border: #dce5dd;
  --shadow: 0 12px 30px rgba(20, 40, 30, 0.10);
  --placeholder: rgba(27, 31, 30, 0.45);

  --accent: #1f9d55;
  --accent-2: #2a6fdb;
  --danger: #d64545;
  --warn: #f2c94c;
  --focus: rgba(31, 157, 85, 0.22);

  --name-row-h: 56px;
  --name-row-gap: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(900px circle at 15% 0%, rgba(31, 157, 85, 0.18), transparent 55%),
    radial-gradient(900px circle at 110% 10%, rgba(42, 111, 219, 0.12), transparent 58%),
    repeating-linear-gradient(
      90deg,
      rgba(31, 157, 85, 0.04) 0 60px,
      rgba(31, 157, 85, 0.02) 60px 120px
    ),
    var(--bg);
  color: var(--ink);
}

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

a:hover {
  text-decoration: underline;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(18px, 3.2vw, 40px) clamp(14px, 2.4vw, 28px) calc(56px + env(safe-area-inset-bottom, 0px));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(42, 111, 219, 0.35);
  background: linear-gradient(135deg, rgba(42, 111, 219, 0.16), rgba(31, 157, 85, 0.10));
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, filter 120ms ease;
}

.admin-btn:hover {
  text-decoration: none;
  filter: brightness(1.03);
}

.admin-btn:active { transform: translateY(1px); }

.admin-btn:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(42, 111, 219, 0.20);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  font-size: clamp(30px, 4.1vw, 48px);
  margin: 6px 0 8px;
  letter-spacing: -0.01em;
}

.sub { margin: 0; color: var(--muted); }

h2 {
  font-size: clamp(20px, 2.2vw, 28px);
  letter-spacing: -0.01em;
}

.status-chip {
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
}

.status-chip.open { color: var(--accent); }
.status-chip.locked { color: var(--warn); }

.content-switch {
  position: relative;
}

.view-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.view-toggle {
  display: none;
  position: sticky;
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 50;
  width: 100%;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  gap: 6px;
  padding: 6px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.view-tab {
  flex: 1;
  text-align: center;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.view-tab:active { transform: translateY(1px); }

#view-signup:checked ~ .view-toggle label[for="view-signup"],
#view-info:checked ~ .view-toggle label[for="view-info"] {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 12px 26px rgba(20, 40, 30, 0.10);
}

.panels {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(320px, 0.95fr);
  gap: 20px;
  align-items: start;
}

.panel { min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(16px, 2.2vw, 22px);
  box-shadow: var(--shadow);
}

.card h2 { margin-top: 0; }

.card.stats {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 20px;
}

.stats-line {
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.stat {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.stat-total { color: var(--ink); }
.stat-yes { color: #0f6a3a; border-color: rgba(31, 157, 85, 0.30); background: rgba(31, 157, 85, 0.12); }
.stat-wait { color: #7a5b2f; border-color: rgba(242, 201, 76, 0.40); background: rgba(242, 201, 76, 0.18); }
.stat-no { color: #8f1f1f; border-color: rgba(214, 69, 69, 0.35); background: rgba(214, 69, 69, 0.12); }
.stat-pending { color: var(--muted); border-color: var(--border); background: var(--surface-3); }

.stat-spots {
  font-weight: 900;
}

.stat-number {
  font-size: 18px;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

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

label { display: grid; gap: 6px; font-weight: 600; }

input, select, button {
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
}

input::placeholder {
  color: var(--placeholder);
}

input:focus, select:focus, button:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
  border-color: rgba(31, 157, 85, 0.55);
}

.small {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.name-picker {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.name-list {
  display: grid;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 6px;
  align-content: start;
}

.name-card {
  display: flex;
  flex-direction: column;
  height: clamp(460px, 72vh, 860px);
  min-height: 0;
}

.roster-card {
  min-height: 0;
}

.name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  min-height: var(--name-row-h);
  align-self: start;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.60), var(--surface-2));
  border: 1px solid var(--border);
}

.name-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.name-text {
  font-weight: 700;
  font-size: clamp(16px, 1.6vw, 18px);
  line-height: 1.15;
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}

.name-actions .action-btn {
  background: var(--card);
  border: 1px solid rgba(27, 31, 30, 0.18);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(20, 40, 30, 0.10);
  min-height: 42px;
  border-radius: 12px;
}

.name-actions .action-btn.action-yes {
  background: rgba(31, 157, 85, 0.12);
  border-color: rgba(31, 157, 85, 0.30);
  color: #0f6a3a;
}

.name-actions .action-btn.action-no {
  background: rgba(214, 69, 69, 0.10);
  border-color: rgba(214, 69, 69, 0.30);
  color: #8f1f1f;
}

.name-actions .action-btn.action-gk {
  background: rgba(242, 153, 74, 0.16);
  border-color: rgba(242, 153, 74, 0.42);
  color: #5c2c00;
}

.name-actions .action-btn.action-clear {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--ink);
}

.name-actions .action-btn:hover {
  filter: brightness(0.98);
}

.name-actions .action-btn.is-yes {
  background: var(--accent);
  border-color: rgba(31, 157, 85, 0.55);
  color: #ffffff;
}

.name-actions .action-btn.is-no {
  background: var(--danger);
  border-color: rgba(214, 69, 69, 0.55);
  color: #ffffff;
}

.name-actions .action-btn.is-gk {
  background: #f2994a;
  border-color: rgba(242, 153, 74, 0.65);
  color: #111;
}

.teams {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.teams.teams-top {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.teams-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.teams-header h3 {
  margin: 0;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.team-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 12px;
}

.team-title {
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 12px;
  margin-bottom: 10px;
}

.team-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.team-card li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}

.segmented {
  display: flex;
  gap: 10px;
  font-weight: 600;
}

.segmented input { margin-right: 6px; }

.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.hint { font-size: 12px; color: var(--muted); font-weight: 400; }

.primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.primary:hover { filter: brightness(1.05); }

.primary:active { transform: translateY(1px); }

.roster {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.roster h3 { margin: 0 0 10px; }

.roster-head {
  margin: 0 0 10px;
}

.roster ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.roster li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.meta {
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--ink);
}

.badge.ok {
  background: rgba(31, 157, 85, 0.12);
  border: 1px solid rgba(31, 157, 85, 0.35);
  color: #0f6a3a;
}

.badge.warn {
  background: rgba(242, 201, 76, 0.18);
  border: 1px solid rgba(242, 201, 76, 0.40);
  color: #7a5b2f;
}

.winner-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 12px;
  line-height: 1.1;
}

.winner-dark {
  background: #0b0f0e;
  border-color: #0b0f0e;
  color: #fff;
}

.winner-white {
  background: #fff;
  border-color: rgba(255, 255, 255, 0.40);
  color: #111;
}

.winner-draw {
  background: #f6d34a;
  border-color: rgba(246, 211, 74, 0.70);
  color: #111;
}

.pool {
  margin-top: 14px;
}

.pool summary {
  cursor: pointer;
  font-weight: 600;
}

.pool-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  font-size: 13px;
}

.admin {
  margin-top: 20px;
}

.admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-link {
  margin-top: 10px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.score-boxes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #fff8ee;
}

.score-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.score-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 38px;
  font-weight: 700;
  color: var(--ink);
}

.score-pill input:checked + span {
  background: var(--accent);
  color: #fff;
}

.ghost {
  text-decoration: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-2);
  transition: transform 120ms ease, filter 120ms ease;
}

.ghost.small {
  padding: 8px 10px;
}

.ghost:hover {
  filter: brightness(0.98);
  text-decoration: none;
}

.alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.alert {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.alert.error { border-color: rgba(214, 69, 69, 0.40); background: rgba(214, 69, 69, 0.10); }
.alert.success { border-color: rgba(31, 157, 85, 0.30); background: rgba(31, 157, 85, 0.10); }

.hidden { display: none; }

.table {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  overflow-x: visible;
}

.row {
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.row > div {
  padding: 6px 8px;
  border-left: 2px solid rgba(220, 229, 221, 0.8);
}

.row > div:first-child {
  border-left: none;
}

.row.head > div {
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.match-history .match-row {
  grid-template-columns: 160px 1fr 110px 90px;
}

.match-history .match-row.row.head > div {
  text-align: left;
}

.match-history .match-row > div:last-child {
  justify-self: end;
}

.matches-split {
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 20px;
  align-items: start;
}

.match-panel {
  min-height: 220px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  font-weight: 800;
  font-size: 18px;
  margin: 0;
}

.panel-subtitle {
  margin-top: 18px;
  font-weight: 800;
}

.panel-actions {
  margin-top: 12px;
}

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

@media (max-width: 900px) {
  .matches-split { grid-template-columns: 1fr; }

  .view-toggle { display: flex; }
  .panels { grid-template-columns: 1fr; }
  .panel { display: none; }

  #view-signup:checked ~ .panels .panel-signup { display: block; }
  #view-info:checked ~ .panels .panel-info { display: block; }

  .name-card { height: min(72vh, 720px); }
}

.roster-grid {
  grid-template-columns:
    40px
    minmax(180px, 1.4fr)
    minmax(70px, 0.6fr)
    minmax(70px, 0.6fr)
    minmax(70px, 0.6fr)
    minmax(110px, 0.8fr);
}


.row.head {
  background: var(--surface-3);
  font-weight: 700;
}

.row.danger {
  background: rgba(214, 69, 69, 0.12);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
}

.archived {
  margin-top: 10px;
}

.archived summary {
  cursor: pointer;
  font-weight: 600;
}

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

.archived-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.archived-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-inline {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 10px;
  align-items: center;
}

.admin-inline.add-player {
  grid-template-columns: 1fr auto;
}

.row.head .sort-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
}

.row.head .sort-link:hover {
  text-decoration: underline;
}

.sort-arrow {
  font-size: 12px;
  opacity: 0.7;
}

.table input,
.table select {
  width: 100%;
  padding: 8px 10px;
}

.points-cell {
  text-align: center;
}

.total-cell {
  font-weight: 700;
  color: #1c1c1c;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(214, 69, 69, 0.40);
  background: rgba(214, 69, 69, 0.10);
  color: #8f1f1f;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(214, 69, 69, 0.16);
}

.footer {
  margin-top: 30px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

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

@media (max-width: 700px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-actions { width: 100%; flex-wrap: wrap; }
  .footer { flex-direction: column; gap: 8px; }
  .row { grid-template-columns: 1fr; }
  .admin-inline { grid-template-columns: 1fr; }
  .roster-grid { grid-template-columns: 1fr; }

  .card.stats { width: 100%; }
  .stats-line {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
  .stats-line::-webkit-scrollbar { display: none; }

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

  .name-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    justify-content: flex-start;
  }

  .name-actions {
    width: 100%;
  }

  .name-actions .inline-form {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .name-actions .action-btn {
    width: 100%;
  }
}
