/* ===================== Familledoku — styles ===================== */
:root {
  --bg-outer: #F3E3DF;
  --bg: #FBF3E6;
  --paper: #FFFBF3;
  --ink: #1F2A1E;
  --ink-soft: #4A5547;
  --green: #1E5A2C;
  --green-2: #2D6E3A;
  --green-line: #1D4A28;
  --green-pale: #DCE8C6;
  --card-line: #D9CFB6;
  --sun: #F2B33D;
  --heart: #E5603E;
  --r1: #C8DDAE; /* vert */
  --r2: #F7E6A0; /* jaune */
  --r3: #F9D8C1; /* pêche */
  --r4: #BFDCEB; /* bleu */
  --r5: #E1D2F0; /* lavande */
  --r6: #F6CDD2; /* rose */
  --r7: #CDEBDD; /* menthe */
  --r8: #F5D2A6; /* abricot */
  --r9: #D3DAEE; /* pervenche */
  --shadow: 0 2px 0 rgba(30, 60, 30, .08), 0 8px 24px rgba(60, 50, 20, .08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-outer);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

#app {
  position: relative;
  max-width: 480px; height: 100%; height: 100dvh; margin: 0 auto;
  background:
    radial-gradient(120% 60% at 50% 0%, #FFF8EC 0%, transparent 60%),
    var(--bg);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,.08);
  /* les adaptations « petit écran » suivent la taille du jeu (téléphone ou cadre sur ordinateur) */
  container: app / size;
}
/* Sur ordinateur ou tablette : le jeu s'affiche dans un téléphone (proportions d'un
   cellulaire moderne, 390 × 844), car il est pensé pour être joué au téléphone. */
@media (min-width: 600px) and (min-height: 560px) {
  body { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; }
  #app {
    --ph: min(calc(100vh - 40px), 880px);
    --ph: min(calc(100dvh - 40px), 880px);
    height: var(--ph); width: calc(var(--ph) * 390 / 844); max-width: none; margin: 0; flex: none;
    border: 11px solid #26302A; border-radius: 52px;
    box-shadow: 0 0 0 2px #4A564E, 0 30px 70px rgba(40,50,30,.35);
  }
  #app::after {
    content: ''; position: absolute; z-index: 100; top: 8px; left: 50%; transform: translateX(-50%);
    width: 30%; height: 24px; border-radius: 14px; background: #26302A; pointer-events: none;
  }
  #app { --safe-top: 26px; }
}

/* ---------- écrans ---------- */
.screen {
  position: absolute; inset: 0;
  padding: calc(14px + var(--safe-top)) 18px calc(96px + var(--safe-bot));
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; align-items: center;
  opacity: 0; pointer-events: none;
  transform: translateX(24px);
  transition: opacity .35s ease, transform .45s cubic-bezier(.2,.8,.2,1);
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen > * { flex-shrink: 0; } /* sur petit écran on fait défiler, on ne comprime jamais */
.screen.active { opacity: 1; pointer-events: auto; transform: none; }
.screen.leave { transform: translateX(-24px); }
#screen-game, #screen-win { padding-bottom: calc(16px + var(--safe-bot)); }
/* L'écran de jeu ne défile pas : la grille prend toute la place restante. */
#screen-game { overflow: hidden; padding-left: 14px; padding-right: 14px; }
#screen-game > * { flex: none; }

/* ---------- décorations ---------- */
.deco { position: absolute; width: 110px; height: 110px; pointer-events: none; z-index: 0; opacity: .95; }
.deco svg { width: 100%; height: 100%; }
.deco-tl { top: calc(-8px + var(--safe-top)); left: -14px; transform: scaleX(-1) rotate(180deg) scaleY(-1); }
.deco-tl svg { transform: rotate(-90deg); }
.deco-tr { top: calc(-6px + var(--safe-top)); right: -12px; }
.deco svg, .hero-sprig, .hero-lav { transform-origin: bottom left; animation: sway 6s ease-in-out infinite; }
@keyframes sway { 0%,100% { rotate: 0deg; } 50% { rotate: 3deg; } }

.tl-leaf { width: 18px; height: 18px; flex: none; }
.tl-leaf.l { transform: scaleX(-1) rotate(-20deg); }
.tl-leaf.r { transform: rotate(-20deg); }

/* ---------- accueil ---------- */
.home-top { width: 100%; display: flex; justify-content: center; position: relative; min-height: 48px; z-index: 2; }
.paw-badge {
  width: 52px; height: 52px; border-radius: 50%; background: var(--green-pale);
  display: grid; place-items: center; color: var(--green);
  animation: pawBob 3.2s ease-in-out infinite;
}
.paw-badge svg { width: 28px; height: 28px; }
@keyframes pawBob { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-4px) rotate(6deg); } }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--green-line); transition: transform .15s, background .2s; }
.icon-btn svg { width: 28px; height: 28px; }
.icon-btn:active { transform: scale(.88); background: rgba(30,90,44,.08); }
#btn-settings { position: absolute; right: 0; top: 2px; background: rgba(251,243,230,.92); box-shadow: 0 0 0 6px rgba(251,243,230,.6); }
#screen-home .deco-tr { top: calc(56px + var(--safe-top)); right: -30px; width: 90px; height: 90px; }
#btn-settings:hover svg { animation: spin 1.2s linear; }
#btn-win-home { position: absolute; left: 0; top: 2px; }
@keyframes spin { to { transform: rotate(180deg); } }

