/* ============================================================
   KID-FRIENDLY THEME — That'School
   Palette : couleurs chaudes et joyeuses
   Typo : Fredoka (Google Fonts, rounded + playful)
   Principes : arrondis généreux, ombres colorées, gros boutons pill
   ============================================================ */

:root {
  /* Arrière-plans */
  --bg-primary:     #FFF4E0;       /* crème chaude */
  --bg-secondary:   #FFFFFF;       /* cartes blanches */
  --bg-card:        #FFE8CC;       /* pêche pastel */
  --bg-soft:        #FFF8EC;

  /* Couleurs d'accent joyeuses */
  --accent-coral:   #FF6B6B;       /* corail vif */
  --accent-turquoise: #4ECDC4;     /* turquoise */
  --accent-yellow:  #FFD93D;       /* jaune soleil */
  --accent-mint:    #95E1D3;       /* menthe */
  --accent-purple:  #B388FF;       /* lavande */
  --accent-pink:    #FFB3D1;       /* rose poudré */
  --accent-orange:  #FFA94D;       /* orange doux */

  /* Texte */
  --text-dark:      #2C3E50;       /* bleu-gris foncé */
  --text-soft:      #7F8C8D;
  --text-light:     #FFFFFF;

  /* Rayons / ombres */
  --radius:         24px;
  --radius-sm:      16px;
  --radius-pill:    999px;
  --shadow-soft:    0 6px 20px rgba(255, 107, 107, 0.15);
  --shadow-strong:  0 10px 30px rgba(255, 107, 107, 0.25);
  --shadow-card:    0 8px 24px rgba(44, 62, 80, 0.08);

  --transition:     0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  --digit-font:     Arial, "Helvetica Neue", Helvetica, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(135deg, #FFF4E0 0%, #FFE8CC 50%, #FFD0B4 100%);
  color: var(--text-dark);
  font-family: 'Fredoka', 'Segoe UI', Arial, sans-serif;
  font-size: 18px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: inherit;
  font-weight: 600;
}

/* ============================================================
   FOCUS VISIBLE — indication claire du focus clavier
   ============================================================ */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 4px solid var(--accent-turquoise);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.level-card:focus-visible {
  outline: 5px solid var(--accent-coral);
  outline-offset: 3px;
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 14px 32px rgba(255, 107, 107, 0.35);
}

.btn-confirm-big:focus-visible,
.btn-validate:focus-visible,
.btn-clear:focus-visible,
.btn-results:focus-visible,
.correction-btn:focus-visible,
.key-btn:focus-visible,
.filter-btn:focus-visible {
  outline: 4px solid var(--accent-yellow);
  outline-offset: 3px;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 1.5rem 1rem;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* ============================================================
   SCREEN: HOME
   ============================================================ */
.game-title {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent-coral);
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  text-shadow: 4px 4px 0 rgba(255, 107, 107, 0.15);
}

.total-score-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  padding: 0.8rem 1.8rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  box-shadow: var(--shadow-card);
  border: 3px solid var(--accent-yellow);
}

.total-score-label {
  color: var(--text-soft);
  font-size: 1rem;
  font-weight: 500;
}

#total-score-value,
#gs-total-score-value {
  color: var(--accent-coral);
  font-weight: 700;
  font-size: 2rem;
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
}

.total-score-stars {
  font-size: 1.5rem;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-btn {
  background: var(--bg-secondary);
  color: var(--text-dark);
  padding: 0.9rem 1.8rem;
  border-radius: var(--radius-pill);
  font-size: 1.15rem;
  font-weight: 600;
  border: 3px solid transparent;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
}

.filter-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent-turquoise);
}

.filter-btn.active {
  background: var(--accent-turquoise);
  color: var(--text-light);
  border-color: var(--accent-turquoise);
  box-shadow: 0 8px 24px rgba(78, 205, 196, 0.4);
  transform: translateY(-2px);
}

/* Level grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.2rem;
  width: 100%;
  max-width: 750px;
  padding-bottom: 1rem;
}

.level-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  border: 4px solid var(--accent-yellow);
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}

.level-card:hover {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: 0 14px 32px rgba(255, 107, 107, 0.25);
  border-color: var(--accent-coral);
}

.level-card .level-icon {
  font-size: 2rem;
  margin-bottom: 0.4rem;
}

.level-card .level-number {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent-coral);
  line-height: 1;
}

.level-card .level-stars {
  margin-top: 0.6rem;
  color: var(--accent-yellow);
  font-size: 1.6rem;
  letter-spacing: 0.1em;
}

/* Treasures section */
.treasures-section {
  margin-top: 2rem;
  width: 100%;
  max-width: 750px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow-card);
  border: 3px solid var(--accent-purple);
  text-align: center;
}

