/* ===== Variables CSS ===== */
:root {
  --primary-color: #58cc02;
  --primary-hover: #46a302;
  --primary-dark: #3d8a02;
  --secondary-color: #1cb0f6;
  --secondary-hover: #1899d6;
  --accent-color: #ff4b4b;
  --accent-hover: #ea2b2b;
  --warning-color: #ffc800;
  --background-color: #131f24;
  --background-light: #1a2c32;
  --card-background: #1f3540;
  --text-color: #ffffff;
  --text-secondary: #afafaf;
  --text-muted: #777777;
  --border-color: #3a4a50;
  --success-color: #58cc02;
  --error-color: #ff4b4b;
  --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --border-radius: 16px;
  --border-radius-small: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-large: 0 8px 24px rgba(0, 0, 0, 0.4);
  --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  /* Empêche le zoom sur les inputs pour mobile */
  touch-action: manipulation;
  /* Améliore le défilement sur iOS */
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: var(--font-family);
  background: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* ===== App Container ===== */
.app-container {
  width: 100%;
  height: 100vh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  /* Support pour les appareils avec encoche */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== Screens ===== */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.screen-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

/* ===== Back Button ===== */
.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--border-radius-small);
  transition: var(--transition);
  z-index: 10;
}

.back-btn:hover {
  background: var(--card-background);
  color: var(--text-color);
}

/* ===== Home Screen ===== */
#homeScreen {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.logo-container {
  margin-bottom: 40px;
}

.logo {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.logo-container h1 {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.pvp-badge {
  background: linear-gradient(135deg, var(--accent-color), #ff6b6b);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 24px;
  color: white;
  margin-left: 8px;
}

.tagline {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 600;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.home-footer {
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 0 var(--primary-dark);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--primary-dark);
}

.btn-primary:disabled {
  background: var(--text-muted);
  box-shadow: 0 4px 0 #555;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
  box-shadow: 0 4px 0 #1280b3;
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--text-color);
  border: 3px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-large {
  padding: 18px 36px;
  font-size: 18px;
  width: 100%;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

.btn-icon {
  font-size: 20px;
}

/* ===== Form Elements ===== */
.form-group {
  width: 100%;
  max-width: 320px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 16px 20px;
  background: var(--card-background);
  border: 3px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color);
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(88, 204, 2, 0.2);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

/* ===== Difficulty Selector ===== */
.difficulty-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.difficulty-option {
  cursor: pointer;
}

.difficulty-option input[type="radio"] {
  display: none;
}

.difficulty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: var(--card-background);
  border: 3px solid var(--border-color);
  border-radius: var(--border-radius-small);
  transition: var(--transition);
  text-align: center;
  min-height: 100px;
}

.difficulty-card:hover {
  border-color: var(--text-secondary);
  transform: translateY(-2px);
}

.difficulty-option input[type="radio"]:checked + .difficulty-card {
  border-color: var(--primary-color);
  background: rgba(88, 204, 2, 0.1);
  box-shadow: 0 0 20px rgba(88, 204, 2, 0.2);
}

.difficulty-option input[type="radio"]:checked + .difficulty-card.beginner {
  border-color: #58cc02;
  background: rgba(88, 204, 2, 0.1);
}

.difficulty-option input[type="radio"]:checked + .difficulty-card.intermediate {
  border-color: #1cb0f6;
  background: rgba(28, 176, 246, 0.1);
}

.difficulty-option input[type="radio"]:checked + .difficulty-card.advanced {
  border-color: #ff4b4b;
  background: rgba(255, 75, 75, 0.1);
}

.difficulty-option input[type="radio"]:checked + .difficulty-card.mixed {
  border-color: #ffc800;
  background: rgba(255, 200, 0, 0.1);
}

.difficulty-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.difficulty-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-color);
  margin-bottom: 2px;
}

.difficulty-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Difficulty Badge in Lobby */
.difficulty-badge-container {
  text-align: center;
  margin: 15px 0;
}

.difficulty-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
}

.difficulty-badge.beginner {
  background: rgba(88, 204, 2, 0.2);
  color: #58cc02;
  border: 2px solid #58cc02;
}

