@font-face { font-family: "Cormorant Garamond"; font-weight: 700; font-display: swap; src: url("/fonts/cormorant-garamond-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url("/fonts/nunito-600.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("/fonts/nunito-800.woff2") format("woff2"); }

/* Linen and fir theme: Louise in white, Cyprien in fir green, friends in gold. */
:root {
  --bg: #e9e2d2;
  --bg2: #f7f3ea;
  --ink: #173f30;
  --muted: #6a8173;
  --fir: #174a37;
  --gold: #c6a55c;
  --louise: #ffffff;
  --cyprien: var(--fir);
  --amis: var(--gold);
  --danger: #b3312a;
  --title: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 0%, var(--bg2), var(--bg) 75%) fixed;
  color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 600;
}

/* A hint of winter: a few snowflakes, and a fir branch with berries in the top right corner. */
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; }
body::before {
  opacity: 0.7;
  background:
    radial-gradient(circle, #fff 0 2.5px, transparent 3px) 0 0 / 190px 170px,
    radial-gradient(circle, #fff 0 1.5px, transparent 2px) 70px 90px / 130px 150px;
}
body::after { background: url("/sapin.svg") right -1vw top -0.5vh / min(26vw, 46vh) no-repeat; }
body > * { position: relative; z-index: 1; }

h1, h2 { margin: 0; line-height: 1.05; font-family: var(--title); font-weight: 700; }
.phone h1::after, .join h1::after { content: "✦"; display: block; margin-top: 0.15em; font-size: 0.45em; color: var(--gold); }

.hidden { display: none !important; }

/* ---------- Téléphone ---------- */

.phone {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  text-align: center;
}

.phone h1 { font-size: 2.2rem; }
.phone p { margin: 0; color: var(--muted); font-size: 1.1rem; }

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 16px;
  font: inherit;
  font-size: 1.3rem;
  text-align: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--gold);
  border-radius: 16px;
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--amis); }

.groups { display: grid; gap: 12px; }

.group {
  padding: 16px;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid var(--gold);
  border-radius: 16px;
  cursor: pointer;
}
.group[aria-pressed="true"] { background: var(--c); color: var(--on); transform: scale(1.03); box-shadow: 0 0 0 2px var(--fir); }

.louise { --c: var(--louise); --on: var(--fir); }
.cyprien { --c: var(--cyprien); --on: #ffffff; }
.amis { --c: var(--amis); --on: var(--ink); }

.go {
  padding: 18px;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  background: var(--fir);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.go:disabled { opacity: 0.4; }

.error { color: var(--danger) !important; min-height: 1.4em; }

.badge {
  display: inline-block;
  align-self: center;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--c);
  color: var(--on);
  font-weight: 800;
}

.bounce { font-size: 4rem; animation: bounce 1.2s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-14px) rotate(8deg); } }

.offline.pause { background: var(--amis); color: var(--ink); }

