:root {
  --bg: #0a0f1c;
  --bg-elevated: #0f1626;
  --surface: #151d30;
  --surface-2: #1c2540;
  --border: #263153;
  --text: #eef2f9;
  --text-muted: #8b97b8;
  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-dark-text: #052e16;
  --teal: #2dd4bf;
  --warning: #fbbf24;
  --danger-bg: #3b1414;
  --danger-text: #fca5a5;

  --heat-0-bg: #131b2e;
  --heat-1: #163828;
  --heat-2: #1b5236;
  --heat-3: #1f7a49;
  --heat-4: #22a25c;
  --heat-5: #3ecb75;
  --heat-6: #86f5ae;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 999px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 1.1rem 1.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

nav#tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  max-width: 700px;
  margin: 1rem auto 0;
}

.tab-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent);
  color: var(--accent-dark-text);
}

main {
  padding: 1.25rem 1rem 3rem;
  max-width: 700px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 0.75rem;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.1rem 0 0.5rem;
}

.section-label:first-child {
  margin-top: 0;
}

.error-msg {
  background: var(--danger-bg);
  color: var(--danger-text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 13px;
  font-weight: 500;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(45, 212, 191, 0.15);
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.badge-fixed {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}

.badge-guest {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1rem;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.picker-row:has(input:checked) {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.08);
}

.picker-row span {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.picker-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.inline-form input[type='text'] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-md);
  font-size: 14px;
  min-width: 120px;
}

.inline-form input[type='text']::placeholder {
  color: var(--text-muted);
}

.inline-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-outline.danger {
  color: var(--danger-text);
  border-color: rgba(252, 165, 165, 0.3);
}

.btn-outline.danger:hover {
  background: var(--danger-bg);
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.draw-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 2px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: 0.6rem;
}

.segmented-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  font-size: 12px;
  border-radius: var(--radius-pill);
}

.segmented-btn.active {
  background: var(--accent);
  color: var(--accent-dark-text);
}

.admin-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-action {
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
}

.history-round {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.history-round-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.history-match {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.history-match:last-child {
  margin-bottom: 0;
}

.history-match .vs {
  margin: 0;
}

.history-winner {
  color: var(--accent);
  font-weight: 700;
}

button {
  background: var(--accent);
  color: var(--accent-dark-text);
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  bottom: 0.75rem;
}

#picker-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.round-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 0.9rem;
}

.round-dot {
  width: 28px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.round-dot.done {
  background: var(--accent-strong);
}

.round-dot.current {
  background: var(--accent);
}

.courts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.court-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-md);
}

.court-card h3 {
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.team-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.team-btn:last-of-type {
  margin-bottom: 0;
}

.team-btn:hover:not(:disabled) {
  background: #253053;
}

.team-btn .team-names {
  flex: 1;
}

.team-btn .avatar {
  margin-right: -4px;
}

.team-btn.winner {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(74, 222, 128, 0.4);
}

.team-btn:disabled {
  cursor: default;
  opacity: 0.9;
}

.vs {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 2px 0;
}

.roster-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1rem;
}

.roster-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.roster-table td {
  text-align: left;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.roster-table .player-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.roster-table input[type='text'] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.roster-table .save-btn,
.roster-table .cancel-btn,
.roster-table .edit-btn {
  padding: 6px 14px;
  font-size: 12px;
}

.roster-table .cancel-btn {
  background: var(--surface-2);
  color: var(--text-muted);
}

.heatmap-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.heatmap-table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}

.heatmap-table th,
.heatmap-table td {
  padding: 4px 5px;
  text-align: center;
  white-space: nowrap;
}

.heatmap-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-elevated);
}

.heat-name-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(45, 212, 191, 0.15);
  color: var(--teal);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.heat-name-btn:hover {
  background: rgba(45, 212, 191, 0.28);
}

.heat-name-display {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 1.4em;
  margin-bottom: 0.5rem;
}

.heat-cell {
  font-weight: 700;
}

.heat-diagonal {
  background: var(--bg-elevated);
}

.heat-0 {
  background: var(--heat-0-bg);
  color: var(--text-muted);
  font-weight: 400;
}

.heat-1 {
  background: var(--heat-1);
  color: #d3f5e2;
}

.heat-2 {
  background: var(--heat-2);
  color: #dffbe9;
}

.heat-3 {
  background: var(--heat-3);
  color: #f0fff5;
}

.heat-4 {
  background: var(--heat-4);
  color: #f0fff5;
}

.heat-5 {
  background: var(--heat-5);
  color: #06240f;
}

.heat-6 {
  background: var(--heat-6);
  color: #06240f;
}
