/* ============================================================
   Pokdraft — Shared CSS
   Fonts: Lilita One (headings), Nunito (body)
   Palette follows alanpep.com design tokens
   ============================================================ */

:root {
  --color-cream: #FDF6EC;
  --color-forest: #2D6A4F;
  --color-coral: #E76F51;
  --color-charcoal: #2B2D2E;

  /* Pokdraft-specific */
  --color-bg: #1a1a2e;
  --color-bg-panel: #16213e;
  --color-bg-card: #0f3460;
  --color-accent: #e94560;
  --color-gold: #FFD700;
  --color-text: #f0f0f0;
  --color-text-muted: #a0a8b8;
  --color-border: rgba(255,255,255,0.08);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure the HTML `hidden` attribute always wins over display properties set by classes */
[hidden] { display: none !important; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: 'Lilita One', cursive;
  letter-spacing: 0.02em;
}

/* ============================================================
   Lobby Page
   ============================================================ */

.lobby-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.lobby-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.lobby-header {
  text-align: center;
}

.site-title {
  font-size: 3rem;
  color: var(--color-gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.site-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.panel {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.panel h2 {
  font-size: 1.2rem;
  color: var(--color-gold);
  margin-bottom: 1rem;
}

.panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}

.panel input:focus {
  outline: none;
  border-color: var(--color-gold);
}

.panel input::placeholder { color: var(--color-text-muted); }

.divider {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition), background var(--transition);
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--color-gold);
  color: var(--color-charcoal);
  width: 100%;
}

.btn-primary:hover:not(:disabled) { background: #ffe44d; }

.btn-secondary {
  background: var(--color-accent);
  color: #fff;
  width: 100%;
}

.btn-secondary:hover:not(:disabled) { background: #ff6a7d; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

/* ============================================================
   Waiting Lobby
   ============================================================ */

.waiting-panel { display: flex; flex-direction: column; gap: 1rem; }

.room-code-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255,215,0,0.08);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.room-code-display .label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.room-code-display .code {
  font-family: 'Lilita One', cursive;
  font-size: 2rem;
  color: var(--color-gold);
  letter-spacing: 0.15em;
  flex: 1;
  text-align: center;
}

.waiting-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

#player-list-wrap h3 {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

#player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#player-list li {
  padding: 0.4rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.host-badge {
  font-size: 0.7rem;
  background: var(--color-gold);
  color: var(--color-charcoal);
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 800;
}

.you-badge {
  font-size: 0.7rem;
  background: var(--color-accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 800;
}

.status-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

.leave-btn {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

.leave-btn:hover {
  opacity: 1;
}

.error-banner {
  background: rgba(233,69,96,0.15);
  border: 1px solid var(--color-accent);
  color: #ff8fa3;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
}

/* ============================================================
   Draft Page Layout
   ============================================================ */

.draft-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.draft-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-bg-panel);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.site-title-small {
  font-family: 'Lilita One', cursive;
  color: var(--color-gold);
  font-size: 1.3rem;
  letter-spacing: 0.05em;
}

.draft-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  flex: 1;
}

.sep { opacity: 0.4; }

#header-pending {
  font-weight: 700;
  color: var(--color-gold);
}

.header-player {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.draft-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ============================================================
   Pack Section
   ============================================================ */

.pack-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.25rem 1.5rem;
  gap: 1rem;
  position: relative;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.section-header h2 {
  font-size: 1.1rem;
  color: var(--color-text);
}

.pack-size-badge {
  font-size: 0.75rem;
  background: rgba(255,255,255,0.08);
  color: var(--color-text-muted);
  padding: 2px 10px;
  border-radius: 20px;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  overflow-y: auto;
  padding-right: 4px;
}

.pokemon-card {
  background: var(--color-bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  font-family: 'Nunito', sans-serif;
}

.pokemon-card:hover:not(:disabled) {
  transform: translateY(-4px);
  border-color: var(--color-gold);
  box-shadow: 0 8px 24px rgba(255,215,0,0.2);
}

.pokemon-card:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-sprite {
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
}

.card-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  line-height: 1.2;
}

.tier-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.type-badges {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.type-badge {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 20px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Waiting overlay */
.waiting-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,26,46,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius);
}

.waiting-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.waiting-msg p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,215,0,0.2);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Sidebar
   ============================================================ */

.draft-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
}

.sidebar-panel {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-panel h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.badge {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.1);
  padding: 1px 7px;
  border-radius: 20px;
}

/* Player status list */
.player-status-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-row.picked .player-dot  { background: #2ecc71; }
.player-row.waiting .player-dot { background: var(--color-text-muted); }

.player-row-name { flex: 1; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row.picked .player-row-name { color: var(--color-text-muted); }

.player-row-status { font-size: 0.8rem; color: var(--color-text-muted); }
.player-row.picked .player-row-status { color: #2ecc71; }

/* Mini picks grid */
.picks-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.mini-card {
  position: relative;
  background: var(--color-bg-card);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.mini-tier-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
}

/* ============================================================
   Complete Screen
   ============================================================ */

.complete-screen {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  overflow-y: auto;
  padding: 2rem;
  text-align: center;
}

.complete-screen h1 {
  font-size: 2.5rem;
  color: var(--color-gold);
  margin-bottom: 2rem;
}

.all-picks-wrap {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  text-align: left;
  max-width: 960px;
  margin: 0 auto 2rem;
}

.player-result h2 {
  font-size: 1.2rem;
  color: var(--color-gold);
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.6rem;
}

.result-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
}

.result-card.first-pick {
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--color-accent) 40%, transparent);
}

.result-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
}

.result-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  .draft-main {
    flex-direction: column;
    overflow: visible;
  }

  .draft-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--color-border);
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
    flex-shrink: 0;
  }

  .sidebar-panel {
    flex-shrink: 0;
    min-width: 180px;
    border-bottom: none;
    border-right: 1px solid var(--color-border);
  }

  /* Hide player status on mobile — only show my picks */
  #players-panel { display: none; }

  #my-picks-panel {
    flex: 1;
    min-width: 0;
  }

  .picks-mini-grid {
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    overflow-y: visible;
  }

  .pack-section {
    overflow: visible;
  }

  .draft-header {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
  }
}
