/* ── Theme ─────────────────────────────────────────────────────── */
:root {
  --bg-body:      #0d1117;
  --bg-panel:     #161b22;
  --bg-surface:   #21262d;
  --text:         #e6edf3;
  --text-dim:     #8b949e;
  --accent:       #d4a843;
  --accent-hover: #e6bc5a;
  --error:        #f85149;
  --success:      #3fb950;
  --border:       #30363d;
  --radius:       10px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); }
input, button, select { font-family: inherit; font-size: inherit; }

/* ── Screens ───────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--border); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.small { padding: 6px 14px; font-size: 0.85rem; }
.btn.large { padding: 14px 36px; font-size: 1.1rem; }

/* ── Inputs ────────────────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-body);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--accent); }
label { display: block; margin-bottom: 4px; font-size: 0.85rem; color: var(--text-dim); }
form { display: flex; flex-direction: column; gap: 12px; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 9999;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateX(0); }
.toast.error { background: var(--error); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

/* ── Top Bar ───────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-right { display: flex; align-items: center; gap: 12px; color: var(--text-dim); }

/* ── Logo ──────────────────────────────────────────────────────── */
.logo { font-size: 1.8rem; color: var(--accent); text-align: center; margin-bottom: 24px; }
.logo-sm { font-size: 1.1rem; color: var(--accent); white-space: nowrap; }

/* ── Helper ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.hint { font-size: 0.8rem; color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════ */
#auth-screen {
  justify-content: center;
  align-items: center;
}
.auth-card {
  background: var(--bg-panel);
  padding: 40px 36px;
  border-radius: 14px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
}
.tabs { display: flex; gap: 4px; margin-bottom: 24px; }
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--bg-surface);
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--accent); color: #000; }

/* ═══════════════════════════════════════════════════════════════
   HOME SCREEN
   ═══════════════════════════════════════════════════════════════ */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 700px;
  margin: 60px auto;
  padding: 0 24px;
}
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
}
.panel h2 { margin-bottom: 18px; font-size: 1.15rem; }

/* ═══════════════════════════════════════════════════════════════
   LOBBY SCREEN (Waiting Room)
   ═══════════════════════════════════════════════════════════════ */
.lobby-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 24px;
  flex: 1;
}
.label { color: var(--text-dim); font-size: 0.9rem; }
.code-display {
  display: flex;
  align-items: center;
  gap: 14px;
}
.code-display span {
  font-family: "Courier New", monospace;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.25em;
}
.player-list {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 28px;
  min-width: 280px;
  text-align: left;
}
.player-list h3 { margin-bottom: 10px; font-size: 0.95rem; color: var(--text-dim); }
.player-list .player-row {
  padding: 6px 0;
  font-size: 1rem;
}
.player-list .player-row.owner::after {
  content: " (owner)";
  color: var(--accent);
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════════════════════════
   DRAFT SCREEN
   ═══════════════════════════════════════════════════════════════ */
.turn-banner {
  text-align: center;
  padding: 14px 24px;
  font-size: 1.15rem;
  font-weight: 700;
  flex-shrink: 0;
}
.turn-banner.your-turn {
  background: linear-gradient(135deg, #1a3a1a, #0d1117);
  color: var(--success);
  border-bottom: 2px solid var(--success);
}
.turn-banner.waiting {
  background: var(--bg-panel);
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.draft-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.draft-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.draft-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}
.draft-sidebar h2 { font-size: 1rem; margin-bottom: 16px; color: var(--text-dim); }

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.card-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.3s ease;
}
.card-cell.drafted { opacity: 0.2; pointer-events: none; }
.card-cell img {
  width: 100%;
  aspect-ratio: 488 / 680;
  object-fit: cover;
  border-radius: 4.5%;
  background: var(--bg-surface);
}
.draft-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.15s, transform 0.1s;
}
.draft-btn:hover:not(:disabled) { background: var(--accent); color: #000; }
.draft-btn:active:not(:disabled) { transform: scale(0.95); }
.draft-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Draft board sidebar */
.player-section { margin-bottom: 18px; }
.player-section h3 {
  font-size: 0.9rem;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.player-section.active h3 { color: var(--accent); }
.player-section ul { list-style: none; }
.player-section li {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 2px 0;
}

/* ═══════════════════════════════════════════════════════════════
   RESULTS SCREEN
   ═══════════════════════════════════════════════════════════════ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
}
.result-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.result-card h3 { margin-bottom: 12px; color: var(--accent); }
.result-card .pick-list { list-style: none; margin-bottom: 14px; }
.result-card .pick-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 0.9rem;
}
.result-card .pick-list img {
  width: 44px;
  aspect-ratio: 488 / 680;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-surface);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .draft-sidebar { width: 220px; }
  .home-grid { grid-template-columns: 1fr; max-width: 400px; }
}
@media (max-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .draft-layout { flex-direction: column; }
  .draft-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 200px;
  }
  .code-display span { font-size: 2rem; }
}
