/* Trait pour trait : un salon chaleureux, un chat qui dort, un cadre où le dessin se compose. */
:root {
  --mur: #f1dcc0;
  --mur-bas: #e6c39b;
  --bois: #9a6a43;
  --bois-fonce: #6f4529;
  --papier: #fbf5e8;
  --toile: #f5edde;
  --encre: #4a2f20;
  --doux: #7a5a44;
  --accent: #c0582f;
  --accent-texte: #fff8ee;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, var(--mur) 0%, var(--mur) 62%, var(--mur-bas) 100%);
  color: var(--encre);
  font: 17px/1.4 Georgia, 'Times New Roman', serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }

.jeu {
  height: 100vh; height: 100dvh; height: var(--h, 100dvh);
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}

/* barre du haut : discrète */
.barre { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 0; min-height: 46px; flex: none; }
.titre { margin: 0; font-size: 16px; color: var(--doux); letter-spacing: .02em; }
.outils { display: flex; gap: 4px; }
.icone {
  width: 42px; height: 42px; border: 0; border-radius: 12px; background: transparent;
  font-size: 24px; line-height: 1; color: var(--bois-fonce);
}
.icone:disabled { opacity: .3; cursor: default; }
.icone:not(:disabled):active { background: rgba(111, 69, 41, .1); }

/* la scène : le chat sur son coussin, posé sur le cadre */
.scene { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 8px; }
.chat { position: relative; z-index: 2; margin-bottom: -5px; flex: none; }
.chat canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; transform-origin: 50% 100%; animation: souffle 3.6s ease-in-out infinite; }
.chat.reveil canvas { animation: etire 2.4s ease-in-out 1; }
@keyframes souffle { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.035); } }
@keyframes etire { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02, .98); } }
.z { position: absolute; color: var(--doux); font-style: italic; opacity: 0; animation: zz 4.8s linear infinite; pointer-events: none; }
.z1 { left: -4%; top: 20%; font-size: 10px; }
.z2 { left: -10%; top: 5%; font-size: 12px; animation-delay: 1.6s; }
.z3 { left: -16%; top: -10%; font-size: 15px; animation-delay: 3.2s; }
.chat.reveil .z, .chat.eveille .z { display: none; }
.chat { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chat:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.chat.eveille canvas { animation-duration: 2.4s; }
.coeur { position: absolute; left: 22%; top: -6%; color: #ec9fb8; font: 16px/1 system-ui, sans-serif; pointer-events: none; text-shadow: 0 1px 0 rgba(255, 248, 238, .9); animation: coeur 1.6s ease-out forwards; }
@keyframes coeur { 0% { opacity: 0; transform: translate(0, 4px) scale(.6); } 20% { opacity: 1; transform: translate(-2px, -6px) scale(1.1); } 100% { opacity: 0; transform: translate(-10px, -34px) scale(1); } }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 0); } 15% { opacity: .8; } 80% { opacity: .5; } 100% { opacity: 0; transform: translate(-14px, -26px); } }