.sun-rays { position: relative; height: 0; width: 110px; z-index: 1; }
.sun-rays i { position: absolute; width: 3px; height: 14px; background: var(--sun); border-radius: 3px; top: -6px; animation: ray 2.4s ease-in-out infinite; }
.sun-rays i:nth-child(1) { left: 22px; transform: rotate(-50deg); top: 6px; }
.sun-rays i:nth-child(2) { left: 40px; transform: rotate(-25deg); top: -4px; animation-delay: .2s; }
.sun-rays i:nth-child(3) { left: 58px; top: -8px; animation-delay: .4s; }
.sun-rays i:nth-child(4) { left: 76px; transform: rotate(25deg); top: -4px; animation-delay: .6s; }
.sun-rays i:nth-child(5) { left: 94px; transform: rotate(50deg); top: 6px; animation-delay: .8s; }
#screen-home .sun-rays { left: 70px; top: 4px; }
@keyframes ray { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

.title {
  font-family: 'Fraunces', Georgia, serif; font-weight: 800;
  font-size: clamp(42px, 13vw, 58px); letter-spacing: -.5px; line-height: 1;
  margin: 8px 0 4px; color: #16301A; z-index: 1;
  text-shadow: 0 2px 0 rgba(255,255,255,.7);
}
.title { animation: titleIn .8s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes titleIn { from { opacity: 0; transform: translateY(-14px) scale(.92); } }
.tagline { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 600; color: var(--ink); z-index: 1; }

.hero { position: relative; width: 100%; max-width: 380px; height: 230px; margin: 4px 0 0; z-index: 1; }
.hero.small { height: 210px; }
.hero-pet { position: absolute; bottom: 18px; width: 52%; filter: drop-shadow(0 6px 10px rgba(60,40,10,.18)); }
.hero-pet.a { left: 4%; animation: petA 4.2s ease-in-out infinite; z-index: 2; }
.hero-pet.b { right: 2%; width: 50%; animation: petB 4.6s ease-in-out infinite; z-index: 1; }
@keyframes petA { 0%,100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(1deg) translateY(-5px); } }
@keyframes petB { 0%,100% { transform: rotate(3deg) translateY(-2px); } 50% { transform: rotate(-1deg) translateY(3px); } }
.hero-sprig { position: absolute; width: 90px; height: 90px; bottom: 10px; z-index: 0; }
.hero-sprig.l { left: -16px; transform: scaleX(-1); }
.hero-sprig.r { right: -18px; }
.hero-lav { position: absolute; width: 24px; height: 80px; bottom: 30px; z-index: 0; }
.hero-lav.l { left: 4px; }
.hero-lav.r { right: 8px; animation-delay: -2s; }
.hero-flower { position: absolute; width: 30px; height: 30px; z-index: 3; animation: flw 5s ease-in-out infinite; }
.hero-flower.f1 { left: 10%; bottom: 8px; }
.hero-flower.f2 { right: 14%; bottom: 6px; width: 26px; height: 26px; animation-delay: -1.6s; }
.hero-flower.f3 { left: 47%; bottom: 0; width: 22px; height: 22px; animation-delay: -3s; }
@keyframes flw { 0%,100% { transform: rotate(0) scale(1); } 50% { transform: rotate(25deg) scale(1.08); } }
.ribbon {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%) rotate(-2deg);
  z-index: 4; padding: 5px 28px 7px;
  background: linear-gradient(#F5E7C4, #EBD7A9);
  border-radius: 6px; box-shadow: 0 3px 8px rgba(80,60,20,.18);
  font-family: 'Fraunces', serif; font-style: italic; font-weight: 700; font-size: 22px; color: #2E4A26; white-space: nowrap;
}
.ribbon::before, .ribbon::after { content: ''; position: absolute; top: 7px; width: 18px; height: 100%; background: #DCC48F; z-index: -1; }
.ribbon::before { left: -12px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 40% 50%); }
.ribbon::after { right: -12px; clip-path: polygon(0 0, 100% 0, 60% 50%, 100% 100%, 0 100%); }

.card { background: var(--paper); border: 1.5px solid var(--card-line); border-radius: 20px; box-shadow: var(--shadow); }
.chars-card { width: 100%; margin-top: 22px; padding: 6px 12px 10px; position: relative; z-index: 1; }
.card-title { display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; margin-top: -2px; }
.chars { display: flex; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.char { flex: 1 1 0; min-width: 80px; max-width: 140px; display: flex; flex-direction: column; align-items: center; padding: 2px 4px; position: relative; }
.char + .char::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1.5px; background: var(--card-line); }
.char img { width: 64px; height: 64px; object-fit: contain; transition: transform .2s; }
.char:active img { transform: scale(1.15) rotate(-6deg); }
.char span { font-weight: 700; font-size: 16px; }
.chars.many .char img { width: 50px; height: 50px; }
.chars.many .char { min-width: 64px; }
.chars.many .char span { font-size: 13px; }

.btn-primary {
  width: 100%; margin-top: 14px; min-height: 60px; padding: 10px 20px;
  background: linear-gradient(#25693A, var(--green)); color: #fff;
  font-weight: 800; font-size: 24px; border-radius: 999px;
  box-shadow: 0 4px 0 #123D1C, 0 10px 18px rgba(20,60,30,.25);
  transition: transform .12s, box-shadow .12s; position: relative; overflow: hidden; z-index: 1;
}
.btn-primary::after { content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.25), transparent); animation: shine 4s ease-in-out infinite; }
@keyframes shine { 0%,70% { left: -60%; } 100% { left: 130%; } }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #123D1C, 0 4px 10px rgba(20,60,30,.2); }
.btn-primary.small { width: auto; min-height: 44px; font-size: 18px; margin: 0; padding: 6px 22px; }
.btn-primary:disabled { filter: grayscale(.6) opacity(.6); }

