/* =====================================================
   BASE GÉNÉRALE - OPTIMISÉE MOBILE/TABLETTE/DESKTOP
===================================================== */
:root {
  --primary-blue: #4facfe;
  --secondary-blue: #00f2fe;
  --danger-red: #ff6b6b;
  --success-green: #4caf50;
  --warning-yellow: #ffc107;
  --text-dark: #2c3e50;
  --container-bg: rgba(255, 255, 255, 0.95);
  --disabled-gray: #9e9e9e;
  
  --container-padding: 1.5rem;
  --button-height: 3.5rem;
  --input-height: 3.5rem;
  --spacing: 1rem;
}

html {
  font-size: clamp(16px, 4vw, 22px);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Comic Sans MS', cursive, Tahoma, sans-serif;
  position: relative;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 2px, transparent 2px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(255,255,255,0.1) 3px, transparent 3px);
  background-size: 60px 60px, 40px 40px, 80px 80px;
  pointer-events: none;
  z-index: -1;
}

h1 {
  color: var(--text-dark);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
  font-size: 1.6em;
  margin-bottom: 1rem;
  line-height: 1.2;
}

h2 {
  color: var(--text-dark);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
  font-size: 1.4em;
  margin-bottom: 1rem;
  line-height: 1.2;
}

h3 {
  color: var(--text-dark);
  font-size: 1.2em;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

p {
  color: var(--text-dark);
  font-size: 1em;
  line-height: 1.5;
  margin: 0.5rem 0;
}

/* =====================================================
   QUESTIONS - Mise en forme spéciale
===================================================== */
.question-text {
  font-size: 1.3em;
  line-height: 1.4;
  font-weight: bold;
  color: var(--text-dark);
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.target-word {
  text-decoration: underline;
  font-size: 1.4em;
  color: var(--primary-blue);
  font-weight: bold;
}

/* =====================================================
   CONTENEUR CENTRAL - RESPONSIVE
===================================================== */
.container {
  width: calc(100vw - 2rem);
  max-width: 800px;
  margin: 1rem auto;
  padding: var(--container-padding);
  background: var(--container-bg);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 
    0 10px 30px rgba(0,0,0,0.15),
    0 0 0 1px rgba(255,255,255,0.2);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  min-height: calc(100vh - 2rem);
  min-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
}

.container::before {
  content: '🌟';
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.2em;
  opacity: 0.7;
}

.container::after {
  content: '📚';
  position: absolute;
  bottom: 10px;
  left: 15px;
  font-size: 1.2em;
  opacity: 0.7;
}

#screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--spacing);
}

/* =====================================================
   BOUTONS - OPTIMISÉS POUR TACTILE ET LISIBILITÉ
===================================================== */
button {
  display: block;
  width: 66%;
  max-width: 400px;
  min-height: var(--button-height);
  padding: 1rem;
  margin: 0.5rem auto;
  font-size: 1.2em;
  border: none;
  border-radius: 12px;
  background: linear-gradient(45deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
  color: #000000;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Times New Roman", Times, serif;
  font-weight: bold;
  text-shadow: none;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  text-align: center;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

button:hover, button:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 172, 254, 0.4);
}

button:hover::before, button:focus::before {
  left: 100%;
}

button:active {
  transform: translateY(0);
  transition: transform 0.1s;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  background: linear-gradient(45deg, var(--disabled-gray) 0%, #bdbdbd 100%);
  box-shadow: 0 4px 15px rgba(158, 158, 158, 0.3);
}

button:disabled:hover {
  transform: none !important;
  box-shadow: 0 4px 15px rgba(158, 158, 158, 0.3);
}

/* Boutons spéciaux */
.reset-btn {
  background: linear-gradient(45deg, var(--danger-red) 0%, #ff8e53 100%);
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.reset-btn:hover, .reset-btn:focus {
  box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.success-btn {
  background: linear-gradient(45deg, var(--success-green) 0%, #81c784 100%);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.success-btn:hover, .success-btn:focus {
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4);
}

/* Boutons de familles */
.family-button {
  width: 80% !important;
  font-size: 1.1em;
  padding: 1.5rem;
  margin: 1rem auto;
  text-align: center;
  line-height: 1.3;
  min-height: 4rem;
}

.family-completed {
  background: linear-gradient(45deg, var(--disabled-gray) 0%, #bdbdbd 100%) !important;
  opacity: 0.6;
  color: #666;
}

/* =====================================================
   INPUTS - TACTILE FRIENDLY
===================================================== */
input {
  width: 100%;
  min-height: var(--input-height);
  padding: 1rem;
  margin: 0.5rem 0;
  font-size: 1em;
  border: 3px solid #e3f2fd;
  border-radius: 12px;
  box-sizing: border-box;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 15px rgba(79, 172, 254, 0.3);
  transform: scale(1.02);
}

#name-input {
  width: 100%;
  max-width: 350px;
  margin: 0 auto 1rem;
  text-align: right;
  background: linear-gradient(45deg, rgba(255,255,255,0.9), rgba(240,248,255,0.9));
}

#inp {
  width: 66%;
  max-width: 400px;
  margin: 0.5rem auto;
  display: block;
  text-align: center;
  font-family: "Times New Roman", Times, serif;
  font-weight: bold;
  font-size: 1.2em;
}

/* =====================================================
   LISTES & CARTES D'INFORMATION
===================================================== */
ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  margin: 0.5rem 0;
  padding: 0.8rem;
  background: rgba(79, 172, 254, 0.1);
  border-radius: 10px;
  border-left: 4px solid var(--primary-blue);
  font-weight: bold;
  font-size: 0.9em;
}

.ltr, .options {
  direction: ltr;
}

#progress {
  margin-top: 1rem;
  font-size: 0.9rem;
  padding: 1rem;
  background: rgba(255, 235, 59, 0.2);
  border-radius: 12px;
  border: 2px dashed var(--warning-yellow);
}

/* Cartes d'information */
.info-card {
  background: rgba(33, 150, 243, 0.1);
  padding: 1rem;
  border-radius: 12px;
  margin: 1rem 0;
  border: 2px solid #2196f3;
}

.info-card h4 {
  color: #1976d2;
  margin: 0 0 0.5rem 0;
}

.stats-card {
  background: rgba(76, 175, 80, 0.1);
  padding: 1rem;
  border-radius: 12px;
  margin: 1rem 0;
  border: 2px solid #4caf50;
}

.stats-card h3 {
  color: #2e7d32;
  margin: 0 0 0.5rem 0;
}

.success-card {
  background: rgba(76, 175, 80, 0.2);
  padding: 1rem;
  border-radius: 12px;
  margin: 1rem 0;
  border: 2px solid #4caf50;
}

.success-card h3 {
  color: #2e7d32;
}

/* Affichage des familles en grille */
.families-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1rem 0;
  text-align: center;
}

.family-item {
  background: rgba(79, 172, 254, 0.1);
  padding: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--primary-blue);
  font-weight: bold;
  font-size: 0.9em;
}

