:root {
  --bg1: #eef2ff; --bg2: #fdf2f8; --card: #fff;
  --violet: #7c3aed; --green: #10b981; --red: #ef4444;
  --text: #1f2937; --muted: #6b7280;
  --shadow: 0 14px 28px rgba(0,0,0,.10);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(145deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  transition: background 250ms ease, color 250ms ease;
}

/* ── Fond étoilé ── */
.stars-bg {
  position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: .25;
}

/* ── Layout principal ── */
.app {
  max-width: 760px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(100px, calc(env(safe-area-inset-bottom) + 80px))
           max(12px, env(safe-area-inset-left));
}

/* ── Header ── */
.top { display: flex; flex-direction: column; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.title { font-size: 1.2rem; font-weight: 900; color: var(--violet); }
.hud { flex-grow:1; width: 100%; display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.pill { background: var(--card); border-radius: 999px; padding: 7px 11px; box-shadow: var(--shadow); font-weight: 800; }

/* ── Carte ── */
.card { margin-top: 10px; background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); }

/* ── Mascotte ── */
.mascot {
  font-size: 3rem;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.18));
  animation: bob 1.8s ease-in-out infinite;
  user-select: none;
}
@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }

/* ── Zone de jeu ── */
.game-head { display: flex; justify-content: space-between; align-items: center; }
.q { font-size: 2rem; font-weight: 900; text-align: center; margin: 8px 0; }
.input {
  width: 100%; font-size: 2rem; text-align: center;
  padding: 10px; border: 2px solid #ddd; border-radius: var(--radius); background: var(--card);
}