.cadre {
  position: relative; flex: none;
  padding: 6px; border-radius: 8px;
  background: linear-gradient(145deg, #b07c50, var(--bois) 45%, var(--bois-fonce));
  box-shadow: 0 10px 24px rgba(74, 47, 32, .28), inset 0 0 0 2px rgba(255, 255, 255, .12);
}
.cadre canvas { display: block; border-radius: 3px; touch-action: none; background: var(--toile); }
.bulle {
  position: absolute; z-index: 3; min-width: 34px; height: 34px; padding: 0 9px; border-radius: 17px;
  display: flex; align-items: center; justify-content: center;
  background: var(--encre); color: #fff; font: bold 18px/1 system-ui, sans-serif;
  pointer-events: none; transform: translate(-50%, -100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}
.bulle.pile { background: #3f7d4a; }
.bulle[hidden] { display: none; }

/* bas : nom du dessin et suite */
.bas { height: 142px; flex: none; }
/* nom du dessin et « Dessin suivant » toujours collés au bas de l'écran visible */
.bas-fixe {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 0 16px calc(12px + env(safe-area-inset-bottom)); pointer-events: none;
}
.bas-fixe > * { pointer-events: auto; }
.consigne {
  margin: 0; max-width: 440px; padding: 10px 14px; border-radius: 14px; text-align: center; font-size: 17px; line-height: 1.35;
  background: var(--papier); box-shadow: 0 4px 14px rgba(74, 47, 32, .18); border: 1px solid rgba(111, 69, 41, .18);
}
.consigne b { color: var(--accent); font-size: 1.1em; }
.consigne[hidden] { display: none; }
.jeu.tuto .bas { height: 226px; }
.nom-dessin { margin: 0; font-size: 19px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 0 rgba(255,248,238,.8); min-height: 1.4em; text-align: center; opacity: 0; transition: opacity .8s; }
.nom-dessin.vu { opacity: 1; }

.plein {
  border: 0; border-radius: 999px; padding: 8px 24px; background: var(--accent); color: var(--accent-texte);
  font-size: 17px; box-shadow: 0 3px 0 #8e3d1f;
}
.plein:active { transform: translateY(2px); box-shadow: 0 1px 0 #8e3d1f; }
.second {
  border: 1px solid rgba(111, 69, 41, .35); border-radius: 12px; padding: 10px 14px; background: #fffaf1;
  text-align: left; font-size: 16px;
}

/* panneaux */
.panneau {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto;
  border: 0; border-radius: 16px; padding: 20px 20px 16px; background: var(--papier); color: var(--encre);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
}
.panneau::backdrop { background: rgba(74, 47, 32, .45); }
.panneau h2 { margin: 0 0 12px; font-size: 22px; }
.panneau h3 { margin: 16px 0 8px; font-size: 16px; color: var(--doux); font-weight: normal; }
.panneau p { margin: 0 0 10px; }
.menu-liste { display: grid; gap: 8px; }
/* FR · EN : en haut à droite du menu, la langue choisie en gras */
.langue { position: absolute; top: 20px; right: 20px; margin: 0 !important; color: var(--doux); font-size: 15px; }
.langue button { border: 0; background: none; padding: 4px 6px; color: var(--doux); font-weight: normal; letter-spacing: .5px; }
.langue button[aria-pressed="true"] { color: var(--encre); font-weight: bold; text-decoration: underline; text-underline-offset: 4px; }
.boutons { text-align: center; margin: 14px 0 0 !important; }
.pyment-share { display: flex; flex-wrap: wrap; gap: 8px; }
.pyment-share button {
  border: 1px solid rgba(111, 69, 41, .35); border-radius: 12px; padding: 8px 12px; background: #fffaf1; font-size: 15px;
}

/* galerie des dessins */
.galerie { width: min(560px, calc(100vw - 24px)); }
.compte { color: var(--doux); font-size: 15px; }
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.vignette {
  position: relative; aspect-ratio: 1; border: 1px solid rgba(111, 69, 41, .25); border-radius: 10px; background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 6px;
}
.vignette canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.vignette .num { font-size: 18px; color: var(--doux); }
.vignette.ferme { opacity: .45; cursor: default; }
.vignette.courant { outline: 3px solid var(--accent); outline-offset: 1px; }

.noscript { padding: 20px; text-align: center; }
.pyment-banner { background: #fff3cd; color: #5c4400; padding: 6px 12px; font-size: 14px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .chat canvas, .z, .coeur { animation: none !important; }
  .nom-dessin { transition: none; }
}

/* Pied de page commun aux jeux Pyment (« le bouton dé ») : seules --pp-accent et la couleur changent d'un jeu à l'autre */
.pp { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; margin: 28px auto 16px; padding: 0 12px; }
.pp p { margin: 0; }
.pp a { color: inherit; text-decoration: none; }
.pp a:hover, .pp a:focus-visible { text-decoration: underline; }
.pp .pp-de { display: inline-block; padding: 6px 18px; border: 2px solid var(--pp-accent); border-radius: 999px; color: var(--pp-accent); font-weight: 600; font-size: 16px; line-height: 1.3; margin-bottom: 8px; }
.pp .pp-de:hover, .pp .pp-de:focus-visible { text-decoration: none; background: color-mix(in srgb, var(--pp-accent) 14%, transparent); }
.pp-inspi { font-size: 13px; font-style: italic; opacity: .75; max-width: 46ch; }
.pp-sig { font-size: 13px; opacity: .75; }
.pp .pp-ico { display: inline-block; padding: 0 2px; }
.pp .pp-ico:hover, .pp .pp-ico:focus-visible { text-decoration: none; }
/* pied de page commun, collé au bas de l'écran sous le nom du dessin */
.bas-fixe .pp { --pp-accent: var(--accent); color: var(--doux); margin: 4px 0 0; gap: 4px; }
.bas-fixe .pp .pp-de { padding: 2px 14px; font-size: 14px; background: var(--papier); margin-bottom: 6px; }