.treasures-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

#treasures-count {
  color: var(--accent-purple);
  font-size: 1.1rem;
}

.treasures-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.6rem;
}

@media (max-width: 600px) {
  .treasures-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.treasure-slot {
  aspect-ratio: 1 / 1;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  border: 3px solid transparent;
  transition: all var(--transition);
  position: relative;
}

.treasure-slot.locked {
  opacity: 0.3;
  filter: grayscale(100%);
}

.treasure-slot.unlocked {
  border-color: var(--accent-yellow);
  background: linear-gradient(135deg, #FFF8E0, var(--accent-yellow));
  animation: float 3s ease-in-out infinite;
  box-shadow: 0 4px 16px rgba(255, 217, 61, 0.4);
}

.treasure-slot.unlocked:hover {
  transform: scale(1.15) rotate(-5deg);
}

/* Reset button */
.btn-reset {
  background: transparent;
  color: var(--text-soft);
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border: 2px dashed var(--text-soft);
  border-radius: var(--radius-pill);
  margin-top: 1rem;
  margin-bottom: 2rem;
  transition: all var(--transition);
}

.btn-reset:hover {
  color: var(--accent-coral);
  border-color: var(--accent-coral);
}

/* ============================================================
   SCREEN: GAME
   ============================================================ */

/* Header */
.game-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 850px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
}

.btn-icon {
  background: var(--accent-coral);
  color: var(--text-light);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-icon:hover {
  transform: scale(1.1) rotate(-10deg);
}

.header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.level-name-display {
  font-size: 1.1rem;
  color: var(--text-dark);
  font-weight: 700;
}

.progress-bar-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  height: 14px;
  overflow: hidden;
  width: 100%;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-turquoise), var(--accent-yellow), var(--accent-coral));
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 600;
  text-align: right;
}

.header-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  background: var(--bg-card);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
}

.score-label {
  font-size: 0.7rem;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
}

#game-score-value,
#counting-score-value,
#problem-score-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-coral);
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
}

.streak-display { display: none; }

/* Barre d'énergie (remplace le streak) */
.energy-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex-shrink: 0;
  min-width: 180px;
}

.energy-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.energy-bar {
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  height: 18px;
  overflow: hidden;
  border: 3px solid var(--accent-coral);
  box-shadow: inset 0 2px 6px rgba(44, 62, 80, 0.1);
}

.energy-fill {
  height: 100%;
  background: linear-gradient(90deg,
    var(--accent-coral) 0%,
    var(--accent-orange) 25%,
    var(--accent-yellow) 50%,
    var(--accent-mint) 75%,
    var(--accent-turquoise) 100%);
  border-radius: var(--radius-pill);
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 12px rgba(255, 217, 61, 0.4);
}

.energy-fill.full {
  animation: energyPulse 0.8s ease-in-out infinite alternate;
}

@keyframes energyPulse {
  0%   { box-shadow: 0 0 12px rgba(255, 217, 61, 0.4); }
  100% { box-shadow: 0 0 24px rgba(255, 217, 61, 1), 0 0 36px rgba(255, 107, 107, 0.6); }
}

/* Game main content */
.game-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 850px;
  flex: 1;
  pointer-events: none;
}

.writing-section,
.fallback-keyboard,
.game-header,
.operation-section {
  pointer-events: auto;
}

.answer-cell,
.carry-cell {
  pointer-events: auto;
  cursor: pointer;
}

/* Operation display */
.operation-section {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  pointer-events: none;
}

.operation-display {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-card);
  border: 4px solid var(--accent-yellow);
}

.op-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
}

.op-separator {
  height: 4px;
  background: var(--text-dark);
  width: 100%;
  border-radius: 2px;
}

/* Generic cell */
.op-cell {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 4.5rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  color: var(--text-dark);
}

.op-cell-digit,
.answer-cell,
.carry-cell {
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
}

/* Answer cells (dashed border) */
.answer-cell {
  border: 4px dashed var(--accent-coral);
  background: rgba(255, 217, 61, 0.1);
  transition: all var(--transition);
}

.answer-cell.active {
  border-color: var(--accent-turquoise);
  border-style: dashed;
  background: rgba(78, 205, 196, 0.15);
  box-shadow: 0 0 24px rgba(78, 205, 196, 0.5);
  animation: activePulse 1.5s ease-in-out infinite;
}

