:root {
  --night-1: #0b1026;
  --night-2: #1a1f4a;
  --gold: #ffd166;
  --gold-2: #f4a261;
  --red: #e63946;
  --red-2: #b5172b;
  --green: #2a9d5c;
  --snow: #f8f9ff;
  --ink: #f1f3ff;
  --muted: #aab3e0;
  --card: rgba(255, 255, 255, 0.08);
  --card-line: rgba(255, 255, 255, 0.16);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 120%, #2b2f6b 0%, var(--night-2) 35%, var(--night-1) 80%) fixed;
  background-color: var(--night-1);
  color: var(--ink);
  font-family: "Fredoka", system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
canvas.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#snow { z-index: 0; }
#fireworks { z-index: 5; }

.wrap { position: relative; z-index: 2; max-width: 560px; margin: 0 auto; padding: 18px 16px 64px; text-align: center; }
h1, .title {
  font-family: "Mountains of Christmas", "Fredoka", serif;
  font-weight: 700; color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 209, 102, .45), 0 3px 0 #7a4b00;
  margin: 8px 0 4px; line-height: 1.05;
}
h1 { font-size: clamp(38px, 11vw, 64px); }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 17px; }
.hidden { display: none !important; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; }
.pill {
  border: 1px solid var(--card-line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 15px; cursor: pointer;
}
.pill:active { transform: scale(.96); }
.live { background: var(--red); border-color: var(--red); font-weight: 600; animation: pulse 1.4s infinite; cursor: default; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(230, 57, 70, .25); } }

.card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: 22px;
  padding: 18px; margin: 14px 0; backdrop-filter: blur(4px);
}
.btn {
  display: inline-block; border: 0; border-radius: 16px; padding: 14px 22px; margin: 6px;
  font: inherit; font-size: 18px; font-weight: 600; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, var(--red), var(--red-2));
  box-shadow: 0 5px 0 #7d0f1d, 0 8px 20px rgba(0, 0, 0, .35);
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #7d0f1d; }
.btn.green { background: linear-gradient(180deg, #34b26a, #1f7a45); box-shadow: 0 5px 0 #11502b, 0 8px 20px rgba(0,0,0,.35); }
.btn.ghost { background: var(--card); border: 1px solid var(--card-line); box-shadow: none; }

/* attente */
.names { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.name-tag { background: rgba(255,255,255,.1); border-radius: 999px; padding: 6px 12px; font-size: 16px; }
.big-emoji { font-size: 72px; line-height: 1; margin: 10px 0; display: inline-block; animation: sway 3s ease-in-out infinite; }
@keyframes sway { 50% { transform: rotate(-8deg) scale(1.05); } }

/* compte à rebours */
.countdown { font-size: clamp(64px, 22vw, 140px); font-weight: 700; color: var(--snow); text-shadow: 0 0 30px rgba(255,255,255,.4); margin: 10px 0; font-variant-numeric: tabular-nums; }
.countdown.beat { animation: beat .9s ease-out; }
@keyframes beat { 0% { transform: scale(1.5); color: var(--gold); } 100% { transform: scale(1); } }

/* scène du tirage */
.progress { color: var(--muted); font-size: 15px; margin: 4px 0 8px; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-bottom: 8px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.2); }
.dots i.done { background: var(--gold); }
.dots i.now { background: var(--red); transform: scale(1.3); }

.giver { font-size: 20px; min-height: 60px; }
.giver b { display: block; font-size: clamp(30px, 9vw, 44px); color: var(--gold); line-height: 1.15; }
.giver.pop { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.machine {
  position: relative; margin: 14px auto 8px; width: min(100%, 380px);
  padding: 16px; border-radius: 28px;
  background: linear-gradient(180deg, #c62835, #8f1422);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.25), 0 10px 30px rgba(0,0,0,.45);
}
.machine::before, .machine::after { /* guirlande lumineuse */
  content: ""; position: absolute; left: 14px; right: 14px; height: 8px;
  background: radial-gradient(circle, var(--gold) 0 3px, transparent 4px) 0 0 / 22px 8px repeat-x;
  animation: blink 1s steps(2) infinite;
}
.machine::before { top: 4px; } .machine::after { bottom: 4px; animation-delay: .5s; }
@keyframes blink { 50% { filter: hue-rotate(140deg) brightness(1.3); } }
.window {
  position: relative; height: 192px; overflow: hidden; border-radius: 16px;
  background: linear-gradient(180deg, #fff8e8, #fff 45%, #fff 55%, #fff8e8);
  box-shadow: inset 0 6px 14px rgba(0,0,0,.35);
}
.window::before { /* ligne gagnante */
  content: ""; position: absolute; left: 0; right: 0; top: 64px; height: 64px; z-index: 1;
  border-top: 3px solid var(--gold-2); border-bottom: 3px solid var(--gold-2);
  background: rgba(255, 209, 102, .18); pointer-events: none;
}
.window::after { /* fondu haut et bas */
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.35), transparent 28%, transparent 72%, rgba(0,0,0,.35));
}
.strip { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.strip div {
  height: 64px; display: flex; align-items: center; justify-content: center;
  color: #2a1a10; font-size: 28px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px;
}
.window.landed .strip div.hit { color: var(--red-2); transform: scale(1.12); transition: transform .2s; }
.window.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.quip { min-height: 30px; font-size: 18px; color: var(--snow); margin: 8px 0; font-style: italic; }

.reveal {
  font-size: 21px; padding: 16px; border-radius: 20px; margin: 10px 0;
  background: linear-gradient(180deg, rgba(255,209,102,.25), rgba(255,209,102,.08));
  border: 2px solid var(--gold); animation: pop .7s cubic-bezier(.2, 1.6, .4, 1);
}
.reveal b { color: var(--gold); font-size: 1.35em; }

.chain { list-style: none; padding: 0; margin: 0; text-align: left; }
.chain li {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; margin: 6px 0;
  background: rgba(255,255,255,.07); font-size: 18px;
}
.chain li .from, .chain li .to { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chain li .to { text-align: right; color: var(--gold); font-weight: 600; }
.chain li.fresh { animation: slidein .5s ease-out; }
@keyframes slidein { from { transform: translateX(-30px); opacity: 0; } }
.chain-title { margin: 0 0 6px; font-size: 18px; color: var(--muted); text-align: center; font-weight: 500; }

.finale h1 { font-size: clamp(46px, 14vw, 84px); animation: pop 1s cubic-bezier(.2, 1.6, .4, 1); }
.controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tip { color: var(--muted); font-size: 14px; margin-top: 18px; }
.err { color: #ffb3b9; }

/* page organisateur */
.admin { text-align: left; }
.admin label { display: block; font-weight: 600; margin: 12px 0 6px; }
.admin textarea, .admin input, .admin select {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: rgba(0,0,0,.25);
  border: 1px solid var(--card-line); border-radius: 12px; padding: 10px 12px;
}
.admin textarea { min-height: 170px; resize: vertical; }
.admin .help { color: var(--muted); font-size: 14px; margin: 4px 0; }
.admin .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin .row > * { flex: 1; }
.msg { min-height: 24px; margin: 8px 0; }
.ok { color: #9ff0bd; }
.btn:disabled { opacity: .4; pointer-events: none; }
