/* Millésime : le grenier en pixels. */
@font-face { font-family: 'Pixelify Sans'; font-weight: 400; font-display: block; src: url('/polices/pixelify-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Pixelify Sans'; font-weight: 500; font-display: block; src: url('/polices/pixelify-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'Pixelify Sans'; font-weight: 600; font-display: block; src: url('/polices/pixelify-sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Pixelify Sans'; font-weight: 700; font-display: block; src: url('/polices/pixelify-sans-700.woff2') format('woff2'); }

:root { --encre: #2a1a10; --papier: #fbecc8; --papier-fonce: #ecd39c; --or: #f2b632; --violet: #8b5cf6; --violet-fonce: #5b32b8; --pix: 'Pixelify Sans', monospace; }
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: #2a1a10; }
body { font-family: var(--pix); color: var(--papier); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; border: 0; background: none; }
button { cursor: pointer; }
button:focus { outline: none; }
.clavier button:focus-visible { outline: 3px solid var(--or); outline-offset: 3px; }
img { image-rendering: pixelated; }
a { color: inherit; }

.jeu { position: relative; height: 100svh; max-width: 520px; margin: 0 auto; overflow: hidden; }
.grenier { position: absolute; inset: 0; background: url('images/grenier.webp') center 32% / cover no-repeat; image-rendering: pixelated; }
.voile { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,10,4,.25) 0%, rgba(20,10,4,.05) 35%, rgba(20,10,4,.55) 70%, rgba(20,10,4,.85) 100%); transition: background .5s; }
.ecran { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }

/* la barre : le Q du site, où on en est, le son */
.haut { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; }
.haut .retour { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.haut img { width: 32px; height: 32px; border-radius: 9px; image-rendering: auto; }
.haut .titre { font-weight: 700; font-size: 18px; letter-spacing: .04em; text-shadow: 0 2px 0 var(--encre); }
.haut .vide { flex: 1; }
.haut .compte { font-size: 16px; font-weight: 600; text-shadow: 0 2px 0 var(--encre); }
.haut .son { width: 36px; height: 36px; display: grid; place-items: center; font-size: 18px; text-shadow: 0 2px 0 var(--encre); opacity: .9; }
.haut .son.coupe { opacity: .45; }

/* les cadres en pixels : un contour d'encre qui suit les coins en escalier */
.cadre { filter: drop-shadow(3px 0 0 var(--encre)) drop-shadow(-3px 0 0 var(--encre)) drop-shadow(0 3px 0 var(--encre)) drop-shadow(0 -3px 0 var(--encre)) drop-shadow(0 5px 0 rgba(20,10,4,.6)); }
.cadre > * { clip-path: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px)); }

/* l'étiquette du millésime : l'image, et l'année posée par le code */
.etiquette { position: relative; aspect-ratio: 960 / 597; background: url('images/etiquette.png') center / contain no-repeat; image-rendering: pixelated; display: grid; place-items: center; }
.etiquette .mot { position: absolute; top: 22%; width: 100%; text-align: center; color: var(--violet-fonce); font-weight: 700; letter-spacing: .18em; }
.annee { display: flex; gap: .04em; color: var(--encre); font-weight: 700; line-height: 1; margin-top: 6%; }
.chiffre { display: inline-block; width: .62em; text-align: center; }
.chiffre.flou { color: rgba(42,26,16,.35); }
.chiffre.fixe { animation: fixe .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes fixe { 0% { transform: scale(1.6); color: var(--violet); } 100% { transform: none; } }

/* les boutons */
.gros > button { width: 100%; min-height: 58px; background: var(--violet); color: #fff; font-size: 24px; font-weight: 700; letter-spacing: .03em; box-shadow: inset 0 -6px 0 var(--violet-fonce); }
.clair > button { background: var(--papier); color: var(--encre); font-weight: 700; box-shadow: inset 0 -5px 0 var(--papier-fonce); }
.cadre > button:active { transform: translateY(3px); }
@media (hover: hover) {
  .gros > button:hover { background: #7c4ef0; }
  .clair > button:hover, .reponses .cadre > button:hover { background: #f3dfb1; }
}

/* l'accueil du jeu */
.accueil .etiquette { width: min(86%, 380px); margin-top: 6svh; }
.accueil .etiquette .mot { font-size: clamp(14px, 4.2vw, 20px); }
.accueil .annee { font-size: clamp(44px, 15vw, 70px); }
.accroche { margin-top: 3svh; text-align: center; font-size: clamp(24px, 7vw, 32px); font-weight: 700; line-height: 1.12; text-shadow: 0 3px 0 var(--encre); }
.accroche small { display: block; margin-top: 10px; font-size: 17px; font-weight: 500; line-height: 1.3; opacity: .92; }
.defi { margin-top: 14px; padding: 8px 12px; background: rgba(20,10,4,.6); font-size: 17px; font-weight: 600; text-align: center; line-height: 1.3; }
.defi b { color: var(--or); }
.bas { margin-top: auto; width: 100%; display: grid; gap: 12px; }
.compteur { text-align: center; font-size: 16px; text-shadow: 0 2px 0 var(--encre); min-height: 1.3em; }
.compteur b { color: var(--or); }
.pied { display: flex; justify-content: center; gap: 14px; font-size: 13px; opacity: .8; text-shadow: 0 2px 0 var(--encre); }

/* une question */
.question .etiquette { width: min(54%, 230px); margin-top: 2px; flex: none; }
.question .etiquette .mot { font-size: clamp(9px, 2.6vw, 12px); }
.question .annee { font-size: clamp(28px, 9vw, 40px); }
.souvenir { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.souvenir img { height: clamp(70px, 15svh, 130px); width: auto; filter: drop-shadow(0 6px 0 rgba(20,10,4,.5)); animation: sort .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes sort { 0% { transform: translateY(40px) scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
.souvenir .nom { margin-top: 10px; font-size: clamp(22px, 6.6vw, 28px); font-weight: 700; line-height: 1.1; text-shadow: 0 3px 0 var(--encre); }
.souvenir .ligne { margin-top: 6px; font-size: 16px; line-height: 1.3; opacity: .95; text-shadow: 0 2px 0 var(--encre); max-width: 340px; }
.note { width: min(100%, 340px); animation: sort .45s cubic-bezier(.2,1.4,.4,1); }
.note > div { background: var(--papier); color: var(--encre); padding: 18px 16px 20px; box-shadow: inset 0 -6px 0 var(--papier-fonce); }
.note .nom { text-shadow: none; color: var(--encre); }
.note .ligne { text-shadow: none; color: #5a4030; opacity: 1; margin-left: auto; margin-right: auto; }
.reponses { width: 100%; display: grid; gap: 11px; flex: none; }
.reponses .cadre > button { width: 100%; min-height: 48px; padding: 6px 14px; background: var(--papier); color: var(--encre); font-size: 19px; font-weight: 600; text-align: left; box-shadow: inset 0 -5px 0 var(--papier-fonce); }
.reponses .cadre > button.choisi { background: var(--or); box-shadow: inset 0 -5px 0 #c98d16; }

/* la révélation */
.revelation .voile, .fiche .voile { background: rgba(20,10,4,.78); }
.revelation { justify-content: center; }
.revelation .etiquette { width: min(92%, 420px); }
.revelation .etiquette .mot { font-size: clamp(14px, 4.4vw, 21px); }
.revelation .annee { font-size: clamp(56px, 18vw, 84px); }
.age { margin-top: 26px; font-size: clamp(30px, 9vw, 40px); font-weight: 700; text-align: center; text-shadow: 0 3px 0 #000; opacity: 0; transition: opacity .4s; }
.vu { opacity: 1 !important; }
.juste { margin-top: 22px; display: flex; gap: 12px; opacity: 0; transition: opacity .4s; }
.juste .cadre > button { min-width: 130px; min-height: 50px; font-size: 20px; }
.vraie { margin-top: 22px; width: min(100%, 320px); display: grid; gap: 12px; text-align: center; }
.vraie p { font-size: 20px; font-weight: 700; text-shadow: 0 3px 0 #000; }
.vraie .champ > input { width: 100%; min-height: 56px; background: var(--papier); color: var(--encre); font-size: 30px; font-weight: 700; text-align: center; letter-spacing: .1em; }
.vraie .champ > input::placeholder { color: rgba(42,26,16,.35); }
.vraie .lien { font-size: 15px; text-decoration: underline; opacity: .85; text-shadow: 0 2px 0 #000; }

/* la fiche à partager */
.fiche .carte { width: min(100%, 380px); margin-top: 1svh; }
.fiche .carte > div { background: var(--papier); color: var(--encre); padding: 16px 16px 18px; display: grid; justify-items: center; text-align: center; box-shadow: inset 0 -6px 0 var(--papier-fonce); }
.fiche .etiquette { width: 88%; }
.fiche .etiquette .mot { font-size: clamp(11px, 3.4vw, 15px); }
.fiche .annee { font-size: clamp(40px, 12vw, 56px); }
.fiche .donne { margin-top: 10px; font-size: 22px; font-weight: 700; line-height: 1.15; }
.fiche .generation { margin-top: 8px; display: inline-block; background: var(--violet); color: #fff; padding: 5px 12px 6px; font-size: 18px; font-weight: 700; }
.fiche .details { margin-top: 12px; width: 100%; display: grid; gap: 6px; font-size: 15px; text-align: left; }
.fiche .details div { display: flex; justify-content: space-between; gap: 10px; border-top: 2px dashed var(--papier-fonce); padding-top: 6px; }
.fiche .details b { text-align: right; }
.fiche .signe { margin-top: 12px; display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; letter-spacing: .06em; opacity: .8; }
.fiche .signe img { width: 20px; height: 20px; border-radius: 6px; image-rendering: auto; }
.fiche .bas { gap: 10px; }
.fiche .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fiche .deux .cadre > button { width: 100%; min-height: 48px; font-size: 17px; }
.fiche .autres { text-align: center; font-size: 15px; text-shadow: 0 2px 0 var(--encre); }

/* un petit mot qui passe : lien copié, image enregistrée */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); translate: -50% 20px; opacity: 0; pointer-events: none; z-index: 5; background: var(--encre); color: var(--papier); padding: 10px 16px; font-size: 17px; font-weight: 600; transition: opacity .2s, translate .2s; }
.toast.vu { translate: -50% 0; }

@media (min-width: 900px) {
  .jeu { max-width: 100%; }
  /* sur ordinateur : le grenier entier au milieu, et une seule couleur sombre sur les côtés, sans flou */
  .grenier { background-size: auto 100%; background-position: center; }
  .voile { left: 50%; width: calc(100svh * 941 / 1672); translate: -50% 0; }
  /* le jeu tient dans la largeur du grenier, jamais plus : sur un portable, le grenier fait à peine 400 points de large */
  .ecran { right: auto; width: min(480px, calc(100svh * 941 / 1672)); left: 50%; translate: -50% 0; }
}

/* un téléphone tenu en largeur n'a pas la hauteur du jeu : on lui demande de se tourner */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .jeu, .toast { display: none; }
  body { display: grid; place-items: center; padding: 24px; }
  body::after { content: 'Tourne ton téléphone pour jouer.'; font-size: 24px; font-weight: 700; text-align: center; color: var(--papier); }
}