.answer-cell.filled {
  border-color: var(--accent-mint);
  background: rgba(149, 225, 211, 0.25);
  border-style: solid;
  color: var(--accent-coral);
}

.answer-cell.wrong {
  border-color: var(--accent-orange);
  background: rgba(255, 169, 77, 0.2);
  border-style: solid;
  color: var(--accent-orange);
}

/* Carry cells (retenues) */
.carry-cell {
  width: 55px;
  height: 55px;
  font-size: 1.8rem;
  border: 3px dashed var(--accent-purple);
  border-radius: 10px;
  color: var(--accent-purple);
  background: rgba(179, 136, 255, 0.1);
}

.carry-cell.active {
  border-color: var(--accent-turquoise);
  background: rgba(78, 205, 196, 0.15);
  box-shadow: 0 0 16px rgba(78, 205, 196, 0.4);
  animation: activePulse 1.5s ease-in-out infinite;
}

.carry-cell.filled {
  border-style: solid;
  color: var(--accent-coral);
}

/* Writing section */
.writing-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.2rem 1.8rem;
  box-shadow: var(--shadow-card);
  border: 3px solid var(--accent-turquoise);
}

.active-cell-label {
  font-size: 1.3rem;
  color: var(--text-dark);
  font-weight: 700;
}

.preview-canvas {
  width: 200px;
  height: 200px;
  background: var(--text-dark);
  border-radius: var(--radius);
  border: 4px solid var(--accent-coral);
  display: block;
  box-shadow: var(--shadow-card);
}

.writing-buttons {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  z-index: 200;
  pointer-events: auto;
}

.btn-validate,
.btn-clear {
  padding: 1.1rem 1.8rem;
  border-radius: var(--radius-pill);
  font-size: 1.3rem;
  font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  min-width: 160px;
  touch-action: manipulation;
}

.btn-validate {
  background: linear-gradient(135deg, var(--accent-turquoise), var(--accent-mint));
  color: var(--text-light);
}

.btn-validate:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(78, 205, 196, 0.45);
}

.btn-clear {
  background: var(--bg-card);
  color: var(--text-dark);
  border: 3px solid var(--accent-coral);
}

.btn-clear:hover {
  transform: translateY(-3px) scale(1.03);
  background: var(--accent-coral);
  color: var(--text-light);
}

/* Fallback keyboard */
.fallback-keyboard {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-card);
  border: 3px solid var(--accent-purple);
}

.keyboard-hint {
  font-size: 0.95rem;
  color: var(--text-soft);
  text-align: center;
  margin-bottom: 0.6rem;
  font-weight: 600;
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.key-btn {
  background: var(--bg-card);
  color: var(--text-dark);
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
  padding: 1rem 0;
  transition: all var(--transition);
  border: 3px solid transparent;
}

.key-btn:hover,
.key-btn:active {
  background: var(--accent-turquoise);
  color: var(--text-light);
  transform: scale(1.08);
}

.key-zero {
  grid-column: 1 / -1;
}

/* Drawing canvas: full-viewport overlay */
#drawing-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5;
  cursor: crosshair;
  touch-action: none;
  background: transparent;
  transition: opacity 1.5s ease-out;
}

/* ============================================================
   OVERLAYS
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(44, 62, 80, 0.55);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

/* ============================================================
   CONFIRMATION MODAL — "J'ai lu ce chiffre : X"
   ============================================================ */
.confirmation-modal {
  z-index: 150;
}

.confirmation-box {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(44, 62, 80, 0.3);
  border: 5px solid var(--accent-turquoise);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: auto;
}

.confirmation-mascot {
  font-size: 4rem;
  margin-bottom: -0.5rem;
  animation: bounceSoft 1.2s ease-in-out infinite;
}

.confirmation-mascot::before {
  content: "🐲";
}

.confirmation-title {
  font-size: 1.4rem;
  color: var(--text-dark);
  font-weight: 600;
}

.confirmation-digit-box {
  width: 160px;
  height: 160px;
  background: linear-gradient(135deg, var(--bg-card), var(--accent-yellow));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 5px solid var(--accent-coral);
  box-shadow: 0 8px 24px rgba(255, 107, 107, 0.3);
}

#confirmation-digit {
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
  font-size: 7rem;
  font-weight: 700;
  color: var(--accent-coral);
  line-height: 1;
}

.confirmation-question {
  font-size: 1.3rem;
  color: var(--text-dark);
  font-weight: 600;
}

