/* Devine la région: cut-paper style of Mémo en Chanson (style/palette.json). */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('fonts/BricolageGrotesque.ttf') format('truetype');
  font-weight: 200 800;
  font-display: swap;
}
:root {
  --ivory: #FFF2DB; --paper: #FFFBF3; --ink: #201E32; --ink-soft: rgba(32, 30, 50, .62);
  --coral: #FF5A3D; --butter: #FFE76D; --mint: #86F4CC; --cobalt: #234EFA;
  --tone-a: #FFE27A; --tone-b: #9FF0CF; --tone-c: #FFBDAE; --tone-d: #BFCBFF;
  --lift: 0 4px 0 rgba(32, 30, 50, .14), 0 10px 24px -12px rgba(32, 30, 50, .35);
  --radius: 18px;
  --ease-out: cubic-bezier(.2, .9, .3, 1);
  --pad: max(14px, env(safe-area-inset-left));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ivory); color: var(--ink); overflow: hidden; }
body { font: 500 17px/1.35 'Bricolage Grotesque', system-ui, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  position: relative; height: 100%; height: 100dvh; max-width: 1280px; margin: 0 auto;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 231, 109, .35), transparent 38%),
    radial-gradient(circle at 88% 90%, rgba(134, 244, 204, .28), transparent 40%);
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 10px var(--pad) max(14px, env(safe-area-inset-bottom)); }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: var(--radius); background: var(--paper); box-shadow: var(--lift);
  padding: 15px 22px; font-size: 19px; font-weight: 700; letter-spacing: -.01em;
  transition: transform .12s var(--ease-out), box-shadow .12s;
}
.btn:active, .choice:active, .level-card:active, .channel:active { transform: translateY(2px) scale(.98); box-shadow: 0 1px 0 rgba(32, 30, 50, .16); }
.btn-primary { background: var(--cobalt); color: var(--ivory); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 2px rgba(32, 30, 50, .14); }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 14px; background: var(--paper); box-shadow: var(--lift); font-size: 19px; font-weight: 700; display: grid; place-items: center; }
.btn:focus-visible, .choice:focus-visible, .icon-btn:focus-visible, .level-card:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; }

.bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; min-height: 48px; }
.bar h2 { margin: 0; text-align: center; font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.toggles { position: absolute; right: var(--pad); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.app:not([data-screen="home"]) .toggles { display: none; }
#toggle-music.is-off { opacity: .45; text-decoration: line-through; }

/* ---------- map ---------- */
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.map { width: 100%; height: 100%; overflow: hidden; touch-action: manipulation; }
.map-shadow path { fill: var(--ink); opacity: .16; transition: opacity .35s; }
.region { stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: fill .25s, opacity .35s; transform-box: fill-box; transform-origin: center; }
.tone-a { fill: var(--tone-a); } .tone-b { fill: var(--tone-b); } .tone-c { fill: var(--tone-c); } .tone-d { fill: var(--tone-d); }
.dep { fill: none; stroke: var(--ink); stroke-width: .5; opacity: .22; vector-effect: non-scaling-stroke; pointer-events: none; transition: opacity .35s, fill .25s; }
.dep.is-dep { fill: var(--butter); opacity: 1; stroke-width: 1.2; }
.map-deps { pointer-events: none; }
.hit { fill: transparent; }
.inset { fill: rgba(255, 251, 243, .7); stroke: var(--ink); stroke-opacity: .18; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; transition: fill .25s, opacity .35s; }
.map-caption { font-size: 15px; font-weight: 600; fill: var(--ink-soft); transition: opacity .35s; }
.map.is-tappable .region, .map.is-tappable .inset, .map.is-tappable .hit { cursor: pointer; }
@media (hover: hover) { .map.is-tappable .region:hover { filter: brightness(1.06) saturate(1.15); } }

.region.is-target { fill: var(--coral); animation: breathe 1.6s ease-in-out infinite; }
.region.is-right, .inset.is-right { fill: var(--mint); }
.region.is-right { fill: #3FE0A5; }
.region.is-wrong { fill: var(--coral); }
.inset.is-wrong { fill: #FFD9D0; }
@keyframes breathe { 50% { opacity: .78; } }

/* silhouette questions: only one region stays */
.map.is-solo .region:not(.is-solo), .map.is-solo .inset, .map.is-solo .dep, .map.is-solo .map-shadow path, .map.is-solo .map-caption { opacity: 0; }
.map.is-solo .region.is-solo { fill: var(--coral); }
.map.is-dim .region:not(.is-keep) { opacity: .35; }

.ripple { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; transform-box: fill-box; transform-origin: center; }
.ripple-right { stroke: #12B981; } .ripple-wrong { stroke: var(--coral); }
.leader { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.pin circle { fill: var(--ink); stroke: var(--paper); stroke-width: 3; vector-effect: non-scaling-stroke; }
.pin text { font-size: 30px; font-weight: 800; text-anchor: middle; fill: var(--ink); paint-order: stroke; stroke: var(--paper); stroke-width: 7px; stroke-linejoin: round; }
.map-overlay { pointer-events: none; }

/* ---------- home ---------- */
.home { justify-content: flex-end; }
.home-map { flex: 1; min-height: 0; margin: 4px 0 10px; }
.home-panel { position: relative; display: grid; justify-items: center; text-align: center; gap: 4px; padding-bottom: 52px; }
.mascot { display: block; }
.mascot-big { width: 96px; height: 96px; margin-bottom: -8px; }
.title { margin: 0; font-size: clamp(42px, min(11vw, 7.5vh), 78px); line-height: .9; font-weight: 800; letter-spacing: -.045em; }
.tagline { margin: 6px 0 14px; color: var(--ink-soft); font-weight: 600; }
.home-actions { display: grid; gap: 10px; width: min(360px, 100%); }
.home-progress { margin: 14px 0 0; font-size: 14px; color: var(--ink-soft); font-weight: 600; min-height: 1.3em; }

/* ---------- levels ---------- */
.level-list { display: grid; gap: 14px; align-content: center; flex: 1; width: min(520px, 100%); margin: 0 auto; }
.level-card { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px; text-align: left; border: 0; border-radius: 22px; background: var(--paper); box-shadow: var(--lift); padding: 16px 18px; transition: transform .12s var(--ease-out); }
.level-num { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 800; background: var(--butter); }
.level-card:nth-child(2) .level-num { background: var(--mint); }
.level-card:nth-child(3) .level-num { background: var(--tone-c); }
.level-body strong { display: block; font-size: 20px; letter-spacing: -.015em; }
.level-body small { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.level-stars { font-size: 20px; color: #F2B300; letter-spacing: 1px; }
.level-stars i { font-style: normal; color: rgba(32, 30, 50, .14); }

/* ---------- play ---------- */
.progress { display: flex; gap: 6px; justify-content: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(32, 30, 50, .14); transition: background .25s, transform .25s; }
.dot.is-now { background: var(--ink); transform: scale(1.25); }
.dot.is-right { background: #12B981; } .dot.is-wrong { background: var(--coral); }
.heart { font-size: 22px; color: var(--coral); transition: color .3s, transform .3s; }
.heart.is-lost { color: rgba(32, 30, 50, .15); transform: scale(.8); }
.score { justify-self: end; display: flex; gap: 6px; align-items: center; font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; min-width: 44px; justify-content: flex-end; }
.score #score { display: inline-block; }
.streak { font-size: 15px; }

.prompt { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; margin: 6px 0 4px; }
.mascot-small { width: 64px; height: 64px; }
.prompt-text { margin: 0; font-size: clamp(20px, 5.4vw, 27px); font-weight: 750; line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; }
.play-stage { margin: 4px 0; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 64px; }
.choice { position: relative; border: 0; border-radius: 16px; background: var(--paper); box-shadow: var(--lift); padding: 14px 12px 14px 14px; min-height: 62px; font-size: clamp(15px, 4.2vw, 18px); font-weight: 700; line-height: 1.15; text-align: left; display: flex; align-items: center; gap: 10px; transition: background .2s, color .2s, transform .12s var(--ease-out); }
.choice kbd { flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font: 700 13px/1 inherit; background: rgba(32, 30, 50, .07); color: var(--ink-soft); }
.choice.is-right { background: #3FE0A5; }
.choice.is-wrong { background: var(--coral); color: var(--paper); animation: nope .36s ease-out; }
.choice.is-wrong kbd { background: rgba(255, 255, 255, .25); color: var(--paper); }
.choice:disabled { cursor: default; }
.choice:disabled:not(.is-right):not(.is-wrong) { opacity: .55; }
@keyframes nope { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-2px); } }
.tap-hint { grid-column: 1 / -1; margin: 0; align-self: center; text-align: center; font-weight: 700; color: var(--ink-soft); }
.tap-hint::before { content: '☝ '; }

.sheet { position: absolute; left: var(--pad); right: var(--pad); bottom: max(14px, env(safe-area-inset-bottom)); background: var(--paper); border-radius: 24px; box-shadow: 0 -2px 0 rgba(32, 30, 50, .06), 0 18px 40px -16px rgba(32, 30, 50, .45); padding: 18px 18px 16px; display: grid; gap: 8px; z-index: 3; }
.sheet-verdict { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.sheet-verdict.is-right { color: #0E9F6E; } .sheet-verdict.is-wrong { color: #E2401F; }
.sheet-text { margin: 0 0 6px; font-size: 18px; font-weight: 550; }
.fly { position: fixed; z-index: 9; pointer-events: none; font-weight: 800; font-size: 22px; color: #0E9F6E; text-shadow: 0 2px 0 var(--paper); }

/* ---------- result ---------- */
.result { justify-content: center; align-items: center; gap: 18px; }
.result-card { width: min(460px, 100%); background: var(--paper); border-radius: 28px; box-shadow: var(--lift); padding: 26px 22px 20px; text-align: center; display: grid; gap: 8px; }
.result-kicker { margin: 0; font-weight: 700; color: var(--ink-soft); }
.stars { display: flex; justify-content: center; gap: 6px; font-size: 54px; line-height: 1; }
.stars span { color: rgba(32, 30, 50, .12); transition: color .2s; }
.stars span.is-on { color: #F2B300; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: scale(.4) rotate(-20deg); } 100% { transform: none; } }
.result-score { margin: 4px 0 0; font-size: 20px; font-weight: 800; }
.result-review { margin: 0 0 8px; font-size: 15px; color: var(--ink-soft); font-weight: 550; }
.result-actions { display: grid; gap: 10px; }
.channel { display: flex; align-items: center; gap: 12px; text-align: left; width: min(460px, 100%); border: 0; border-radius: 20px; background: var(--ink); color: var(--ivory); padding: 10px 16px 10px 10px; box-shadow: var(--lift); font-size: 15px; }
.channel img { border-radius: 50%; background: var(--ivory); }
.channel strong { font-size: 17px; }

/* ---------- explore ---------- */
.explore-hint { margin: 4px 0 0; text-align: center; font-weight: 700; color: var(--ink-soft); }
.explore-sheet { gap: 4px; }
.explore-sheet .sheet-verdict { color: var(--ink); }
.dep-list { margin: 0; font-size: 14px; color: var(--ink-soft); font-weight: 600; max-height: 22vh; overflow: auto; }

/* ---------- landscape: map left, panel right ---------- */
@media (min-aspect-ratio: 5/4) {
  .play { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: 28px; }
  .play .bar { grid-column: 1 / -1; }
  .play .play-stage { grid-column: 1; grid-row: 2 / 5; }
  .play .prompt { grid-column: 2; grid-row: 2; margin-top: 18px; }
  .play .answers { grid-column: 2; grid-row: 3; grid-template-columns: 1fr; align-content: start; }
  .play .sheet { left: auto; width: min(460px, 42%); }
  .home { flex-direction: row; align-items: center; justify-content: flex-end; }
  .home-map { height: 100%; margin: 0; }
  .home-panel { flex: none; width: 44%; padding: 0 0 20px; }
  .explore { display: grid; grid-template-columns: 1fr minmax(300px, 34%); grid-template-rows: auto auto 1fr; column-gap: 24px; }
  .explore .bar, .explore .explore-hint { grid-column: 1 / -1; }
  .explore .explore-stage { grid-column: 1; grid-row: 3; }
  .explore .explore-sheet { position: static; grid-column: 2; grid-row: 3; align-self: center; }
}

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