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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1f3056;
  --primary: #e94560;
  --primary-hover: #ff6b81;
  --text: #eee;
  --text-muted: #8892b0;
  --green: #2ecc71;
  --red: #e74c3c;
  --choice-1: #e74c3c;
  --choice-2: #3498db;
  --choice-3: #f39c12;
  --choice-4: #2ecc71;
  --choice-1-hover: #ff6b6b;
  --choice-2-hover: #5dade2;
  --choice-3-hover: #f7b731;
  --choice-4-hover: #58d68d;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#view-game.active {
  justify-content: flex-start;
}

.container {
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  text-align: center;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Logo */
.logo {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.logo span {
  color: var(--primary);
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.subtle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 1rem;
}

/* Inputs */
input[type="text"] {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--surface-light);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

input[type="text"]:focus {
  border-color: var(--primary);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

/* Settings */
.settings-label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.time-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.time-btn,
.count-btn,
.lang-btn {
  flex: 1;
  padding: 0.6rem;
  border: 2px solid var(--surface-light);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.time-btn:hover,
.count-btn:hover,
.lang-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.time-btn.active,
.count-btn.active,
.lang-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Buttons */
.btn {
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  width: 100%;
}

.btn-secondary:hover {
  background: #2a4070;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background: var(--surface-light);
  color: var(--text);
  border-radius: 6px;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

/* Lobby code */
.lobby-code-box {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.3rem;
  color: var(--primary);
}

/* Player list */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.player-chip {
  background: var(--surface-light);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.9rem;
}

.player-chip.host::before {
  content: '\u2605 ';
  color: var(--primary);
}

/* Spinner */
.spinner {
  width: 60px;
  height: 60px;
  border: 5px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5rem;
}

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

/* Game header */
.game-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  width: 100%;
}

#q-counter {
  font-weight: 700;
  white-space: nowrap;
  min-width: 60px;
}

.timer-bar-track {
  flex: 1;
  height: 10px;
  background: var(--surface-light);
  border-radius: 5px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--primary);
  border-radius: 5px;
  transition: width 0.25s linear;
}

.timer-bar.warning {
  background: var(--red);
}

#timer-text {
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}

/* Game body */
.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}

.question-text {
  font-size: 1.4rem;
  margin-bottom: 2rem;
  line-height: 1.4;
  text-align: center;
}

/* Choices */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.choice-btn {
  padding: 1.2rem 1rem;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, filter 0.2s;
  text-align: center;
  line-height: 1.3;
}

.choice-btn:nth-child(1) { background: var(--choice-1); }
.choice-btn:nth-child(2) { background: var(--choice-2); }
.choice-btn:nth-child(3) { background: var(--choice-3); }
.choice-btn:nth-child(4) { background: var(--choice-4); }

.choice-btn:hover:not(.disabled) {
  transform: scale(1.03);
}

.choice-btn:nth-child(1):hover:not(.disabled) { background: var(--choice-1-hover); }
.choice-btn:nth-child(2):hover:not(.disabled) { background: var(--choice-2-hover); }
.choice-btn:nth-child(3):hover:not(.disabled) { background: var(--choice-3-hover); }
.choice-btn:nth-child(4):hover:not(.disabled) { background: var(--choice-4-hover); }

.choice-btn:active:not(.disabled) {
  transform: scale(0.97);
}

.choice-btn.disabled {
  cursor: default;
  opacity: 0.4;
}

.choice-btn.selected {
  opacity: 1;
  outline: 3px solid #fff;
  outline-offset: -3px;
}

.choice-btn.correct {
  opacity: 1;
  outline: 3px solid var(--green);
  outline-offset: -3px;
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.4);
}

.choice-btn.wrong {
  opacity: 1;
  outline: 3px solid var(--red);
  outline-offset: -3px;
}

/* Answer feedback */
.answer-feedback {
  margin-top: 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

.answer-feedback.correct-feedback {
  color: var(--green);
}

.answer-feedback.wrong-feedback {
  color: var(--red);
}

/* Live scores sidebar */
.live-scores {
  position: fixed;
  top: 60px;
  right: 0;
  width: 200px;
  padding: 1rem;
  background: var(--surface);
  border-left: 1px solid var(--surface-light);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}

.live-scores h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.score-row .rank {
  color: var(--text-muted);
  margin-right: 0.4rem;
}

.score-row .pts {
  font-weight: 700;
  color: var(--primary);
}

/* Results */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1rem;
  margin: 2rem 0;
}

.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.podium-bar {
  width: 100px;
  background: var(--surface-light);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-muted);
}

.podium-place:nth-child(1) .podium-bar { background: #ffd700; color: #1a1a2e; }
.podium-place:nth-child(2) .podium-bar { height: 120px; }
.podium-place:nth-child(3) .podium-bar { height: 80px; }

.podium-name {
  font-weight: 700;
  font-size: 1rem;
}

.podium-score {
  color: var(--primary);
  font-weight: 700;
}

.full-leaderboard {
  margin: 1.5rem 0;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--surface-light);
}

.lb-row:last-child {
  border-bottom: none;
}

.lb-rank {
  width: 30px;
  font-weight: 700;
  color: var(--text-muted);
}

.lb-name {
  flex: 1;
  font-weight: 600;
}

.lb-score {
  font-weight: 700;
  color: var(--primary);
}

/* Responsive */
@media (max-width: 600px) {
  .live-scores {
    position: static;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--surface-light);
    max-height: 150px;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .podium-bar {
    width: 80px;
  }

  .question-text {
    font-size: 1.1rem;
  }
}
