/* ASPIRE À MIEUX. Une seule ambiance : panneaux encre posés sur le sol du monde.
   Accent unique : la menthe des yeux d'Aspi. Jaune post-it et or des étoiles sont des couleurs d'objet, pas d'accent ;
   l'or sert aussi à marquer ce qui est définitif (paires exclusives).
   Rayons : boutons en pilule, panneaux 18 px, puces 10 px, nœuds de l'arbre ronds.
   Mouvement : ease-out fort pour ce qui entre, rien d'animé sur une action clavier répétée. */

@font-face {
  font-family: 'Fredoka';
  src: url('../assets/fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  src: url('../assets/fonts/caveat.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink: #171c29;
  --ink-2: #212839;
  --ink-3: #2e374d;
  --line: rgba(255, 255, 255, 0.09);
  --paper: #fbf5ea;
  --muted: #aeb6c8;
  --faint: #8790a5;
  --led: #5ef0c0;
  --led-ink: #0b2a22;
  --led-soft: rgba(94, 240, 192, 0.16);
  --warn: #ff7a5c;
  --gold: #ffcf4d;
  --gold-ink: #3a2a00;
  --postit: #ffe37e;
  --postit-ink: #3b2f10;
  --shadow: 0 18px 40px -12px rgba(8, 10, 18, 0.65), 0 2px 6px rgba(8, 10, 18, 0.35);
  --r-panel: 18px;
  --r-chip: 10px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: 'Fredoka', ui-rounded, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #151924;
  color: var(--paper);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* iOS : sans le préfixe, un pouce resté posé sélectionne le texte et ouvre « Copier / Rechercher » (vu au simulateur). */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }
/* lu par les lecteurs d'écran et les moteurs, invisible à l'écran (le h1 de la page) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; touch-action: none; }
/* Flèche qui remplace le pointeur système quand la souris est capturée : même forme, même taille, pas
   d'animation (elle suit la main), au-dessus de tout. La pointe (1.5, 1.5) tombe sur le point visé. */
.cursor { position: fixed; left: -1.5px; top: -1.5px; z-index: 20; pointer-events: none; overflow: visible; filter: drop-shadow(0 1px 1.5px rgba(8, 10, 18, 0.55)); }
.cursor path { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }

/* ---------- Boutons ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, box-shadow 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .node:focus-visible, .icon-btn:focus-visible, .at-tab:focus-visible, .switch:focus-visible, .linkish:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.btn-primary { background: var(--led); color: var(--led-ink); box-shadow: 0 8px 22px -8px rgba(94, 240, 192, 0.55); }
.btn-ghost { background: rgba(255, 255, 255, 0.07); color: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.btn-gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 8px 22px -8px rgba(255, 207, 77, 0.6); }
.btn-dark { background: var(--ink); color: var(--paper); box-shadow: 0 10px 26px -10px rgba(23, 28, 41, 0.5); }
.btn[disabled] { cursor: not-allowed; background: var(--ink-3); color: var(--muted); box-shadow: none; transform: none; }
.btn-xl { font-size: 1.25rem; padding: 18px 40px; }
.btn-ic { display: inline-grid; width: 18px; height: 18px; }
.btn-ic svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not([disabled]) { background: #7cf5cf; }
  .btn-gold:hover:not([disabled]) { background: #ffd966; }
  .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
  .btn-dark:hover { background: var(--ink-2); }
}
.icon-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 44px; height: 44px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(23, 28, 41, 0.78); color: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 22px; height: 22px; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: rgba(46, 55, 77, 0.9); } }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; border-radius: 4px; }
@media (hover: hover) and (pointer: fine) { .linkish:hover { color: var(--paper); } }

/* ---------- Écrans ---------- */
.screen { position: fixed; inset: 0; z-index: 10; }

/* Titre : le texte en bas à gauche, Aspi en gros plan à droite (au-dessus sur téléphone) */
.screen-title {
  display: grid;
  align-content: end;
  padding: clamp(20px, 5vw, 64px);
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 90% at 0% 100%, rgba(21, 25, 36, 0.94) 0%, rgba(21, 25, 36, 0.7) 38%, rgba(21, 25, 36, 0) 70%),
    linear-gradient(180deg, rgba(21, 25, 36, 0.35) 0%, rgba(21, 25, 36, 0) 22%);
  cursor: pointer;
}
.title-block { max-width: 660px; }
.title-name {
  margin: 0;
  font-size: clamp(3.2rem, 9.5vw, 6rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-shadow: 0 6px 0 rgba(8, 10, 18, 0.35), 0 18px 40px rgba(8, 10, 18, 0.45);
}
.title-name .a { color: var(--led); }
.title-br { display: none; }
.tw { display: inline-block; white-space: nowrap; }
.tl { display: inline-block; }
.screen-title.intro .tl { animation: letter 620ms var(--ease-back) both; animation-delay: calc(var(--i) * 42ms + 80ms); }
.screen-title.intro .a .tl { animation-delay: calc(var(--i) * 42ms + 380ms); }
@keyframes letter { from { opacity: 0; transform: translateY(0.45em) scale(0.6) rotate(-6deg); filter: blur(4px); } }
.title-tag { margin: 18px 0 28px; font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: #cfd5e2; max-width: 34ch; }
.screen-title.intro .title-tag, .screen-title.intro .title-cta, .screen-title.intro .title-foot { animation: fadeup 520ms var(--ease-out) both; }
.screen-title.intro .title-tag { animation-delay: 620ms; }
.screen-title.intro .title-cta { animation-delay: 740ms; }
.screen-title.intro .title-foot { animation-delay: 860ms; }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } }
.title-cta { display: inline-flex; align-items: center; gap: 14px; }
.title-cta .btn { animation: breathe 2.4s ease-in-out 1.4s infinite; }
.title-hint { color: var(--faint); font-size: 0.92rem; }
.title-foot { margin-top: 34px; display: flex; gap: 18px; flex-wrap: wrap; color: var(--faint); font-size: 0.85rem; align-items: baseline; }
@keyframes breathe { 0%, 100% { box-shadow: 0 8px 22px -8px rgba(94, 240, 192, 0.55); } 50% { box-shadow: 0 10px 38px -4px rgba(94, 240, 192, 0.85); } }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); }
.hud-pill {
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(23, 28, 41, 0.8);
  box-shadow: inset 0 0 0 1px var(--line), 0 6px 16px -8px rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  padding: 8px 14px 8px 10px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}