/* =====================================================
   RESPONSIVE - ADAPTATIONS MOBILES
===================================================== */

/* Smartphones en portrait */
@media (max-width: 480px) {
  :root {
    --container-padding: 1rem;
    --button-height: 3rem;
    --input-height: 3rem;
  }
  
  .container {
    margin: 0.5rem;
    padding: 1rem;
    max-width: calc(100vw - 1rem);
  }
  
  h1 {
    font-size: 1.4em;
  }
  
  button {
    width: 85%;
    font-size: 1.1em;
    padding: 0.8rem;
  }
  
  .family-button {
    width: 90% !important;
    font-size: 1em;
    padding: 1.2rem;
  }
  
  .question-text {
    font-size: 1.2em;
  }
  
  .target-word {
    font-size: 1.3em;
  }
  
  /* Grille des familles responsive */
  .families-grid {
    gap: 0.3rem;
  }
  
  .family-item {
    padding: 0.6rem;
    font-size: 0.8em;
  }
}

/* Tablettes */
@media (min-width: 481px) and (max-width: 768px) {
  button {
    width: 70%;
  }
  
  .family-button {
    width: 75% !important;
  }
}

/* Desktop */
@media (min-width: 769px) {
  .container {
    max-width: 900px;
  }
  
  button {
    width: 60%;
  }
  
  .family-button {
    width: 70% !important;
  }
}

/* =====================================================
   ANIMATIONS ET TRANSITIONS
===================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.success-card {
  animation: pulse 0.6s ease-in-out;
}

/* =====================================================
   ACCESSIBILITÉ
===================================================== */
button:focus-visible {
  outline: 3px solid #4facfe;
  outline-offset: 2px;
}

input:focus-visible {
  outline: 3px solid #4facfe;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}