.confirmation-buttons {
  display: flex;
  gap: 1.2rem;
  width: 100%;
  justify-content: center;
}

.btn-confirm-big {
  padding: 1.1rem 2.4rem;
  border-radius: var(--radius-pill);
  font-size: 1.4rem;
  font-weight: 700;
  transition: all var(--transition);
  min-width: 140px;
  box-shadow: var(--shadow-soft);
}

.btn-yes-big {
  background: linear-gradient(135deg, var(--accent-turquoise), var(--accent-mint));
  color: var(--text-light);
}

.btn-yes-big:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 14px 32px rgba(78, 205, 196, 0.5);
}

.btn-no-big {
  background: var(--bg-card);
  color: var(--text-dark);
  border: 3px solid var(--accent-coral);
}

.btn-no-big:hover {
  transform: translateY(-4px) scale(1.05);
  background: var(--accent-coral);
  color: var(--text-light);
}

/* Grille de correction (0-9) */
.confirmation-correction {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.8rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--accent-coral);
}

.confirmation-correction::before {
  content: "Clique sur le bon chiffre :";
  grid-column: 1 / -1;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.correction-btn {
  padding: 1rem 0;
  background: var(--bg-card);
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
  transition: all var(--transition);
  border: 3px solid transparent;
}

.correction-btn:hover {
  background: var(--accent-turquoise);
  color: var(--text-light);
  transform: scale(1.08);
  border-color: var(--accent-turquoise);
}

/* ============================================================
   FEEDBACK OVERLAY (bravo / presque)
   ============================================================ */
.feedback-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-secondary);
  padding: 2rem 3rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.feedback-icon {
  font-size: 5rem;
  line-height: 1;
}

.feedback-message {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-turquoise);
}

.feedback-message.wrong {
  color: var(--accent-orange);
}

.feedback-points {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-yellow);
}

/* ============================================================
   SCREEN: RESULTS
   ============================================================ */
#screen-results {
  justify-content: center;
}

.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2.5rem 3rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-strong);
  border: 5px solid var(--accent-yellow);
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.results-title {
  font-size: 2.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-coral), var(--accent-orange), var(--accent-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-stars {
  display: flex;
  gap: 0.8rem;
  font-size: 4rem;
}

.star {
  color: #CCCCCC;
  transition: all 0.4s ease;
}

.star.earned {
  color: var(--accent-yellow);
  text-shadow: 0 4px 16px rgba(255, 217, 61, 0.6);
  animation: starBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.results-score-label {
  font-size: 1rem;
  color: var(--text-soft);
  font-weight: 600;
}

.results-score-value {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent-coral);
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
}

.results-message {
  font-size: 1.3rem;
  color: var(--text-dark);
  text-align: center;
  font-weight: 600;
}

.results-treasure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--bg-card), var(--accent-yellow));
  border-radius: var(--radius);
  border: 4px solid var(--accent-purple);
  animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.treasure-reveal-label {
  font-size: 0.9rem;
  color: var(--accent-purple);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.treasure-reveal-emoji {
  font-size: 4rem;
  animation: float 2.5s ease-in-out infinite;
}

.treasure-reveal-name {
  font-size: 1.1rem;
  color: var(--text-dark);
  font-weight: 700;
}

.results-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
}

.btn-results {
  width: 100%;
  padding: 1.1rem;
  border-radius: var(--radius-pill);
  font-size: 1.2rem;
  font-weight: 700;
  transition: all var(--transition);
  box-shadow: var(--shadow-soft);
}

.btn-results:hover {
  transform: translateY(-3px) scale(1.02);
}

.btn-replay {
  background: var(--bg-card);
  color: var(--text-dark);
  border: 3px solid var(--accent-turquoise);
}

.btn-next {
  background: linear-gradient(135deg, var(--accent-turquoise), var(--accent-mint));
  color: var(--text-light);
}

.btn-home {
  background: var(--bg-card);
  color: var(--text-soft);
}

/* ============================================================
   CONFIRM QUIT OVERLAY
   ============================================================ */
.confirm-box {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  min-width: 320px;
  box-shadow: var(--shadow-strong);
  border: 4px solid var(--accent-coral);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: auto;
}

.confirm-question {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-dark);
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.btn-confirm {
  flex: 1;
  padding: 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 1.2rem;
  font-weight: 700;
  transition: all var(--transition);
  box-shadow: var(--shadow-soft);
}

.btn-confirm:hover {
  transform: translateY(-3px) scale(1.03);
}

.btn-yes {
  background: var(--accent-coral);
  color: var(--text-light);
}

