/* Nuit Secrète — habillage selon la charte Crafty Yum.
   Jour : fond Ivoire, texte Espresso, actions Teal. Nuit (body.night) : dégradé de marque Teal → Espresso. */

@font-face { font-family: "Autumn Cartoon"; src: url("fonts/autumn-cartoon.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Montreal"; font-weight: 300; src: url("fonts/montreal-300.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Montreal"; font-weight: 500; src: url("fonts/montreal-500.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Montreal"; font-weight: 700; src: url("fonts/montreal-700.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Photography"; src: url("fonts/photography.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Sambrel Gatha"; src: url("fonts/sambrel-gatha.woff") format("woff"); font-display: swap; }

:root {
  --espresso: #18100A;
  --teal: #265C58;
  --rouge: #9E1F35;
  --creme: #F5E6C8;
  --sable: #EDE0CC;
  --ivoire: #FAF5EE;

  --bg: var(--ivoire);
  --surface: var(--sable);
  --surface-2: #fff;
  --ink: var(--espresso);
  --mut: rgba(24, 16, 10, .64);
  --line: rgba(24, 16, 10, .16);
  --accent: var(--teal);
  --on-accent: var(--ivoire);
  --title: var(--teal);

  --display: "Autumn Cartoon", "Baloo 2", "Trebuchet MS", sans-serif;
  --body: "Montreal", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --hand: "Photography", "Bradley Hand", "Segoe Script", cursive;
  --script: "Sambrel Gatha", "Brush Script MT", cursive;
}
body.night {
  --bg: var(--espresso);
  --surface: rgba(250, 245, 238, .09);
  --surface-2: rgba(250, 245, 238, .16);
  --ink: var(--ivoire);
  --mut: rgba(250, 245, 238, .72);
  --line: rgba(250, 245, 238, .22);
  --accent: var(--ivoire);
  --on-accent: var(--espresso);
  --title: var(--ivoire);
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body); font-weight: 300;
  font-size: clamp(1rem, 1.1vw, 1.125rem); line-height: 1.6;
  color: var(--ink); background: var(--bg); min-height: 100dvh;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
body.night { background: linear-gradient(135deg, var(--teal) 0%, var(--espresso) 100%) fixed; }
b, strong { font-weight: 700; }

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.1; color: var(--title); text-wrap: balance; letter-spacing: .01em; }
h1 { font-size: clamp(2.25rem, 5vw, 4.5rem); }
h2 { font-size: clamp(1.75rem, 3.5vw, 3.25rem); }
h3 { font-size: clamp(1.25rem, 2.25vw, 1.75rem); font-weight: 700; line-height: 1.3; }
p { text-wrap: pretty; }
.mut { color: var(--mut); }
.small { font-size: clamp(.8rem, .9vw, .875rem); line-height: 1.4; }
.center { text-align: center; }
.boot { text-align: center; padding-top: 40dvh; color: var(--mut); }

#app { max-width: 30rem; margin: 0 auto; padding: 16px 20px calc(32px + env(safe-area-inset-bottom)); }
#app.wide { max-width: 75rem; padding-inline: clamp(20px, 4vw, 40px); }
#app.tv { max-width: none; padding: 0; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---- éléments de base ---- */
.card { background: var(--surface); border-radius: 12px; padding: 24px; }
.card.plain { background: transparent; border: 1px solid var(--line); }
.btn {
  appearance: none; font: inherit; font-weight: 500; cursor: pointer; width: 100%; min-height: 48px; padding: 8px 24px;
  border-radius: 8px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  transition: transform .08s, opacity .15s; touch-action: manipulation;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { border: 1px solid var(--line); color: var(--ink); font-weight: 300; }
.btn.danger { background: var(--rouge); border-color: var(--rouge); color: var(--ivoire); }
.btn.slim { min-height: 40px; padding: 4px 16px; width: auto; white-space: nowrap; flex: none; font-size: .9rem; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn:focus-visible, .chip:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label.field { display: block; font-size: .875rem; color: var(--mut); }
input[type=text], input[type=password] {
  width: 100%; margin-top: 8px; font: inherit; font-size: 1.125rem; color: var(--ink);
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 8px; padding: 12px 16px;
}
input.code { text-transform: uppercase; letter-spacing: .35em; text-align: center; font-weight: 700; }
input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--teal); }

.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; min-height: 44px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: .8rem; font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.badge.soft { background: var(--surface); color: var(--ink); }
.badge.rouge { background: var(--rouge); color: var(--ivoire); }
.screen-tag { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--mut); }
.phase-tag { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 700; color: var(--accent); }

/* ---- Mochi : la voix du conteur ---- */
.mochi { display: flex; gap: 12px; align-items: flex-end; }
/* Mochi animé : une bande d'images par humeur, 192 × 200 px par pose */
.mochi-sprite {
  flex: none; width: 76px; aspect-ratio: 192 / 200; background: no-repeat 0 0 / calc(var(--n) * 100%) 100%;
  animation: sprite calc(var(--n) * .15s) steps(var(--n), jump-none) infinite;
}
.m-idle { --n: 6; background-image: url("mochi/idle.webp"); animation-duration: 1.6s; }
.m-wave { --n: 4; background-image: url("mochi/wave.webp"); animation-duration: 1s; }
.m-jump { --n: 5; background-image: url("mochi/jump.webp"); }
.m-sad { --n: 8; background-image: url("mochi/sad.webp"); animation-duration: 2.4s; }
.m-cheer { --n: 6; background-image: url("mochi/cheer.webp"); }
.m-sly { --n: 6; background-image: url("mochi/sly.webp"); animation-duration: 1.5s; }
.m-laugh { --n: 6; background-image: url("mochi/laugh.webp"); }
.m-run { --n: 8; background-image: url("mochi/run.webp"); animation-duration: .7s; }
@keyframes sprite { from { background-position: 0 0; } to { background-position: 100% 0; } }
.mochi .bubble { margin-bottom: 14px; }
.bubble {
  position: relative; background: var(--creme); color: var(--espresso); border-radius: 16px; padding: 16px 20px;
  font-family: var(--hand); font-size: clamp(1.45rem, 2.2vw, 1.9rem); line-height: 1.4; flex: 1; min-width: 0;
}
.bubble::before {
  content: ""; position: absolute; left: -8px; bottom: 14px; width: 18px; height: 18px; background: var(--creme);
  transform: rotate(45deg); border-radius: 3px;
}
.bubble p + p { margin-top: 8px; }

/* ---- accueil ---- */
.wordmark { text-align: center; padding: 24px 0 8px; }
.wordmark .by { font-family: var(--script); font-size: 1.6rem; line-height: 1.1; color: var(--ink); }
.wordmark .by b { font-family: var(--display); font-weight: 400; color: var(--teal); letter-spacing: .02em; }
.wordmark h1 { margin-top: 4px; }
.wordmark .mochi-sprite { width: 120px; margin: 8px auto 0; }
.choices { display: grid; gap: 16px; }
.choice {
  appearance: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; width: 100%;
  background: var(--surface); border: 0; border-radius: 12px; padding: 20px 24px; display: grid; gap: 4px;
}
.choice b { font-size: 1.125rem; }
.choice.main { background: linear-gradient(135deg, var(--teal) 0%, var(--espresso) 100%); color: var(--ivoire); }
.choice.main .mut { color: rgba(250, 245, 238, .78); }

/* ---- grille de joueurs ---- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.chip {
  appearance: none; font: inherit; font-weight: 500; color: var(--ink); background: var(--surface);
  border: 1.5px solid transparent; border-radius: 8px; padding: 12px 8px; min-height: 56px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  overflow-wrap: anywhere; touch-action: manipulation; line-height: 1.3;
}
.chip.on { background: var(--accent); color: var(--on-accent); }
.chip .sub { font-size: .75rem; font-weight: 300; opacity: .85; }
.chip.static { cursor: default; }

.question { text-align: center; }
.sealed { text-align: center; padding: 32px 8px; }
.timer { font-family: var(--display); font-size: clamp(3.5rem, 16vw, 6rem); text-align: center; font-variant-numeric: tabular-nums; line-height: 1; color: var(--title); }
.timer.low { color: var(--rouge); }
body.night .timer.low { color: var(--creme); }

/* ---- secrets : maintenir pour révéler ---- */
.secret {
  position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  border-radius: 12px; border: 1.5px dashed var(--accent); min-height: 150px;
  display: grid; place-items: center; padding: 24px; cursor: pointer; text-align: center;
}
.secret > .inside { visibility: hidden; width: 100%; }
.secret > .cover { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 4px; padding: 16px; font-weight: 700; color: var(--accent); }
.secret.revealed { border-style: solid; background: var(--surface); }
.secret.revealed > .inside { visibility: visible; }
.secret.revealed > .cover { visibility: hidden; }
.role-emoji { font-size: 3.5rem; line-height: 1.1; }
.role-name { font-family: var(--display); font-size: 2.25rem; line-height: 1.1; color: var(--title); }
.camp { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; margin-top: 4px; }
.notes { text-align: left; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .92rem; line-height: 1.4; }
.notes li { margin-left: 18px; }
.notes li + li { margin-top: 4px; }

.tally { display: grid; gap: 8px; }
.tally .line { display: grid; grid-template-columns: minmax(0, 7.5em) 1fr auto; align-items: center; gap: 8px; font-weight: 700; }
.tally .line > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally .track { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.tally .fill { height: 100%; border-radius: 999px; background: var(--accent); }

.banner { border-radius: 12px; padding: 32px 24px; text-align: center; background: linear-gradient(135deg, var(--teal) 0%, var(--espresso) 100%); color: var(--ivoire); }
.banner h1, .banner h2 { color: var(--ivoire); }

/* ---- feuille (modale) ---- */
#sheet { position: fixed; inset: 0; z-index: 20; background: rgba(24, 16, 10, .6); display: flex; align-items: flex-end; justify-content: center; }
#sheet[hidden] { display: none; }
.sheet-body {
  --bg: var(--ivoire); --surface: var(--sable); --surface-2: #fff; --ink: var(--espresso); --mut: rgba(24, 16, 10, .64);
  --line: rgba(24, 16, 10, .16); --accent: var(--teal); --on-accent: var(--ivoire); --title: var(--teal);
  color: var(--ink); background: var(--bg); width: 100%; max-width: 30rem; max-height: 92dvh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}
.sheet-body h2 { font-size: 1.75rem; }
@media (min-width: 640px) { #sheet { align-items: center; } .sheet-body { border-radius: 16px; } }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: min(100%, 260px); margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--espresso); color: var(--ivoire); font-weight: 700; padding: 12px 24px; border-radius: 8px; max-width: min(92vw, 28rem);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--espresso); color: var(--ivoire); text-align: center; font-size: .85rem; padding: 4px; z-index: 25; }

/* ---- écran central ---- */
.host { display: grid; gap: 24px; }
@media (min-width: 880px) { .host { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); align-items: start; } }
.join-card { display: grid; gap: 16px; align-items: center; text-align: center; }
@media (min-width: 560px) { .join-card { grid-template-columns: 200px 1fr; text-align: left; } }
.bigcode { font-family: var(--display); font-size: clamp(3.5rem, 12vw, 5.5rem); letter-spacing: .08em; line-height: 1; color: var(--title); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  appearance: none; font: inherit; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; background: var(--surface-2); border: 1.5px solid transparent; line-height: 1.2;
}
div.pill { cursor: default; }
.pill.open { border-color: var(--accent); }
.pill.wait { opacity: .55; }
.pill .tick { font-weight: 700; color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); opacity: .5; flex: none; }
.dot.on { background: var(--teal); opacity: 1; }
body.night .dot.on { background: var(--creme); }
.pdetail { font-size: .85rem; color: var(--mut); line-height: 1.4; }
details { border-radius: 12px; background: var(--surface); }
details > summary { cursor: pointer; padding: 16px 24px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; line-height: 1; }
details[open] > summary::after { content: "–"; }
details > .inner { padding: 0 24px 24px; }
.rolepick { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.rolepick .e { font-size: 1.4rem; }
.rolepick.locked { cursor: default; }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper button { width: 40px; height: 40px; border-radius: 8px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); font-size: 1.3rem; cursor: pointer; }
.progress { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.alert { font-weight: 700; }
.alert::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rouge); margin-right: 8px; }

/* ---- écran télé : une scène par étape ---- */
.tv { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: clamp(16px, 3vh, 40px) clamp(24px, 4vw, 80px); gap: clamp(12px, 2vh, 24px); overflow: hidden; position: relative; }
.tv-top { display: flex; align-items: center; gap: 24px; }
.tv-top .name { font-family: var(--display); font-size: clamp(1.5rem, 2.6vw, 2.5rem); color: var(--title); line-height: 1; }
.lanterns { display: flex; gap: 10px; margin-left: auto; align-items: center; }
.lantern { width: clamp(14px, 1.6vw, 22px); aspect-ratio: 3 / 4; border-radius: 40% 40% 45% 45%; border: 2px solid var(--accent); opacity: .5; }
.lantern.lit { background: var(--creme); border-color: var(--creme); opacity: 1; box-shadow: 0 0 18px rgba(245, 230, 200, .7); }
body:not(.night) .lantern.lit { background: var(--teal); border-color: var(--teal); box-shadow: none; }
.stage { display: grid; place-items: center; text-align: center; position: relative; min-height: 0; }
.stage h1 { font-size: clamp(3rem, 8vw, 7.5rem); animation: rise .7s both; }
.stage .lead { font-size: clamp(1.25rem, 2.2vw, 2rem); max-width: 28ch; margin: 16px auto 0; animation: rise .7s .15s both; }
.stage .timer { font-size: clamp(5rem, 16vw, 13rem); }
.stage .bigcode { font-size: clamp(5rem, 14vw, 11rem); }
.tv-join { display: flex; align-items: center; gap: clamp(24px, 5vw, 80px); text-align: left; }
.tv-join .qr { width: clamp(180px, 24vw, 340px); margin: 0; flex: none; }
.tv-bottom { display: grid; gap: 16px; }
.tv .mochi-sprite { width: clamp(120px, 13vw, 210px); }
.runner { position: absolute; left: 0; bottom: 0; width: clamp(90px, 9vw, 150px); animation: sprite .7s steps(8, jump-none) infinite, cross 3.2s linear both; }
@keyframes cross { from { transform: translateX(-20vw); } to { transform: translateX(110vw); } }
.tv .bubble { font-size: clamp(1.4rem, 2.6vw, 2.5rem); padding: clamp(16px, 2vw, 28px) clamp(20px, 2.6vw, 36px); animation: pop .45s both; }
.tv .bubble p { animation: rise .5s both; }
.tv .bubble p:nth-child(2) { animation-delay: 1.6s; }
.tv .bubble p:nth-child(3) { animation-delay: 3.2s; }
.tv .pills { justify-content: center; }
.tv .pill { font-size: clamp(.9rem, 1.4vw, 1.25rem); padding: 8px 16px; }
.tv .pill.done { background: var(--accent); color: var(--on-accent); animation: pop .35s both; }
.tv .pill.done .tick { color: inherit; }
.tv .pill.speaking { background: var(--creme); color: var(--espresso); transform: scale(1.12); }
.tv-start { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(24, 16, 10, .72); }
.tv-start .stack { display: grid; gap: 16px; justify-items: center; }
.tv-start .stack > * + * { margin-top: 0; }
.tv-start .btn { width: auto; font-size: 1.5rem; padding: 16px 40px; background: var(--creme); color: var(--espresso); border-color: var(--creme); }
.tv-start .btn.ghost { font-size: 1rem; padding: 8px 24px; background: transparent; color: var(--ivoire); border-color: rgba(250, 245, 238, .5); }

/* décor : lune, soleil, algues, vapeur */
.moon { width: clamp(90px, 14vw, 220px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto 3vh; background: var(--creme); box-shadow: 0 0 80px rgba(245, 230, 200, .45), inset -18px -12px 0 rgba(24, 16, 10, .12); animation: float 6s ease-in-out infinite; }
.sun { width: clamp(90px, 14vw, 220px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto 3vh; background: var(--teal); animation: sunrise 1.6s cubic-bezier(.2, .8, .2, 1) both; }
.algae { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.algae i { position: absolute; bottom: -12vh; width: 3vw; height: 34vh; border-radius: 50% 50% 0 0; background: rgba(24, 16, 10, .55); transform-origin: bottom center; animation: sway 5s ease-in-out infinite; }
.algae i:nth-child(1) { left: 6%; height: 30vh; }
.algae i:nth-child(2) { left: 14%; height: 42vh; animation-delay: -1.5s; }
.algae i:nth-child(3) { right: 16%; height: 38vh; animation-delay: -2.8s; }
.algae i:nth-child(4) { right: 7%; height: 28vh; animation-delay: -.8s; }
.suspense .reveal { animation: reveal .6s 2.6s both; }
.suspense .drum { animation: drum 2.6s both; }
.creeping { animation: creep 2.4s both; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes sunrise { from { opacity: 0; transform: translateY(40vh) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes sway { 50% { transform: rotate(7deg) scaleY(1.06); } }
@keyframes reveal { from { opacity: 0; transform: scale(.7); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes drum { 0%, 100% { transform: none; } 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); } 20%, 40%, 60%, 80% { transform: translateX(4px); } }
@keyframes creep { from { letter-spacing: .4em; opacity: 0; } to { letter-spacing: .01em; opacity: 1; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.tv-bottom.late .mochi { animation: rise .5s 2.9s both; }