.offline {
  position: fixed;
  inset: 0 0 auto 0;
  padding: 10px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

/* ---------- Écran projecteur ---------- */

.screen {
  height: 100vh;
  padding: 4vh 4vw;
  display: grid;
  grid-template-columns: minmax(280px, 32vw) 1fr;
  gap: 4vw;
  overflow: hidden;
}

.join { display: flex; flex-direction: column; justify-content: center; gap: 3vh; text-align: center; }
.join h1 { font-size: 4.2vw; }
.join .qr { background: #fff; border-radius: 2vw; padding: 1.5vw; }
.join .qr img { display: block; width: 100%; }
.join .url { font-size: 1.8vw; color: var(--muted); word-break: break-all; }

.crowd { display: flex; flex-direction: column; min-height: 0; gap: 3vh; }
.crowd h2 { font-size: 3vw; }
.counts { display: flex; gap: 1.5vw; font-size: 1.6vw; font-weight: 700; }
.counts span { padding: 0.4vw 1.2vw; border-radius: 999px; background: var(--c); color: var(--on); box-shadow: inset 0 0 0 1.5px var(--gold); }

/* --fit shrinks the names so that the whole room fits: see fitPlayers() in ecran.js. */
.players { --fit: 1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: calc(1vw * var(--fit)); overflow: hidden; }
.player {
  padding: calc(0.5vw * var(--fit, 1)) calc(1.4vw * var(--fit, 1));
  border-radius: 999px;
  background: var(--c);
  color: var(--on);
  font-size: calc(1.9vw * var(--fit, 1));
  font-weight: 800;
  transition: opacity 0.4s;
}
.player.away { opacity: 0.35; }
.player.pop { animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop {
  0% { transform: scale(0) rotate(-20deg); }
  70% { transform: scale(1.35) rotate(6deg); }
  100% { transform: scale(1); }
}

.empty { font-size: 2.2vw; color: var(--muted); }

.players { flex: 1; }
.launch { display: flex; align-items: center; justify-content: flex-end; gap: 1.5vw; }
.launch button {
  padding: 1.2vw 3vw;
  font: inherit;
  font-size: 2.4vw;
  font-weight: 800;
  color: #ffffff;
  background: var(--fir);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.launch button:disabled { opacity: 0.4; }
.launch input { width: 26vw; padding: 1vw; font-size: 1.6vw; border-radius: 1vw; }
.launch .error { font-size: 1.6vw; }

/* ---------- Téléphone : vote ---------- */

.vote { position: fixed; inset: 0; display: flex; flex-direction: column; }

.half {
  flex: 1;
  border: 0;
  background: var(--c);
  color: var(--on);
  font: inherit;
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
}
.half:active { filter: brightness(1.2); }
.half:disabled { opacity: 0.5; }

.ask {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--fir);
  color: var(--bg2);
  border-block: 2px solid var(--gold);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}
.ask span { flex: 1; }

.timer {
  min-width: 2.2em;
  text-align: center;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  transition: font-size 0.3s;
}
.timer.hurry { font-size: 3.4rem; color: var(--danger); animation: blink 0.6s steps(2, jump-none) infinite; }

.halo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 50px 22px var(--danger);
  animation: blink 0.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Écran : question et résultats ---------- */

.stage {
  height: 100vh;
  padding: 5vh 6vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vh;
  text-align: center;
}
.stage .step { font-size: 2vw; color: var(--muted); font-weight: 700; }
.stage .text { font-size: 6vw; font-weight: 800; line-height: 1.1; }
.stage .voted { font-size: 2.4vw; color: var(--muted); }

.clock {
  font-size: 12vw;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: font-size 0.4s, color 0.4s;
}
.clock.hurry { font-size: 18vw; color: var(--danger); animation: blink 0.6s steps(2, jump-none) infinite; }

/* ---------- Écran : révélation animée ---------- */

.stage.reveal { justify-content: flex-start; gap: 2vh; padding-top: 4vh; }
.stage.reveal .text { font-size: 3.4vw; }
.arena { position: relative; width: 88vw; height: 44vh; flex: none; }
.head { width: 14vw; height: 14vw; flex: none; }
.head svg { display: block; width: 100%; height: 100%; overflow: visible; }

.verdict { font-size: 3.4vw; font-weight: 800; line-height: 1.1; min-height: 1.1em; }
.verdict.waiting { color: var(--muted); animation: blink 0.9s ease-in-out infinite; }
.facts { display: flex; flex-direction: column; gap: 1vh; font-size: 1.9vw; font-weight: 700; }
.verdict.pop, .fact.pop { animation: pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1); }

.tug, .balloons, .pies { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-around; }
.tug { justify-content: center; }
.team { display: flex; align-items: center; width: 44vw; transition: transform 1.4s cubic-bezier(0.5, -0.3, 0.3, 1.2); }
.team.wobble { animation: wobble 1.1s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: translateX(-3vw); } 50% { transform: translateX(3vw); } }
.rope { flex: 1; height: 1vw; border-radius: 1vw; background: repeating-linear-gradient(90deg, #c9a26b 0 1vw, #a47c48 1vw 2vw); }
.mud { position: absolute; left: 50%; bottom: 1vh; width: 24vw; height: 7vh; margin-left: -12vw; border-radius: 50%; background: #6b4a2b; }
.team .head { transition: transform 0.6s ease-in, filter 0.6s; }
.team .head.fallen { transform: translateY(11vh) rotate(100deg); filter: sepia(1) saturate(1.6) brightness(0.6); }

.balloons .head { width: 15vw; height: 15vw; transition: transform 0.7s ease-in-out, opacity 1.2s; }
.balloons .head.bighead { transition: transform 0.6s cubic-bezier(0.3, 1.9, 0.5, 1); }
.balloons .head.bighead svg { animation: throb 1.1s ease-in-out 2s infinite; }
@keyframes throb { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.06) rotate(2deg); } }
/* The swollen head overflows the arena: the texts stay readable in front of it. */
.stage.reveal .text, .verdict, .facts { position: relative; z-index: 2; }
.balloons .head.deflated { transition: transform 1.3s ease-in, opacity 1.3s; transform: translate(0, -60vh) rotate(900deg) scale(0.15) !important; opacity: 0; }

.race { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-around; }
.lane { position: relative; height: 46%; border-bottom: 0.4vw dashed var(--gold); }
.runner { position: absolute; left: 0; bottom: 0; display: flex; align-items: flex-end; transition: left 0.9s ease-in-out; }
.runner .head { width: 9vw; height: 9vw; margin-left: -3vw; }
.snail { font-size: 6vw; line-height: 1; transform: scaleX(-1); }
.finish { position: absolute; right: 9vw; top: 0; bottom: 0; width: 2vw; background: repeating-conic-gradient(#fff 0 25%, #222 0 50%) 0 0 / 2vw 2vw; }

.pies .head { width: 16vw; height: 16vw; }
.pie { position: absolute; top: -4vh; left: 50%; margin-left: -4.5vw; font-size: 9vw; line-height: 1; transition: transform 0.45s cubic-bezier(0.6, 0, 0.9, 0.4); }
.pie.swing { animation: swing 1.3s ease-in-out infinite alternate; }
@keyframes swing { from { transform: translateX(-24vw) rotate(-20deg); } to { transform: translateX(24vw) rotate(20deg); } }
.head.splat { animation: splat 0.5s ease-out; }
@keyframes splat { 0% { transform: scale(1.5, 0.6); } 60% { transform: scale(0.9, 1.15); } 100% { transform: none; } }

.end-heads { display: flex; gap: 4vw; }
.end-heads .head { width: 18vw; height: 18vw; animation: bounce 1.2s ease-in-out infinite; }
.end-heads .head:last-child { animation-delay: 0.3s; }

.pause-veil {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(233, 226, 210, 0.9);
  font-size: 8vw;
  font-weight: 800;
}

.corner { position: fixed; left: 2vw; bottom: 2vw; width: 9vw; background: #fff; border-radius: 1vw; padding: 0.5vw; }
.corner img { display: block; width: 100%; }

/* ---------- Régie ---------- */

.regie { max-width: 720px; margin: 0 auto; padding: 20px; display: grid; gap: 20px; }
.regie h1 { font-size: 1.8rem; }
.regie h2 { font-size: 1.2rem; margin-bottom: 10px; }
.regie section { background: rgba(255, 255, 255, 0.55); border-radius: 16px; padding: 16px; }
.regie .status { font-size: 1.1rem; color: var(--muted); margin: 0 0 12px; }
.regie button, .regie select {
  font: inherit;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--fir);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  cursor: pointer;
}
.regie select option { color: #000; }
.regie button.primary { width: 100%; padding: 18px; font-size: 1.3rem; font-weight: 800; background: var(--fir); color: #ffffff; border: 0; }
.regie button.danger { border-color: var(--danger); color: var(--danger); }
.regie button:disabled { opacity: 0.4; }
.regie .row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid rgba(23, 63, 48, 0.15); }
.regie .row span { flex: 1; }
.regie .row.done span { opacity: 0.45; text-decoration: line-through; }
.regie .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.regie .row.current span { color: var(--danger); font-weight: 800; }
.regie form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.regie textarea {
  flex: 1;
  padding: 10px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--fir);
  border-radius: 10px;
  resize: vertical;
}
.regie .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.regie .chips .player { font-size: 0.95rem; padding: 3px 12px; }

/* ---------- Thème : détails ---------- */

.player, .badge { box-shadow: inset 0 0 0 1.5px var(--gold); }
.half { font-family: var(--title); font-size: 3.6rem; }
.stage .text { font-family: var(--title); }
.join .qr, .corner { box-shadow: 0 0 0 0.3vw var(--gold); }
.offline, .vote, .halo, .corner, .pause-veil { position: fixed; }
.verdict { font-family: var(--title); }
.verdict.louise, .verdict.cyprien {
  padding: 0.15em 0.9em;
  border-radius: 999px;
  background: var(--c);
  color: var(--on);
  box-shadow: 0 0 0 0.2vw var(--gold);
}

.fact { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.8vw; }
.fact-title { color: var(--muted); }
.chip {
  padding: 0.25vw 1.2vw;
  border-radius: 999px;
  background: var(--c);
  color: var(--on);
  box-shadow: inset 0 0 0 1.5px var(--gold);
}
.regie .row.current span { opacity: 1; text-decoration: none; }

/* ---------- Téléphone des mariés : bouton pause ---------- */

.pause-toggle {
  position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  padding: 10px 16px; border: 2px solid var(--gold); border-radius: 999px;
  background: var(--bg2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 1rem;
  box-shadow: 0 4px 14px rgba(23, 63, 48, 0.25);
}
.pause-toggle:disabled { opacity: 0.6; }