.btn-no {
  background: linear-gradient(135deg, var(--accent-turquoise), var(--accent-mint));
  color: var(--text-light);
}

/* ============================================================
   MASCOT — Drago le dragon
   ============================================================ */
.mascot {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 20;
}

.mascot-body {
  font-size: 5rem;
  line-height: 1;
  display: inline-block;
  transform-origin: center bottom;
  transition: transform 0.3s ease;
}

.mascot-body.state-idle {
  animation: mascotBreathe 3s ease-in-out infinite;
}

.mascot-body.state-happy {
  animation: mascotHappy 0.6s ease-in-out infinite alternate;
}

.mascot-body.state-cheering {
  animation: mascotCheer 0.5s ease-in-out infinite alternate;
}

.mascot-body.state-thinking {
  animation: mascotThink 2.4s ease-in-out infinite;
}

.mascot-body.state-sad {
  animation: mascotSad 2s ease-in-out infinite;
  filter: grayscale(30%);
}

.mascot-bubble {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) scale(0);
  transform-origin: center bottom;
  background: var(--bg-secondary);
  color: var(--text-dark);
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-pill);
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(44, 62, 80, 0.2);
  border: 4px solid var(--accent-yellow);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: 320px;
  text-align: center;
  white-space: normal;
}

.mascot-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.mascot-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 14px solid var(--accent-yellow);
}

/* Mascotte sur l'écran d'accueil : en grand */
.home-mascot {
  margin-bottom: 1rem;
}

.home-mascot:has(.mascot-bubble.visible) {
  margin-bottom: 5.8rem;
}

.home-mascot .mascot-body {
  font-size: 7rem;
}

.home-mascot .mascot-bubble {
  top: calc(100% + 10px);
  bottom: auto;
  width: min(360px, 72vw);
  max-width: none;
  padding: 0.8rem 1.1rem;
  border-radius: 20px;
  font-size: 1.05rem;
  line-height: 1.25;
  transform-origin: center top;
}

.home-mascot .mascot-bubble.visible {
  transform: translateX(-50%) scale(1);
}

.home-mascot .mascot-bubble::after {
  top: auto;
  bottom: 100%;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 0;
  border-bottom: 14px solid var(--accent-yellow);
}

/* Mascotte sur l'écran de résultats */
.results-mascot {
  margin-bottom: -0.5rem;
}
.results-mascot .mascot-body {
  font-size: 5rem;
}

/* Mascotte sur l'écran de jeu : en coin */
.game-mascot {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 20;
}

.game-mascot .mascot-body {
  font-size: 4rem;
}

/* ============================================================
   BOUTON AIDE (Génie)
   ============================================================ */
.btn-aide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  align-self: center;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  margin-top: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-light);
  background: linear-gradient(135deg, var(--accent-purple), #9C6ADE);
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-pill);
  cursor: pointer;
  pointer-events: auto;
  z-index: 11;
  position: relative;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(179, 136, 255, 0.28);
  transition: all var(--transition);
}

.btn-aide:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(179, 136, 255, 0.5);
}

/* ============================================================
   OVERLAY: GENIE TUTORIAL
   ============================================================ */
.genie-overlay {
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(44, 62, 80, 0.58);
  backdrop-filter: blur(3px);
}

.genie-content {
  background: linear-gradient(180deg, #FFF8EC 0%, #FFF0D8 100%);
  border-radius: 22px;
  padding: 1.5rem 1.7rem;
  max-width: 540px;
  width: min(92%, 540px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 18px 48px rgba(44, 62, 80, 0.22);
  border: 3px solid var(--accent-purple);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.genie-character {
  display: flex;
  align-items: center;
  justify-content: center;
}

.genie-emoji {
  font-size: 4rem;
  animation: bounceSoft 1.2s ease-in-out infinite;
}

.genie-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.genie-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-purple);
}

.genie-name-input {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-purple);
  background: var(--bg-secondary);
  border: 2px solid var(--accent-purple);
  border-radius: 10px;
  padding: 0.2rem 0.5rem;
  width: 140px;
  text-align: center;
  outline: none;
}

.genie-name-input:focus {
  box-shadow: 0 0 8px rgba(179, 136, 255, 0.4);
}

.genie-rename-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.1rem;
  transition: transform 0.2s ease;
}

.genie-rename-btn:hover {
  transform: scale(1.2);
}

.genie-bubble-wrapper {
  width: 100%;
}

.genie-bubble {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(179, 136, 255, 0.75);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.42;
  text-align: center;
  min-height: 0;
  transition: all 0.3s ease;
}