/* ── Clavier numérique ── */
.kbd { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.key { font-size: 1.3rem; padding: 14px; border: 0; border-radius: 12px; background: #eef2ff; font-weight: 900; cursor: pointer; transition: transform 100ms; }
.key:active { transform: scale(.98); }

/* ── Boutons ── */
.row { display: flex; gap: 8px; margin-top: 10px; }
.btn { flex: 1; border: 0; border-radius: 12px; padding: 12px; font-weight: 900; cursor: pointer; transition: transform 100ms; }
.btn:active { transform: scale(.98); }
.ok   { background: var(--green); color: #fff; }
.del  { background: #f3f4f6; }
.skip { background: #fee2e2; color: #991b1b; }

/* ── Feedback ── */
.feedback { min-height: 24px; text-align: center; font-weight: 900; margin-top: 8px; }
.good { color: #065f46; }
.bad  { color: #991b1b; }
.tiny { font-size: .88rem; color: var(--muted); }

/* ── Barres de progression ── */
.progress, .bar {
  height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden;
}
.progress { height: 12px; }
.progress > span,
.bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, #a78bfa, #34d399);
}
.stat { margin: 7px 0; }

/* ── Collection animaux ── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.monster {
  border-radius: var(--radius);
  padding: 8px 2px;
  text-align: center;
  background: #f8fafc;
  border: 2px solid #eef2ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* aspect-ratio: 1 / 1; */
  transition: all 200ms ease;
}
.monster .e {
  font-size: 2.4rem;
  margin-bottom: 5px;
}
.monster strong {
  font-size: 1rem;
  margin-bottom: 4px;
}
.monster small {
  display: block;
  color: var(--muted);
  font-size: .8rem;
}
.monster.locked {
  filter: grayscale(1);
  opacity: .45;
}
.monster:not(.locked) {
  box-shadow: 0 4px 12px rgba(124, 58, 237, .15);
  border-color: #ede9fe;
}

/* ── Carte de chaleur ── */
.heat { font-family: ui-monospace, Consolas, monospace; white-space: pre; line-height: 1.35; font-size: .86rem; }

/* ── Footer navigation ── */
.footer {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top: 1px solid #eee;
  display: flex; gap: 8px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  z-index: 999;
}
.footer button {
  flex: 1; border: 0; border-radius: 10px; padding: 10px;
  font-weight: 900; cursor: pointer; transition: all 200ms;
}
.footer button.active-tab { background: #ede9fe; color: var(--violet); }

/* ── Écrans ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Dialogs ── */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(680px, 95vw); box-shadow: var(--shadow); }
.modal { padding: 14px; }

/* ── Bannière installation PWA ── */
#installBannerContainer {
    display: none;
    position: fixed;
    margin: auto;
    bottom: 60px;
    left: 0;
    right: 0;
    z-index: 1000;
    text-align: center;
}
#installBanner {
    margin: auto;
    border: 0;
    background: linear-gradient(90deg, var(--violet), #ec4899);
    color: #fff; text-align: center;
    padding: 10px 14px; font-weight: 700;
    border-radius: var(--radius); margin-top: 10px; cursor: pointer;
}

/* ── Bouton parent caché ── */
.parent-hit { position: fixed; right: 4px; top: 4px; opacity: .08; font-size: 11px; }

@keyframes animal-pop {
  0%   { transform: scale(.75) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes animal-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-10px); }
}

.animal-modal {
  text-align: center;
}
.animal-big {
  font-size: clamp(8rem, 20vw, 8rem);
  line-height: 1;
  display: inline-block;
  margin: 2rem;
  filter: drop-shadow(0 10px 18px rgba(124,58,237,.28));
  animation: animal-pop .45s ease-out, animal-float 1.8s ease-in-out infinite .45s;
}

.badges-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.badge-chip {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: .9rem;
}

/* Thème par défaut */
:root[data-theme="violet"] {
  --bg1: #eef2ff;
  --bg2: #fdf2f8;
  --violet: #7c3aed;
  --green: #10b981;
  --red: #ef4444;
}

/* Thème Égypte */
:root[data-theme="egypte"] {
  --bg1: #fff7d6;
  --bg2: #ffe8b6;
  --violet: #b7791f; /* or doré */
  --green: #2f855a;
  --red: #c53030;
}

/* Thème Océan */
:root[data-theme="ocean"] {
  --bg1: #e0f2fe;
  --bg2: #ecfeff;
  --violet: #0369a1;
  --green: #0f766e;
  --red: #dc2626;
}

/* Thème Bonbon */
:root[data-theme="bonbon"] {
  --bg1: #fdf2f8;
  --bg2: #fae8ff;
  --violet: #db2777;
  --green: #16a34a;
  --red: #e11d48;
}

.theme-picker{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:8px;
  margin-top:10px;
}
.theme-btn{
  border:1px solid #ddd;
  background:#fff;
  border-radius:10px;
  padding:8px;
  font-weight:800;
  cursor:pointer;
}
.theme-btn.active{
  border-color:#c4b5fd;
  background:#ede9fe;
  color:var(--violet);
}

.heatmap-table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  table-layout: fixed;
  font-size: .78rem;
}
.heatmap-table th,
.heatmap-table td{
  text-align: center;
  padding: 3px;
}
.heatmap-table thead th{
  color: var(--muted);
  font-weight: 700;
}
.heat-cell{
  display: inline-block;
  width: 100%;
  max-width: 20px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}

.app-version{
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  margin-left: 6px;
  vertical-align: middle;
}

.mistake-popup{
  position: fixed;
  left: 50%;
  right:-30%;
  top: 20rem;
  transform: translateX(-50%);
  background: #fff;
  color: #1f2937;
  border: 2px solid #fecaca;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  padding: 20px 30px;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  text-align: center;
}
.mistake-popup.show{
  opacity: 1;
  transform: translateX(-50%) translateY(10px);
}
.mistake-title{
  font-weight: 800;
  font-size: 1.3rem;
  color: #991b1b;
}
.mistake-eq{
  margin-top: 10px;
  font-size: 1.8rem;
  font-weight: 900;
}
.expected-green{
  color: #16a34a;
}

#celebrationContent {
    text-align: center;
}

.celebrate-animal{
  margin: 6px 0 8px;
}
.celebrate-text{
  margin: 6px 0 12px;
  font-weight: 800;
  text-align: center;
}