.difficulty-badge.intermediate {
  background: rgba(28, 176, 246, 0.2);
  color: #1cb0f6;
  border: 2px solid #1cb0f6;
}

.difficulty-badge.advanced {
  background: rgba(255, 75, 75, 0.2);
  color: #ff4b4b;
  border: 2px solid #ff4b4b;
}

.difficulty-badge.mixed {
  background: rgba(255, 200, 0, 0.2);
  color: #ffc800;
  border: 2px solid #ffc800;
}

.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 24px !important;
}

/* ===== Game Code Display ===== */
.game-code-container {
  text-align: center;
  margin: 20px 0;
}

.game-code-container p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 600;
}

.game-code {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--primary-color);
  background: var(--card-background);
  padding: 16px 32px;
  border-radius: var(--border-radius);
  border: 3px solid var(--primary-color);
  margin-bottom: 12px;
}

/* ===== Players List ===== */
.players-list {
  width: 100%;
  max-width: 400px;
}

.players-list h3 {
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-background);
  padding: 16px 20px;
  border-radius: var(--border-radius-small);
  margin-bottom: 12px;
  border: 2px solid var(--border-color);
}

.player-card.waiting {
  opacity: 0.5;
  border-style: dashed;
}

.player-avatar {
  font-size: 32px;
}

.player-name {
  flex: 1;
  font-weight: 700;
  font-size: 18px;
}

.host-badge {
  background: var(--warning-color);
  color: #333;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.hint-text {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  margin-top: 16px;
}

/* ===== Game Screen ===== */
#gameScreen, #localGameScreen {
  padding: 16px;
  gap: 0;
}

.game-header {
  margin-bottom: 16px;
}

/* Progress Bar */
.progress-container {
  position: relative;
  height: 24px;
  background: var(--card-background);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: 12px;
  transition: width 0.3s ease;
  width: 10%;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Scores Container */
.scores-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.score-card {
  flex: 1;
  background: var(--card-background);
  padding: 12px 16px;
  border-radius: var(--border-radius-small);
  text-align: center;
  border: 3px solid var(--border-color);
  transition: var(--transition);
}

.score-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 20px rgba(88, 204, 2, 0.3);
}

.score-card .score-name {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-card .score-value {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-color);
}

.score-card .score-status {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  min-height: 16px;
}

.score-card .score-status.answered {
  color: var(--success-color);
}

.vs-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-color);
  background: var(--card-background);
  padding: 8px 12px;
  border-radius: 50%;
}

/* Timer */
.timer-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.timer-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--card-background);
  border: 4px solid var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.timer-circle.warning {
  border-color: var(--warning-color);
  animation: pulse 0.5s infinite;
}

.timer-circle.danger {
  border-color: var(--error-color);
  animation: pulse 0.3s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.timer-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-color);
}

/* Local Turn Indicator */
.local-turn-indicator {
  text-align: center;
  margin: 16px 0;
  padding: 12px;
  background: var(--card-background);
  border-radius: var(--border-radius-small);
  border: 2px solid var(--primary-color);
}

.turn-text {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.turn-player {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-color);
}

/* Question Container */
.question-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: var(--card-background);
  border-radius: var(--border-radius);
  margin-bottom: 16px;
}

.question-type-badge {
  background: var(--secondary-color);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.question-text {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 12px;
  max-width: 100%;
}

.question-hint {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 24px;
}

/* Answer Input */
.answer-input-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  gap: 12px;
}

.answer-input-container input {
  flex: 1;
  padding: 16px 20px;
  background: var(--background-color);
  border: 3px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-color);
  transition: var(--transition);
}

.answer-input-container input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* MCQ Options */
.mcq-container {
  width: 100%;
  max-width: 400px;
}

.mcq-options {
  display: grid;
  gap: 12px;
}

.mcq-option {
  padding: 16px 20px;
  background: var(--background-color);
  border: 3px solid var(--border-color);
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-color);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.mcq-option:hover {
  border-color: var(--primary-color);
  background: var(--card-background);
}

.mcq-option.selected {
  border-color: var(--primary-color);
  background: rgba(88, 204, 2, 0.1);
}

.mcq-option.correct {
  border-color: var(--success-color);
  background: rgba(88, 204, 2, 0.2);
}

