/* ============================================================
   Les 100 chats — feuille de style unique
   Thème kawaii pastel, pensé pour les doigts (cibles ≥ 40px)
   ============================================================ */

:root {
  --pink: #ff8fab;
  --pink-soft: #ffe3ea;
  --mint: #6ed3ae;
  --mint-soft: #d8f5ea;
  --sky: #74b3f0;
  --sky-soft: #dcecfd;
  --lemon: #ffd166;
  --violet: #b39ddb;
  --ink: #4a3b45;
  --ink-soft: #8b7a84;
  --bg: #fff7f9;
  --card: #ffffff;
  --line: #f0dfe6;
  --shadow: 0 6px 0 rgba(74, 59, 69, .08);
  --radius: 18px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Nos règles `display` (grid, inline-flex…) battent la feuille du navigateur :
   sans ceci, un élément portant l'attribut `hidden` resterait affiché. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 12% 8%, var(--pink-soft) 0 22%, transparent 22.5%),
    radial-gradient(circle at 88% 4%, var(--sky-soft) 0 18%, transparent 18.5%),
    radial-gradient(circle at 76% 92%, var(--mint-soft) 0 20%, transparent 20.5%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 8px; top: 8px; z-index: 99;
  background: #fff; padding: 8px 12px; border-radius: 10px;
}

/* ------------------------------------------------------------ boutons ---- */

.btn {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--pink-soft); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn--ghost { background: rgba(255, 255, 255, .7); box-shadow: none; border-color: transparent; }
.btn--ghost:hover { background: #fff; }
.btn--small { padding: 6px 14px; min-height: 38px; font-size: .92em; }
.btn--icon { padding: 8px 12px; }
.btn[aria-pressed="true"] { background: var(--lemon); border-color: #f0b429; }

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ topbar ----- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px clamp(10px, 3vw, 22px);
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar__title {
  font-size: clamp(1.05rem, 3.4vw, 1.5rem);
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__right { display: flex; align-items: center; gap: 8px; }

.catcount {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 800;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-variant-numeric: tabular-nums;
}
.catcount__icon { font-size: 1.05em; }
.catcount__total { color: var(--ink-soft); font-size: .85em; }
.catcount.is-up { animation: pop .45s ease; }
.catcount.is-down { animation: shake .4s ease; }

@media (max-width: 430px) {
  .catcount { padding: 6px 10px; }
  .catcount__total { display: none; }
  .topbar { gap: 6px; padding-left: 8px; padding-right: 8px; }
}

main { padding: 0 clamp(10px, 3vw, 22px) 32px; }

.screen[hidden] { display: none; }

/* ------------------------------------------------------------ accueil --- */

.screen--home { max-width: 760px; margin: 0 auto; text-align: center; }
.home__intro { font-size: 1.05rem; color: var(--ink-soft); margin: 6px 0 22px; }
.home__foot { margin-top: 26px; }

.cards { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .cards .card--soft { grid-column: 1 / -1; }
}

.card {
  display: grid;
  gap: 4px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 22px;
  padding: 18px 20px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(74, 59, 69, .07);
  transition: transform .14s, box-shadow .14s, border-color .14s;
}
.card:hover { transform: translateY(-3px); border-color: var(--pink); box-shadow: 0 11px 0 rgba(255, 143, 171, .22); }
.card:active { transform: translateY(2px); box-shadow: none; }
.card--soft { border-color: var(--sky-soft); }
.card--soft:hover { border-color: var(--sky); box-shadow: 0 11px 0 rgba(116, 179, 240, .22); }
.card__emoji { font-size: 2rem; line-height: 1; }
.card__title { font-size: 1.22rem; font-weight: 800; }
.card__desc { color: var(--ink-soft); font-size: .95rem; }
.card__progress { margin-top: 8px; font-weight: 700; color: var(--mint); font-size: .95rem; }

/* --------------------------------------------------- disposition modes -- */

.mode {
  display: grid;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
}
@media (min-width: 900px) {
  .mode { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
}

.mode__side {
  display: grid;
  gap: 12px;
  align-content: start;
  background: rgba(255, 255, 255, .72);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.mode__tools { display: flex; flex-wrap: wrap; gap: 8px; }
.mode__stat { margin: 0; color: var(--ink-soft); font-size: .85rem; text-align: center; }

/* ------------------------------------------------------------ plateau --- */

.boardwrap {
  container-type: inline-size;
  max-width: min(100%, 680px);
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: .6cqw;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: .8cqw;
  box-shadow: var(--shadow);
}

.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font: inherit;
  font-weight: 700;
  font-size: 3.1cqw;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: #fdf4f7;
  border: 1px solid #f4e7ec;
  border-radius: 16%;
  cursor: pointer;
  padding: 0;
  transition: background .12s, transform .12s, color .12s;
  /* les décennies restent lisibles même très petites */
  letter-spacing: -.02em;
}
.cell:hover:not(:disabled) { background: var(--pink-soft); transform: scale(1.06); }

/* une colonne sur deux légèrement teintée : repère visuel des unités */
.cell.is-odd-col { background: #f7f2fb; }
.cell.is-odd-col:hover:not(:disabled) { background: var(--pink-soft); }

/* Les classes d'état doublent `.cell` pour passer devant `.is-odd-col`. */
.cell.cell--empty { color: transparent; }
.cell.cell--empty::after {
  content: "";
  width: 14%; aspect-ratio: 1;
  background: #e6d6de;
  border-radius: 50%;
}
.cell.cell--ghost { color: #d9c6cf; }
.cell.cell--ghost::after { display: none; }

.cell.cell--filled {
  background: var(--mint-soft);
  border-color: #b9e8d5;
  color: #2f6b56;
  cursor: default;
  animation: pop .4s ease;
}
.cell.cell--target {
  background: var(--lemon);
  border-color: #f0b429;
  color: #6b4c00;
  animation: glow 1.4s ease-in-out infinite;
  z-index: 1;
}
.cell.cell--done { background: var(--mint-soft); border-color: #b9e8d5; color: #2f6b56; }
.cell.cell--missed { background: #ffe0e6; border-color: #ffc2cf; color: #a3455c; }
.cell.cell--hint { animation: hint 1s ease-in-out 3; }
/* en dernier : l'erreur doit gagner sur tous les autres états */
.cell.cell--wrong { animation: shake .4s ease; background: #ffd7de; border-color: #ffb3c2; }
.cell:disabled { cursor: default; }

/* ------------------------------------------------------------- consigne -- */

.prompt {
  display: grid;
  justify-items: center;
  gap: 2px;
  background: #fff;
  border: 3px dashed var(--pink);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.prompt__label { color: var(--ink-soft); font-size: .88rem; }
.prompt__number {
  font-size: clamp(3rem, 12vw, 4.4rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--pink);
  animation: pop .35s ease;
}
.prompt__hint { color: var(--ink-soft); font-size: .85rem; min-height: 1.2em; }
.prompt.is-done { border-style: solid; border-color: var(--mint); }

/* --------------------------------------------------------------- micro --- */

.mic {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4px;
  width: 100%;
  min-height: 130px;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  background: var(--mint-soft);
  border: 3px solid var(--mint);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.mic:active { transform: translateY(2px); }
.mic__icon { font-size: 2.4rem; line-height: 1; }
.mic__label { font-size: .95rem; }
.mic__ring {
  position: absolute;
  inset: 8px;
  width: auto; height: auto;
  pointer-events: none;
  opacity: 0;
}
.mic__ring circle {
  fill: none;
  stroke: var(--pink);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 289;
  transform: rotate(-90deg);
  transform-origin: center;
}
.mic.is-recording { background: var(--pink-soft); border-color: var(--pink); animation: breathe 1.1s ease-in-out infinite; }
.mic.is-recording .mic__ring { opacity: 1; }
.mic.is-recording .mic__ring circle { animation: countdown var(--rec-ms, 5000ms) linear forwards; }
.mic.is-busy { background: var(--sky-soft); border-color: var(--sky); cursor: progress; }
.mic:disabled { opacity: .55; cursor: not-allowed; }

.heard { margin: 0; text-align: center; min-height: 1.4em; color: var(--ink-soft); font-size: .92rem; }
.heard strong { color: var(--ink); }
.heard.is-error { color: #b3455f; }

/* ----------------------------------------------------------- récompense -- */

.reward {
  display: grid;
  place-items: center;
  min-height: 96px;
}
.reward__card {
  display: grid;
  justify-items: center;
  gap: 2px;
  animation: pop .4s ease;
}
.reward__art { width: 88px; height: 88px; }
.reward__art img, .reward__art svg { width: 100%; height: 100%; object-fit: contain; }
.reward__name { font-weight: 800; }
.reward__sub { font-size: .8rem; color: var(--ink-soft); }
.reward--lost .reward__art { filter: grayscale(1); opacity: .45; }
.reward--lost .reward__name { color: #b3455f; }

/* ----------------------------------------------------------- collection -- */

.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.tabs__tab {
  font: inherit;
  font-weight: 700;
  padding: 8px 18px;
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .7);
  color: var(--ink-soft);
  cursor: pointer;
}
.tabs__tab.is-active { background: #fff; color: var(--ink); border-color: var(--pink); }

.collection__bar {
  max-width: 620px;
  margin: 0 auto;
  height: 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.collection__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), var(--lemon), var(--mint));
  transition: width .5s ease;
}
.collection__count { text-align: center; color: var(--ink-soft); margin: 8px 0 16px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
}
@media (min-width: 520px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
}

.slot {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 5px 5px 15px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
}
.slot img, .slot svg { width: 100%; height: 100%; object-fit: contain; }
.slot--locked { background: #fbf1f4; cursor: default; }
.slot--locked { padding: 5px; }
.slot--locked::after {
  content: attr(data-id);
  color: #d8c4cd;
  font-weight: 800;
  font-size: .95rem;
}
.slot--new { animation: pop .5s ease; border-color: var(--mint); }
.slot__name {
  position: absolute;
  bottom: 3px; left: 2px; right: 2px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- fiche -- */

.sheet {
  border: none;
  border-radius: 24px;
  padding: 22px;
  max-width: 340px;
  width: calc(100% - 32px);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(74, 59, 69, .25);
}
.sheet::backdrop { background: rgba(74, 59, 69, .35); backdrop-filter: blur(2px); }
.sheet__close { position: absolute; top: 10px; right: 10px; }
.sheet__body { display: grid; justify-items: center; gap: 4px; text-align: center; }
.sheet__art { width: min(220px, 60vw); aspect-ratio: 1; }
.sheet__art img, .sheet__art svg { width: 100%; height: 100%; object-fit: contain; }
.sheet__name { font-size: 1.5rem; font-weight: 800; margin: 0; }
.sheet__meta { color: var(--ink-soft); font-size: .9rem; margin: 0; }

.engine-line {
  margin: 0;
  text-align: center;
  font-size: .78rem;
  color: var(--ink-soft);
}
.engine-line.is-fallback { color: #a2701a; font-weight: 700; }

/* -------------------------------------------------------------- ardoise -- */

.writepad {
  border: none;
  border-radius: 28px;
  padding: 28px 18px 22px;
  max-width: min(720px, calc(100vw - 16px));
  width: calc(100% - 16px);
  background: #fff;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 18px 50px rgba(74, 59, 69, .25);
}
.writepad::backdrop { background: rgba(74, 59, 69, .4); backdrop-filter: blur(2px); }
.writepad__title { font-size: 1.25rem; margin: 0 36px 18px; }

.writepad__boxes { display: flex; gap: clamp(10px, 2.5vw, 20px); justify-content: center; }

.writebox { position: relative; display: grid; gap: 6px; justify-items: center; }
.writebox__label { font-size: .8rem; color: var(--ink-soft); text-transform: lowercase; }
.writebox__canvas {
  /* --boxes vaut 1, 2 ou 3 : on remplit l’écran tout en gardant 3 cadres côte à côte */
  width: min(
    calc((100vw - 48px - (var(--boxes, 2) - 1) * 16px) / var(--boxes, 2)),
    220px
  );
  aspect-ratio: 1;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) center / 100% 33.33%,
    #fdf4f7;
  border: 3px dashed var(--pink);
  border-radius: 20px;
  cursor: crosshair;
  /* indispensable : sinon le doigt fait défiler la page au lieu d'écrire */
  touch-action: none;
}
.writebox__mark {
  position: absolute;
  right: -4px;
  bottom: -6px;
  font-size: 1.25rem;
  font-weight: 800;
}
.writebox.is-ok .writebox__canvas { border-style: solid; border-color: var(--mint); background: var(--mint-soft); }
.writebox.is-ok .writebox__mark { color: #2f6b56; }
.writebox.is-ko .writebox__canvas { border-color: #f78ca2; animation: shake .4s ease; }
.writebox.is-ko .writebox__mark { color: #b3455f; }

.writepad__feedback { min-height: 2.6em; margin: 10px 0 8px; color: var(--ink-soft); font-size: .95rem; }
.writepad__feedback.is-ok { color: #2f6b56; font-weight: 700; }
.writepad__feedback.is-ko, .writepad__feedback.is-warn { color: #b3455f; }

.writepad__tools { display: flex; gap: 10px; justify-content: center; }

/* ----------------------------------------------------------- particules -- */

.particles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.particle {
  position: absolute;
  font-size: 1.4rem;
  animation: fly .9s ease-out forwards;
}

/* ------------------------------------------------------------ animations - */

@keyframes pop {
  0% { transform: scale(.6); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 180, 41, .7); }
  50% { box-shadow: 0 0 0 .9cqw rgba(240, 180, 41, 0); }
}
@keyframes hint {
  0%, 100% { background: #fdf4f7; }
  50% { background: var(--lemon); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
@keyframes countdown {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 289; }
}
@keyframes fly {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx, 0), var(--dy, -120px)) scale(.4) rotate(var(--rot, 90deg)); opacity: 0; }
}

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