
* { box-sizing: border-box; }
:root {
  --bg1: #eef6ff;
  --bg2: #fffaf1;
  --panel: rgba(255,255,255,0.95);
  --card: #ffffff;
  --shadow: 0 18px 50px rgba(55, 75, 120, 0.14);
  --red: #ff6f61;
  --blue: #5b8def;
  --green: #66c47a;
  --orange: #ffb84d;
  --gray: #b8c4ce;
  --text: #27323f;
  --muted: #6a7b8d;
  --border: #dbe6f1;
  --success-bg: #effbf3;
  --error-bg: #fff3f1;
}
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 225, 138, 0.28), transparent 26%),
    radial-gradient(circle at top right, rgba(91, 141, 239, 0.20), transparent 22%),
    radial-gradient(circle at bottom left, rgba(255, 111, 97, 0.12), transparent 28%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  color: var(--text);
  padding: 18px;
}
#app {
  max-width: 1520px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.92);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px 28px 18px;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 184, 77, 0.22), transparent 22%),
    radial-gradient(circle at 92% 25%, rgba(102, 196, 122, 0.18), transparent 20%),
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(255,251,245,0.96));
  border-bottom: 1px solid var(--border);
}
.hero-copy {
  width: 100%;
  text-align: center;
}
.hero-copy h1 {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.8rem, 3.2vw, 2.9rem);
  line-height: 1.05;
}
.hero-actions {
  position: absolute;
  top: 24px;
  right: 28px;
}
main { padding: 22px 28px 28px; }
.site-footer {
  width: 100%;
  padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.site-footer-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 auto;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 10px 22px rgba(37, 63, 102, 0.08);
  max-width: min(calc(100% - 12px), 520px);
}
.hero-actions, .settings-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.secondary-btn, .primary-btn, .floating-reset-btn, .category-toggle, .sound-option, .sound-front, .word-button, .sound-replay {
  font-family: 'Fredoka', sans-serif;
}
.secondary-btn, .primary-btn, .floating-reset-btn {
  border: none;
  border-radius: 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.secondary-btn {
  background: linear-gradient(135deg, #fff, #f8fbff);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 14px 18px;
  box-shadow: 0 8px 18px rgba(37, 63, 102, 0.08);
}
.primary-btn {
  background: linear-gradient(135deg, #ff9b73, #ffd45b);
  color: #513615;
  padding: 14px 20px;
  box-shadow: 0 14px 26px rgba(255, 167, 38, 0.25);
}
.floating-reset-btn {
  position: static;
  z-index: auto;
  width: min(100%, 320px);
  min-width: 210px;
  min-height: 84px;
  margin: 18px auto 12px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #6e7cf6, #7a59d1);
  color: #fff;
  box-shadow: 0 18px 36px rgba(92, 107, 192, 0.34);
  border-radius: 26px;
}
.reset-big-icon { font-size: 1.9rem; line-height: 1; }
.secondary-btn:hover, .primary-btn:hover, .floating-reset-btn:hover, .category-toggle:hover, .sound-option:hover, .sound-front:hover, .word-button:hover, .sound-replay:hover { transform: translateY(-2px); }
.settings-panel {
  background: rgba(255,255,255,0.84);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 12px 30px rgba(36, 58, 92, 0.08);
}
.panel-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
h2, h3 { margin: 0; }
.panel-help { margin: 8px 0 0; color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.category-toggle {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.category-toggle.active.red, .sound-option.active.red { border-color: rgba(239,83,80,0.42); background: rgba(239,83,80,0.08); }
.category-toggle.active.blue, .sound-option.active.blue { border-color: rgba(66,165,245,0.42); background: rgba(66,165,245,0.08); }
.category-toggle.active.green, .sound-option.active.green { border-color: rgba(102,187,106,0.45); background: rgba(102,187,106,0.10); }
.category-toggle.active.orange, .sound-option.active.orange { border-color: rgba(255,179,0,0.45); background: rgba(255,179,0,0.12); }
.category-toggle.active.gray, .sound-option.active.gray { border-color: rgba(176,190,197,0.5); background: rgba(176,190,197,0.14); }
.selection-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.selected-count, .current-selection, .status-message {
  padding: 12px 16px;
  border-radius: 18px;
  background: #f7fafc;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.98rem;
}
.selector-groups, .sound-grid { display: flex; flex-direction: column; gap: 20px; }
.selector-group, .card-group {
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 18px;
}
.selector-group-head, .card-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.selector-group-count, .card-group-head span {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef4fb;
  color: var(--muted);
  font-size: 0.92rem;
}
.sound-option-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.sound-option {
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 88px;
}
.sound-option-label { font-size: 1.45rem; font-weight: 700; line-height: 1; }
.sound-option-word { font-size: 0.85rem; color: var(--muted); text-align: center; }
.game-topbar {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.legend { display: flex; flex-wrap: wrap; gap: 10px; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: #fff;
  font-weight: 600;
}
.legend-chip.red { background: var(--red); }
.legend-chip.blue { background: var(--blue); }
.legend-chip.green { background: var(--green); }
.legend-chip.orange { background: var(--orange); color: #4e342e; }
.legend-chip.gray { background: var(--gray); }
.status-message { margin-bottom: 18px; font-size: 1.05rem; }
.status-message[data-tone="success"] { background: var(--success-bg); border-color: rgba(102,187,106,0.28); color: #2e7d32; }
.status-message[data-tone="error"] { background: var(--error-bg); border-color: rgba(239,83,80,0.22); color: #c62828; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 22px; }
.sound-card {
  position: relative;
  min-height: 430px;
  border-radius: 30px;
  background: var(--card);
  border: 2px solid var(--border);
  overflow: hidden;
  box-shadow: 0 16px 34px rgba(34, 49, 63, 0.10);
}
.sound-card[data-color="red"] { border-color: rgba(239,83,80,0.22); }
.sound-card[data-color="blue"] { border-color: rgba(66,165,245,0.26); }
.sound-card[data-color="green"] { border-color: rgba(102,187,106,0.34); }
.sound-card[data-color="orange"] { border-color: rgba(255,179,0,0.34); }
.sound-card[data-color="gray"] { border-color: rgba(176,190,197,0.5); }
.sound-front, .sound-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}
.sound-front {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.97), rgba(247,250,252,0.99));
}
.sound-front.is-playing, .sound-replay.is-playing { animation: pulse 0.9s ease infinite; }
@keyframes pulse { 0%{transform:scale(1)} 50%{transform:scale(1.035)} 100%{transform:scale(1)} }
.sound-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 200px);
  min-height: 180px;
  padding: 16px;
  border-radius: 42px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,255,0.98));
  border: 2px solid var(--border);
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(3rem, 6vw, 4.3rem);
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(34, 49, 63, 0.08);
}
.sound-front[data-color="red"] .sound-badge {
  color: var(--red);
  border-color: rgba(239,83,80,0.26);
  background: linear-gradient(180deg, rgba(255,248,247,0.98), rgba(255,253,252,0.99));
}
.sound-front[data-color="blue"] .sound-badge {
  color: var(--blue);
  border-color: rgba(66,165,245,0.28);
  background: linear-gradient(180deg, rgba(247,251,255,0.98), rgba(252,254,255,0.99));
}
.sound-front[data-color="green"] .sound-badge {
  color: var(--green);
  border-color: rgba(102,187,106,0.30);
  background: linear-gradient(180deg, rgba(248,255,249,0.98), rgba(253,255,253,0.99));
}
.sound-front[data-color="orange"] .sound-badge {
  color: var(--green);
  border-color: rgba(102,187,106,0.30);
  background: linear-gradient(180deg, rgba(248,255,249,0.98), rgba(253,255,253,0.99));
}
.sound-front[data-color="gray"] .sound-badge {
  color: var(--gray);
  border-color: rgba(176,190,197,0.34);
  background: linear-gradient(180deg, rgba(250,252,253,0.98), rgba(255,255,255,0.99));
}
.sound-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,255,0.98));
  border: 2px solid var(--border);
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}
.sound-pill.red { color: var(--red); border-color: rgba(239,83,80,0.26); }
.sound-pill.blue { color: var(--blue); border-color: rgba(66,165,245,0.28); }
.sound-pill.green { color: var(--green); border-color: rgba(102,187,106,0.30); }
.sound-pill.orange { color: var(--green); border-color: rgba(102,187,106,0.30); }
.sound-pill.gray { color: var(--gray); border-color: rgba(176,190,197,0.34); }
.sound-front-icon { margin-top: 18px; font-size: 1.55rem; }
.sound-back { display: none; padding: 14px; }
.sound-card.revealed .sound-front { display: none; }
.sound-card.revealed .sound-back { display: block; }
.sound-replay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.dice-chip, .ear-chip {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff7df, #fff);
  border: 1px solid rgba(255, 184, 77, 0.38);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 18px rgba(255, 184, 77, 0.15);
  font-size: 1.1rem;
}
.word-button {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(246,249,252,0.99));
  padding: 16px 16px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.word-button-top {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}