.mcq-option.incorrect {
  border-color: var(--error-color);
  background: rgba(255, 75, 75, 0.2);
}

/* Feedback Overlay */
.feedback-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 100;
}

.feedback-overlay.show {
  opacity: 1;
  visibility: visible;
}

.feedback-content {
  text-align: center;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.feedback-icon {
  font-size: 80px;
  margin-bottom: 16px;
}

.feedback-icon.correct {
  color: var(--success-color);
}

.feedback-icon.incorrect {
  color: var(--error-color);
}

.feedback-text {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.feedback-xp {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  text-align: center;
}

.feedback-xp .xp-gain {
  display: block;
  font-size: 32px;
  font-weight: 800;
  color: var(--primary-color);
  margin-bottom: 16px;
}

.feedback-xp .correct-answer {
  display: block;
  font-size: 16px;
  color: var(--text-color);
  margin-bottom: 8px;
}

.feedback-xp .correct-answer strong {
  color: var(--primary-color);
  font-size: 20px;
}

.feedback-xp .your-answer {
  font-size: 14px;
  color: var(--text-muted);
}

.opponent-result {
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--card-background);
  border-radius: var(--border-radius-small);
  border: 2px solid var(--border-color);
}

.opponent-name {
  font-weight: 700;
  color: var(--text-secondary);
}

.opponent-correct {
  color: var(--success-color);
  font-weight: 700;
}

.opponent-incorrect {
  color: var(--error-color);
  font-weight: 700;
}

.opponent-timeout {
  color: var(--warning-color);
  font-weight: 700;
}

.next-question-timer {
  margin-top: 24px;
  padding: 12px 20px;
  background: var(--secondary-color);
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.next-question-timer span {
  font-size: 20px;
  font-weight: 800;
}

/* Skip Button */
.skip-btn {
  margin-top: 20px;
  padding: 14px 28px;
  font-size: 16px;
}

.skip-btn.skipped {
  background: var(--primary-color);
  box-shadow: 0 4px 0 var(--primary-dark);
}

.skip-btn #skipStatus {
  opacity: 0.8;
  font-size: 14px;
}

/* ===== Results Screen ===== */
.results-header {
  text-align: center;
  margin-bottom: 32px;
}

.trophy-icon {
  font-size: 80px;
  margin-bottom: 16px;
  animation: bounce 2s infinite;
}

.results-header h2 {
  font-size: 28px;
  color: var(--text-color);
}

.final-scores {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.final-score-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card-background);
  padding: 20px 24px;
  border-radius: var(--border-radius);
  border: 3px solid var(--border-color);
}

.final-score-card.winner {
  border-color: var(--warning-color);
  box-shadow: 0 0 30px rgba(255, 200, 0, 0.3);
}

.final-rank {
  font-size: 40px;
}

.final-name {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
}

.final-score {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary-color);
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

/* ===== Récapitulatif ===== */
.results-content {
  padding-bottom: 40px;
  /* Support pour les barres de navigation iOS/Android */
  padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
}

.recap-container {
  width: 100%;
  max-width: 500px;
  margin: 24px 0;
}

.recap-container h3 {
  text-align: center;
  color: var(--text-color);
  margin-bottom: 16px;
  font-size: 20px;
}

.recap-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.recap-item {
  background: var(--card-background);
  border-radius: var(--border-radius-small);
  padding: 16px;
  border: 2px solid var(--border-color);
}

