/* ============================================
   Nobody is Perfect - Dark Theme CSS
   Mobile-first, glassmorphism, stunning design
   ============================================ */

/* --- CSS Variables & Theme --- */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: rgba(0, 0, 0, 0.3);
  --text-primary: #f0f0ff;
  --text-secondary: rgba(240, 240, 255, 0.7);
  --text-muted: rgba(240, 240, 255, 0.4);
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #22c55e;
  --accent-orange: #f59e0b;
  --gradient-main: linear-gradient(135deg, #a855f7, #ec4899, #3b82f6);
  --gradient-purple: linear-gradient(135deg, #7c3aed, #a855f7);
  --gradient-pink: linear-gradient(135deg, #ec4899, #f43f5e);
  --gradient-cyan: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-bg: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 30%, #0a1628 60%, #0a0a1a 100%);
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-xl: 32px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--gradient-bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

/* --- Animated Background Particles --- */
#bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
  animation: floatParticle linear infinite;
}

.particle:nth-child(1) {
  width: 120px; height: 120px;
  background: radial-gradient(circle, var(--accent-purple), transparent);
  top: 10%; left: 5%;
  animation-duration: 25s;
  animation-delay: 0s;
}
.particle:nth-child(2) {
  width: 80px; height: 80px;
  background: radial-gradient(circle, var(--accent-pink), transparent);
  top: 60%; left: 80%;
  animation-duration: 30s;
  animation-delay: 2s;
}
.particle:nth-child(3) {
  width: 150px; height: 150px;
  background: radial-gradient(circle, var(--accent-blue), transparent);
  top: 30%; left: 70%;
  animation-duration: 35s;
  animation-delay: 4s;
}
.particle:nth-child(4) {
  width: 60px; height: 60px;
  background: radial-gradient(circle, var(--accent-cyan), transparent);
  top: 70%; left: 20%;
  animation-duration: 20s;
  animation-delay: 1s;
}
.particle:nth-child(5) {
  width: 100px; height: 100px;
  background: radial-gradient(circle, var(--accent-purple), transparent);
  top: 80%; left: 50%;
  animation-duration: 28s;
  animation-delay: 3s;
}

@keyframes floatParticle {
  0% { transform: translate(0, 0) scale(1); opacity: 0.15; }
  25% { transform: translate(30px, -40px) scale(1.1); opacity: 0.2; }
  50% { transform: translate(-20px, -80px) scale(0.9); opacity: 0.15; }
  75% { transform: translate(40px, -30px) scale(1.05); opacity: 0.2; }
  100% { transform: translate(0, 0) scale(1); opacity: 0.15; }
}

/* --- App Container --- */
#app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --- Screen Management --- */
.screen {
  display: none;
  animation: fadeSlideIn var(--transition-slow);
  flex: 1;
}
.screen.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes confetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-200px) rotate(720deg); opacity: 0; }
}

/* --- Logo --- */
.game-logo {
  text-align: center;
  padding: 20px 0 10px;
  user-select: none;
}

.game-logo .logo-text {
  font-size: 2rem;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  position: relative;
  display: inline-block;
}

.game-logo .logo-text::after {
  content: '✦';
  position: absolute;
  top: -8px;
  right: -20px;
  font-size: 1rem;
  -webkit-text-fill-color: initial;
  color: var(--accent-pink);
  animation: pulse 2s infinite;
}

.game-logo .logo-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* --- Glass Card --- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 8px 32px var(--glass-shadow);
  padding: 24px;
  transition: all var(--transition-normal);
}

.glass-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 48px rgba(168, 85, 247, 0.15);
}

/* --- Glass Card Variants --- */
.glass-card.purple-glow {
  border-color: rgba(168, 85, 247, 0.3);
  box-shadow: 0 8px 32px rgba(168, 85, 247, 0.1);
}
.glass-card.pink-glow {
  border-color: rgba(236, 72, 153, 0.3);
  box-shadow: 0 8px 32px rgba(236, 72, 153, 0.1);
}
.glass-card.blue-glow {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--border-radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.btn:hover::before {
  opacity: 1;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 30px rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
  box-shadow: 0 6px 30px rgba(34, 197, 94, 0.5);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* --- Input Fields --- */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-main);
  transition: all var(--transition-normal);
  outline: none;
}

.input-field:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.input-field::placeholder {
  color: var(--text-muted);
}

.input-field.large {
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 6px;
  font-weight: 700;
}

/* --- Slider --- */
.slider-container {
  margin-bottom: 16px;
}

.slider-container label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.slider-container label span {
  color: var(--accent-purple);
  font-size: 1.1rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  transition: background var(--transition-normal);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gradient-main);
  cursor: pointer;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
  transition: all var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gradient-main);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

/* --- Tabs --- */
.tab-container {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-md);
  padding: 4px;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: calc(var(--border-radius-md) - 4px);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.tab-btn.active {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.tab-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* --- Player List --- */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: fadeIn var(--transition-normal);
}

.player-badge .host-icon {
  font-size: 0.7rem;
  background: var(--accent-orange);
  color: #000;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.player-badge .crown {
  color: var(--accent-orange);
}