/* Opération clonée dans le génie */
.genie-operation {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 0.85rem 1rem;
  border: 2px solid var(--accent-yellow);
}

.genie-op-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.genie-op-cell {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 2.45rem;
  font-weight: 700;
  color: var(--text-dark);
  border-radius: 12px;
  transition: all 0.4s ease;
  position: relative;
}

.genie-op-operator {
  font-size: 1.8rem;
  font-weight: 600;
  width: 34px;
}

.genie-op-separator {
  height: 3px;
  background: var(--text-dark);
  width: 100%;
  border-radius: 2px;
}

.genie-answer {
  border: 2px dashed var(--accent-coral);
  background: rgba(255, 217, 61, 0.1);
  font-size: 1.9rem;
  color: var(--text-soft);
}

.genie-answer.genie-result-filled {
  border-style: solid;
  border-color: var(--accent-mint);
  background: rgba(149, 225, 211, 0.25);
  color: var(--accent-coral);
  font-size: 2.45rem;
}

.genie-op-digit,
.genie-answer {
  font-family: var(--digit-font);
  font-variant-numeric: tabular-nums;
}

/* Highlight (brillance sur les colonnes ciblées) */
.genie-highlight {
  background: rgba(78, 205, 196, 0.16) !important;
  box-shadow: inset 0 0 0 2px rgba(78, 205, 196, 0.35);
  border-radius: 12px;
}

/* Barré (emprunt : ancien chiffre barré) */
.genie-crossout {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent-coral);
  text-decoration-thickness: 3px;
  opacity: 0.5;
}

/* Annotation : nouveau chiffre au-dessus */
.genie-annotation {
  position: absolute;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}

.genie-annotation-new {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-coral);
  animation: popIn 0.3s ease both;
}

.genie-annotation-bonus {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-turquoise);
  animation: popIn 0.3s ease both;
}

/* Contrôles du génie */
.genie-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-genie {
  padding: 0.68rem 1.6rem;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
  background: linear-gradient(135deg, var(--accent-purple), #9C6ADE);
  box-shadow: 0 4px 12px rgba(179, 136, 255, 0.3);
}

.btn-genie:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 18px rgba(179, 136, 255, 0.5);
}

.btn-genie-close {
  background: linear-gradient(135deg, var(--accent-turquoise), #3DBDB4);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.btn-genie-close:hover {
  box-shadow: 0 6px 18px rgba(78, 205, 196, 0.5);
}

/* Mode centaines (4 colonnes) — cellules plus petites */
.operation-display.has-hundreds .op-cell {
  width: 80px;
  height: 80px;
  font-size: 3.5rem;
}

.operation-display.has-hundreds .carry-cell {
  width: 45px;
  height: 45px;
  font-size: 1.5rem;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes mascotBreathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.05) translateY(-3px); }
}

@keyframes mascotHappy {
  0%   { transform: translateY(0) rotate(-4deg) scale(1); }
  100% { transform: translateY(-10px) rotate(4deg) scale(1.08); }
}

@keyframes mascotCheer {
  0%   { transform: translateY(0) rotate(-8deg) scale(1); }
  100% { transform: translateY(-14px) rotate(8deg) scale(1.15); }
}

@keyframes mascotThink {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

@keyframes mascotSad {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(0.95) translateY(2px); }
}


@keyframes activePulse {
  0%, 100% { box-shadow: 0 0 24px rgba(78, 205, 196, 0.5); }
  50%      { box-shadow: 0 0 32px rgba(78, 205, 196, 0.8); }
}

@keyframes bounceSoft {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.6); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes starBounce {
  0%   { opacity: 0; transform: scale(0) rotate(-45deg); }
  60%  { transform: scale(1.35) rotate(15deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-4deg); }
  75%      { transform: rotate(4deg); }
}

/* ============================================================
   SCREEN: PROFILE SELECTION
   ============================================================ */
#screen-profile {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  gap: 3rem;
}

#screen-profile.active {
  display: flex;
}

.profile-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--accent-coral);
  text-align: center;
  text-shadow: 3px 3px 0 var(--accent-yellow);
  margin: 0;
}

.profile-cards {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2.5rem 3rem;
  min-width: 260px;
  font-family: 'Fredoka', sans-serif;
  background: var(--bg-secondary);
  border: 5px solid var(--accent-yellow);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-card);
}

.profile-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-strong);
}

.profile-card-gs {
  border-color: var(--accent-mint);
}

.profile-card-ce1 {
  border-color: var(--accent-turquoise);
}