.hud-tl { position: absolute; left: 16px; top: max(14px, env(safe-area-inset-top)); display: grid; gap: 8px; justify-items: start; }
.hud-tr { position: absolute; right: 16px; top: max(14px, env(safe-area-inset-top)); display: grid; gap: 8px; justify-items: end; }
.hud-bl { position: absolute; left: 16px; bottom: max(14px, env(safe-area-inset-bottom)); }
.hud-br { position: absolute; right: 16px; bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: auto; display: flex; gap: 8px; }
/* Au doigt : joystick sous le pouce, bouton du geste au-dessus du son et de la pause (zone du pouce droit). */
.joy {
  position: fixed; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 999px;
  background: rgba(23, 28, 41, 0.32);
  box-shadow: inset 0 0 0 2px rgba(251, 245, 234, 0.2), 0 10px 28px -14px rgba(8, 10, 18, 0.7);
  pointer-events: none; opacity: 0; transition: opacity 120ms ease;
}
.joy.on { opacity: 1; }
.joy-knob {
  position: absolute; left: 34px; top: 34px; width: 52px; height: 52px; border-radius: 999px;
  background: rgba(251, 245, 234, 0.92);
  box-shadow: inset 0 -3px 0 rgba(23, 28, 41, 0.14), 0 6px 14px -6px rgba(8, 10, 18, 0.65);
}
.act-btn {
  position: absolute; right: 16px; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 58px);
  width: 80px; height: 80px; padding: 5px; border: 0; border-radius: 999px;
  pointer-events: auto; touch-action: none; cursor: pointer;
  background: conic-gradient(var(--led) calc(var(--p, 1) * 1turn), rgba(251, 245, 234, 0.14) 0);
  box-shadow: 0 10px 24px -10px rgba(8, 10, 18, 0.7);
  transition: transform 140ms var(--ease-out);
}
.act-face {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 999px;
  background: var(--ink); color: var(--led); font-weight: 700; font-size: 0.92rem; letter-spacing: 0.01em;
  transition: background-color 120ms ease, color 120ms ease;
}
.act-btn.down { transform: scale(0.93); }
.act-btn.down .act-face { background: var(--led); color: var(--led-ink); }
.act-btn.off .act-face { color: var(--faint); }
body:not(.touch) .act-btn, body:not(.touch) .only-touch, body.touch .only-mouse { display: none; }
.hud-tc { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; }

