/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #0f0e17;
  --bg-card: #1a1932;
  --bg-card-light: #232246;
  --primary: #7f5af0;
  --primary-light: #a78bfa;
  --secondary: #2cb67d;
  --accent: #e94560;
  --text: #fffffe;
  --text-muted: #94a1b2;
  --text-dark: #0f0e17;
  --warning: #ff8906;
  --heart: #e94560;
  --heart-empty: #3a3960;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow-x: hidden;
}

body {
  background: linear-gradient(135deg, #0f0e17 0%, #1a1040 50%, #0f0e17 100%);
  min-height: 100vh;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100vh;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== TYPOGRAPHY ===== */
.title {
  font-size: 2.8rem;
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

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

h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  text-align: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.8rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6c3bd5);
  color: white;
  box-shadow: 0 4px 15px rgba(127, 90, 240, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(127, 90, 240, 0.5);
}

.btn-secondary {
  background: var(--bg-card-light);
  color: var(--text);
  border: 2px solid var(--primary);
}

.btn-accent {
  background: linear-gradient(135deg, var(--secondary), #1e9e6b);
  color: white;
  box-shadow: 0 4px 15px rgba(44, 182, 125, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent), #c23152);
  color: white;
}

.btn-full {
  width: 100%;
  margin-top: 1rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  width: 100%;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 1rem;
  padding: 0.3rem 0;
}

.btn-back:hover {
  color: var(--text);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border: 2px solid var(--bg-card-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ===== TOGGLE BUTTONS ===== */
.toggle-group {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.toggle-btn {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card);
  border: 2px solid var(--bg-card-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== ROOM CODE BOX ===== */
.room-code-box {
  text-align: center;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.room-code-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.room-code {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 0.4rem;
  color: var(--primary-light);
}

/* ===== SETTINGS DISPLAY ===== */
.settings-display {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
}

.settings-tag {
  padding: 0.3rem 0.8rem;
  background: var(--bg-card-light);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lobby-settings-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.lobby-settings-form .form-group {
  margin-bottom: 0.8rem;
}

.lobby-settings-form .form-group:last-child {
  margin-bottom: 0;
}

.lobby-settings-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== PLAYER LIST ===== */
.player-list {
  margin-bottom: 1rem;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.player-item .player-name {
  font-weight: 600;
}

.player-item .player-role {
  font-size: 0.8rem;
  color: var(--primary-light);
}

/* ===== GAME HEADER ===== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  padding: 0.3rem 0.8rem;
  background: var(--primary);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.round-info, .question-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 0.8rem;
}

.card.highlight {
  border-left: 4px solid var(--primary);
}

.current-player-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.current-player-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-light);
}

.question-label, .answer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
}

.answer-card {
  background: linear-gradient(135deg, #1a3a2a, #1a2a1a);
  border-left: 4px solid var(--secondary);
}

.answer-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--secondary);
}

/* ===== LIVES ===== */
.player-lives-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.lives-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.lives-item.eliminated {
  opacity: 0.4;
  text-decoration: line-through;
}

.lives-item.current-turn {
  border: 2px solid var(--primary);
  background: var(--bg-card-light);
}

.hearts {
  display: inline-flex;
  gap: 2px;
}

.heart {
  color: var(--heart);
  font-size: 0.9rem;
}

.heart.empty {
  color: var(--heart-empty);
}

/* ===== PLAYER LIVES GRID ===== */
.player-lives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.lives-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.8rem;
  text-align: center;
  transition: all 0.3s;
}

.lives-card.eliminated {
  opacity: 0.35;
}

.lives-card.current-turn {
  border: 2px solid var(--primary);
  box-shadow: 0 0 15px rgba(127, 90, 240, 0.3);
}

.lives-card .lives-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lives-card .lives-hearts {
  font-size: 1.3rem;
  display: flex;
  justify-content: center;
  gap: 3px;
}

/* ===== PLAYER GAME CONTENT ===== */
.player-question-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.player-question-card .q-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.player-question-card .q-text {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
}

.player-answer-box {
  background: linear-gradient(135deg, #1a3a2a, #1a2a1a);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
  margin-bottom: 1rem;
  border-left: 4px solid var(--secondary);
}

.player-answer-box .a-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.player-answer-box .a-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--secondary);
}

.waiting-box {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.waiting-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-card-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.turn-indicator {
  text-align: center;
  padding: 0.6rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 600;
  color: var(--primary-light);
}

/* ===== VOTING ===== */
.vote-progress {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.vote-btn {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--bg-card);
  border: 2px solid var(--bg-card-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

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

.vote-btn:active {
  transform: scale(0.98);
}

.vote-btn.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, #3a1525, #2a1020);
}

/* ===== ROUND RESULT ===== */
.result-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}

.result-entry.loser {
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, #2a1525, var(--bg-card));
}

.result-name {
  font-weight: 600;
}

.result-votes {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-weight: 700;
}

.result-votes .vote-count {
  font-size: 1.2rem;
  color: var(--accent);
}

.result-message {
  text-align: center;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.1rem;
}

.result-message.lost-life {
  background: linear-gradient(135deg, #3a1525, #2a1020);
  color: var(--accent);
}

.result-message.tie {
  background: var(--bg-card);
  color: var(--warning);
}

/* ===== DUEL (STECHEN) ===== */
.duel-title {
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
  color: var(--warning);
  margin-bottom: 1rem;
}

.duel-scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.duel-score-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.8rem;
  text-align: center;
  transition: all 0.3s;
  max-width: 160px;
}

.duel-score-card.current-turn {
  border: 2px solid var(--primary);
  box-shadow: 0 0 15px rgba(127, 90, 240, 0.3);
}

.duel-score-card .ds-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duel-score-card .ds-score {
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary-light);
}

.duel-vs {
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--accent);
}

.duel-judge-buttons {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.duel-judge-buttons .btn {
  flex: 1;
}

.judgment-result {
  text-align: center;
  padding: 1rem;
  margin: 0.8rem 0;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.3rem;
}

.judgment-result.correct {
  background: linear-gradient(135deg, #1a3a2a, #1a2a1a);
  color: var(--secondary);
}

.judgment-result.wrong {
  background: linear-gradient(135deg, #3a1525, #2a1020);
  color: var(--accent);
}

.duel-final-scores {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.duel-final-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: center;
}

.duel-final-card.winner {
  border: 2px solid var(--secondary);
  box-shadow: 0 0 20px rgba(44, 182, 125, 0.3);
}

.duel-final-card .df-name {
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.duel-final-card .df-score {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary-light);
}

/* ===== GAME OVER ===== */
.game-over-content {
  text-align: center;
}

.winner-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.winner-name {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--secondary);
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
}

/* ===== DISPLAY VIEW ===== */
.display-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
}

.display-title {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.display-info {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.display-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.display-player-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: all 0.5s ease;
}

.display-player-card.eliminated {
  opacity: 0.25;
  transform: scale(0.9);
}

.display-player-card.current-turn {
  border: 3px solid var(--primary);
  box-shadow: 0 0 30px rgba(127, 90, 240, 0.4);
  transform: scale(1.05);
}

.display-player-card .dp-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.display-player-card .dp-hearts {
  font-size: 2rem;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.display-player-card.eliminated .dp-name {
  text-decoration: line-through;
}

.display-status {
  font-size: 1.3rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 1rem;
}

.display-status.voting {
  color: var(--warning);
}

.display-status.game-over {
  color: var(--secondary);
  font-size: 2rem;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card-light);
  color: var(--text);
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  z-index: 1000;
  transition: transform 0.3s ease;
  border: 1px solid var(--primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--accent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .title {
    font-size: 2.2rem;
  }

  .room-code {
    font-size: 2rem;
  }

  .display-title {
    font-size: 2rem;
  }

  .btn {
    padding: 0.75rem 1.2rem;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 520px;
  }
}

/* ===== SCREEN: DISPLAY (full-screen optimized) ===== */
#screen-display {
  padding: 2rem;
}

#screen-display.active {
  align-items: flex-start;
}