.profile-emoji {
  font-size: 5rem;
  line-height: 1;
}

.profile-name {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
}

.profile-hint {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-soft);
}

/* ============================================================
   RESPONSIVE — max-width: 900px
   ============================================================ */
@media (max-width: 900px) {
  html, body { font-size: 15px; }

  .game-title { font-size: 2.8rem; }

  .op-cell {
    width: 72px;
    height: 72px;
    font-size: 3.2rem;
  }

  .carry-cell {
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
  }

  .preview-canvas {
    width: 160px;
    height: 160px;
  }

  .confirmation-digit-box {
    width: 120px;
    height: 120px;
  }
  #confirmation-digit { font-size: 5rem; }

  .operation-display.has-hundreds .op-cell {
    width: 60px;
    height: 60px;
    font-size: 2.6rem;
  }

  .operation-display.has-hundreds .carry-cell {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }

  .results-stars { font-size: 2.8rem; }
  .results-score-value { font-size: 2.8rem; }
}

/* ============================================================
   HOME TOPBAR + PROFILE SWITCH
   ============================================================ */
.home-topbar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 0.8rem 1rem 0;
  box-sizing: border-box;
}

.btn-switch-profile {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--accent-purple);
  border: 2px solid var(--accent-purple);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-switch-profile:hover {
  background: var(--accent-purple);
  color: var(--text-light);
  transform: translateY(-2px);
}

/* ============================================================
   COUNTING GAME
   ============================================================ */
.counting-question-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 720px;
}

.counting-question-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  margin: 0;
}

.counting-objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 1.5rem 2rem;
  background: var(--bg-secondary);
  border: 4px solid var(--accent-yellow);
  border-radius: var(--radius);
  min-height: 140px;
  box-shadow: var(--shadow-card);
  pointer-events: none;
}

.counting-object {
  font-size: 3rem;
  line-height: 1;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Sum mode: two groups separated by + */
.counting-objects.sum-mode {
  gap: 1rem;
}

.counting-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: rgba(255, 217, 61, 0.15);
  border-radius: var(--radius-sm);
  min-width: 120px;
}

.counting-plus {
  font-family: 'Fredoka', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-coral);
  padding: 0 0.5rem;
}

.counting-answer-section {
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.counting-answer-cells {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border: 4px solid var(--accent-mint);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.counting-answer-cells .answer-cell {
  pointer-events: auto;
}

/* ============================================================
   PROBLEM GAME (CE1 — énoncés)
   ============================================================ */
.problem-statement-section {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 760px;
  padding: 0 1rem;
}

.problem-statement-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem 1.6rem;
  background: var(--bg-secondary);
  border: 4px solid var(--accent-coral);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  width: 100%;
}

.problem-statement-icon {
  font-size: 2.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.problem-statement-text {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-dark);
  line-height: 1.4;
  margin: 0;
}

.problem-answer-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  pointer-events: none;
}

.problem-answer-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dark);
}

.problem-answer-unit {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-coral);
  margin-left: 0.4rem;
}

/* ============================================================
   AUTH (login / signup)
   ============================================================ */
.auth-card {
  background: var(--bg-secondary);
  border: 4px solid var(--accent-mint);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2rem 2rem 1.5rem;
  width: min(420px, 92vw);
  margin: auto;
  text-align: center;
}

.auth-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 0.4rem;
}

.auth-subtitle {
  font-family: 'Fredoka', sans-serif;
  color: var(--text-dark);
  opacity: 0.75;
  margin: 0 0 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
}

.auth-label input {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  padding: 0.7rem 0.9rem;
  border: 3px solid var(--accent-yellow);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease;
}

.auth-label input:focus {
  border-color: var(--accent-coral);
}

.btn-auth-primary {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.85rem 1.4rem;
  margin-top: 0.4rem;
  background: var(--accent-coral);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-auth-primary:hover { transform: translateY(-2px); }
.btn-auth-primary:active { transform: translateY(0); }
.btn-auth-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-auth-link {
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  margin-top: 1rem;
  background: transparent;
  color: var(--accent-turquoise);
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.auth-error {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-orange);
  background: rgba(255, 107, 75, 0.1);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  margin: 0;
}

.auth-info {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-turquoise);
  background: rgba(102, 217, 200, 0.15);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  margin: 0;
}

.auth-greeting {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-right: auto;
}

.auth-greeting strong {
  color: var(--accent-coral);
  font-weight: 700;
}

/* ============================================================
   BRAND — That'School
   ============================================================ */
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}