.battery { display: inline-flex; align-items: center; gap: 2px; }
.battery-body { position: relative; width: 74px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 2px #cfd6e4; padding: 3px; }
.battery-fill { height: 100%; border-radius: 3px; background: var(--led); transform-origin: left center; transition: background-color 200ms ease; }
.battery-cap { width: 4px; height: 10px; border-radius: 0 2px 2px 0; background: #cfd6e4; }
.battery-s { min-width: 3ch; text-align: right; }
.hud.low .battery-fill { background: var(--warn); }
.hud.low .battery-pill { animation: lowpulse 0.8s ease-in-out infinite; }
@keyframes lowpulse { 50% { box-shadow: inset 0 0 0 2px var(--warn), 0 0 22px rgba(255, 122, 92, 0.6); } }
.hud-size { font-weight: 500; color: var(--muted); font-size: 0.95rem; padding: 5px 12px; }
.hud-size b { color: var(--paper); font-weight: 600; }

.mote { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f3eee6, #b9b1a6 60%, #8d867c); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08); flex: none; }
.star { width: 18px; height: 18px; flex: none; transition: opacity 200ms ease, filter 200ms ease; }
.star.off { opacity: 0.28; filter: grayscale(1); }
.star.pop { animation: starpop 520ms var(--ease-back); }
@keyframes starpop { 0% { transform: scale(0.4) rotate(-40deg); } 60% { transform: scale(1.6) rotate(8deg); } }
.hud-gain { font-size: 1.15rem; }
.hud-gain .plus { color: var(--muted); font-weight: 500; }

/* Combo : le chiffre prend la couleur du palier, la jauge se vide entre deux bouchées */
.combo { display: grid; justify-items: center; gap: 5px; opacity: 0; transform: translateY(-4px) scale(0.92); transition: opacity 160ms ease, transform 220ms var(--ease-out); --k: 0; }
.combo.on { opacity: 1; transform: none; }
.combo-x {
  font-size: calc(2rem + var(--k) * 0.9rem); font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  text-shadow: 0 3px 0 rgba(10, 12, 20, 0.55), 0 0 calc(var(--k) * 26px) currentColor;
}
.combo-bar { width: calc(76px + var(--k) * 40px); height: 6px; border-radius: 3px; background: rgba(23, 28, 41, 0.78); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.combo-bar i { display: block; height: 100%; background: currentColor; transform-origin: left center; }
.combo.max .combo-x { animation: wobble 0.5s ease-in-out infinite; }
@keyframes wobble { 50% { transform: scale(1.08) rotate(-3deg); } }
/* cassure : le chiffre tombe, grise et s'efface */
.combo.broken { opacity: 1; animation: comboFall 620ms var(--ease-in-out) forwards; }
@keyframes comboFall { 0% { transform: none; } 20% { transform: translateY(-3px) rotate(-4deg); color: var(--warn); } 100% { opacity: 0; transform: translateY(22px) rotate(10deg) scale(0.9); color: #6e7486; } }
.combo-lost { font-size: 0.95rem; font-weight: 600; color: var(--warn); opacity: 0; text-shadow: 0 2px 0 rgba(10, 12, 20, 0.6); white-space: nowrap; }
.combo-lost.show { animation: lost 1s var(--ease-out); }
@keyframes lost { 0% { opacity: 0; transform: translateY(-4px) scale(1.15); } 12% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(6px); } }
.frenzy-tag { display: grid; justify-items: center; gap: 4px; font-size: 1rem; font-weight: 700; letter-spacing: 0.02em; color: var(--led-ink); background: var(--led); border-radius: 999px; padding: 4px 16px 6px; box-shadow: 0 0 0 4px rgba(94, 240, 192, 0.25), 0 10px 30px -6px rgba(94, 240, 192, 0.8); animation: slam 420ms var(--ease-back); }
@keyframes slam { from { transform: scale(1.9); opacity: 0; } }
.frenzy-bar { width: 96px; height: 4px; border-radius: 2px; background: rgba(11, 42, 34, 0.25); overflow: hidden; }
.frenzy-bar i { display: block; height: 100%; background: var(--led-ink); transform-origin: left center; }
.hud.frenzy .hud-gain { box-shadow: inset 0 0 0 2px var(--led), 0 0 24px rgba(94, 240, 192, 0.5); }

.clean { display: grid; gap: 6px; min-width: 220px; padding: 10px 14px; border-radius: var(--r-panel); background: rgba(23, 28, 41, 0.8); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(6px); }
.clean-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.clean-stars { display: inline-flex; gap: 2px; }
.meter { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--led); transition: width 300ms var(--ease-out); }
.meter > i.gain { background: #b6ffe6; }
.meter .tick { position: absolute; top: -3px; width: 2px; height: 14px; border-radius: 1px; background: rgba(255, 255, 255, 0.35); }

/* ---------- Panneau générique ---------- */
.panel { background: var(--ink); border-radius: var(--r-panel); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }

/* ---------- Bilan ---------- */
.screen-bilan { display: grid; place-items: start center; padding: 16px; background: rgba(12, 14, 22, 0.5); backdrop-filter: blur(3px); overflow-y: auto; }
/* margin auto : centrée quand elle tient, calée en haut et défilable quand elle dépasse (place-items: center coupait le titre) */
.bilan { width: min(540px, 100%); margin: auto 0; padding: 28px; display: grid; gap: 20px; animation: rise 340ms var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.bilan h2 { margin: 0; font-size: 1.9rem; line-height: 1.05; letter-spacing: -0.02em; }
.bilan .sub { margin: 6px 0 0; color: var(--muted); }
.bilan.final { box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 207, 77, 0.35), 0 0 60px -20px rgba(255, 207, 77, 0.5); }
.bilan.final h2 { color: var(--gold); }
.bilan-gain { display: flex; align-items: center; gap: 12px; font-size: 2.8rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.bilan-gain .mote { width: 32px; height: 32px; }
.bilan-gain small { font-size: 1rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.bilan-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--ink-2); border-radius: var(--r-chip); padding: 10px 12px; opacity: 0; transform: translateY(8px); }
.bilan.stats-in .stat { opacity: 1; transform: none; transition: opacity 260ms ease, transform 360ms var(--ease-out); transition-delay: calc(var(--i) * 70ms); }
.stat span { display: block; font-size: 0.8rem; color: var(--muted); }
.stat b { font-size: 1.3rem; }
.stat-v { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.record { font-style: normal; font-size: 0.72rem; font-weight: 700; color: var(--gold-ink); background: var(--gold); border-radius: 999px; padding: 1px 7px; transform: scale(0); }
.bilan.stats-in .record { animation: badge 460ms var(--ease-back) 520ms forwards; }
@keyframes badge { to { transform: scale(1); } }
.kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.kind { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px; background: var(--ink-2); font-weight: 600; font-size: 0.92rem; animation: fadeup 300ms var(--ease-out) both; animation-delay: calc(400ms + var(--i) * 45ms); }
.kind img, .kind .mote { width: 22px; height: 22px; }
.bilan-clean { display: grid; gap: 8px; }
.bilan-clean .row { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.clean-v { display: inline-flex; gap: 8px; align-items: baseline; white-space: nowrap; }
.bilan-clean .delta { color: var(--led); opacity: 0; }
.bilan.clean-in .delta { animation: fadeup 320ms var(--ease-out) forwards; }
.clean-line { display: flex; align-items: center; gap: 14px; }
.clean-line .meter { flex: 1; }
.bilan .meter > i.gain { transition: width 800ms var(--ease-out); }
.slots { display: flex; gap: 4px; }
.slot { position: relative; width: 26px; height: 26px; display: grid; place-items: center; }
.slot .star { width: 24px; height: 24px; }
.slot .star.drop { position: absolute; inset: 1px; opacity: 0; transform: translateY(-70px) scale(1.6) rotate(-30deg); }
.bilan.stars-in .slot .star.drop { animation: drop 560ms var(--ease-back) forwards; animation-delay: calc(var(--i) * 180ms); }
@keyframes drop { 0% { opacity: 0; transform: translateY(-70px) scale(1.6) rotate(-30deg); } 30% { opacity: 1; } 100% { opacity: 1; transform: none; } }
.bilan.stars-in .slot.won::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold); opacity: 0; animation: ping 600ms var(--ease-out) forwards; animation-delay: calc(var(--i) * 180ms + 420ms); }
@keyframes ping { 0% { opacity: 1; transform: scale(0.5); } 100% { opacity: 0; transform: scale(1.5); } }
.newstar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-chip); background: rgba(255, 207, 77, 0.12); color: var(--gold); font-weight: 600; animation: fadeup 360ms var(--ease-out) 1.5s both; }
.bilan-actions { display: flex; gap: 10px; }
.bilan-actions .btn { flex: 1; }
.bilan-actions .btn-primary { flex: 1.6; }

/* ---------- Atelier ---------- */
.screen-atelier {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  background: rgba(14, 17, 26, 0.88);
  backdrop-filter: blur(4px);
  animation: fade 220ms ease-out;
}
@keyframes fade { from { opacity: 0; } }
.at-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.at-head h2 { margin: 0; font-size: 1.7rem; letter-spacing: -0.02em; line-height: 1; }
.at-head .world { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.wallet { display: flex; gap: 10px; align-items: center; }
.wallet .hud-pill { font-size: 1.15rem; transition: color 200ms ease, box-shadow 200ms ease; }
.wallet .hud-pill.spent { color: var(--gold); box-shadow: inset 0 0 0 1px rgba(255, 207, 77, 0.5); }
.at-tools { display: flex; gap: 8px; }
.at-main { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; min-height: 0; min-width: 0; }

.at-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; scroll-behavior: smooth; }
.at-tabs::-webkit-scrollbar { display: none; }
/* onglets qui débordent : le bord coupé s'estompe et une flèche montre qu'il y a la suite */
.at-tabs-wrap { position: relative; min-width: 0; }
.at-tabs-wrap.more-l .at-tabs { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 56px); mask-image: linear-gradient(90deg, transparent 0, #000 56px); }
.at-tabs-wrap.more-r .at-tabs { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent 100%); mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent 100%); }
.at-tabs-wrap.more-l.more-r .at-tabs { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 56px, #000 calc(100% - 56px), transparent 100%); }
.tabs-more {
  position: absolute; top: 50%; width: 32px; height: 32px; margin-top: -16px; border: 0; border-radius: 50%; display: none; place-items: center;
  background: var(--ink-3); color: var(--paper); box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.14); cursor: pointer;
  transition: transform 140ms var(--ease-out);
}
.tabs-more svg { width: 16px; height: 16px; }
.tabs-more:active { transform: scale(0.94); }
.tabs-more.l { left: 0; }
.tabs-more.r { right: 0; }
.at-tabs-wrap.more-l .tabs-more.l, .at-tabs-wrap.more-r .tabs-more.r { display: grid; }
.notice { flex-basis: 100%; margin: 0; padding: 10px 14px; border-radius: var(--r-chip); background: rgba(255, 122, 92, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 122, 92, 0.4); color: #ffd9cf; font-size: 0.92rem; line-height: 1.35; max-width: 72ch; }
.notice[hidden] { display: none; }
.at-tab {
  appearance: none; border: 0; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.05); color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 600; font-size: 0.9rem; position: relative;
  transition: background-color 160ms ease, color 160ms ease;
}
.at-tab[aria-selected='true'] { background: var(--ink-3); color: var(--paper); box-shadow: inset 0 0 0 1.5px rgba(251, 245, 234, 0.5); }
.at-tab-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); font-size: 0.82rem; }
.at-tab[aria-selected='true'] .at-tab-n { background: var(--led); color: var(--led-ink); }
.at-tab-stars { display: inline-flex; gap: 1px; }
.at-tab-stars .star { width: 13px; height: 13px; }
.at-tab.has-afford::after { content: ''; position: absolute; top: 4px; left: 25px; width: 8px; height: 8px; border-radius: 50%; background: var(--led); box-shadow: 0 0 0 2px var(--ink); }
.at-tab-next { cursor: default; color: var(--faint); background: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07); box-shadow: none; border: 1.5px dashed rgba(255, 255, 255, 0.14); }
.at-tab-next .at-tab-name { font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .at-tab:not(.at-tab-next):not([aria-selected='true']):hover { background: rgba(255, 255, 255, 0.09); color: var(--paper); } }

