:root {
  --bg-main: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #334155;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --primary: #8B5CF6;
  --primary-hover: #7C3AED;
  --secondary: #FBBF24;
  --secondary-hover: #F59E0B;
  --accent: #10B981;
  --danger: #EF4444;
  --radius: 16px;
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  position: relative;
  background-color: var(--bg-main);
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

@media (min-width: 640px) {
  #app {
    height: 90vh;
    border-radius: var(--radius);
  }
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 30px 20px;
  animation: popIn 0.3s ease-out forwards;
}

.screen.active {
  display: flex;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Typography & General */
h1 { font-size: 2.5rem; text-align: center; margin-bottom: 5px; }
h2 { font-size: 1.5rem; margin-bottom: 20px; }
h3 { font-size: 1.2rem; margin-bottom: 10px; color: var(--text-muted); }
.primary { color: var(--primary); }
.subtitle { text-align: center; color: var(--text-muted); margin-bottom: 40px; }

/* Buttons & Inputs */
.btn {
  padding: 16px 24px;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--secondary); color: #000; box-shadow: 0 4px 14px rgba(251, 191, 36, 0.4); }
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-text { background: transparent; color: var(--text-muted); border: none; font-weight: 600; cursor: pointer; }
.btn-text:hover { color: white; }

.btn-block { width: 100%; margin-bottom: 15px; }

input[type="text"], select {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--bg-card-hover);
  background: var(--bg-main);
  color: white;
  font-family: var(--font-main);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }

/* Menu Specific */
.logo { display: flex; align-items: center; justify-content: center; gap: 15px; margin-top: 40px; margin-bottom: 10px; }
.logo-icon { font-size: 3rem; background: var(--primary); border-radius: 50%; width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 20px rgba(139, 92, 246, 0.5); }
.menu-card, .lobby-card, .results-card { background: var(--bg-card); padding: 30px; border-radius: var(--radius); width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }

.divider { text-align: center; margin: 25px 0; position: relative; }
.divider span { background: var(--bg-card); padding: 0 15px; color: var(--text-muted); position: relative; z-index: 1; font-weight: 600; }
.divider::before { content: ''; position: absolute; top: 50%; left: 0; width: 100%; height: 2px; background: var(--bg-card-hover); z-index: 0; }

.join-group { display: flex; gap: 10px; }
.join-group input { flex: 1; text-transform: uppercase; }

/* Lobby Specific */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.player-list { list-style: none; margin-bottom: 30px; }
.player-item { padding: 15px; background: var(--bg-main); border-radius: 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; font-weight: 600; border: 2px solid transparent; }
.player-item.is-me { border-color: var(--primary); }
.player-item .avatar { font-size: 1.5rem; }
.settings-group { margin-bottom: 25px; }

/* Game Specific */
.game-header { margin-bottom: 20px; }
.question-counter { text-align: center; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }
.timer { width: 100%; height: 8px; background: var(--bg-card); border-radius: 4px; overflow: hidden; }
.timer-bar { height: 100%; background: var(--accent); width: 100%; transition: width 0.1s linear, background-color 0.3s; }
.timer-bar.danger { background: var(--danger); }

.players-hud { display: flex; justify-content: space-between; margin-bottom: 30px; gap: 10px; }
.hud-item { flex: 1; background: var(--bg-card); padding: 10px; border-radius: 12px; text-align: center; transition: transform 0.2s; }
.hud-item.is-me { border: 2px solid var(--primary); }
.hud-item .score { font-size: 1.2rem; font-weight: bold; color: var(--secondary); }

.question-card { background: var(--bg-card); padding: 30px 20px; border-radius: var(--radius); text-align: center; margin-bottom: 30px; min-height: 180px; display: flex; flex-direction: column; justify-content: center; position: relative; }
.category-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; }
#q-text { font-size: 1.4rem; line-height: 1.4; }

.answers-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
@media(min-width: 480px) { .answers-grid { grid-template-columns: 1fr 1fr; } }

.answer-btn { background: var(--bg-card); border: 2px solid var(--bg-card-hover); padding: 20px; border-radius: 12px; color: white; font-size: 1.1rem; font-family: var(--font-main); cursor: pointer; transition: all 0.2s; text-align: left; position: relative; overflow: hidden; }
.answer-btn:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--primary); transform: translateY(-2px); }
.answer-btn:active:not(:disabled) { transform: scale(0.98); }
.answer-btn:disabled { cursor: default; }

.answer-btn.correct { background: rgba(16, 185, 129, 0.2); border-color: var(--accent); color: var(--accent); }
.answer-btn.wrong { background: rgba(239, 68, 68, 0.2); border-color: var(--danger); color: var(--danger); opacity: 0.6; }

/* Results Specific */
.results-header { text-align: center; margin-bottom: 30px; margin-top: 20px; }
.winner-announcement { font-size: 1.8rem; font-weight: bold; text-align: center; color: var(--secondary); margin-bottom: 30px; }
.leaderboard { list-style: none; margin-bottom: 40px; }
.lb-item { display: flex; justify-content: space-between; padding: 15px 20px; background: var(--bg-main); margin-bottom: 10px; border-radius: 12px; font-weight: bold; font-size: 1.1rem; }
.lb-item:nth-child(1) { background: linear-gradient(90deg, rgba(251,191,36,0.1) 0%, transparent 100%); border-left: 4px solid var(--secondary); }
.lb-item:nth-child(2) { border-left: 4px solid #94A3B8; }
.lb-item:nth-child(3) { border-left: 4px solid #B45309; }
.lb-item .lb-score { color: var(--secondary); }

/* Utilities */
.bot-hint { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: 15px; font-style: italic; }

.toast { position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%); background: var(--primary); color: white; padding: 12px 24px; border-radius: 30px; font-weight: bold; transition: bottom 0.3s; z-index: 9999; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.toast.show { bottom: 30px; }

/* Confetti */
.confetti { position: absolute; width: 10px; height: 10px; z-index: 100; animation: fall 3s linear forwards; }
@keyframes fall { to { transform: translateY(100vh) rotate(720deg); } }