.brand-logo {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.brand-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--accent-coral);
  margin: 0;
  letter-spacing: -0.5px;
}

.brand-level {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-turquoise);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand-auth {
  margin: 0 0 1rem;
  gap: 0.5rem;
}

.brand-auth .brand-logo { font-size: 2.2rem; }
.brand-auth .brand-name { font-size: 1.8rem; }

/* ============================================================
   TABLETTE — Optimisation stylet (Lenovo & autres touch)
   Cible : écrans tactiles >= 768px (paysage tablette)
   Objectifs : header compact, énoncé+réponse alignés,
   aperçu d'écriture plus petit, plus de place pour le tracé
   ============================================================ */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) {

  /* Header compact : barre de progression mince + énergie réduite */
  .game-header {
    padding: 0.5rem 0.9rem;
    margin-bottom: 0.5rem;
    gap: 0.7rem;
    max-width: 100%;
  }

  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .header-info {
    gap: 0.15rem;
  }

  .level-name-display {
    font-size: 0.9rem;
  }

  .progress-bar-wrapper {
    height: 8px;
  }

  .progress-text {
    font-size: 0.75rem;
  }

  .header-score {
    padding: 0.25rem 0.7rem;
  }

  .score-label {
    font-size: 0.6rem;
  }

  #game-score-value,
  #counting-score-value,
  #problem-score-value {
    font-size: 1.3rem;
  }

  .energy-wrapper {
    min-width: 120px;
    gap: 0.15rem;
  }

  .energy-label {
    font-size: 0.7rem;
  }

  .energy-bar {
    height: 10px;
    border-width: 2px;
  }

  /* Plus d'espace pour le contenu du jeu */
  .game-content {
    gap: 0.8rem;
    max-width: 100%;
  }

  /* Aperçu d'écriture : plus petit pour ne pas voler la place
     Le tracé réel se fait sur le drawing-canvas plein écran */
  .preview-canvas,
  #preview-canvas,
  #preview-canvas-counting,
  #preview-canvas-problem {
    width: 110px !important;
    height: 110px !important;
    border-width: 3px;
  }

  .writing-section {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    border-width: 2px;
  }

  .active-cell-label {
    font-size: 1rem;
    flex: 1;
    text-align: left;
  }

  /* PROBLÈMES : énoncé + réponse côte à côte, vraiment alignés */
  #screen-problem-game .game-content {
    align-items: stretch;
  }

  .problem-statement-section {
    max-width: 100%;
    padding: 0;
  }

  .problem-statement-box {
    padding: 0.8rem 1.2rem;
    gap: 0.7rem;
    border-width: 3px;
  }

  .problem-statement-icon {
    font-size: 2rem;
  }

  .problem-statement-text {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  .problem-answer-section {
    padding: 0.4rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 3px solid var(--accent-turquoise);
    box-shadow: var(--shadow-card);
    pointer-events: auto;
  }

  .problem-answer-label {
    font-size: 1.05rem;
  }

  .problem-answer-unit {
    font-size: 1.5rem;
  }

  /* COMPTAGE : question + réponse plus compactes */
  .counting-question-section {
    padding: 0.4rem 0.8rem;
  }

  /* Indicateur visuel discret de la zone d'écriture (drawing canvas) */
  .drawing-canvas {
    background: radial-gradient(
      ellipse at center,
      rgba(78, 205, 196, 0.04) 0%,
      transparent 70%
    );
  }

  /* Boutons flottants un peu plus gros pour le stylet */
  .btn-validate,
  .btn-clear {
    padding: 1.2rem 1.6rem;
    min-width: 150px;
    font-size: 1.2rem;
  }

  /* Clavier de secours plus compact si visible */
  .fallback-keyboard {
    padding: 0.6rem 0.9rem;
    max-width: 280px;
  }
}

/* Mode paysage tablette extra-compact (hauteur limitée) */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 900px) {
  .game-header {
    margin-bottom: 0.3rem;
  }

  .game-content {
    gap: 0.5rem;
  }

  .preview-canvas,
  #preview-canvas,
  #preview-canvas-counting,
  #preview-canvas-problem {
    width: 90px !important;
    height: 90px !important;
  }

  .writing-section {
    padding: 0.4rem 0.8rem;
  }
}

/* ===================== Sync banner ===================== */
.sync-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 0.5rem 1rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .25s ease;
}
.sync-banner.hidden {
  display: none;
}
.sync-banner.warn {
  background: var(--accent-yellow);
}
.sync-banner.error {
  background: var(--accent-coral);
  color: #fff;
}