.board-wrap { position: relative; overflow: auto; padding: 8px; min-height: 0; }
.board { position: relative; margin: 0 auto; }
.board-empty { color: var(--muted); text-align: center; padding: 40px 0; margin: 0; }
.board svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.board .edge { stroke: rgba(255, 255, 255, 0.14); stroke-width: 3; fill: none; stroke-linecap: round; }
.board .edge.lit { stroke: rgba(94, 240, 192, 0.55); }
.board .pair-frame { fill: rgba(255, 207, 77, 0.045); stroke: rgba(255, 207, 77, 0.55); stroke-width: 1.5; stroke-dasharray: 6 6; }
.board .pair-frame.chosen { fill: none; stroke: rgba(255, 207, 77, 0.28); }
.pair-or { position: absolute; transform: translate(-50%, -50%); font-weight: 700; font-size: 0.85rem; color: var(--gold-ink); background: var(--gold); border-radius: 999px; padding: 2px 10px 3px; box-shadow: 0 0 0 4px rgba(14, 17, 26, 0.9); pointer-events: none; }
.pair-or.chosen { background: #6f6440; color: #1b1606; }
.pair-label { position: absolute; transform: translate(-50%, -50%); font-size: 0.78rem; font-weight: 600; color: var(--gold); background: #141823; padding: 0 8px; white-space: nowrap; pointer-events: none; }
.node {
  /* left/top = centre de l'anneau (js/ui/atelier.js pose --ring-r) ; le nom et la jauge pendent dessous */
  position: absolute; transform: translate(-50%, calc(-1 * var(--ring-r, 34px)));
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 6px; width: 112px;
}
.node-ring {
  position: relative;
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink-2);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}
.node-ring img { width: 38px; height: 38px; }
/* un mot plus large que la colonne (« Amortisseurs », « Débordement ») se coupe au lieu de pousser l'anneau */
.node-name { font-size: 0.86rem; font-weight: 600; line-height: 1.15; text-align: center; text-wrap: balance; overflow-wrap: anywhere; }
.node-pips { display: flex; gap: 3px; height: 6px; }
.node-pips i { width: 10px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); transition: background-color 200ms ease; }
.node-pips i.on { background: var(--led); }
.node:active .node-ring { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) { .node:hover .node-ring { transform: scale(1.06); } }
.node[data-state='afford'] .node-ring { box-shadow: inset 0 0 0 3px var(--led), 0 0 0 6px var(--led-soft); }
.node[data-state='afford'][data-pair] .node-ring { box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 6px rgba(255, 207, 77, 0.16); }
.node[data-state='max'] .node-ring { box-shadow: inset 0 0 0 3px var(--gold); background: #2a2a24; }
.node[data-state='max'] .node-pips i.on { background: var(--gold); }
.node[data-state='locked'] .node-ring { background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1); }
/* verrouillé : l'image reste reconnaissable (formes et détails), éteinte en gris ; jamais sa description */
.node[data-state='locked'] .node-ring img { filter: grayscale(1) brightness(0.7) contrast(1.1); opacity: 0.5; }
.node[data-state='locked'] .node-name { color: var(--faint); }
.node[data-state='excluded'] { opacity: 0.4; }
.node[data-state='excluded'] .node-ring img { filter: grayscale(1); }
.node[data-state='excluded'] .node-ring::after { content: ''; position: absolute; left: 14%; right: 14%; top: 50%; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.5); transform: rotate(-40deg); }
.node[aria-pressed='true'] .node-ring { transform: scale(1.08); box-shadow: inset 0 0 0 3px var(--paper), 0 0 0 7px rgba(251, 245, 234, 0.12); }
.node.bought .node-ring { animation: bought 560ms var(--ease-out); }
@keyframes bought { 0% { transform: scale(0.9); } 30% { transform: scale(1.24); box-shadow: inset 0 0 0 3px var(--led), 0 0 0 18px rgba(94, 240, 192, 0.28); } }
.node.fresh .node-ring { animation: freshRing 1.2s var(--ease-out) 2; }
@keyframes freshRing { 0% { box-shadow: inset 0 0 0 3px var(--led), 0 0 0 0 rgba(94, 240, 192, 0.6); } 100% { box-shadow: inset 0 0 0 3px var(--led), 0 0 0 16px rgba(94, 240, 192, 0); } }
.node .stars-cost { position: absolute; top: -4px; right: 18px; display: flex; align-items: center; gap: 2px; background: var(--ink); border-radius: 999px; padding: 2px 6px 2px 3px; font-size: 0.75rem; font-weight: 700; color: var(--gold); box-shadow: inset 0 0 0 1px var(--line); }
.node .stars-cost .star { width: 14px; height: 14px; }
.spark { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 50%; background: var(--led); pointer-events: none; animation: spark 620ms var(--ease-out) var(--d) both; }
.spark:nth-child(3n) { background: var(--gold); width: 5px; height: 5px; }
@keyframes spark { 0% { transform: translate(0, 0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }

.at-side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.dock { display: contents; }
.dock .detail { order: 1; }
.at-side .postit { order: 2; }
.dock .launch { order: 3; margin-top: auto; }
.detail { padding: 20px; display: grid; gap: 12px; transition: box-shadow 200ms ease; }
.detail.pair { box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 207, 77, 0.35); }
.detail-top { display: flex; gap: 14px; align-items: center; }
.detail-top img { width: 48px; height: 48px; }
.detail.locked .detail-top img { filter: grayscale(1) brightness(0.7) contrast(1.1); opacity: 0.5; }
.detail h3 { margin: 0; font-size: 1.3rem; line-height: 1.1; }
.detail .fam { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.detail.pair .fam { color: var(--gold); }
.detail p { margin: 0; color: #dfe4ee; max-width: 42ch; }
.detail .req { color: var(--muted); }
.detail .lvl { font-size: 0.9rem; color: var(--muted); }
.detail .lvl.done { color: var(--gold); }
.choice { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--r-chip); background: rgba(255, 207, 77, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 207, 77, 0.3); }
.choice b { color: var(--gold); font-size: 0.9rem; }
.choice span { color: #efe3c0; font-size: 0.9rem; }
.detail .buy-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.detail .cancel { justify-self: end; font-size: 0.88rem; }
.price { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; }
.price.short { color: var(--warn); }

.postit {
  justify-self: center;
  width: min(300px, 100%);
  padding: 22px 22px 18px;
  background: linear-gradient(180deg, #fff0a0 0%, var(--postit) 30%, #f9d96a 100%);
  color: var(--postit-ink);
  font-family: 'Caveat', 'Segoe Print', cursive;
  font-size: 1.55rem;
  line-height: 1.12;
  border-radius: 3px 3px 22px 3px;
  box-shadow: 0 14px 22px -10px rgba(0, 0, 0, 0.55);
  transform: rotate(-2.2deg);
  position: relative;
}
.postit::before { content: ''; position: absolute; top: -10px; left: 50%; width: 84px; height: 22px; transform: translateX(-50%) rotate(2deg); background: rgba(255, 255, 255, 0.42); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.postit p { margin: 0; }
.postit .sign { margin-top: 10px; text-align: right; font-size: 1.25rem; opacity: 0.8; }
.postit.new { animation: stick 520ms var(--ease-out); }
@keyframes stick { from { opacity: 0; transform: rotate(-9deg) translateY(-18px) scale(1.06); } }
.launch { display: grid; gap: 6px; }
.launch .btn { width: 100%; font-size: 1.2rem; padding: 18px 26px; }
.launch .btn-replay { font-size: 1rem; padding: 12px 22px; }
.launch small { text-align: center; color: var(--faint); }

/* ---------- Boîtes de dialogue (pause, réglages, sauvegarde, crédits) ---------- */
dialog.sheet { border: 0; padding: 0; color: var(--paper); background: var(--ink); border-radius: var(--r-panel); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog.sheet[open] { animation: rise 240ms var(--ease-out); }
dialog.sheet::backdrop { background: rgba(8, 10, 16, 0.62); backdrop-filter: blur(3px); }
.sheet-in { padding: 24px; display: grid; gap: 14px; }
.sheet h3 { margin: 0; font-size: 1.35rem; }
.sheet .pause-h { font-size: 2rem; letter-spacing: -0.02em; }
.sheet p { margin: 0; color: var(--muted); }
.sheet .hint { font-size: 0.88rem; color: var(--faint); }
.pause-actions { display: grid; gap: 10px; }
.pause-actions .btn { width: 100%; }
.sheet textarea { width: 100%; min-height: 110px; resize: vertical; border-radius: var(--r-chip); border: 0; padding: 12px; background: var(--ink-2); color: var(--paper); font: 0.85rem/1.4 ui-monospace, Consolas, monospace; box-shadow: inset 0 0 0 1px var(--line); user-select: text; }
.sheet textarea::placeholder { color: var(--faint); }
.sheet textarea:focus { outline: 2px solid var(--led); }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.sheet .row-start { justify-content: flex-start; }
.sheet .msg { min-height: 1.2em; font-size: 0.92rem; color: var(--led); }
.sheet .msg.err { color: var(--warn); }
.sheet a { color: var(--led); }
.switches { display: grid; gap: 8px; }
.switch { appearance: none; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; border-radius: var(--r-chip); background: var(--ink-2); font-weight: 600; text-align: left; }
.switch-track { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); transition: background-color 180ms ease; flex: none; }
.switch-track i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 200ms var(--ease-out), background-color 180ms ease; }
.switch[aria-checked='true'] .switch-track { background: var(--led); }
.switch[aria-checked='true'] .switch-track i { transform: translateX(18px); background: var(--led-ink); }
.credits-list { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.credits-list dt { color: var(--faint); font-size: 0.88rem; }
.credits-list dd { margin: 0; color: var(--paper); }

/* ---------- Cinéma : carte de titre, fin, statistiques, crédits ---------- */
.screen-cinema { z-index: 12; display: grid; place-items: center; padding: 24px 16px; pointer-events: auto; }
.screen-cinema.is-card { place-items: start center; padding-top: clamp(40px, 13vh, 130px); background: radial-gradient(70% 45% at 50% 22%, rgba(12, 14, 22, 0.6) 0%, rgba(12, 14, 22, 0) 70%); cursor: pointer; }
/* la carte porte sa propre plaque d'encre : lisible sur le carrelage crème et les pavés comme sur l'espace */
.wcard {
  text-align: center; display: grid; justify-items: center; gap: 10px;
  max-width: min(640px, calc(100vw - 32px)); padding: 22px clamp(20px, 4vw, 40px) 24px; border-radius: 28px;
  background: rgba(16, 19, 29, 0.74); box-shadow: 0 24px 60px -24px rgba(8, 10, 18, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade 260ms var(--ease-out) both;
}
.wcard-n { margin: 0; font-size: 1rem; font-weight: 600; color: var(--led); letter-spacing: 0.04em; animation: fadeup 420ms var(--ease-out) both; }
.wcard-name { margin: 0; font-size: clamp(2.6rem, 9vw, 5.2rem); font-weight: 700; line-height: 0.95; letter-spacing: -0.02em; text-wrap: balance; text-shadow: 0 6px 0 rgba(8, 10, 18, 0.35), 0 20px 50px rgba(8, 10, 18, 0.55); animation: cardName 700ms var(--ease-out) 120ms both; }
@keyframes cardName { from { opacity: 0; transform: scale(1.12); filter: blur(10px); letter-spacing: 0.06em; } }
.wcard-rule { width: 64px; height: 4px; border-radius: 2px; background: var(--led); animation: rule 500ms var(--ease-out) 420ms both; }
@keyframes rule { from { transform: scaleX(0); } }
.wcard-line { margin: 4px 0 0; font-size: 1.1rem; font-weight: 500; color: var(--paper); max-width: 36ch; text-wrap: balance; animation: fadeup 420ms var(--ease-out) 560ms both; }
.screen-cinema.out { animation: fadeout 260ms ease-out forwards; }
@keyframes fadeout { to { opacity: 0; } }

.screen-cinema.is-note { place-items: center end; padding-right: clamp(24px, 12vw, 180px); }
.finale { display: grid; justify-items: center; gap: 28px; }
@media (max-aspect-ratio: 9/10) {
  .screen-cinema.is-note { place-items: end center; padding: 0 16px max(48px, 10vh); }
}
.postit-final { width: min(340px, 86vw); font-size: 2rem; padding: 30px 28px 22px; transform: rotate(-3deg); box-shadow: 0 24px 40px -18px rgba(40, 32, 8, 0.45); }
.postit-final.new { animation: stickBig 760ms var(--ease-out) both; }
@keyframes stickBig { from { opacity: 0; transform: rotate(-14deg) translateY(-60px) scale(1.15); } }
.finale .btn { opacity: 0; transform: translateY(8px); transition: opacity 320ms ease, transform 420ms var(--ease-out); }
.finale .btn.in { opacity: 1; transform: none; }

.screen-cinema.is-stats, .screen-cinema.is-credits { background: rgba(250, 248, 244, 0.8); backdrop-filter: blur(6px); animation: fade 400ms ease-out; }
.endstats { width: min(560px, 100%); padding: 30px; display: grid; gap: 18px; animation: rise 380ms var(--ease-out); }
.endstats h2 { margin: 0; font-size: 2rem; letter-spacing: -0.02em; line-height: 1.05; }
.endstats .sub { margin: -8px 0 0; color: var(--muted); }
.endstats-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.es { background: var(--ink-2); border-radius: var(--r-chip); padding: 12px 14px; animation: fadeup 380ms var(--ease-out) both; animation-delay: calc(200ms + var(--i) * 80ms); }
.es dt { font-size: 0.85rem; color: var(--muted); }
.es dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; }
.endstats .btn { justify-self: stretch; }

.credits { display: grid; gap: 24px; justify-items: center; width: min(560px, 100%); }
.roll-mask { height: min(56dvh, 440px); width: 100%; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 86%, transparent 100%); mask-image: linear-gradient(180deg, transparent 0%, #000 14%, #000 86%, transparent 100%); }
.roll { display: grid; gap: 22px; justify-items: center; text-align: center; color: var(--ink); padding: 40% 0; animation: roll 22s linear forwards; }
@keyframes roll { from { transform: translateY(20%); } to { transform: translateY(-62%); } }
.roll-title { margin: 0; font-size: 2.6rem; font-weight: 700; letter-spacing: -0.01em; }
.roll-line { margin: 0; color: #4a5164; font-size: 1.1rem; }
.roll-item { display: grid; gap: 2px; }
.roll-item span { color: #5c6478; font-size: 0.9rem; }
.roll-item b { font-size: 1.1rem; font-weight: 600; }
.roll-end { margin: 0; font-size: 1.4rem; font-weight: 600; color: #1e8e6a; }
.credits-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.is-credits .btn-ghost { background: rgba(23, 28, 41, 0.08); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(23, 28, 41, 0.18); }

/* ---------- Téléphone ---------- */
/* debout (étroit) ou couché (bas) : la même requête est lue par js/ui/atelier.js pour la largeur de l'arbre */
@media (max-width: 860px), (max-height: 520px) and (orientation: landscape) {
  /* pas de padding en bas : le dock collant s'arrêterait 16 px au-dessus du bord et l'arbre passerait dessous */
  .screen-atelier { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; overflow-y: auto; gap: 12px; padding: 12px 16px 0; }
  .at-side { display: contents; }
  /* le post-it passe sous l'en-tête : en bas du flux, il glissait sous le dock collant et ne se lisait
     qu'à moitié entre le détail et « Relancer Aspi » */
  .at-side .postit { order: 2; margin: 6px auto 4px; }
  .screen-atelier { align-content: start; }
  .at-main { order: 3; grid-template-rows: auto auto; min-height: auto; }
  .at-main .board-wrap { min-height: auto; }
  .at-tab-next .at-tab-name { display: none; }
  .at-tab-next { padding-right: 7px; }
  .at-head { order: 1; }
  .dock { order: 4; display: grid; gap: 10px; position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); background: rgb(14, 17, 26); box-shadow: 0 -12px 24px -10px rgba(0, 0, 0, 0.6); }
  .dock .detail { padding: 14px 16px; gap: 8px; box-shadow: inset 0 0 0 1px var(--line); }
  .dock .detail.pair { box-shadow: inset 0 0 0 1px rgba(255, 207, 77, 0.4); }
  .dock .detail-top img { width: 36px; height: 36px; }
  .dock .detail h3 { font-size: 1.12rem; }
  .dock .detail p { font-size: 0.95rem; }
  .dock .launch .btn { padding: 14px 22px; font-size: 1.1rem; }
  .dock .launch .btn-replay { padding: 10px 20px; font-size: 0.98rem; }
  .dock .launch small { display: none; }
  .board-wrap { padding: 0; overflow: visible; }
  .node { width: var(--node-w, 76px); }
  .node-ring { width: 54px; height: 54px; }
  .node-ring img { width: 30px; height: 30px; }
  /* colonnes de 60 à 70 px : césure, mais seulement des mots de 10 lettres et plus (5 avant, 4 après) */
  .node-name { font-size: 0.74rem; -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 10 5 4; }
  .node .stars-cost { right: 4px; }
  .pair-label { font-size: 0.7rem; }
  .postit { font-size: 1.3rem; padding: 18px 20px 14px; transform: rotate(-1.4deg); }
  .postit .sign { margin-top: 6px; font-size: 1.1rem; }
  .at-tab-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 560px) {
  .screen-title { padding-bottom: max(24px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(21, 25, 36, 0) 40%, rgba(21, 25, 36, 0.82) 62%, rgba(21, 25, 36, 0.96) 100%); }
  .title-br { display: inline; }
  .title-name { font-size: clamp(3.4rem, 17vw, 4.6rem); }
  .title-tag { margin: 14px 0 22px; }
  .title-cta { display: flex; }
  .title-cta .btn { flex: 1; }
  .title-hint { display: none; }
  .title-foot { margin-top: 22px; font-size: 0.8rem; gap: 10px 16px; }
}
@media (max-width: 560px), (max-height: 520px) and (orientation: landscape) {
  .hud-pill { padding: 6px 11px 6px 8px; font-size: 0.92rem; }
  .battery-body { width: 56px; height: 18px; }
  .combo-x { font-size: calc(1.6rem + var(--k) * 0.6rem); }
  .frenzy-tag { font-size: 0.88rem; padding: 3px 12px 5px; }
  .clean { min-width: 0; width: auto; padding: 8px 11px; }
  .clean .star { width: 15px; height: 15px; }
  .clean-top { font-size: 0.82rem; }
  .bilan { padding: 22px 18px; gap: 16px; }
  .bilan h2 { font-size: 1.55rem; }
  .bilan-gain { font-size: 2.2rem; }
  .bilan-stats { gap: 6px; }
  .stat { padding: 8px 9px; }
  .stat b { font-size: 1.05rem; }
  .at-head h2 { font-size: 1.4rem; }
  .wallet .hud-pill { font-size: 1rem; }
  .endstats { padding: 22px 18px; }
  .es dd { font-size: 1.2rem; }
  .postit-final { font-size: 1.7rem; }
  /* dock plus bas : il prenait près de la moitié de l'écran et cachait l'arbre */
  .dock { gap: 8px; padding-top: 10px; }
  .dock .detail { padding: 12px 14px; gap: 6px; }
  .dock .detail-top { gap: 10px; }
  .dock .detail-top img { width: 30px; height: 30px; }
  .dock .detail h3 { font-size: 1.02rem; }
  .dock .detail .fam { font-size: 0.76rem; margin-top: 1px; }
  .dock .detail p { font-size: 0.88rem; line-height: 1.3; }
  .dock .detail .lvl { font-size: 0.82rem; }
  .dock .detail .btn { padding: 10px 20px; font-size: 0.98rem; }
  .price { font-size: 1.05rem; }
  .launch { display: flex; gap: 8px; }
  .dock .launch .btn { flex: 1.5; width: auto; padding: 12px 16px; font-size: 1.02rem; }
  .dock .launch .btn-replay { flex: 1; padding: 8px 12px; font-size: 0.86rem; line-height: 1.15; white-space: normal; text-wrap: balance; }
  .bilan-actions .btn { padding: 12px 14px; font-size: 1rem; }
}

/* ---------- Téléphone couché ---------- */
/* À gauche l'en-tête, les onglets et l'arbre, qui défilent ; à droite, sur toute la hauteur, la fiche de
   l'amélioration et les boutons, toujours sous le pouce. Le bilan passe sur deux colonnes pour tenir sans défiler. */
@media (max-height: 520px) and (orientation: landscape) {
  .screen-atelier {
    grid-template-columns: minmax(0, 1fr) min(42%, 330px); grid-template-rows: auto auto auto;
    gap: 8px 14px; overflow-y: auto; align-content: start;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }
  .at-side { display: contents; }
  .at-head { order: 0; grid-column: 1; grid-row: 1; padding-top: 10px; gap: 8px 12px; }
  .at-head h2 { font-size: 1.25rem; }
  .at-head .world { font-size: 0.85rem; margin-top: 2px; }
  .at-side .postit { order: 0; grid-column: 1; grid-row: 2; margin: 4px auto; font-size: 1.15rem; padding: 14px 18px 10px; }
  .at-main { order: 0; grid-column: 1; grid-row: 3; padding-bottom: 10px; }
  .dock {
    order: 0; grid-column: 2; grid-row: 1 / span 3; align-self: start;
    position: sticky; top: 0; bottom: auto; height: 100dvh;
    display: flex; flex-direction: column; gap: 8px;
    margin: 0; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: none; box-shadow: none;
  }
  .dock .detail { flex: 1; min-height: 0; overflow-y: auto; align-content: start; }
  .dock .launch { margin-top: 0; }

  .bilan { width: min(780px, 100%); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: row dense; gap: 10px 22px; padding: 16px 20px; align-items: start; }
  .bilan-head, .bilan-gain, .bilan-stats { grid-column: 1; }
  .kinds, .bilan-clean, .newstar { grid-column: 2; }
  .bilan-actions { grid-column: 1 / -1; }
  .bilan h2 { font-size: 1.35rem; }
  .bilan .sub { margin-top: 2px; font-size: 0.9rem; }
  .bilan-gain { font-size: 1.9rem; }
  .bilan-gain .mote { width: 24px; height: 24px; }
  .newstar { padding: 6px 12px; font-size: 0.9rem; }
  .screen-bilan { padding: 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; animation-delay: 0ms !important; }
  .roll { transform: none; padding: 0; }
  .roll-mask { height: auto; -webkit-mask-image: none; mask-image: none; }
}
