/* ── Design tokens ── */
:root {
  --color-bg: #f9f9f7;
  --color-surface: #ffffff;
  --color-border: #e2e2dc;
  --color-text: #1a1a18;
  --color-text-muted: #6b6b65;
  --color-primary: #2a5cc4;
  --color-primary-dark: #1e46a0;
  --color-danger: #c0392b;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --max-w: 1100px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--color-bg); color: var(--color-text); line-height: 1.5; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; }

/* ── Layout ── */
.nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 100;
}
.nav__inner {
  max-width: var(--max-w); margin: 0 auto; padding: .75rem 1rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.nav__logo { font-weight: 700; font-size: 1.1rem; color: var(--color-primary); }
.nav__links { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.nav__user { color: var(--color-text-muted); font-size: .875rem; }

.main { max-width: var(--max-w); margin: 0 auto; padding: 1.5rem 1rem; }

/* ── Messages ── */
.messages { margin-bottom: 1rem; }
.message {
  padding: .75rem 1rem; border-radius: var(--radius);
  margin-bottom: .5rem; font-size: .9rem;
}
.message--error { background: #fde8e8; color: var(--color-danger); border: 1px solid #f5c6c6; }
.message--success { background: #e8f7ed; color: var(--color-success); border: 1px solid #b7e4c7; }
.message--warning { background: #fef3e2; color: var(--color-warning); border: 1px solid #fad7a0; }
.message--info { background: #e8f0fd; color: var(--color-primary); border: 1px solid #b7cef5; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .6rem 1.2rem; border-radius: var(--radius); border: none;
  font-size: .9rem; font-weight: 600; transition: background .15s;
  text-decoration: none;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); text-decoration: none; color: #fff; }
.btn--secondary { background: var(--color-border); color: var(--color-text); }
.btn--secondary:hover { background: #d5d5cc; }
.btn--ghost { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn--ghost:hover { background: var(--color-border); }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--sm { padding: .35rem .8rem; font-size: .8rem; }
.btn--full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}

/* ── MP Card Grid ── */
.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.mp-card {
  background: var(--color-surface); border: 2px solid var(--color-border);
  border-radius: var(--radius); padding: .75rem; text-align: center;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  position: relative;
  user-select: none;
}
.mp-card:hover { border-color: var(--color-primary); box-shadow: 0 2px 8px rgba(42,92,196,.15); }
.mp-card.is-selected { border-color: var(--color-primary); background: #f0f5ff; }
.mp-card.is-bench { border-color: var(--color-warning); background: #fef9f0; }
.mp-card.is-taken { opacity: .45; cursor: not-allowed; }

.mp-card__photo {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  margin: 0 auto .5rem;
  background: var(--color-border);
}
.mp-card__initials {
  width: 64px; height: 64px; border-radius: 50%; background: var(--color-border);
  margin: 0 auto .5rem; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; color: var(--color-text-muted);
}
.mp-card__name { font-size: .8rem; font-weight: 600; margin-bottom: .25rem; line-height: 1.2; }
.mp-card__group {
  display: inline-block; font-size: .7rem; padding: .15rem .4rem;
  border-radius: 4px; margin-bottom: .3rem;
  background: var(--color-border); color: var(--color-text-muted);
}
.mp-card__price {
  font-size: .85rem; font-weight: 700; color: var(--color-primary);
  margin-bottom: .25rem;
}
.mp-card__stats { font-size: .7rem; color: var(--color-text-muted); line-height: 1.4; }
.mp-card__badge {
  position: absolute; top: .35rem; right: .35rem;
  font-size: .65rem; font-weight: 700; padding: .1rem .3rem;
  border-radius: 4px; background: var(--color-primary); color: #fff;
}
.mp-card__bench-badge {
  position: absolute; top: .35rem; left: .35rem;
  font-size: .65rem; font-weight: 700; padding: .1rem .3rem;
  border-radius: 4px; background: var(--color-warning); color: #fff;
}

/* ── Filter chips ── */
.filter-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.chip {
  padding: .3rem .75rem; border-radius: 999px; font-size: .8rem; font-weight: 500;
  border: 1px solid var(--color-border); background: var(--color-surface);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.chip.is-active, .chip:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Draft builder layout ── */
.draft-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
@media (max-width: 768px) { .draft-layout { grid-template-columns: 1fr; } }

.draft-panel {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem; position: sticky; top: 72px;
}
.draft-panel h2 { font-size: 1rem; margin-bottom: .75rem; }

/* ── Budget bar ── */
.budget-bar-wrap { margin-bottom: .75rem; }
.budget-bar-label { display: flex; justify-content: space-between; font-size: .8rem; margin-bottom: .25rem; }
.budget-bar { height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.budget-bar__fill { height: 100%; background: var(--color-primary); border-radius: 4px; transition: width .2s; }
.budget-bar__fill.is-over { background: var(--color-danger); }

/* ── Squad slots ── */
.squad-slots { display: grid; gap: .5rem; margin-bottom: .75rem; }
.squad-slot {
  display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem;
  border: 2px dashed var(--color-border); border-radius: var(--radius);
  font-size: .85rem; min-height: 2.75rem;
  background: var(--color-bg);
}
.squad-slot.is-filled { border-style: solid; border-color: var(--color-primary); background: var(--color-surface); }
.squad-slot.is-bench-slot { border-color: var(--color-warning); }
.squad-slot.is-bench-slot.is-filled { border-color: var(--color-warning); background: #fef9f0; }
.squad-slot__num { font-size: .7rem; color: var(--color-text-muted); min-width: 1.2rem; }
.squad-slot__name { flex: 1; font-weight: 500; }
.squad-slot__price { font-size: .75rem; color: var(--color-primary); font-weight: 600; }
.squad-slot__remove {
  border: none; background: none; color: var(--color-text-muted);
  font-size: 1rem; padding: 0 .2rem; line-height: 1;
}
.squad-slot__remove:hover { color: var(--color-danger); }

/* ── Indicators ── */
.indicators { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; font-size: .8rem; }
.indicator {
  padding: .2rem .5rem; border-radius: 4px;
  background: var(--color-bg); border: 1px solid var(--color-border);
}
.indicator.ok { background: #e8f7ed; border-color: #b7e4c7; color: var(--color-success); }
.indicator.warn { background: #fef3e2; border-color: #fad7a0; color: var(--color-warning); }
.indicator.bad { background: #fde8e8; border-color: #f5c6c6; color: var(--color-danger); }

/* ── My squad page ── */
.my-squad-grid { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
@media (max-width: 768px) { .my-squad-grid { grid-template-columns: 1fr; } }

.squad-heading { margin-bottom: 1rem; }
.squad-heading h1 { font-size: 1.4rem; }
.squad-heading .squad-meta { font-size: .85rem; color: var(--color-text-muted); margin-top: .25rem; }

.mp-row {
  display: flex; align-items: center; gap: .75rem; padding: .75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface); margin-bottom: .5rem;
}
.mp-row__photo {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  background: var(--color-border); flex-shrink: 0;
}
.mp-row__initials {
  width: 44px; height: 44px; border-radius: 50%; background: var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: var(--color-text-muted);
  flex-shrink: 0;
}
.mp-row__info { flex: 1; }
.mp-row__name { font-weight: 600; font-size: .9rem; }
.mp-row__group { font-size: .75rem; color: var(--color-text-muted); }
.mp-row__price { font-size: .8rem; font-weight: 600; color: var(--color-primary); }
.mp-row__actions { display: flex; gap: .4rem; align-items: center; }
.captain-badge {
  background: var(--color-warning); color: #fff;
  font-size: .7rem; font-weight: 700; padding: .15rem .4rem; border-radius: 4px;
}

.section-label {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--color-text-muted); margin-bottom: .5rem; margin-top: 1rem;
}

/* ── Feed ── */
.feed { margin-top: 1.5rem; }
.feed-entry { border-left: 3px solid var(--color-primary); padding: .5rem .75rem; margin-bottom: .5rem; font-size: .85rem; }

/* ── Score sidebar ── */
.score-card { text-align: center; padding: 1.25rem; }
.score-card__label { font-size: .8rem; color: var(--color-text-muted); }
.score-card__value { font-size: 2rem; font-weight: 700; color: var(--color-primary); }

/* ── Leaderboard ── */
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th, .leaderboard-table td {
  padding: .6rem .75rem; text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: .875rem;
}
.leaderboard-table th { font-size: .75rem; text-transform: uppercase; color: var(--color-text-muted); }
.leaderboard-table tr:hover td { background: var(--color-bg); }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: .75rem; font-weight: 700;
  background: var(--color-border); color: var(--color-text-muted);
}
.rank-badge.gold { background: #f7c948; color: #7a5800; }
.rank-badge.silver { background: #d5d5d5; color: #555; }
.rank-badge.bronze { background: #d4956a; color: #fff; }

/* ── Forms ── */
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field select,
.form-field textarea {
  width: 100%; padding: .6rem .75rem;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font: inherit; font-size: .9rem; background: var(--color-surface);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(42,92,196,.12);
}
.form-errors { margin-bottom: .5rem; }
.form-errors ul { padding-left: 1.2rem; }
.form-errors li { color: var(--color-danger); font-size: .85rem; }

/* ── Page headers ── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; margin-bottom: .25rem; }
.page-header p { color: var(--color-text-muted); font-size: .9rem; }

/* ── Hero (home page) ── */
.hero { padding: 3rem 0; max-width: 600px; }
.hero h1 { font-size: 2rem; line-height: 1.2; margin-bottom: 1rem; }
.hero p { font-size: 1.05rem; color: var(--color-text-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.hero-ctas { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ── League ── */
.invite-box {
  display: flex; align-items: center; gap: .5rem;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: .5rem .75rem;
  font-family: monospace; font-size: .875rem; margin-bottom: 1rem;
}
.invite-box button { flex-shrink: 0; }

/* ── Draft room ── */
.draft-status {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
}
.draft-picks-list { display: grid; gap: .35rem; }
.draft-pick-row {
  display: flex; gap: .5rem; align-items: center;
  font-size: .8rem; padding: .3rem .5rem;
  border-radius: 4px; background: var(--color-bg);
}
.draft-pick-row__num { color: var(--color-text-muted); min-width: 1.5rem; }

/* ── Guest banner ── */
.guest-banner {
  background: #e8f0fd; border: 1px solid #b7cef5;
  border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;
}
.guest-banner p { font-size: .9rem; color: var(--color-primary); }

/* ── Off-season ── */
.off-season {
  padding: 3rem 0; text-align: center; color: var(--color-text-muted);
}
.off-season h2 { margin-bottom: .5rem; }

/* ── Utility ── */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
