:root {
  --bg: #FFF8EE;
  --ink: #2B2A33;
  --muted: #6F6A78;
  --card: #FFFFFF;
  --shadow: 0 6px 0 rgba(43, 42, 51, .10), 0 10px 24px rgba(43, 42, 51, .07);
  --ui: 'Fredoka', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --let: 'Andika', 'Fredoka', system-ui, sans-serif;
  --emo: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); overscroll-behavior: none; }
body { overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
#app {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background .3s;
}
main { flex: 1; min-height: 0; }
.emo { font-family: var(--emo); line-height: 1; }
svg.i { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* barre du haut */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex: none; }
.top h1 { flex: 1; margin: 0; font-size: clamp(24px, 4.6vw, 40px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb { width: clamp(58px, 9vw, 74px); aspect-ratio: 1; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; flex: none; transition: transform .08s; }
.rb svg.i { width: 54%; height: 54%; }
.rb.sm { width: clamp(52px, 7vw, 62px); }
.press:active { transform: translateY(4px) scale(.97); box-shadow: 0 2px 0 rgba(43, 42, 51, .1); }
.stars { font-size: clamp(20px, 3.8vw, 30px); font-weight: 700; background: var(--card); border-radius: 999px; padding: 8px 18px; box-shadow: var(--shadow); white-space: nowrap; }

/* accueil */
.home-top { padding-top: 16px; }
.brand { flex: 1; font-size: clamp(36px, 7vw, 60px); font-weight: 700; letter-spacing: 1px; }
.brand b:nth-child(1) { color: #E53935; } .brand b:nth-child(2) { color: #F57C00; } .brand b:nth-child(3) { color: #43A047; }
.brand b:nth-child(4) { color: #1E88E5; } .brand b:nth-child(5) { color: #8E24AA; } .brand b:nth-child(6) { color: #D81B60; }
.hold { position: relative; opacity: .7; }
.hold .ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.hold .ring circle { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 145; stroke-dashoffset: 145; }
.hold.holding .ring circle { stroke-dashoffset: 0; transition: stroke-dashoffset 1.3s linear; }
.hgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(40vw, 200px), 1fr));
  gap: clamp(12px, 2.4vw, 24px); align-content: center; padding: 8px 16px 24px; overflow-y: auto;
}
.htile {
  background: var(--bg2); border-radius: 30px; aspect-ratio: 1 / .88; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; box-shadow: 0 7px 0 var(--c), 0 12px 26px rgba(0, 0, 0, .06);
}
.htile:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--c); }
.hv { font-size: clamp(54px, 11vw, 100px); line-height: 1; }
.hv.txt { font-family: var(--let); font-weight: 700; letter-spacing: 2px; }
.hv.txt b { color: var(--c); }
.hv.shapes { display: flex; gap: 6px; }
.hv.shapes svg { width: .62em; height: .62em; }
.hl { font-size: clamp(20px, 3.6vw, 32px); font-weight: 700; color: var(--c); }

/* grilles */
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px 28px; }
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px; }
.ngrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.ltile {
  aspect-ratio: 1; border-radius: 24px; background: var(--bg2); box-shadow: 0 6px 0 var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.ltile .lg { font-family: var(--let); font-weight: 700; font-size: clamp(42px, 7vw, 60px); color: var(--c); line-height: 1; }
.lg small, .arrow small, .opt small { font-size: .72em; margin-left: .06em; }
.ltile .le { font-size: clamp(24px, 4vw, 32px); }
.dmini { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 70%; }
.dmini i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: .75; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.ctile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 10px 14px; background: var(--card); border-radius: 26px; box-shadow: var(--shadow); }
.cdot { width: 72%; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .12), 0 0 0 3px rgba(0, 0, 0, .06); }
.cn { font-size: clamp(20px, 3.4vw, 26px); font-weight: 700; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.atile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 1; background: var(--card); border-radius: 26px; box-shadow: 0 6px 0 var(--c), 0 10px 22px rgba(0, 0, 0, .05); }
.atile .emo { font-size: clamp(56px, 10vw, 80px); }
.atile svg.shape { width: 58%; height: auto; }
.an { font-size: clamp(18px, 3vw, 24px); font-weight: 700; color: var(--c); text-transform: capitalize; }
svg.shape { fill: var(--c); stroke: rgba(0, 0, 0, .14); stroke-width: 3; stroke-linejoin: round; overflow: visible; }

