/* ========================================
   FamPicks — Dark Theme, Mobile-First
   ======================================== */

:root {
  --bg: #0d1117;
  --surface: #161b27;
  --card: #1c2333;
  --text: #e6edf3;
  --muted: #7d8590;
  --muted-light: #b0bec5;
  --line: #30363d;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.12);
  --danger: #f85149;
  --radius: 12px;
  --radius-sm: 8px;
}

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

.hidden {
  display: none !important;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ── */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px 40px;
}

/* ── Header ── */
.top {
  padding: 12px 0 16px;
}

.top h1 {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text);
}

.subtitle {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 3px;
}

/* ── Section headings ── */
h2 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

/* ── Form controls ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

select,
input,
button {
  font: inherit;
}

select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

select:focus,
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

/* Fix autofill background on dark inputs */
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 30px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* ── Buttons ── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: var(--accent);
  color: #0d1117;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  min-height: 42px;
  transition: opacity 0.15s;
  white-space: nowrap;
}

button:hover {
  opacity: 0.85;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger {
  background: var(--danger);
  color: #fff;
}

/* ── Inline flex row ── */
.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── Auth section ── */
.auth-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: none;
  background: none;
  padding: 0;
}

.auth-grid article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
}

.auth-grid article h2 {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 14px;
}

.auth-grid .field {
  margin-bottom: 10px;
}

/* ── Profile nav bar ── */
.profile-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
}

.profile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

/* ── Team chip ── */
.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--muted-light);
  white-space: nowrap;
}

/* ── Logos ── */
.logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo.sm {
  width: 16px;
  height: 16px;
}

/* ── List ── */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Game row ── */
.game-row,
.pick-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
}

.teams-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.teams-line strong {
  font-size: 0.95rem;
}

/* ── Spread chip ── */
.spread-chip {
  font-size: 0.72rem;
  background: var(--accent-dim);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Result line ── */
.result-line {
  font-size: 0.82rem;
  color: var(--muted-light);
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

/* ── Picks section ── */
.picks-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.pick-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 6px;
}

/* ── Team pick buttons ── */
.team-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--radius-sm);
}

.team-btn.active {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
  font-weight: 800;
}

/* ── Admin collapsible edit ── */
.admin-game-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.admin-game-details summary {
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Score grid ── */
.score-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  margin-bottom: 4px;
}

/* ── Week bar ── */
.week-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.week-field {
  min-width: 100px;
  flex-shrink: 0;
}

/* ── Muted text ── */
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Leaderboard table ── */
.standings-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 380px;
}

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

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td:first-child {
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* ── Picks reveal (post-lockout) ── */
.picks-reveal {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.picks-reveal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  flex-wrap: wrap;
}

.picks-reveal-me {
  background: rgba(34, 197, 94, 0.06);
}

.picks-reveal-name {
  font-size: 0.83rem;
  font-weight: 600;
  min-width: 80px;
  flex: 1;
}

.pick-reveal-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.pick-reveal-chip.correct {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--accent);
}

.pick-reveal-chip.wrong {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--danger);
}

.pick-reveal-chip.pending {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

/* ── Empty state ── */
.empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.875rem;
}

/* ── Avatar ── */
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #0d1117;
  font-weight: 800;
  font-size: 0.82rem;
}

.avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-placeholder-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #0d1117;
  font-weight: 800;
  font-size: 2.2rem;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

/* ── Navigation links (outline buttons) ── */
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 38px;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-link:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 0.875rem;
  min-height: 38px;
}

/* ── Locked pick chip ── */
.locked-chip {
  font-size: 0.72rem;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--danger);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── Text-style button (e.g. "Forgot password?") ── */
.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  min-height: unset;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  margin-top: 8px;
}

/* ── Back link ── */
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}

.back-link:hover {
  text-decoration: underline;
}

/* ── Two-col grid ── */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

/* ── Responsive breakpoints ── */
@media (min-width: 560px) {
  .auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .auth-grid article {
    margin-bottom: 0;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: end;
  }

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

@media (min-width: 720px) {
  .app {
    padding: 20px 20px 48px;
  }

  .top h1 {
    font-size: 2.1rem;
  }

  .card {
    padding: 18px;
  }
}