.recap-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.recap-question-num {
  background: var(--secondary-color);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.recap-type {
  font-size: 12px;
  color: var(--text-muted);
}

.recap-question {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 12px;
  line-height: 1.4;
}

.recap-correct-answer {
  background: rgba(88, 204, 2, 0.1);
  border: 1px solid var(--success-color);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.recap-correct-answer span {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.recap-correct-answer strong {
  display: block;
  color: var(--success-color);
  font-size: 14px;
  margin-top: 2px;
}

.recap-players {
  display: flex;
  gap: 8px;
}

.recap-player {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.recap-player.correct {
  background: rgba(88, 204, 2, 0.15);
  border: 1px solid var(--success-color);
}

.recap-player.incorrect {
  background: rgba(255, 75, 75, 0.15);
  border: 1px solid var(--error-color);
}

.recap-player.no-answer {
  background: rgba(175, 175, 175, 0.15);
  border: 1px solid var(--text-muted);
}

.recap-player-name {
  display: block;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 2px;
  font-size: 11px;
}

.recap-player-answer {
  display: block;
  color: var(--text-color);
  font-weight: 600;
}

.recap-player-xp {
  display: block;
  font-size: 10px;
  color: var(--primary-color);
  margin-top: 2px;
}

/* ===== Local Mode ===== */
.local-players-form {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

.local-players-form .form-group {
  flex: 1;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  padding: 16px 24px;
  border-radius: var(--border-radius-small);
  font-weight: 700;
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success {
  background: var(--success-color);
  color: white;
}

.toast.error {
  background: var(--error-color);
  color: white;
}

.toast.info {
  background: var(--secondary-color);
  color: white;
}

/* ===== Responsive ===== */

/* Tablettes et petits écrans */
@media (max-width: 768px) {
  .app-container {
    max-width: 100%;
  }
  
  .screen {
    padding: 16px;
  }
  
  .home-buttons {
    max-width: 100%;
    padding: 0 20px;
  }
  
  .form-group {
    max-width: 100%;
  }
  
  .difficulty-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .difficulty-card {
    padding: 12px 8px;
    min-height: 90px;
  }
  
  .difficulty-icon {
    font-size: 24px;
  }
  
  .difficulty-name {
    font-size: 13px;
  }
  
  .difficulty-desc {
    font-size: 10px;
  }
  
  .players-list {
    max-width: 100%;
  }
  
  .answer-input-container {
    max-width: 100%;
  }
  
  .mcq-container {
    max-width: 100%;
  }
  
  .final-scores {
    max-width: 100%;
  }
  
  .results-actions {
    max-width: 100%;
  }
  
  .recap-container {
    max-width: 100%;
  }
  
  .total-scores-display {
    max-width: 100%;
  }
  
  .local-players-form {
    max-width: 100%;
  }
}

/* Smartphones */
@media (max-width: 480px) {
  body {
    font-size: 14px;
  }
  
  .screen {
    padding: 12px;
    padding-bottom: 100px; /* Marge pour la barre de navigation mobile */
  }
  
  .results-content {
    padding-bottom: 120px; /* Plus d'espace pour l'écran des résultats */
  }
  
  .back-btn {
    top: 12px;
    left: 12px;
    font-size: 14px;
    padding: 6px 12px;
  }
  
  /* Logo et titre */
  .logo {
    font-size: 60px;
  }
  
  .logo-container {
    margin-bottom: 30px;
  }
  
  .logo-container h1 {
    font-size: 24px;
  }
  
  .pvp-badge {
    font-size: 16px;
    padding: 3px 10px;
    margin-left: 6px;
  }
  
  .tagline {
    font-size: 16px;
  }
  
  /* Boutons */
  .btn {
    padding: 12px 24px;
    font-size: 14px;
  }
  
  .btn-large {
    padding: 16px 28px;
    font-size: 16px;
  }
  
  .btn-icon {
    font-size: 18px;
  }
  
  .home-buttons {
    gap: 12px;
    padding: 0 12px;
  }
  
  /* Code de partie */
  .game-code {
    font-size: 32px;
    letter-spacing: 4px;
    padding: 12px 20px;
  }
  
  /* Cartes joueurs */
  .player-card {
    padding: 12px 16px;
    gap: 12px;
  }
  
  .player-avatar {
    font-size: 28px;
  }
  
  .player-name {
    font-size: 16px;
  }
  
  .host-badge {
    font-size: 11px;
    padding: 3px 10px;
  }
  
  /* Scores */
  .scores-container {
    gap: 8px;
  }
  
  .score-card {
    padding: 10px 12px;
  }
  
  .score-card .score-name {
    font-size: 11px;
  }
  
  .score-card .score-value {
    font-size: 18px;
  }
  
  .score-card .score-status {
    font-size: 10px;
  }
  
  .vs-badge {
    font-size: 12px;
    padding: 6px 10px;
  }
  
  /* Timer */
  .timer-container {
    margin: 16px 0;
  }
  
  .timer-circle {
    width: 70px;
    height: 70px;
    border-width: 3px;
  }
  
  .timer-value {
    font-size: 28px;
  }
  
  /* Indicateur de tour local */
  .local-turn-indicator {
    margin: 12px 0;
    padding: 10px;
  }
  
  .turn-text {
    font-size: 12px;
  }
  
  .turn-player {
    font-size: 20px;
  }
  
  /* Questions */
  .question-container {
    padding: 16px;
    margin-bottom: 12px;
  }
  
  .question-type-badge {
    font-size: 11px;
    padding: 5px 14px;
    margin-bottom: 12px;
  }
  
  .question-text {
    font-size: 18px;
    line-height: 1.3;
    margin-bottom: 10px;
  }
  
  .question-hint {
    font-size: 13px;
    margin-bottom: 20px;
  }
  
  /* Input et options */
  .answer-input-container {
    gap: 8px;
  }
  
  .answer-input-container input {
    padding: 14px 16px;
    font-size: 16px;
  }
  
  .mcq-options {
    gap: 10px;
  }
  
  .mcq-option {
    padding: 14px 16px;
    font-size: 14px;
  }
  
  /* Formulaires */
  .form-group input {
    padding: 14px 18px;
    font-size: 16px;
  }
  
  .form-group label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  
  .code-input {
    letter-spacing: 3px;
    font-size: 20px !important;
  }
  
  /* Feedback */
  .feedback-icon {
    font-size: 60px;
    margin-bottom: 12px;
  }
  
  .feedback-text {
    font-size: 20px;
    margin-bottom: 6px;
  }
  
  .feedback-xp {
    font-size: 16px;
  }
  
  .feedback-xp .xp-gain {
    font-size: 28px;
    margin-bottom: 12px;
  }
  
  .feedback-xp .correct-answer {
    font-size: 14px;
  }
  
  .feedback-xp .correct-answer strong {
    font-size: 18px;
  }
  
  .feedback-xp .your-answer {
    font-size: 13px;
  }
  
  .opponent-result {
    margin-top: 16px;
    padding: 10px 14px;
  }
  
  .next-question-timer {
    margin-top: 20px;
    padding: 10px 18px;
    font-size: 14px;
  }
  
  .next-question-timer span {
    font-size: 18px;
  }
  
  /* Bouton skip */
  .skip-btn {
    margin-top: 16px;
    padding: 12px 24px;
    font-size: 14px;
  }
  
  /* Résultats */
  .trophy-icon {
    font-size: 60px;
    margin-bottom: 12px;
  }
  
  .results-header {
    margin-bottom: 24px;
  }
  
  .results-header h2 {
    font-size: 24px;
  }
  
  .final-scores {
    gap: 12px;
    margin-bottom: 24px;
  }
  
  .final-score-card {
    padding: 16px 20px;
    gap: 12px;
  }
  
  .final-rank {
    font-size: 32px;
  }
  
  .final-name {
    font-size: 18px;
  }
  
  .final-score {
    font-size: 20px;
  }
  
  /* Récapitulatif */
  .recap-container {
    margin: 20px 0;
  }
  
  .recap-container h3 {
    font-size: 18px;
    margin-bottom: 12px;
  }
  
  .recap-list {
    gap: 10px;
    max-height: 350px;
  }
  
  .recap-item {
    padding: 12px;
  }
  
  .recap-question-num {
    font-size: 11px;
    padding: 3px 8px;
  }
  
  .recap-type {
    font-size: 11px;
  }
  
  .recap-question {
    font-size: 13px;
    margin-bottom: 10px;
  }
  
  .recap-correct-answer {
    padding: 6px 10px;
  }
  
  .recap-correct-answer span {
    font-size: 10px;
  }
  
  .recap-correct-answer strong {
    font-size: 13px;
  }
  
  .recap-players {
    gap: 6px;
  }
  
  .recap-player {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  .recap-player-name {
    font-size: 10px;
  }
  
  .recap-player-answer {
    font-size: 12px;
  }
  
  .recap-player-xp {
    font-size: 9px;
  }
  
  /* Mode local */
  .local-players-form {
    flex-direction: column;
    gap: 12px;
  }
  
  /* Scores totaux */
  .total-scores-display {
    padding: 12px;
    margin-top: 12px;
  }
  
  .total-scores-display h3 {
    font-size: 16px;
    margin-bottom: 10px;
  }
  
  .total-score-row {
    padding: 8px 10px;
    margin-bottom: 6px;
  }
  
  .total-name {
    font-size: 14px;
  }
  
  .total-xp {
    font-size: 16px;
    margin: 0 12px;
  }
  
  .total-wins {
    font-size: 11px;
    padding: 3px 6px;
  }
  
  /* Toast notifications */
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }
  
  .toast {
    padding: 12px 20px;
    font-size: 14px;
    max-width: 100%;
  }
  
  /* Progress bar */
  .progress-container {
    height: 10px;
    margin-bottom: 12px;
  }
  
  .progress-text {
    font-size: 9px;
  }
  
  /* Footer */
  .home-footer {
    margin-top: 30px;
    font-size: 13px;
  }
  
  .hint-text {
    font-size: 13px;
    margin-top: 12px;
  }
}

/* Très petits écrans (< 360px) */
@media (max-width: 360px) {
  .logo {
    font-size: 50px;
  }
  
  .logo-container h1 {
    font-size: 20px;
  }
  
  .pvp-badge {
    font-size: 14px;
    padding: 2px 8px;
  }
  
  .game-code {
    font-size: 28px;
    letter-spacing: 2px;
    padding: 10px 16px;
  }
  
  .question-text {
    font-size: 16px;
  }
  
  .mcq-option {
    padding: 12px 14px;
    font-size: 13px;
  }
  
  .btn-large {
    padding: 14px 24px;
    font-size: 15px;
  }
  
  .score-card .score-value {
    font-size: 16px;
  }
  
  .timer-circle {
    width: 60px;
    height: 60px;
  }
  
  .timer-value {
    font-size: 24px;
  }
}

/* Mode paysage mobile */
@media (max-height: 600px) and (orientation: landscape) {
  .logo {
    font-size: 40px;
    margin-bottom: 8px;
  }
  
  .logo-container {
    margin-bottom: 20px;
  }
  
  .logo-container h1 {
    font-size: 20px;
    margin-bottom: 4px;
  }
  
  .tagline {
    font-size: 14px;
  }
  
  .home-buttons {
    gap: 10px;
  }
  
  .btn-large {
    padding: 12px 24px;
    font-size: 15px;
  }
  
  .screen {
    padding: 12px;
  }
  
  .timer-circle {
    width: 60px;
    height: 60px;
  }
  
  .timer-value {
    font-size: 24px;
  }
  
  .question-container {
    padding: 12px;
  }
  
  .question-text {
    font-size: 16px;
  }
  
  .feedback-icon {
    font-size: 50px;
  }
  
  .home-footer {
    margin-top: 20px;
  }
}

/* ===== Animations ===== */
.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.celebrate {
  animation: celebrate 0.6s ease;
}

@keyframes celebrate {
  0% { transform: scale(1); }
  25% { transform: scale(1.1) rotate(-5deg); }
  50% { transform: scale(1.1) rotate(5deg); }
  75% { transform: scale(1.1) rotate(-5deg); }
  100% { transform: scale(1); }
}

/* ===== Total Scores Display ===== */
.total-scores-display {
  width: 100%;
  max-width: 400px;
  background: var(--background-color);
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-top: 16px;
}

.total-scores-display h3 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 12px;
  font-size: 18px;
}

.total-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--card-background);
  border-radius: var(--border-radius-small);
  margin-bottom: 8px;
}

.total-score-row:last-child {
  margin-bottom: 0;
}

.total-name {
  font-weight: 700;
  color: var(--text-color);
  flex: 1;
}

.total-xp {
  font-weight: 800;
  color: var(--primary-color);
  margin: 0 16px;
}

.total-wins {
  font-size: 12px;
  color: var(--warning-color);
  background: rgba(255, 200, 0, 0.2);
  padding: 4px 8px;
  border-radius: 12px;
}
