/* Thème « Loups-Garous du Pic Blanc » : nuit d'hiver étoilée / journée givrée en station. */
:root {
  --bg: #061327;
  --sky1: #0c2448;
  --sky2: #061327;
  --card: rgba(13, 35, 68, .82);
  --card2: rgba(6, 22, 46, .75);
  --line: rgba(159, 208, 240, .28);
  --frost: #9fd0f0;
  --text: #eef7fd;
  --muted: #a9c6df;
  --accent: #7fd8ff;
  --gold: #f4d58d;
  --wolf: #e2564f;
  --good: #5fd3a4;
  --love: #ff7eb6;
  --btn: #2a5f96;
  --btn-text: #ffffff;
  --radius: 16px;
  --title: "Cinzel", Georgia, serif;
}
body.day {
  --sky1: #bfe3f8;
  --sky2: #e9f6fd;
  --bg: #dcefff;
  --card: rgba(255, 255, 255, .86);
  --card2: rgba(226, 241, 252, .9);
  --line: rgba(47, 111, 168, .22);
  --text: #0f2747;
  --muted: #4b6a8a;
  --accent: #1f74b8;
  --gold: #b9832a;
  --btn: #2f6fa8;
}
/* Aube (10h–12h, la Sorcière se décide) : la nuit violette se teinte de rose et d'orangé sur les sommets. */
body.dawn {
  --sky1: #2a2257;
  --sky2: #f2a07b;
  --bg: #6c4a7e;
  --card: rgba(48, 30, 78, .8);
  --card2: rgba(32, 20, 56, .7);
  --line: rgba(255, 196, 160, .3);
  --text: #fff4ee;
  --muted: #f0cfc4;
  --accent: #ffb38a;
  --gold: #ffd59a;
  --btn: #b4566f;
}
body.dawn { background: linear-gradient(180deg, #221d4f 0%, #5b3f86 35%, #c66b8a 65%, #f6b17f 100%) fixed, var(--bg); }
body.dawn header.top .ico { filter: drop-shadow(0 0 12px rgba(255, 179, 138, .9)); }
body.dawn #snow { opacity: .55; filter: sepia(.6) saturate(3) hue-rotate(-30deg); }
body.dawn::before {
  content: ""; position: fixed; left: 50%; bottom: 60px; width: 420px; height: 420px; margin-left: -210px; z-index: -1; pointer-events: none;
  border-radius: 50%; background: radial-gradient(circle, rgba(255, 214, 150, .75) 0%, rgba(255, 160, 120, .35) 35%, transparent 70%);
  animation: sunrise 6s ease-out both;
}
@keyframes sunrise { from { transform: translateY(80px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body.dawn::before { animation: none; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 70%) fixed, var(--bg);
  min-height: 100vh;
  padding: 0 16px calc(120px + env(safe-area-inset-bottom));
  transition: background .6s, color .6s;
}
/* Montagnes enneigées au bas de l'écran */
body::after {
  content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 140px; z-index: -1; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 140' preserveAspectRatio='none'%3E%3Cpath d='M0 90 L60 40 L100 70 L160 15 L220 75 L270 45 L330 85 L400 50 V140 H0Z' fill='%2329507f' opacity='.55'/%3E%3Cpath d='M160 15 L148 33 L156 30 L162 37 L170 30 L176 34Z M60 40 L50 54 L58 51 L64 57 L70 52Z M270 45 L261 58 L268 55 L274 61 L281 56Z' fill='%23f2f9ff' opacity='.8'/%3E%3Cpath d='M0 115 Q100 85 200 108 T400 100 V140 H0Z' fill='%23eef7fd'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat;
}
/* Neige qui tombe */
#snow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 90px 120px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 160px 60px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 230px 170px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 300px 90px, #fff 50%, transparent 51%);
  background-size: 320px 220px;
  opacity: .7;
  animation: snow 14s linear infinite;
}
#snow::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 50px 80px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 140px 20px, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 260px 140px, #fff 50%, transparent 51%);
  background-size: 280px 180px;
  animation: snow 22s linear infinite;
  opacity: .8;
}
body.day #snow { opacity: .9; filter: drop-shadow(0 0 1px rgba(47, 111, 168, .6)); }
@keyframes snow { from { background-position: 0 0; } to { background-position: 40px 660px; } }
@media (prefers-reduced-motion: reduce) { #snow, #snow::after { animation: none; } }

.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-family: var(--title); letter-spacing: .02em; }
h2 { font-family: var(--title); font-size: 1.05rem; letter-spacing: .02em; }
h3 { font-size: 1rem; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .9rem; }
.wrap { max-width: 560px; margin: 0 auto; }

header.top {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px 14px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--sky1) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
header.top .ico { font-size: 2rem; filter: drop-shadow(0 0 8px rgba(127, 216, 255, .5)); }
header.top .ph { flex: 1; min-width: 0; }
header.top .ph b { display: block; font-family: var(--title); font-size: 1.12rem; }
header.top .cd { text-align: right; font-variant-numeric: tabular-nums; }
header.top .cd b { display: block; font-size: 1.15rem; color: var(--accent); }

.card {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 10, 30, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}
/* Givre en haut des cartes */
.card::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: -1px; height: 6px; border-radius: 0 0 8px 8px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .85) 0 6px, rgba(255, 255, 255, .35) 6px 10px);
  opacity: .55; pointer-events: none;
}
.card.alert { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent), 0 8px 24px rgba(0, 10, 30, .25); }
.card.wolf { border-color: var(--wolf); background: color-mix(in srgb, var(--card) 85%, #5a1020); }
.card.win { text-align: center; font-size: 1.1rem; border-color: var(--gold); }

/* Affiches */
.role { text-align: center; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.poster { display: block; width: min(78vw, 300px); height: auto; margin: 4px auto 10px; filter: drop-shadow(0 10px 22px rgba(0, 10, 30, .45)); border-radius: 22px; }
.poster.small { width: 140px; margin: 0; }
.role .hint { color: var(--muted); font-size: .9rem; }
.role .rn { font-family: var(--title); font-size: 1.3rem; font-weight: 700; margin: 2px 0; }
.facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0; }
.flip { animation: flip .45s ease; }
@keyframes flip { from { transform: perspective(800px) rotateY(80deg); opacity: .3; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .flip { animation: none; } }
.chefbox { display: flex; gap: 12px; align-items: center; text-align: left; margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--card2); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; background: var(--card2); border: 1px solid var(--line); margin: 2px; }
.badge.love { color: var(--love); border-color: var(--love); }
.badge.chef { color: var(--gold); border-color: var(--gold); }
.badge.dead { color: var(--wolf); border-color: var(--wolf); }

.notes { text-align: left; margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 8px; }
.notes div { padding: 4px 0; font-size: .92rem; }

.list { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--card2); border: 1px solid transparent; border-radius: 12px; min-height: 48px;
}
.row .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row .nm small { display: block; color: var(--muted); font-size: .8rem; }
.row.dead .nm { color: var(--muted); text-decoration: line-through; }
.row.mine { border-color: var(--accent); }
.row .count { font-weight: 800; min-width: 2ch; text-align: center; color: var(--accent); }

button {
  font: inherit; font-weight: 700; color: var(--btn-text); background: var(--btn); border: 0; border-radius: 12px;
  padding: 10px 14px; min-height: 44px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(180deg, #ffe3a3, #f4c66a); color: #2a1a00; }
button.danger { background: var(--wolf); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
button.sel { background: var(--good); color: #062014; }
button.small { padding: 6px 12px; min-height: 38px; font-size: .9rem; }
button.link { background: none; color: var(--muted); text-decoration: underline; min-height: 0; box-shadow: none; font-weight: 400; }
button:disabled { opacity: .45; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btns > button { flex: 1; }
a { color: var(--accent); }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { min-height: 220px; }
label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.screen { min-height: 90vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; }
.screen form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; }
.screen input { text-align: center; font-size: 1.6rem; letter-spacing: .2em; text-transform: uppercase; }
.screen input.code { font-size: 1.15rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.screen .poster { width: min(56vw, 220px); }

#chatMsgs { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.msg { background: var(--card2); border-radius: 12px; padding: 6px 10px; align-self: flex-start; max-width: 85%; }
.msg.mine { align-self: flex-end; background: rgba(122, 32, 48, .75); color: #fff; }
.msg b { font-size: .8rem; color: #ff9a92; display: block; }
#chatForm { display: flex; gap: 8px; }
#chatForm input { flex: 1; }

.log div { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.log div:last-child { border-bottom: 0; }
.log .d { color: var(--muted); font-size: .75rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; }
.gallery .poster { width: 100%; margin: 0 0 6px; }
.gallery figcaption { font-size: .88rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.scroll { overflow-x: auto; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; padding: 12px 14px; border-radius: 14px;
  background: #1f4f84; color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20; text-align: center;
}
#toast.show { opacity: 1; }
#toast.err { background: #8a2a32; }
footer { text-align: center; margin: 16px 0; }

/* ---------- Célébration de victoire ---------- */
#victory {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 35%, #2d6aa8 0%, #0b2246 55%, #050d1d 100%);
  color: #fff; animation: vfade .6s ease both;
}
#victory.v-loups { background: radial-gradient(circle at 50% 35%, #8b1e2e 0%, #3a0c1c 55%, #12050b 100%); }
#victory.v-amoureux { background: radial-gradient(circle at 50% 35%, #e0628f 0%, #6a1f4a 55%, #22081a 100%); }
#victory.v-personne { background: radial-gradient(circle at 50% 35%, #4a4f63 0%, #1c1e28 60%, #08090d 100%); }
#victory .fx { position: absolute; inset: 0; pointer-events: none; }
#victory .fx span { position: absolute; top: -10vh; animation: vfall linear infinite; will-change: transform; }
#victory .rays {
  position: absolute; left: 50%; top: 32%; width: 160vmax; height: 160vmax; margin: -80vmax 0 0 -80vmax; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 255, 255, .09) 0 8deg, transparent 8deg 22deg);
  animation: vspin 30s linear infinite;
}
#victory .vbox { position: relative; width: 100%; max-width: 520px; max-height: 100%; overflow-y: auto; text-align: center; padding: 8px 0 16px; }
#victory .vbox .poster { width: min(46vw, 200px); margin: 0 auto 8px; animation: vpop .8s cubic-bezier(.2, 1.6, .4, 1) .2s both, vglow 2.4s ease-in-out 1s infinite; }
#victory .vkicker { font-weight: 900; letter-spacing: .25em; text-transform: uppercase; font-size: .85rem; opacity: .85; animation: vup .6s ease .5s both; }
#victory .vtitle {
  font-family: var(--title); font-size: clamp(2rem, 10vw, 3.4rem); line-height: 1.05; margin: 6px 0 14px;
  background: linear-gradient(180deg, #fff 20%, #f4d58d 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(244, 213, 141, .35);
  animation: vpop .9s cubic-bezier(.2, 1.6, .4, 1) .6s both;
}
#victory .vnames { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 16px; }
#victory .vnames span.chip {
  font-size: clamp(1.1rem, 5vw, 1.5rem); font-weight: 900; padding: 4px 14px 4px 4px; border-radius: 99px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35);
  animation: vpop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
#victory .vnames span.chip.dead { opacity: .6; font-weight: 700; }
#victory .vnames .av { width: 40px; height: 40px; border-color: #fff; }
#victory .vnames span.chip.me { background: #f4d58d; color: #2a1a00; border-color: #fff; }
#victory .vme { font-size: 1.25rem; font-weight: 900; margin: 6px 0 16px; animation: vup .6s ease both; }
#victory button { min-width: 180px; }
@keyframes vfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vfall { from { transform: translate3d(0, 0, 0) rotate(0); } to { transform: translate3d(var(--dx, 0), 120vh, 0) rotate(540deg); } }
@keyframes vspin { to { transform: rotate(360deg); } }
@keyframes vpop { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vup { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes vglow { 50% { filter: drop-shadow(0 0 24px rgba(255, 230, 160, .8)); } }
@media (prefers-reduced-motion: reduce) {
  #victory .fx, #victory .rays { display: none; }
  #victory *, #victory { animation: none !important; }
}

/* ---------- Photos de profil ---------- */
.av {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none;
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  font-weight: 900; font-size: .8rem; color: #fff; letter-spacing: 0;
  border: 2px solid var(--frost); background: var(--card2);
  box-shadow: 0 2px 6px rgba(0, 10, 30, .3);
}
.av.sm { width: 24px; height: 24px; font-size: .62rem; border-width: 1.5px; }
.av.lg { width: 88px; height: 88px; font-size: 1.8rem; border-width: 3px; }
.av.xl { width: 64px; height: 64px; font-size: 1.3rem; border-width: 3px; }
.row.dead .av, .chip.dead .av { filter: grayscale(1); opacity: .6; }
.row.mine .av { border-color: var(--accent); }
.profile { display: flex; align-items: center; gap: 14px; }
.profile .pinfo { flex: 1; min-width: 0; }
.profile .pinfo b { font-family: var(--title); font-size: 1.15rem; }
.profile .btns { margin-top: 6px; }
.avbtn { padding: 0; min-height: 0; background: none; box-shadow: none; border-radius: 50%; position: relative; }
.avbtn::after { content: "📷"; position: absolute; right: -4px; bottom: -4px; font-size: .7rem; }
.who { display: inline-flex; align-items: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; }

img.av[data-zoom] { cursor: zoom-in; }
button img.av[data-zoom] { cursor: pointer; }
#zoom {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(3, 10, 24, .88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: zoom-out; animation: vfade .2s ease both;
}
#zoom figure { margin: 0; text-align: center; animation: zpop .25s cubic-bezier(.2, 1.3, .4, 1) both; }
#zoom img {
  display: block; width: min(86vw, 70vh, 480px); height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 24px; border: 4px solid #eaf5fc; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
#zoom figcaption { margin-top: 14px; font-family: var(--title); font-size: 1.5rem; color: #fff; }
#zoom .zclose { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; border-radius: 50%; background: rgba(255, 255, 255, .15); }
@keyframes zpop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #zoom, #zoom figure { animation: none; } }

.mephoto { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; font-size: .88rem; color: var(--muted); }
.mephoto button.link { font-size: .88rem; padding: 0; }

/* ---------- MJ discret ---------- */
.secret { letter-spacing: .1em; color: var(--muted); }
.card.discreet { border-color: var(--good); }
.card.revealed { border-color: var(--wolf); background: color-mix(in srgb, var(--card) 80%, #5a1020); }