.daily-card { width: 100%; margin-top: 14px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; text-align: left; transition: transform .15s; z-index: 1; }
.daily-card:active { transform: scale(.98); }
.daily-ico { width: 50px; height: 50px; flex: none; animation: calWiggle 5s ease-in-out infinite; }
.daily-ico.big { width: 58px; height: 58px; }
@keyframes calWiggle { 0%,88%,100% { transform: rotate(0); } 92% { transform: rotate(-8deg); } 96% { transform: rotate(6deg); } }
.daily-txt { flex: 1; display: flex; flex-direction: column; }
.daily-txt b { font-size: 21px; font-weight: 800; }
.daily-txt small { font-size: 14.5px; color: var(--ink-soft); font-weight: 600; }
.chev { width: 22px; height: 22px; color: var(--ink); }
.home-bottom-deco { display: flex; gap: 8px; margin-top: 10px; opacity: .8; }
.home-bottom-deco svg { width: 20px; height: 20px; animation: flw 6s ease-in-out infinite; }

/* ---------- barre d'onglets ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding: 8px 10px calc(8px + var(--safe-bot));
  background: rgba(255,251,243,.96); border-top: 1.5px solid #E6DCC6;
  border-radius: 26px 26px 0 0; backdrop-filter: blur(8px);
  transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.tabbar.hidden { transform: translateY(110%); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 16px; font-weight: 700; color: #3B4A38; padding: 4px 0 6px; transition: color .2s, transform .15s; }
.tab svg { width: 32px; height: 32px; transition: transform .3s cubic-bezier(.2,1.6,.4,1); }
.tab.active { color: var(--green); font-weight: 800; }
.tab.active svg { transform: translateY(-2px) scale(1.06); }
.tab:active { transform: scale(.94); }
.tab-ind { position: absolute; bottom: calc(6px + var(--safe-bot)); height: 5px; border-radius: 4px; background: var(--green); width: 22%; left: 5.5%; transition: left .35s cubic-bezier(.2,1.2,.4,1); }

/* ---------- pages Défis / Famille ---------- */
.page-title { font-family: 'Fraunces', serif; font-weight: 800; font-size: 38px; margin: 18px 0 2px; z-index: 1; }
.page-sub { margin: 0 0 14px; color: var(--ink-soft); font-weight: 600; text-align: center; font-size: 15px; z-index: 1; }
.today-card { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; z-index: 1; }
.today-card > div { flex: 1; }
.today-date { font-weight: 800; font-size: 18px; }
.page-title, .page-sub, .title, .tagline, .section-title, .rank-rule, .week, .board-list { position: relative; z-index: 1; }
.today-status { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.week { display: flex; gap: 6px; width: 100%; margin: 14px 0 6px; }
.day { flex: 1; text-align: center; padding: 8px 0 6px; border-radius: 14px; background: var(--paper); border: 1.5px solid var(--card-line); font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.day b { display: block; font-size: 17px; color: var(--ink); }
.day .dot { width: 18px; height: 18px; margin: 3px auto 0; color: #D8CFBA; }
.day.done .dot { color: var(--sun); animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
.day.today { border-color: var(--green); box-shadow: 0 0 0 2px rgba(30,90,44,.15); }
.section-title { display: flex; align-items: center; gap: 8px; align-self: flex-start; font-size: 19px; font-weight: 800; margin: 18px 0 6px; }
.section-title svg { width: 24px; height: 24px; color: var(--green); }
.rank-rule { align-self: flex-start; margin: -2px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.board-list { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 8px; align-items: center;
  background: var(--paper); border: 1.5px solid var(--card-line); border-radius: 14px; padding: 9px 12px;
  animation: rowIn .45s cubic-bezier(.2,.9,.3,1) both;
}
.rank-row.me { border-color: var(--green); background: #F1F7E6; }
.rank-row .pos { font-weight: 800; font-size: 18px; text-align: center; color: var(--ink-soft); }
.rank-row .pos.m1 { color: #D49A12; } .rank-row .pos.m2 { color: #8E9AA5; } .rank-row .pos.m3 { color: #B87333; }
.rank-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 800; }
.rk-av { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--green-pale); display: grid; place-items: center; overflow: hidden; }
.rk-av img { width: 34px; height: 34px; object-fit: contain; }
.rk-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .who small { display: block; font-weight: 600; font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.rank-row .lvl { font-weight: 800; font-size: 14px; background: var(--green-pale); color: var(--green); border-radius: 999px; padding: 3px 10px; }
.rank-row .pts { font-weight: 800; min-width: 56px; text-align: right; }
.rank-head { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto; gap: 8px; padding: 0 12px; font-size: 12px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.rank-head span:last-child { min-width: 56px; text-align: right; }
@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } }
.empty { text-align: center; color: var(--ink-soft); font-weight: 600; padding: 18px 10px; background: var(--paper); border: 1.5px dashed var(--card-line); border-radius: 16px; }

.account-card { width: 100%; padding: 16px; z-index: 1; margin-top: 8px; }
.account-card h4 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.account-card p { margin: 0 0 10px; color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.me-line { display: flex; align-items: center; gap: 12px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--green-pale); display: grid; place-items: center; overflow: hidden; flex: none; }
.avatar img { width: 48px; height: 48px; object-fit: contain; }
.avatar.big { position: relative; width: 68px; height: 68px; overflow: visible; border: 2.5px solid var(--green-2); }
.avatar.big img { width: 62px; height: 62px; border-radius: 50%; }
.avatar.big i { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; font-style: normal; font-size: 13px; display: grid; place-items: center; }
.avatar-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0 12px; }
.av-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 8px 4px 6px; border-radius: 18px; border: 2.5px solid transparent; background: var(--green-pale); font-weight: 800; font-size: 14px; transition: transform .2s, border-color .2s, background .2s; }
.av-opt img { width: 58px; height: 58px; object-fit: contain; }
.av-opt.on { border-color: var(--green); background: #F1F7E6; transform: scale(1.06); box-shadow: 0 4px 10px rgba(30,90,44,.18); }
.av-opt:active { transform: scale(.95); }
.field-help { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.form-btn { font-size: 20px; min-height: 52px; margin-top: 4px; }
@container app (max-width: 370px) { .av-opt { width: 72px; } .av-opt img { width: 48px; height: 48px; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: #F6EFDF; border-radius: 12px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.row-btns { display: flex; gap: 8px; margin-top: 4px; }
.btn-ghost { flex: 1; min-height: 44px; border-radius: 999px; border: 2px solid var(--green); color: var(--green); font-weight: 800; font-size: 16px; transition: transform .12s, background .2s; }
.btn-ghost:active { transform: scale(.97); background: rgba(30,90,44,.08); }
.offline-note { background: #FBEBC4; color: #6B4A0E; border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 4px; }
.offline-note b { font-weight: 800; }
.offline-tag { display: inline-block; font-size: 12px; font-weight: 800; color: #9A6A12; background: #FBEBC4; border-radius: 999px; padding: 2px 10px; margin-bottom: 8px; }

/* ---------- formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; text-align: left; }
.field label { font-weight: 800; font-size: 14px; }
.field input {
  font: inherit; font-size: 17px; font-weight: 600; padding: 12px 14px; border-radius: 14px;
  border: 1.5px solid var(--card-line); background: #fff; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-user-select: text; user-select: text;
}
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(30,90,44,.15); }
.form-err { color: #B33A1E; font-weight: 700; font-size: 14px; min-height: 18px; margin: 2px 0 6px; }
.switch-auth { margin-top: 10px; text-align: center; font-weight: 700; color: var(--green); text-decoration: underline; width: 100%; padding: 6px; }

/* ---------- partie ---------- */
.game-top { width: 100%; display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5px solid #E2D7C2; padding-bottom: 6px; }
.game-top h2 { margin: 0; font-size: 30px; font-weight: 800; animation: titleIn .6s cubic-bezier(.2,1.4,.4,1) both; }
.game-info { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px; background: var(--green-pale); font-weight: 700; font-size: 16px; }
.pill svg { width: 18px; height: 18px; }
.hearts { display: flex; gap: 4px; }
.hearts svg { width: 26px; height: 26px; fill: var(--heart); filter: drop-shadow(0 1px 0 rgba(140,40,20,.3)); animation: beat 2.4s ease-in-out infinite; }
.hearts svg:nth-child(2) { animation-delay: .15s; }
.hearts svg:nth-child(3) { animation-delay: .3s; }
.hearts svg.lost { fill: #E2D8C8; animation: heartLost .7s ease both; filter: none; }
@keyframes beat { 0%,80%,100% { transform: scale(1); } 88% { transform: scale(1.15); } }
@keyframes heartLost { 0% { transform: scale(1.4); fill: var(--heart); } 40% { transform: scale(.7) rotate(-15deg); } 100% { transform: scale(1); } }
.sep { width: 1.5px; height: 28px; background: #D9CDB6; }
.timer { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.timer svg { width: 24px; height: 24px; }
.game-tag { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 20px; font-weight: 800; }
.counter { background: var(--green-pale); border-radius: 999px; padding: 4px 22px; font-weight: 700; font-size: 16px; transition: transform .3s; }
.counter.bump { animation: bump .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes bump { 40% { transform: scale(1.12); } }

#screen-game > .board-wrap { flex: 1 1 0; min-height: 120px; width: 100%; display: flex; justify-content: center; align-items: center; margin-top: 8px; position: relative; }
.board {
  --n: 6;
  width: min(100%, 54vh, 440px); aspect-ratio: 1; flex: none; max-width: 100%; max-height: 100%;
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  border: 3.5px solid var(--green-line); border-radius: 16px; overflow: hidden;
  background: var(--green-line); gap: 0;
  box-shadow: 0 6px 18px rgba(30,60,30,.16);
  touch-action: none;
  transition: transform .3s;
}
.board.shake { animation: shake .45s; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.cell {
  position: relative; display: grid; place-items: center;
  border-style: solid; border-color: rgba(29,74,40,.28); border-width: 0;
  animation: cellIn .45s cubic-bezier(.2,1.2,.4,1) both;
  transition: filter .2s;
}
.cell.bt { border-top: 2.5px solid var(--green-line); }
.cell.bl { border-left: 2.5px solid var(--green-line); }
.cell.tt { border-top-width: 1px; }
.cell.tl { border-left-width: 1px; }
@keyframes cellIn { from { opacity: 0; transform: scale(.5); } }
.cell { min-width: 0; min-height: 0; overflow: hidden; contain: strict; }
.cell > * { position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: auto; }
.cell .mark { width: 56%; height: 56%; color: var(--green-line); animation: markIn .22s cubic-bezier(.2,1.6,.4,1) both; pointer-events: none; }
.cell .mark.auto { color: var(--green-line); }
@keyframes markIn { from { transform: scale(.2) rotate(-45deg); opacity: 0; } }
.cell .pet { width: 92%; height: 92%; object-fit: contain; pointer-events: none; animation: petIn .5s cubic-bezier(.2,1.6,.4,1) both; filter: drop-shadow(0 2px 2px rgba(0,0,0,.18)); }
@keyframes petIn { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: scale(1); } }
.cell .pet.wrong { animation: wrong .6s ease both; filter: drop-shadow(0 0 6px rgba(220,50,30,.8)) saturate(.3); }
@keyframes wrong { 0% { transform: scale(1); } 20% { transform: translateX(-4px) rotate(-8deg); } 40% { transform: translateX(4px) rotate(8deg); } 60% { transform: translateX(-3px); } 100% { transform: scale(0); opacity: 0; } }
.cell .pet.hinted { animation: petIn .5s cubic-bezier(.2,1.6,.4,1) both, glow 1.4s ease 2; }
@keyframes glow { 50% { filter: drop-shadow(0 0 10px rgba(247,199,68,1)); } }
.cell.flash::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.65); animation: flash .7s ease both; pointer-events: none; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.cell.wave .pet { animation: hop .6s ease both; }
@keyframes hop { 30% { transform: translateY(-22%) scale(1.1); } 60% { transform: translateY(0) scale(.95); } }
.cell.hl { filter: brightness(1.05) saturate(1.3); }
.cell.err-zone::after { content: ''; position: absolute; inset: 0; background: rgba(229,96,62,.28); animation: flash 1s ease both; }
.board.won .cell { animation: none; }
.cell.focus::before { content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: rgba(247,199,68,.30); box-shadow: inset 0 0 0 3px rgba(240,170,30,.9); animation: focusPulse 1s ease-in-out infinite; }
@keyframes focusPulse { 50% { background: rgba(247,199,68,.12); } }

.tools { display: flex; justify-content: center; gap: 30px; margin-top: 6px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 16px; }
.tool-c { position: relative; width: 66px; height: 66px; border-radius: 50%; border: 2px solid var(--green-2); background: var(--paper); display: grid; place-items: center; color: var(--green-line); transition: transform .15s, background .2s; box-shadow: 0 3px 0 rgba(30,70,40,.12); }
.tool-c svg { width: 32px; height: 32px; }
.tool-c.x svg { width: 34px; height: 34px; }
.tool:active .tool-c { transform: scale(.9); }
.tool:disabled { opacity: .45; }
.tool.pulse .tool-c { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(247,199,68,.0); } 50% { box-shadow: 0 0 0 8px rgba(247,199,68,.35); } }
.badge { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--sun); color: #3B2A06; font-style: normal; font-size: 13px; font-weight: 800; display: grid; place-items: center; padding: 0 5px; }
.game-lav { position: absolute; left: 4px; bottom: 24px; width: 20px; height: 70px; opacity: .9; pointer-events: none; }
.game-flw { position: absolute; right: 10px; bottom: 60px; width: 24px; height: 24px; pointer-events: none; animation: flw 5s ease-in-out infinite; }
@container app (max-height: 720px) {
  .game-tag { display: none; }
  .game-top h2 { font-size: 26px; }
  .tool-c { width: 56px; height: 56px; }
  .game-lav, .game-flw { display: none; }
}

/* ---------- victoire ---------- */
#screen-win .sun-rays { left: 0; top: 12px; }
.win-title { margin-top: 18px; animation: winTitle .9s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes winTitle { 0% { opacity: 0; transform: scale(.4) rotate(-6deg); } 100% { opacity: 1; transform: none; } }
.sparkle { position: absolute; width: 24px; height: 24px; fill: var(--sun); z-index: 5; animation: twinkle 1.8s ease-in-out infinite; }
.sparkle.s1 { left: 8%; top: 18%; }
.sparkle.s2 { right: 8%; top: 8%; width: 30px; height: 30px; animation-delay: .5s; }
.sparkle.s3 { right: 2%; top: 38%; width: 18px; height: 18px; animation-delay: 1s; }
@keyframes twinkle { 0%,100% { transform: scale(.6) rotate(0); opacity: .5; } 50% { transform: scale(1.1) rotate(25deg); opacity: 1; } }
.stars { display: flex; gap: 10px; margin: 12px 0 6px; }
.stars svg { width: 46px; height: 46px; fill: #E2D8C8; stroke: #C9B98F; stroke-width: .8; }
.stars svg.on { fill: #F6C53E; stroke: #D69A12; animation: starIn .6s cubic-bezier(.2,1.8,.4,1) both; }
.stars svg:nth-child(2).on { animation-delay: .25s; }
.stars svg:nth-child(3).on { animation-delay: .5s; }
@keyframes starIn { 0% { transform: scale(0) rotate(-120deg); } 100% { transform: scale(1); } }
.result-card { width: 100%; max-width: 360px; overflow: hidden; }
.result-head { background: var(--green-pale); text-align: center; font-weight: 800; font-size: 24px; padding: 8px; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 7px 18px; font-size: 18px; font-weight: 600; border-top: 1.5px solid #EDE4D0; }
.result-row svg { width: 22px; height: 22px; color: var(--ink); }
.result-row b { margin-left: auto; font-size: 20px; font-variant-numeric: tabular-nums; }
.result-row.total { background: #FBF3DA; padding-bottom: 10px; }
.result-row.total b { color: var(--green); font-size: 22px; }
.win-note { min-height: 18px; margin: 8px 0 0; font-size: 14px; font-weight: 700; color: var(--green); text-align: center; }
.link-btn { margin-top: 14px; font-size: 19px; font-weight: 700; text-decoration: underline; text-underline-offset: 5px; padding: 6px; }
#screen-win .btn-primary { max-width: 380px; margin-top: 10px; }

/* ---------- fenêtres ---------- */
.overlay { position: absolute; inset: 0; z-index: 40; background: rgba(30,40,25,.45); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .25s ease both; backdrop-filter: blur(2px); }
.overlay.center { align-items: center; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-height: 92%; overflow-y: auto; background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 22px 20px calc(22px + var(--safe-bot)); animation: sheetIn .4s cubic-bezier(.2,1,.3,1) both; text-align: center;
}
.overlay.center .sheet { width: calc(100% - 40px); border-radius: 28px; animation: popIn .4s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes popIn { from { transform: scale(.7); opacity: 0; } }
@keyframes pop { from { transform: scale(0); } }
.sheet h3 { font-family: 'Fraunces', serif; font-weight: 800; font-size: 30px; margin: 0 0 6px; }
.sheet p { color: var(--ink-soft); font-weight: 600; margin: 0 0 14px; }
.sheet .sheet-pets { display: flex; justify-content: center; gap: 4px; margin: -4px 0 6px; }
.sheet .sheet-pets img { width: 78px; height: 78px; animation: petB 3s ease-in-out infinite; }
.sheet .btn-primary { font-size: 20px; min-height: 54px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1.5px solid #EAE0CB; font-weight: 700; font-size: 17px; text-align: left; }
.setting small { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.toggle { width: 54px; height: 32px; border-radius: 999px; background: #D7CDB8; position: relative; transition: background .25s; flex: none; }
.toggle::after { content: ''; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .3s cubic-bezier(.2,1.5,.4,1); }
.toggle.on { background: var(--green-2); }
.toggle.on::after { transform: translateX(22px); }
.danger { color: #B33A1E; border-color: #B33A1E; }

.toast { position: absolute; left: 50%; top: calc(18px + var(--safe-top)); z-index: 60; transform: translate(-50%, -150%); visibility: hidden; background: var(--green); color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 18px; font-size: 15px; line-height: 1.35; box-shadow: 0 8px 20px rgba(0,0,0,.2); transition: transform .4s cubic-bezier(.2,1.4,.4,1); max-width: 90%; text-align: center; }
.loading { position: absolute; inset: 0; z-index: 55; display: grid; place-items: center; background: rgba(247,241,226,.6); animation: fadeIn .25s ease both; }
.loading-c { display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--paper); border-radius: 22px; padding: 20px 26px; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.loading-dots { display: flex; gap: 8px; }
.loading-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--green-2); animation: dotHop .9s ease-in-out infinite; }
.loading-dots i:nth-child(2) { animation-delay: .15s; background: var(--sun); }
.loading-dots i:nth-child(3) { animation-delay: .3s; background: #F29B7E; }
@keyframes dotHop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-10px); } }
@keyframes fadeIn { from { opacity: 0; } }
.toast { transition: transform .4s cubic-bezier(.2,1.4,.4,1), visibility 0s .4s; }
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .4s cubic-bezier(.2,1.4,.4,1); }
.toast.low { top: auto; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); width: 92%; transform: translate(-50%, 160%); background: #FFF8E6; color: var(--ink, #1F2A1F); border: 2px solid #F0B83A; font-weight: 700; pointer-events: none; }
.toast.low.show { transform: translate(-50%, 0); }

/* ---------- effets ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.particle { position: absolute; width: 8px; height: 8px; border-radius: 50%; animation: burst .7s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.confetti { position: absolute; top: -20px; width: 12px; height: 16px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(var(--rot)); } }
.float-txt { position: absolute; font-weight: 800; color: var(--heart); font-size: 18px; animation: floatUp 1s ease-out forwards; text-shadow: 0 1px 0 #fff; }
@keyframes floatUp { to { transform: translateY(-40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- petits écrans (adaptation à tous les téléphones) ---------- */
@container app (max-height: 620px) {
  .counter { font-size: 14px; padding: 2px 16px; }
  .tool-c { width: 50px; height: 50px; }
  .tool-c svg { width: 26px; height: 26px; }
  .tool { font-size: 14px; }
  .game-info { margin-top: 6px; }
}
@container app (max-width: 370px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .game-top h2 { font-size: 24px; }
  .pill { font-size: 14px; padding: 4px 10px; }
  .timer { font-size: 17px; }
  .timer svg, .hearts svg { width: 20px; height: 20px; }
  .tools { gap: 18px; }
  .title { font-size: 46px; }
}
@container app (max-width: 330px) {
  .sep { display: none; }
  .hearts svg { width: 17px; height: 17px; }
}
