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

:root {
  --bg-deep: #0a0f1a;
  --bg-surface: #121826;
  --bg-card: #1a2035;
  --bg-hover: #222a45;
  --gold: #f0b429;
  --gold-light: #f7d44a;
  --gold-dark: #d4941a;
  --cyan: #36b9d8;
  --cyan-light: #5dcce8;
  --green: #2ed573;
  --red: #ff4757;
  --orange: #ffa502;
  --text-primary: #e8edf5;
  --text-secondary: #8892a8;
  --text-muted: #5a6478;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Ensure the ads grid column doesn't add extra padding around the game */
.div18 {
  padding: 0 !important;
}

.hidden { display: none !important; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

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

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 32px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #1a1a2e;
  box-shadow: 0 4px 20px rgba(240, 180, 41, 0.3);
}
.btn-primary:hover {
  box-shadow: 0 6px 28px rgba(240, 180, 41, 0.45);
  transform: translateY(-1px);
}

.btn-large {
  font-size: 1.2rem;
  padding: 18px 48px;
  border-radius: var(--radius-lg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-full { width: 100%; }

/* Splash */
.splash-screen { gap: 12px; text-align: center; }

.splash-globe {
  font-size: 5rem;
  margin-bottom: 8px;
  animation: pulse 2s ease-in-out infinite;
}

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

.splash-title {
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.splash-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 24px;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card h2 {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
}

.text-muted {
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.9rem;
}

/* Input */
.input-group { display: flex; flex-direction: column; gap: 6px; }

.input {
  font-family: var(--font);
  font-size: 1rem;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.2);
  color: var(--text-primary);
  transition: var(--transition);
  width: 100%;
}

.input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.2);
}

.error-text {
  color: var(--red);
  font-size: 0.85rem;
}

/* Queue Screen */
.queue-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.queue-container h2 { font-size: 1.4rem; }

/* Game Screen */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 8px;
}

.player-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 70px;
}

.opponent-info { text-align: center; }

.player-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-score {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--gold);
}

.opponent-info .player-score { color: var(--cyan); }

.game-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
}

.question-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.timer-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--cyan));
  border-radius: 2px;
  transition: width 1s linear;
  width: 100%;
}

.timer-fill.warning { background: var(--orange); }
.timer-fill.danger { background: var(--red); }

.timer-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.game-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  justify-content: center;
}

.question-area {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  text-align: center;
}

.question-type-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(54, 185, 216, 0.15);
  color: var(--cyan);
}

.question-clue {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  max-width: 100%;
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.answer-btn {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 16px 12px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.1);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
  outline: none;
}

/* Ocultar botones vacíos antes de que cargue la pregunta */
.answer-btn:empty {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

/* Ocultar badge y clue cuando están vacíos */
#questionType:empty,
#questionClue:empty {
  display: none;
}

.answer-btn:hover { background: var(--bg-hover); border-color: rgba(255,255,255,0.2); }
.answer-btn:active { transform: scale(0.97); }
.answer-btn:disabled { cursor: default; opacity: 0.6; }
.answer-btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-color: var(--cyan);
}

.answer-btn.selected {
  background: rgba(54, 185, 216, 0.2);
  border-color: var(--cyan);
}

.answer-btn.correct {
  background: rgba(46, 213, 115, 0.2);
  border-color: var(--green);
  color: var(--green);
  border-width: 2px;
  font-weight: 600;
}

.answer-btn.wrong {
  background: rgba(255, 71, 87, 0.2);
  border-color: var(--red);
  color: var(--red);
  border-width: 2px;
}

.answer-btn.reveal-correct {
  background: rgba(46, 213, 115, 0.15);
  border-color: var(--green);
  color: var(--green);
}

.feedback-area {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.04);
  max-width: 400px;
  width: 100%;
}

.feedback-area.correct { background: rgba(46, 213, 115, 0.1); border: 1px solid rgba(46, 213, 115, 0.2); }
.feedback-area.wrong { background: rgba(255, 71, 87, 0.1); border: 1px solid rgba(255, 71, 87, 0.2); }
.feedback-area.times-up { background: rgba(255, 165, 2, 0.1); border: 1px solid rgba(255, 165, 2, 0.2); }

.feedback-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.feedback-area.correct .feedback-text { color: var(--green); }
.feedback-area.wrong .feedback-text { color: var(--red); }
.feedback-area.times-up .feedback-text { color: var(--orange); }

.game-footer {
  padding: 12px 20px;
  background: var(--bg-surface);
  border-top: 1px solid rgba(255,255,255,0.04);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.opponent-status {
  color: var(--green);
}

/* Result Screen */
.result-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 400px;
}

.result-icon {
  font-size: 4rem;
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.result-title {
  font-size: 2rem;
  font-weight: 800;
}

.result-title.win { color: var(--gold); }
.result-title.lose { color: var(--red); }
.result-title.draw { color: var(--text-secondary); }

.result-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.06);
}

.result-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.result-value {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--gold);
}

.result-vs {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.result-details {
  width: 100%;
  text-align: left;
}

.result-details h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.breakdown-item {
  font-size: 0.85rem;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* Leaderboard Screen */
.leaderboard-content {
  width: 100%;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  margin-bottom: 6px;
}

.leaderboard-rank {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 24px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.leaderboard-rank.top3 { color: var(--gold); }

.leaderboard-name {
  flex: 1;
  font-weight: 500;
}

.leaderboard-rating {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--gold);
}

.leaderboard-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 100;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.show { display: block; }
.toast.info { background: var(--bg-card); border: 1px solid rgba(255,255,255,0.1); }
.toast.error { background: rgba(255, 71, 87, 0.2); border: 1px solid var(--red); color: var(--red); }
.toast.success { background: rgba(46, 213, 115, 0.2); border: 1px solid var(--green); color: var(--green); }

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Mobile Responsive */
@media (max-width: 400px) {
  .splash-title { font-size: 2.2rem; }
  .answers-grid { grid-template-columns: 1fr; }
  .game-header { padding: 12px; }
  .player-score { font-size: 1.2rem; }
  .question-clue { font-size: 1.1rem; }
  .answer-btn { 
    padding: 14px 10px;
    font-size: 0.9rem;
  }
  .answer-btn:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 1px;
  }
}

/* Loading dots for waiting */
.waiting-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

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