/* --- Game Code Display --- */
.game-code-display {
  text-align: center;
  padding: 20px;
}

.game-code-display .code-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.game-code-display .code-value {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 12px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'Courier New', monospace;
}

.game-code-display .code-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* --- Question Display --- */
.question-card {
  text-align: center;
  padding: 32px 20px;
  margin-bottom: 20px;
}

.question-card .question-label {
  font-size: 0.75rem;
  color: var(--accent-pink);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 12px;
  font-weight: 700;
}

.question-card .question-text {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-primary);
}

/* --- Answer Cards (for guessing phase) --- */
.answer-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 16px;
  animation: cardReveal 0.4s ease backwards;
  transition: all var(--transition-normal);
}

.answer-card:nth-child(1) { animation-delay: 0.05s; }
.answer-card:nth-child(2) { animation-delay: 0.1s; }
.answer-card:nth-child(3) { animation-delay: 0.15s; }
.answer-card:nth-child(4) { animation-delay: 0.2s; }
.answer-card:nth-child(5) { animation-delay: 0.25s; }
.answer-card:nth-child(6) { animation-delay: 0.3s; }
.answer-card:nth-child(7) { animation-delay: 0.35s; }
.answer-card:nth-child(8) { animation-delay: 0.4s; }

.answer-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.1);
}

.answer-card .answer-letter {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent-purple);
  margin-bottom: 8px;
}

.answer-card .answer-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  word-break: break-word;
}

.answer-card select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-normal);
  font-family: var(--font-main);
}

.answer-card select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.answer-card select option {
  background: #1a1a2e;
  color: var(--text-primary);
}

/* --- Results Phase --- */
.result-item {
  padding: 16px;
  border-radius: var(--border-radius-md);
  margin-bottom: 12px;
  animation: cardReveal 0.4s ease backwards;
  transition: all var(--transition-normal);
}

.result-item:nth-child(1) { animation-delay: 0.05s; }
.result-item:nth-child(2) { animation-delay: 0.1s; }
.result-item:nth-child(3) { animation-delay: 0.15s; }
.result-item:nth-child(4) { animation-delay: 0.2s; }
.result-item:nth-child(5) { animation-delay: 0.25s; }
.result-item:nth-child(6) { animation-delay: 0.3s; }
.result-item:nth-child(7) { animation-delay: 0.35s; }
.result-item:nth-child(8) { animation-delay: 0.4s; }

.result-item.correct {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.result-item.incorrect {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.result-item.revealed {
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.result-item .result-author {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-purple);
  margin-bottom: 4px;
}

.result-item .result-answer {
  font-size: 1rem;
  margin-bottom: 4px;
}

.result-item .result-guess {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.result-item .result-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
}

.result-item .result-badge.correct-badge {
  background: rgba(34, 197, 94, 0.2);
  color: var(--accent-green);
}

.result-item .result-badge.incorrect-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* --- Score Table --- */
.score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  margin: 16px 0;
}

.score-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--glass-border);
}

.score-table td {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
}

.score-table tr td:first-child {
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}

.score-table tr td:last-child {
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.score-table .rank-1 td {
  background: rgba(255, 215, 0, 0.08);
  color: #ffd700;
  font-weight: 700;
}

.score-table .rank-2 td {
  background: rgba(192, 192, 192, 0.06);
  color: #c0c0c0;
}

.score-table .rank-3 td {
  background: rgba(205, 127, 50, 0.06);
  color: #cd7f32;
}

/* --- Waiting Indicator --- */
.waiting-container {
  text-align: center;
  padding: 40px 20px;
}

.waiting-spinner {
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.waiting-text {
  color: var(--text-secondary);
  font-size: 1rem;
}

.waiting-dots::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

/* --- Game Over --- */
.winner-announcement {
  text-align: center;
  padding: 30px 20px;
}

.winner-announcement .trophy {
  font-size: 4rem;
  animation: pulse 2s infinite;
  display: block;
  margin-bottom: 16px;
}

.winner-announcement .winner-name {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.winner-announcement .winner-subtitle {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 0.9rem;
}

/* --- Section Headers --- */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* --- Spacer Utility --- */
.spacer {
  flex: 1;
}

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--glass-border);
  margin: 20px 0;
}

/* --- Game Info Bar --- */
.game-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--glass-border);
}

.game-info-bar .info-round {
  font-weight: 600;
  color: var(--accent-purple);
}

.game-info-bar .info-code {
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* --- Responsive --- */
@media (min-width: 768px) {
  #app {
    padding: 32px 24px;
  }
  
  .game-logo .logo-text {
    font-size: 2.5rem;
  }
  
  .glass-card {
    padding: 32px;
  }
  
  .btn {
    padding: 16px 32px;
    font-size: 1.05rem;
    width: auto;
    min-width: 200px;
  }
  
  .btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
  }
  
  .question-card .question-text {
    font-size: 1.5rem;
  }
  
  .game-code-display .code-value {
    font-size: 3.5rem;
  }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.5);
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeSlideIn 0.3s ease;
  text-align: center;
  max-width: 90%;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.2);
}
