/* =====================================================================
   MAXI CHRISTMAS — Direction artistique « Riso Party »
   Affiche de fête imprimée en risographie : papier crème, encre indigo,
   quatre encres fluo, contours épais, ombres portées franches, trames.
   Tout nouveau jeu doit se construire avec ces variables et composants.
   ===================================================================== */

@font-face { font-family: 'Bagel'; src: url('/fonts/bagel/bagel-fat-one-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage/bricolage-grotesque-latin-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Bricolage'; src: url('/fonts/bricolage/bricolage-grotesque-latin-ext-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: 'DM Mono'; src: url('/fonts/dmmono/dm-mono-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  /* Papier & encre */
  --paper: #f7f0e1;
  --paper-2: #ece1c8;
  --card: #fffaf0;
  --ink: #1d1765;
  --ink-soft: #625d94;
  /* Les 4 encres fluo + l'orange des grandes occasions */
  --pink: #ff3d7f;
  --blue: #2f5bff;
  --yellow: #ffc21a;
  --green: #00b97f;
  --orange: #ff6b2c;
  /* Une encre par catégorie de jeu */
  --cat-reflexion: var(--blue);
  --cat-mecanique: var(--pink);
  --cat-random: var(--yellow);
  --cat-pubs: var(--green);

  --font-display: 'Bagel', 'Arial Black', sans-serif;
  --font-body: 'Bricolage', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, Consolas, monospace;

  --line: 3px solid var(--ink);
  --radius: 20px;
  --shadow: 5px 5px 0 var(--ink);
  --halftone: radial-gradient(circle at center, var(--ink) 1.3px, transparent 1.6px);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .11 0 0 0 0 .09 0 0 0 0 .4 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: 17px; line-height: 1.45; color: var(--ink);
  background: var(--grain), var(--paper);
  overflow-x: hidden;
}
/* Grandes formes d'encre en fond de page */
body::before, body::after {
  content: ''; position: fixed; z-index: -1; pointer-events: none; mix-blend-mode: multiply;
}
body::before {
  width: 46vmax; height: 46vmax; left: -14vmax; top: -16vmax; border-radius: 50%;
  background: var(--yellow); opacity: .55;
}
body::after {
  width: 40vmax; height: 40vmax; right: -12vmax; bottom: -14vmax;
  background: var(--halftone) 0 0 / 11px 11px; opacity: .22;
  -webkit-mask: radial-gradient(circle, #000 35%, transparent 70%); mask: radial-gradient(circle, #000 35%, transparent 70%);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1; margin: 0; letter-spacing: .01em; }
p { margin: 0 0 .8em; }
a { color: var(--blue); font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--pink); color: #fff; }

/* ---------- Titres « mal calés » façon riso ---------- */
.riso { color: var(--ink); text-shadow: .055em .055em 0 var(--pink); }
.riso-yellow { text-shadow: .055em .055em 0 var(--yellow); }
.logo { font-family: var(--font-display); font-size: 30px; line-height: .9; display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo b { font-weight: 400; color: var(--pink); text-shadow: 2px 2px 0 var(--yellow); }
.logo .star { width: 34px; height: 34px; background: var(--blue); animation: spin 14s linear infinite;
  clip-path: polygon(50% 0, 61% 27%, 85% 15%, 73% 39%, 100% 50%, 73% 61%, 85% 85%, 61% 73%, 50% 100%, 39% 73%, 15% 85%, 27% 61%, 0 50%, 27% 39%, 15% 15%, 39% 27%); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border: var(--line); border-radius: 14px; cursor: pointer;
  background: var(--yellow); color: var(--ink); font-weight: 800; font-size: 17px; text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s; user-select: none;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--ink); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .cell:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.btn-pink { background: var(--pink); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); }
.btn-ghost { background: var(--card); }
.btn-big { font-family: var(--font-display); font-weight: 400; font-size: 28px; padding: 16px 38px; border-radius: 18px; letter-spacing: .03em; }
.btn-small { padding: 6px 12px; font-size: 14px; border-width: 2px; border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); }
.btn-small:hover { box-shadow: 4px 4px 0 var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ---------- Cartes, étiquettes ---------- */
.card { background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border: 2px solid var(--ink); border-radius: 99px;
  background: var(--c, var(--card)); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.sticker {
  display: inline-block; padding: 4px 12px; background: var(--yellow); border: 2px solid var(--ink); border-radius: 8px;
  font-family: var(--font-display); font-size: 15px; transform: rotate(-4deg); box-shadow: 2px 2px 0 var(--ink);
}
[data-cat='reflexion'] { --c: var(--cat-reflexion); --on-c: #fff; }
[data-cat='mecanique'] { --c: var(--cat-mecanique); --on-c: #fff; }
[data-cat='random'] { --c: var(--cat-random); --on-c: var(--ink); }
[data-cat='pubs'] { --c: var(--cat-pubs); --on-c: var(--ink); }
.chip[data-cat] { color: var(--on-c); }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.mono { font-family: var(--font-mono); }

/* ---------- Formulaires ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], input[type=time], select {
  width: 100%; padding: 11px 14px; border: var(--line); border-radius: 12px; background: #fff; font-weight: 600;
}
input::placeholder { color: #a9a5c9; font-weight: 500; }

/* ---------- Tableaux de classement ---------- */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 7px 12px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 700;
}
.board .rk { font-family: var(--font-display); font-size: 18px; text-align: center; }
.board .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .val { font-family: var(--font-mono); font-size: 15px; }
.board li.me { background: var(--ink); color: var(--paper); }
.board li:nth-child(1) .rk { color: var(--orange); }
.board li.me .rk { color: var(--yellow); }
.board-empty { padding: 14px; border: 2px dashed var(--ink-soft); border-radius: 12px; color: var(--ink-soft); text-align: center; font-weight: 600; }

/* ---------- Fenêtres (popup de jeu, dialogues) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; overflow-y: auto;
  background: var(--halftone) 0 0 / 9px 9px, rgba(29, 23, 101, .72); animation: fade .15s;
}
.modal { width: min(1000px, 100%); background: var(--card); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 10px 10px 0 var(--pink); overflow: hidden; animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 24px; background: var(--c, var(--yellow)); color: var(--on-c, var(--ink)); border-bottom: 4px solid var(--ink); }
.modal-head h2 { font-size: clamp(28px, 4vw, 44px); flex: 1; text-shadow: 3px 3px 0 var(--ink); }
[data-cat='random'] .modal-head h2, [data-cat='pubs'] .modal-head h2, .modal-head:not([data-cat]) h2 { text-shadow: 3px 3px 0 #fff; }
.modal-body { padding: 24px; }
.close-x { width: 42px; height: 42px; border: var(--line); border-radius: 50%; background: var(--card); color: var(--ink); font-size: 20px; font-weight: 900; cursor: pointer; flex: none; line-height: 1; }
.close-x:hover { background: var(--ink); color: var(--paper); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9) rotate(-1.5deg); opacity: 0; } }

/* ---------- Messages éphémères ---------- */
#toasts { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 10px; width: min(480px, calc(100vw - 32px)); pointer-events: none; }
.toast { padding: 12px 18px; border: var(--line); border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 700; box-shadow: 4px 4px 0 var(--yellow); animation: pop .25s; }
.toast.error { background: var(--pink); color: #fff; box-shadow: 4px 4px 0 var(--ink); }
.toast.ok { background: var(--green); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }

/* ---------- Scène de jeu (plein écran) : commune à tous les jeux ---------- */
.stage { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: var(--grain), var(--paper); animation: fade .2s; }
.stage-bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 4px solid var(--ink); background: var(--c, var(--yellow)); color: var(--on-c, var(--ink)); z-index: 5; }
.stage-bar h2 { font-size: 26px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-body { position: relative; flex: 1; overflow: auto; }
.result-panel { max-width: 560px; margin: 6vh auto; text-align: center; }
.result-panel .score { font-family: var(--font-display); font-size: clamp(54px, 10vw, 96px); line-height: 1; margin: 12px 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
