/* « Veillée au coin du feu » : vert sapin, bordeaux et or, la lueur du feu en bas de l'écran,
   une guirlande en haut, la neige sur la télé. */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/fraunces/fraunces-latin-wght-normal.eb2486760f75.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/fraunces/fraunces-latin-ext-wght-normal.9cab501e1829.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("../fonts/nunito/nunito-latin-wght-normal.166202cc391c.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("../fonts/nunito/nunito-latin-ext-wght-normal.ffdc8b0c86fb.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

/* Design tokens */
:root {
  --pine: #0e2a1e;
  --pine-2: #1f4a37;
  --surface: rgb(255 255 255 / 0.06);
  --cream: #fbf3e4;
  --muted: #b9c7b4;
  --gold: #e8b94a;
  --gold-line: rgb(232 185 74 / 0.4);
  --burgundy: #7a1f2b;
  --ember: rgb(255 138 61 / 0.42);
  --right: #4cc27e;
  --wrong: #e0575f;
  --choice-0: #b3313f;
  --choice-1: #2b5d96;
  --choice-2: #a87410;
  --choice-3: #2c7a4b;
  --radius: 14px;
  --font: "Nunito", system-ui, sans-serif;
  --font-title: "Fraunces", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(ellipse 90% 55% at 50% 118%, var(--ember), transparent 70%) fixed,
    radial-gradient(ellipse at 50% 0%, var(--pine-2), var(--pine) 70%) fixed;
  background-color: var(--pine);
  color: var(--cream);
  font: 1.125rem/1.45 var(--font);
}
h1, h2 { font-family: var(--font-title); font-weight: 650; line-height: 1.1; margin: 0 0 0.5em; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.center { text-align: center; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 800; font-size: 0.85em; margin: 0 0 0.4em; }

.page { position: relative; z-index: 1; padding: 20px 16px; max-width: 640px; margin: 0 auto; }
.narrow { max-width: 420px; }
.stack { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--gold-line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }

label { display: grid; gap: 6px; font-weight: 700; }
input {
  width: 100%; min-width: 0; /* not the browser's 20 characters, too wide for a phone in big type */
  font: inherit; padding: 12px 14px; border-radius: var(--radius);
  border: 2px solid var(--gold-line); background: var(--cream); color: var(--pine);
}
.code-input { text-align: center; font-size: 2rem; letter-spacing: 0.3em; text-transform: uppercase; font-weight: 800; }

.button, .guest {
  font: inherit; font-weight: 800; border: 0; border-radius: var(--radius); cursor: pointer;
  padding: 14px 20px; background: var(--gold); color: var(--pine);
  box-shadow: 0 3px 0 rgb(0 0 0 / 0.25);
}
a.button { display: block; text-align: center; text-decoration: none; }
.button-secondary { background: transparent; color: var(--cream); border: 2px solid var(--gold-line); box-shadow: none; }
.link-button {
  font: inherit; font-size: 0.9rem; color: var(--gold); background: none; border: 0; padding: 0;
  text-decoration: underline; cursor: pointer;
}
.button:focus-visible, .guest:focus-visible, .choice:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

.messages { position: relative; z-index: 1; list-style: none; padding: 0 16px; margin: 16px auto 0; max-width: 420px; }
.message { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); }
.message-error { background: var(--burgundy); }

.guest-list { display: grid; gap: 10px; }
.guest { background: var(--cream); font-size: 1.25rem; text-align: left; }
.guest:disabled { opacity: 0.45; cursor: default; }

/* Garland: bulbs hanging from a scalloped wire, one scallop per bulb. */
.garland {
  --bulbs: 16;
  position: relative; z-index: 2; display: flex; height: 3em; font-size: 16px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40' preserveAspectRatio='none'%3E%3Cpath d='M0 2 Q50 38 100 2' fill='none' stroke='%236b7a55' stroke-width='3'/%3E%3C/svg%3E") top left / calc(100% / var(--bulbs)) 1.5em repeat-x;
}
.bulb { position: relative; flex: 0 0 calc(100% / var(--bulbs)); --c: #ff5a5a; }
.bulb:nth-child(4n + 2) { --c: #ffd166; }
.bulb:nth-child(4n + 3) { --c: #6ee7a0; }
.bulb:nth-child(4n + 4) { --c: #6ec3ff; }
.bulb::before, .bulb::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); }
.bulb::before { top: 0.66em; width: 0.45em; height: 0.4em; border-radius: 2px; background: #3a3f30; }
.bulb::after {
  top: 1.02em; width: 0.7em; height: 1.05em; border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  background: var(--c); box-shadow: 0 0 0.7em 0.15em var(--c);
}

/* Snow, behind the TV's content. */
.snow { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.snow i {
  position: absolute; top: -6vh; left: var(--x); font-style: normal; color: rgb(255 255 255 / 0.75);
  font-size: calc(1.3vw * var(--s));
}

/* Answer choices: a colour and a bauble with a shape each, never the colour alone. */
.choices { display: grid; gap: 12px; list-style: none; padding: 0; margin: 0; }
.choice {
  --c: var(--choice-0);
  display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 12px 18px;
  border: 2px solid var(--gold-line); border-radius: var(--radius);
  background: linear-gradient(160deg, rgb(255 255 255 / 0.2), transparent 45%), var(--c);
  box-shadow: 0 4px 0 rgb(0 0 0 / 0.28);
  color: #fff; font: inherit; font-weight: 800; text-align: left;
}
.choice-1 { --c: var(--choice-1); }
.choice-2 { --c: var(--choice-2); }
.choice-3 { --c: var(--choice-3); }
.shape {
  position: relative; flex: none; display: grid; place-items: center;
  width: 1.9em; height: 1.9em; margin-top: 0.25em; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / 0.45), rgb(255 255 255 / 0.12) 60%);
  font-size: 1.15em; line-height: 1;
}
.shape::before {
  content: ""; position: absolute; top: -0.3em; left: 50%; transform: translateX(-50%);
  width: 0.55em; height: 0.32em; border-radius: 3px 3px 0 0; background: var(--gold);
}
.choice-text { flex: 1; }
.choice:disabled { opacity: 0.4; }
.choice.is-picked { opacity: 1; outline: 4px solid var(--cream); }
.choice.is-wrong { opacity: 0.3; }
.choice.is-right { outline: 6px solid var(--gold); box-shadow: 0 0 2em rgb(232 185 74 / 0.5); }

/* Countdown: a number and a shrinking golden bar. */
.play-timer, .tv-timer {
  position: relative; font-family: var(--font-title); font-weight: 700; text-align: center;
  padding: 4px 0 14px; margin: 8px 0 16px;
}
.play-timer::after, .tv-timer::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 6px; border-radius: 3px;
  background: var(--gold); box-shadow: 0 0 10px var(--gold);
  width: calc(var(--left, 0) / var(--total) * 100%);
}

/* Phone */
@media (max-width: 700px) {
  .garland { --bulbs: 8; font-size: 12px; }
  .bulb:nth-child(n + 9) { display: none; }
}
.play-screen { min-height: calc(100dvh - 36px); display: grid; align-content: start; }
.play-status { color: var(--muted); font-size: 0.95rem; margin: 0 0 16px; }
.play-question-text { font-family: var(--font-title); font-size: 1.4rem; font-weight: 650; margin: 0; }
.play-question .choice { min-height: 84px; font-size: 1.2rem; }
.play-wait { text-align: center; padding-top: 10vh; }
.play-wait .play-status { text-align: left; }
.play-not-me { margin: 2em 0 0; }
.play-wait > .play-not-me:nth-child(2) { margin: -0.8em 0 1.5em; text-align: left; }
.play-big { font-size: 5rem; line-height: 1; margin: 0 0 12px; }
.play-rank { font-family: var(--font-title); font-size: 4.5rem; font-weight: 700; color: var(--gold); margin: 0; }
.play-points { font-family: var(--font-title); font-size: 2.6rem; font-weight: 700; color: var(--gold); margin: 0; }
.play-wait.is-right .play-big { color: var(--right); }
.play-wait.is-wrong .play-big { color: var(--wrong); }
.toast {
  position: fixed; z-index: 3; left: 16px; right: 16px; bottom: 24px; margin: 0; padding: 14px;
  border-radius: var(--radius); background: var(--burgundy); text-align: center; font-weight: 800;
}
body.offline::before {
  content: "Connexion perdue, on réessaie…"; position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  padding: 8px; background: var(--burgundy); text-align: center; font-weight: 800;
}

/* TV: big, readable from the sofa (sizes follow the screen width). */
body.tv { font-size: 1.6vw; overflow: hidden; }
.tv .garland { font-size: 1.3vw; }
.tv-screen { position: relative; z-index: 1; min-height: calc(100vh - 3.9vw); padding: 1vh 5vw 4vh; }
.tv-next { position: fixed; z-index: 2; right: 3vw; bottom: 3vh; font-size: 1.1em; }
.tv-next kbd { font: inherit; font-size: 0.7em; opacity: 0.6; }

.tv-lobby { display: grid; grid-template-columns: auto 1fr; gap: 5vw; align-items: start; }
.tv-join { text-align: center; }
.tv-join p { margin: 0.3em 0; }
.qr { display: inline-block; line-height: 0; overflow: hidden; border: 0.4vw solid var(--gold); border-radius: var(--radius); }
.qr svg { display: block; width: 21vw; height: 21vw; }
.tv-url { font-weight: 800; color: var(--gold); }
.tv-code { font-family: var(--font-title); font-size: 4em; font-weight: 700; letter-spacing: 0.15em; color: var(--gold); }
.tv-players h1 { font-size: 3.4em; }
.chips { display: flex; flex-wrap: wrap; gap: 0.6em; list-style: none; padding: 0; }
.chip {
  font: inherit; color: var(--cream); cursor: pointer;
  background: var(--burgundy); border: 2px solid var(--gold); border-radius: 999px; padding: 0.3em 0.9em; font-weight: 800;
}
.tv-hint { font-size: 0.75em; }
.chip.is-confirm { background: var(--gold); color: var(--pine); }
.chip:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.tv-players-toggle { position: fixed; z-index: 2; left: 3vw; bottom: 3vh; font-size: 0.9em; }
.tv-players-toggle kbd { font: inherit; font-size: 0.7em; opacity: 0.6; }
.tv-players-panel {
  position: fixed; z-index: 3; left: 3vw; bottom: calc(3vh + 3.5em); width: 40vw; padding: 1em 1.4em;
  background: var(--pine); border: 2px solid var(--gold); border-radius: var(--radius);
  box-shadow: 0 1em 3em rgb(0 0 0 / 0.5);
}
.tv-players-panel h2 { font-size: 1.4em; }
.tv-players-panel p { font-size: 0.8em; margin: 0 0 0.8em; }
.tv-players-panel .chips { margin: 0; }

.tv-question-head { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; }
.tv-question-text { font-size: 2.7em; margin: 0.5em 0 0.3em; }
.tv-timer { font-size: 3em; color: var(--gold); }
.tv-question .choices { grid-template-columns: 1fr 1fr; gap: 1.2vw; }
.tv-question .choice { min-height: 14vh; font-size: 1.5em; }
.choice-count { font-size: 1.2em; }

.tv-board { max-width: 60vw; margin: 0 auto; }
.tv-board h1 { font-size: 3.2em; text-align: center; }
.tv-champion {
  font-family: var(--font-title); font-size: 5em; font-weight: 750; color: var(--gold); text-align: center;
  margin: 0 0 0.5em; text-shadow: 0 0 0.4em rgb(232 185 74 / 0.45);
}
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5em; }
.board-row {
  display: flex; align-items: center; gap: 1em; background: var(--surface); border: 1px solid var(--gold-line);
  border-radius: var(--radius); padding: 0.5em 1em; font-size: 1.4em;
}
.board-rank {
  display: grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 50%;
  background: var(--burgundy); color: var(--gold); font-family: var(--font-title); font-weight: 700;
}
.board-row:first-child .board-rank { background: var(--gold); color: var(--pine); }
.board-name { flex: 1; font-weight: 800; }
.board-gained { color: var(--right); font-weight: 800; }
.board-score { font-family: var(--font-title); font-weight: 700; min-width: 4em; text-align: right; }

/* Presents: wrapped boxes with a golden ribbon, the number on top, the hint below. */
.gift {
  --wrap: var(--burgundy);
  position: relative; display: grid; align-content: center; justify-items: center; gap: 0.3em; width: 100%;
  padding: 0.8em; border: 2px solid var(--gold-line); border-radius: var(--radius); cursor: pointer;
  font: inherit; color: var(--cream); text-align: center;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.35em), rgb(232 185 74 / 0.85) calc(50% - 0.35em) calc(50% + 0.35em), transparent calc(50% + 0.35em)),
    linear-gradient(transparent calc(50% - 0.35em), rgb(232 185 74 / 0.85) calc(50% - 0.35em) calc(50% + 0.35em), transparent calc(50% + 0.35em)),
    var(--wrap);
  box-shadow: 0 4px 0 rgb(0 0 0 / 0.28);
}
li:nth-child(3n + 2) > .gift, .play-gifts > .gift:nth-child(3n + 2) { --wrap: #1f5c3f; }
li:nth-child(3n + 3) > .gift, .play-gifts > .gift:nth-child(3n + 3) { --wrap: #2b4f7e; }
.gift-number {
  font-family: var(--font-title); font-weight: 750; font-size: 2.2em; line-height: 1;
  padding: 0.1em 0.45em; border-radius: 0.3em; background: var(--cream); color: var(--pine);
}
.gift-hint {
  font-weight: 800; padding: 0.2em 0.6em; border-radius: 0.4em; background: rgb(14 42 30 / 0.85);
}
.gift-owner {
  position: absolute; bottom: 0.5em; left: 50%; transform: translateX(-50%); padding: 0.1em 0.8em; border-radius: 999px;
  background: var(--gold); color: var(--pine); font-weight: 800; font-size: 0.8em;
}
.gift.is-picked { opacity: 0.45; cursor: default; }
.gift:disabled:not(.is-picked) { cursor: default; }
.gift.is-confirm { outline: 5px solid var(--gold); box-shadow: 0 0 2em rgb(232 185 74 / 0.6); }
.gift.is-confirm .gift-hint { background: var(--gold); color: var(--pine); }
.gift:focus-visible { outline: 4px solid var(--cream); outline-offset: 3px; }

.tv-gifts-head { text-align: center; margin-bottom: 0.8em; }
.tv-gifts-head h1 { font-size: 2.6em; margin: 0.1em 0 0.2em; }
.tv-gifts-who { color: var(--gold); }
.gift-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11vw, 1fr)); gap: 1vw;
  list-style: none; padding: 0 0 7vh; margin: 0;
}
.gift-grid li { display: grid; }
.gift-grid .gift { min-height: 15vh; font-size: 0.85em; }
.gift-grid .gift.is-picked { padding-bottom: 2.4em; }
.tv-prize { text-align: center; font-size: 1.4em; margin: -0.6em 0 1.2em; }
.tv-final { max-width: 84vw; }
.tv-final h1 { font-size: 2.2em; margin-bottom: 0.1em; }
.tv-final .tv-champion { font-size: 3.4em; margin-bottom: 0.3em; }
.tv-final .tv-prize { font-size: 1.2em; margin-bottom: 0.8em; }
.tv-final .board { grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(var(--rows), auto); column-gap: 1em; }
.tv-final .board { gap: 0.35em 1em; }
.tv-final .board-row { font-size: 0.95em; padding: 0.2em 0.8em; }
.tv-prize strong { color: var(--gold); }

.play-gifts { display: grid; gap: 12px; margin-top: 12px; }
.play-gifts .gift { min-height: 110px; font-size: 1.05rem; }
.play-gift { font-size: 1.3rem; font-weight: 800; margin-top: 1em; }
.play-prize { font-size: 1.3rem; font-weight: 800; color: var(--gold); }

/* Motion, for those who don't ask for less. */
@media (prefers-reduced-motion: no-preference) {
  .tv-question-text, .play-wait > * { animation: pop 0.35s ease-out both; }
  @keyframes pop { from { opacity: 0; transform: translateY(12px); } }

  .bulb::after { animation: twinkle 2.4s ease-in-out infinite; }
  .bulb:nth-child(3n)::after { animation-duration: 3.1s; animation-delay: -1.2s; }
  .bulb:nth-child(3n + 1)::after { animation-duration: 1.9s; animation-delay: -0.6s; }
  @keyframes twinkle { 50% { opacity: 0.45; box-shadow: 0 0 0.2em 0 var(--c); } }

  .snow i { animation: fall var(--d) linear var(--delay) infinite; }
  @keyframes fall { to { transform: translate(3vw, 112vh) rotate(200deg); } }
}
@media (prefers-reduced-motion: reduce) {
  .snow { display: none; }
}