/* fiches détaillées */
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2.4vw, 24px); padding: 4px 16px 8px; }
@media (orientation: portrait) { .detail { grid-template-columns: 1fr; grid-template-rows: minmax(0, .85fr) minmax(0, 1.15fr); } }
.card { background: var(--card); border-radius: 34px; box-shadow: var(--shadow); min-height: 0; min-width: 0; position: relative; overflow: hidden; }
.bigcard { display: flex; align-items: center; justify-content: center; gap: 2vmin; background: var(--bg2); box-shadow: 0 8px 0 var(--c); }
.bigcard.col { flex-direction: column; gap: 0; }
.glyph { font-family: var(--let); font-weight: 700; color: var(--c); line-height: .95; font-size: min(36vmin, 32vw); }
.glyph.lo { font-size: min(29vmin, 26vw); opacity: .85; }
.nword { font-size: clamp(30px, 7vmin, 64px); font-weight: 700; color: var(--c); }
.piccard, .countcard { display: flex; flex-direction: column; }
.pic { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5vmin; min-height: 0; padding: 12px; }
.pic .emo { font-size: min(30vmin, 28vw); }
.word { font-family: var(--let); font-size: clamp(36px, 8vmin, 80px); font-weight: 700; letter-spacing: 1px; text-align: center; }
.word .whl { color: var(--c); }
.wnav { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 0 12px 16px; }
.dots { display: flex; gap: 9px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #E2DED6; transition: transform .2s; }
.dots i.on { background: var(--c); transform: scale(1.3); }
.bnav { display: flex; justify-content: space-between; gap: 16px; padding: 8px 16px 16px; flex: none; }
.arrow {
  display: flex; align-items: center; gap: 8px; min-height: 66px; background: var(--card); border-radius: 999px;
  padding: 8px 24px 8px 14px; box-shadow: var(--shadow); font-family: var(--let); font-weight: 700; font-size: clamp(26px, 5vw, 40px);
}
.arrow.next { padding: 8px 14px 8px 24px; }
.arrow svg.i { width: 38px; height: 38px; }
.mdot { display: inline-block; width: 36px; height: 36px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }

/* compter */
.items { flex: 1; display: grid; grid-template-columns: repeat(var(--cols), auto); place-items: center; place-content: center; gap: 1.6vmin 2vmin; padding: 2vmin; min-height: 0; }
.it { position: relative; font-size: var(--fs); border-radius: 22px; padding: .4vmin; opacity: .55; transition: opacity .2s, transform .2s; }
.it.done { opacity: 1; transform: scale(1.06); }
.badge {
  position: absolute; top: -4px; right: -8px; display: none; min-width: 1.7em; padding: 2px 8px; border-radius: 999px;
  background: var(--c); color: #fff; font-family: var(--let); font-size: clamp(16px, 3.6vmin, 30px); line-height: 1.3; text-align: center;
}
.it.done .badge { display: block; }
.cnav { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 0 12px 16px; }
.pill { display: inline-flex; align-items: center; gap: 10px; background: var(--c); color: #fff; border-radius: 999px; padding: 13px 28px; font-size: clamp(22px, 4vw, 30px); font-weight: 700; box-shadow: 0 5px 0 rgba(0, 0, 0, .18); }
.pill svg.i { width: 30px; height: 30px; }

/* couleurs */
.splash { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vmin; }
.blob { display: block; width: min(44vmin, 70%); aspect-ratio: 1; border-radius: 58% 42% 55% 45% / 48% 58% 42% 52%; box-shadow: inset 0 -14px 0 rgba(0, 0, 0, .12); animation: morph 6s ease-in-out infinite; }
.blob.light { box-shadow: inset 0 -14px 0 rgba(0, 0, 0, .08), 0 0 0 3px rgba(0, 0, 0, .1); }
.blob.sm { width: 74%; }
@keyframes morph { 50% { border-radius: 42% 58% 45% 55% / 58% 42% 58% 42%; transform: rotate(8deg); } }
.cname { font-size: clamp(44px, 10vmin, 96px); font-weight: 700; text-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.cname.light { -webkit-text-stroke: 2px rgba(0, 0, 0, .35); }
.objs { display: grid; grid-template-columns: repeat(2, 1fr); place-items: center; gap: 2vmin; padding: 3vmin; }
.obj { font-size: min(17vmin, 18vw); padding: 1.5vmin; border-radius: 26px; }

/* superposition */
.spot {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 248, 238, .94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s;
  padding: 16px;
}
.spot .close { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: calc(16px + env(safe-area-inset-right)); }
.spot-emo { font-size: min(48vmin, 62vw); }
.spot-shape svg { width: min(46vmin, 62vw); height: auto; }
.spot p { margin: 2.5vmin 0 0; font-size: clamp(30px, 6.5vmin, 60px); font-weight: 700; color: var(--c); text-align: center; }
.ex { display: flex; gap: 3vmin; margin-top: 3vmin; }
.ex button { font-size: min(13vmin, 17vw); background: var(--card); border-radius: 26px; padding: 2vmin; box-shadow: var(--shadow); }
@keyframes fade { from { opacity: 0; } }

/* jeu */
.gq { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 2px 16px 6px; flex: none; }
.gq .rb { background: var(--c); color: #fff; }
.gq p { margin: 0; font-size: clamp(26px, 5vw, 46px); font-weight: 700; }
.opts { display: flex; flex-wrap: wrap; align-items: center; align-content: center; justify-content: center; gap: 20px; padding: 16px; }
.opt { width: var(--ow, 200px); aspect-ratio: 1; border-radius: 34px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; overflow: hidden; }
.opt .glyph { font-size: calc(var(--ow, 200px) * .56); }
.opt .emo { font-size: calc(var(--ow, 200px) * .58); }
.opt svg.shape { width: 70%; height: auto; }
.opt.good { box-shadow: 0 0 0 8px #43A047, var(--shadow); animation: popIn .5s cubic-bezier(.2, .9, .3, 1.3); }
.opt.bad { animation: shake .4s; opacity: .35; }

/* bulles */
.chips { display: flex; gap: 8px; }
.chip { padding: 10px 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: clamp(18px, 3.4vw, 24px); font-weight: 700; font-family: var(--let); }
.chip.on { background: var(--ink); color: #fff; }
.pond { position: relative; overflow: hidden; background: linear-gradient(#CDEFFF, #FFF8EE 85%); border-radius: 34px 34px 0 0; margin: 0 8px; touch-action: none; }
.bub { position: absolute; top: 100%; width: var(--s); height: var(--s); margin-left: calc(var(--s) / -2); animation: rise var(--d) linear forwards; }
.bub .in {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; pointer-events: none;
  font-family: var(--let); font-weight: 700; font-size: calc(var(--s) * .5); color: hsl(var(--h), 70%, 32%);
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, .95) 0 9%, rgba(255, 255, 255, .35) 10% 22%, transparent 23%),
    radial-gradient(circle at 50% 50%, hsla(var(--h), 90%, 80%, .35), hsla(var(--h), 90%, 62%, .6));
  border: 3px solid hsla(var(--h), 80%, 58%, .65);
  animation: sway 2.4s ease-in-out infinite alternate;
}
.bub .in .emo { font-size: .9em; }
.bub.popped .in { animation: burst .28s ease-out forwards; }
@keyframes rise { to { transform: translateY(calc(-1 * (var(--ph) + var(--s) + 40px))); } }
@keyframes sway { from { transform: translateX(-14px); } to { transform: translateX(14px); } }
@keyframes burst { to { transform: scale(1.6); opacity: 0; } }

/* réglages */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(43, 42, 51, .45); }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--card); border-radius: 28px; padding: 24px; user-select: text; }
.sheet h2 { margin: 0 0 6px; font-size: 28px; }
.row { margin: 18px 0; }
.row h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 10px 16px; border-radius: 14px; background: #F1EDE5; font-size: 18px; font-weight: 600; }
.seg button.on { background: var(--ink); color: #fff; }
.note { color: var(--muted); font-size: 15px; line-height: 1.4; }
.pill.done { margin-top: 8px; }

/* animations */
@keyframes popIn { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg) scale(1.08); } 75% { transform: rotate(9deg) scale(1.08); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
@keyframes hop { 0%, 100% { transform: scale(1.06) translateY(0); } 50% { transform: scale(1.2) translateY(-12px); } }
.pop { animation: popIn .45s cubic-bezier(.2, .9, .3, 1.3) both; }
.wiggle { animation: wiggle .5s ease-in-out; }
.it.now, .it.cheer { animation: hop .4s ease-out; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti { position: absolute; top: -60px; font-family: var(--emo); animation: fall var(--t) cubic-bezier(.3, .6, .6, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), calc(100vh + 120px)) rotate(var(--rot)); } }
@media (prefers-reduced-motion: reduce) { .blob, .bub .in { animation: none; } }