.word-image-frame {
  width: 100%;
  height: 230px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
}
.word-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
}
.word-colorized {
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  text-align: center;
  font-size: 1.55rem;
}
.empty-state {
  border: 2px dashed var(--border);
  border-radius: 28px;
  padding: 36px 20px;
  background: rgba(255,255,255,0.86);
  text-align: center;
}
.empty-state-icon { font-size: 2.6rem; margin-bottom: 10px; }
.mot { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 0; font-size: clamp(1.35rem, 3vw, 2rem); font-weight: 700; line-height: 1.15; }
.c-rouge { color: var(--red); }
.c-bleu { color: var(--blue); }
.c-vert { color: var(--green); }
.c-vert-sapin { color: #2e7d32; }
.c-gris { color: var(--gray); }
.c-noir { color: var(--text); }
@media (max-width: 920px) {
  body { padding: 10px; }
  .hero, main, .site-footer { padding-left: 16px; padding-right: 16px; }
  .hero {
    padding-top: 72px;
    justify-content: center;
  }
  .selection-summary, .game-topbar { flex-direction: column; align-items: stretch; }
  .hero-actions {
    position: absolute;
    top: 14px;
    right: 16px;
    width: auto;
  }
  .settings-buttons { width: 100%; }
  .hero-actions > *, .settings-buttons > * { flex: 1 1 180px; }
  .cards-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .floating-reset-btn { min-width: 180px; min-height: 78px; }
}
@media (max-width: 640px) {
  .sound-option-list, .cards-grid { grid-template-columns: 1fr; }
  .sound-card { min-height: 390px; }
  .sound-badge { min-height: 150px; }
  .word-image-frame { height: 190px; }
  .settings-buttons .secondary-btn, .settings-buttons .primary-btn { width: 100%; justify-content: center; }
  .hero-actions .secondary-btn { width: auto; }
  .floating-reset-btn { width: min(100%, 320px); min-width: 0; }
  .site-footer { padding-bottom: 0; }
}


/* Interface enfant : une seule lettre à la fois */
.sound-grid.single-card-mode {
  min-height: min(78vh, 920px);
}
.single-card-shell {
  display: flex;
  justify-content: center;
  align-items: stretch;
}
.fullscreen-card {
  width: min(100%, 980px);
  min-height: min(78vh, 860px);
  position: relative;
  overflow: hidden;
}
.fullscreen-card .sound-front,
.fullscreen-card .sound-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fullscreen-card .sound-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: clamp(20px, 4vw, 40px);
}
.sound-front-help {
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  color: var(--muted);
  text-align: center;
}
.fullscreen-card .sound-badge {
  width: min(100%, 520px);
  min-height: min(48vh, 360px);
  font-size: clamp(4.5rem, 16vw, 9rem);
  border-radius: 48px;
}
.fullscreen-card .sound-back {
  display: none;
  padding: clamp(16px, 3vw, 28px);
  gap: clamp(14px, 2vw, 20px);
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
.sound-card.revealed .sound-back {
  display: flex;
}
.child-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}
.child-action-btn {
  width: 100%;
  min-height: 82px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  border: 2px solid var(--border);
  box-shadow: 0 12px 22px rgba(37, 63, 102, 0.10);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1rem, 2.8vw, 1.22rem);
  font-weight: 600;
  text-align: center;
}
.child-action-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff7df, #fff);
  border: 1px solid rgba(255, 184, 77, 0.38);
  box-shadow: 0 10px 18px rgba(255, 184, 77, 0.15);
  flex: 0 0 auto;
}
.child-action-text {
  white-space: normal;
  overflow-wrap: anywhere;
}
.listen-word-btn {
  background: linear-gradient(135deg, #fff7f2, #ffffff);
}
.change-example-btn {
  background: linear-gradient(135deg, #f7fbff, #ffffff);
}

.word-display-panel {
  cursor: default;
}
.word-display-panel:hover {
  transform: none;
}
.child-action-btn.is-playing {
  animation: pulse 0.9s ease infinite;
}
.fullscreen-card .word-button {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  padding: clamp(14px, 2.3vw, 22px);
  gap: clamp(12px, 1.8vw, 16px);
  justify-content: flex-start;
}
.fullscreen-card .word-image-frame {
  flex: 1 1 0;
  min-height: clamp(180px, 34vh, 340px);
  height: auto;
  margin-top: 0;
  padding: clamp(14px, 2vw, 22px);
}
.fullscreen-card .word-image {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.fullscreen-card .word-colorized {
  width: 100%;
  min-height: 0;
  flex: 0 0 auto;
  padding: 8px 6px 4px;
  font-size: clamp(3.2rem, 8vw, 5.8rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.fullscreen-card .mot {
  max-width: 100%;
  font-size: inherit;
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.floating-reset-btn {
  min-width: 250px;
}
.floating-reset-btn:hover {
  transform: translateY(-2px);
}
@media (max-width: 920px) {
  main {
    padding-bottom: 24px;
  }
  .sound-grid.single-card-mode {
    min-height: auto;
  }
  .fullscreen-card {
    min-height: min(76vh, 760px);
  }
  .fullscreen-card .sound-badge {
    width: min(100%, 420px);
    min-height: min(40vh, 300px);
    font-size: clamp(4rem, 20vw, 7rem);
  }
  .fullscreen-card .word-image-frame {
    min-height: clamp(170px, 30vh, 260px);
  }
  .fullscreen-card .word-colorized {
    font-size: clamp(2.8rem, 9vw, 5rem);
  }
}
@media (max-width: 640px) {
  .child-actions {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .child-action-btn {
    min-height: 74px;
    border-radius: 20px;
    padding: 12px 10px;
    gap: 8px;
    font-size: 0.98rem;
  }
  .child-action-icon {
    width: 38px;
    height: 38px;
  }

/* Correctif ciblé : centrer uniquement l'image et le mot dans le cadre blanc actuel */
.single-sound-stage .word-button {
  align-items: center;
  text-align: center;
}

.single-sound-stage .word-image-frame {
  width: min(100%, 420px);
  margin-left: auto;
  margin-right: auto;
}

.single-sound-stage .word-colorized,
.single-sound-stage .mot {
  width: 100%;
  justify-content: center;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 920px) {
  .single-sound-stage .word-image-frame {
    width: min(100%, 360px);
  }
}

@media (max-width: 640px) {
  .single-sound-stage .word-image-frame {
    width: min(100%, 280px);
  }
}
