:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #ff6b6b;
  --text: #eaeaea;
  --text-dim: #a0a0a0;
  --success: #4ecdc4;
  --warning: #ffd93d;
  --radius: 8px;
}

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

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

header {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  padding: 1.5rem 2rem;
  border-bottom: 2px solid var(--accent);
}

.header-content {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

header h1 {
  font-size: 1.8rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo {
  width: 3rem;
  height: 3rem;
  filter: drop-shadow(0 0 6px rgba(233, 69, 96, 0.5));
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  padding: 0.2rem;
}

.tagline {
  color: var(--text-dim);
  font-style: italic;
  flex: 1;
}

#auth-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#auth-area input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  width: 200px;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

button:hover { background: var(--accent2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

nav {
  background: var(--surface);
  padding: 0.5rem 2rem;
  display: flex;
  gap: 0.25rem;
  max-width: 1000px;
  margin: 0 auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

.nav-btn {
  background: transparent;
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
}

.nav-btn.active {
  background: var(--surface2);
  color: var(--text);
}

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

main {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 2rem;
}

h2 {
  color: var(--accent);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

h3 {
  color: var(--text);
  margin: 1.5rem 0 0.5rem;
}

/* Leaderboard */
.leaderboard-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

select {
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

th {
  background: var(--surface2);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-dim);
}

td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--bg);
}

tr:hover td { background: rgba(233, 69, 96, 0.05); }

/* Roster Builder */
.pos-section {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.pos-section h4 {
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.picks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pick-chip {
  background: var(--surface2);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pick-chip .remove {
  cursor: pointer;
  color: var(--accent);
  font-weight: bold;
}

.team-filter {
  width: 140px;
  margin-right: 0.5rem;
}

.player-select {
  width: 250px;
  margin-right: 0.5rem;
}

.select-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.roster-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

#lock-roster-btn {
  background: var(--warning);
  color: #333;
}

/* Rules */
.rules-content ul {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.rules-content li { margin-bottom: 0.25rem; }

.penalty-note {
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Admin */
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#admin-output {
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  min-height: 2rem;
}

/* Roster display card */
.roster-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--accent);
}

.roster-card h4 {
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.roster-card .locked-badge {
  background: var(--success);
  color: #111;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.roster-card .unlocked-badge {
  background: var(--warning);
  color: #111;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.help-text {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

#auth-message {
  text-align: center;
  padding: 2rem;
  font-size: 1.2rem;
}

footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

footer a { color: var(--accent); }

.small-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
  pointer-events: auto;
  max-width: 360px;
  word-break: break-word;
}

.toast.success { background: var(--success); color: #111; }
.toast.error   { background: var(--accent); }
.toast.info    { background: var(--surface2); border: 1px solid var(--text-dim); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* Loading overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Confirm modal */
#confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal-box p {
  margin-bottom: 1.25rem;
  font-size: 1rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--text-dim);
  color: var(--bg);
}

/* Responsive */
@media (max-width: 600px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  #auth-area { width: 100%; }

  #logged-out {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  #logged-out input { width: 100%; }
  #logged-out button { width: 100%; }

  #logged-in {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  #user-display-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  nav {
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .nav-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
    flex: 1;
    min-width: 0;
    text-align: center;
  }

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

  .team-filter, .player-select {
    width: 100%;
  }

  .roster-card {
    padding: 0.75rem;
  }

  .pos-section h4 {
    font-size: 0.95rem;
  }

  .pick-chip {
    font-size: 0.85rem;
  }

  main {
    padding: 0.75rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.4rem;
  }

  .roster-actions {
    flex-direction: column;
  }

  .roster-actions button {
    width: 100%;
  }
}

/* Typeahead search */
.typeahead-wrap {
  position: relative;
  flex: 1;
}

.typeahead-wrap input {
  width: 100%;
  padding: 0.5rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.typeahead-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 10;
  display: none;
}

.typeahead-list.open { display: block; }

.typeahead-item {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.typeahead-item:hover,
.typeahead-item.highlighted {
  background: var(--surface2);
}

/* Live scoring */
.live-scores {
  margin-top: 1rem;
}

.live-player-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
}

.live-player-row.dropped {
  opacity: 0.4;
  text-decoration: line-through;
}

.live-total {
  font-weight: bold;
  font-size: 1.1rem;
  margin-top: 0.5rem;
  color: var(--accent2);
}
