/* Bingo Navet — tout le CSS vit ici (rien d'inline : la CSP reste « style-src 'self' »). */
:root {
  --night:  #1b1124;  /* fond : salle de cinéma */
  --card:   #2a1b36;
  --line:   #4a3360;
  --cream:  #f6efe4;  /* cases et texte principal */
  --ink:    #2a1b36;  /* texte sur crème */
  --mist:   #cbbbd8;  /* texte secondaire, contraste ≥ 4.5:1 sur --night */
  --violet: #7a3fae;  /* cases cochées (blanc dessus ≥ 6:1) */
  --navet:  #9b4dca;
  --green:  #5cc85f;
  --gold:   #ffcf5a;  /* pop-corn : bouton principal */
  --danger: #ff8a80;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% -20%, #3a2350 0%, var(--night) 60%) fixed, var(--night);
  color: var(--cream);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
.hidden { display: none !important; }
.screen { max-width: 720px; margin: 0 auto; padding: 8px 16px 40px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
h2 { margin: 18px 0 4px; font-size: 1.25rem; color: var(--gold); }
h3 { margin: 14px 0 0; font-size: 1rem; color: var(--mist); font-weight: 600; }
.muted { color: var(--mist); font-size: 0.9rem; line-height: 1.5; margin: 0; }
.small { font-size: 0.8rem; }
.signature { text-align: center; padding: 8px 16px 24px; font-size: 0.9rem; }
.signature a { white-space: nowrap; color: var(--mist); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.signature a:hover, .signature a:focus-visible { color: var(--gold); border-color: var(--gold); }
.guide { margin: 0; font-size: 0.9rem; }
.guide a { color: var(--gold); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.guide a:hover, .guide a:focus-visible { border-color: var(--gold); }
.signature .sep { color: var(--mist); }
.signature p { margin: 0; }
.signature .version { margin-top: 10px; color: var(--mist); font-size: 16px; letter-spacing: 0.08em; }
.signature .copy { margin-top: 6px; font-size: 13px; }

/* --- Interrupteur de langue, en haut à droite de chaque écran */
.lang-bar { max-width: 900px; margin: 0 auto; padding: 12px 16px 0; display: flex; justify-content: flex-end; }
.lang-switch { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; background: var(--card); padding: 3px; gap: 2px; }
.btn.lang-btn {
  border: 0; border-radius: 999px; min-height: 32px; padding: 4px 12px; font-size: 0.85rem; font-weight: 700;
  color: var(--mist); background: transparent; letter-spacing: 0.04em;
}
.btn.lang-btn.on { background: var(--gold); color: var(--ink); }
.btn.lang-btn:not(.on):hover { color: var(--cream); }

/* --- Marque */
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand .logo { width: 84px; height: 84px; animation: wobble 3.5s ease-in-out infinite; transform-origin: 50% 90%; }
.brand h1 { margin: 0; font-size: clamp(2.2rem, 9vw, 3.4rem); letter-spacing: 0.02em; color: var(--cream); text-shadow: 0 3px 0 var(--navet), 0 0 24px rgba(155, 77, 202, 0.5); }
.brand.small .logo { width: clamp(52px, 13vw, 68px); height: clamp(52px, 13vw, 68px); animation: none; }
.brand.small .title { font-size: clamp(1.7rem, 7vw, 2.3rem); font-weight: 800; color: var(--cream); text-shadow: 0 2px 0 var(--navet), 0 0 18px rgba(155, 77, 202, 0.45); }
.tagline { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 1.1rem; margin: 0 0 10px; max-width: 30rem; }
@keyframes wobble { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

/* --- Boutons : un seul « plein » par écran (leçon 6.17.0 de la tour) */
.btn {
  border: 1.5px solid var(--gold); border-radius: 12px; padding: 10px 18px; min-height: 44px;
  font: 600 1rem system-ui, sans-serif; cursor: pointer; background: transparent; color: var(--gold);
}
.btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn.big { font-size: 1.15rem; padding: 14px 30px; }
.btn.link { border: 0; background: none; color: var(--mist); text-decoration: underline; min-height: 0; padding: 6px; font-weight: 400; font-size: 0.9rem; }
.btn:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn.chip { border-color: var(--line); color: var(--cream); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 500; font-size: 0.95rem; }
.btn.chip:hover { border-color: var(--gold); }
.discord-card {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 30rem; margin-top: 18px; padding: 14px 16px;
  border: 1.5px solid #5865f2; border-radius: 14px; background: linear-gradient(135deg, rgba(88, 101, 242, 0.22), rgba(155, 77, 202, 0.18));
  color: var(--cream); text-decoration: none; text-align: left; transition: transform 0.15s, box-shadow 0.15s;
}
.discord-card:hover, .discord-card:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(88, 101, 242, 0.35); outline: none; }
.discord-icon { font-size: 1.8rem; flex: none; }
.discord-txt { display: flex; flex-direction: column; gap: 2px; flex: 1; font-size: 0.88rem; color: var(--mist); line-height: 1.4; }
.discord-txt strong { color: var(--cream); font-size: 1rem; }
.discord-go { font-size: 1.3rem; color: #aab4ff; flex: none; }
.how { text-align: left; max-width: 30rem; margin: 0; padding-left: 1.3rem; line-height: 1.6; }

/* --- Éditeur */
.editor { align-items: stretch; text-align: left; }
.editor .brand, .editor > h2 { align-self: center; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; color: var(--mist); font-size: 0.9rem; }
input[type=text], textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--cream);
  font: 1rem system-ui, sans-serif; padding: 10px 12px;
}
textarea { resize: vertical; line-height: 1.5; min-height: 200px; }
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--gold); }
input:disabled { opacity: 0.5; }
.seg { display: flex; gap: 6px; }
.btn.seg-btn { flex: 1; border-color: var(--line); color: var(--cream); }
.btn.seg-btn.on { border-color: var(--gold); color: var(--gold); background: rgba(255, 207, 90, 0.1); }
.free-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.free-row input[type=text] { flex: 1; min-width: 12rem; width: auto; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-weight: 600; color: var(--mist); font-size: 0.9rem; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.emojis { display: grid; grid-template-columns: repeat(14, 42px); gap: 4px; overflow-x: auto; padding-bottom: 2px; } /* 3 lignes ; défile sur téléphone */
.btn.emo { border: 1px solid var(--line); background: var(--card); padding: 4px 0; min-height: 38px; width: 42px; font-size: 1.2rem; border-radius: 8px; }
.count { margin: 0; font-size: 0.9rem; }
.count.ok { color: var(--green); }
.count.warn { color: var(--mist); }
.error { color: var(--danger); margin: 0; min-height: 1.2em; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.editor .btn.link { align-self: center; }
.editor .chips { justify-content: flex-start; }
.editor > .btn.link.hidden + * { margin-top: 0; }

/* --- Invitation */
.big-title { font-size: 1.8rem; color: var(--cream); margin: 0; }

/* --- Partie (mode soirée : la grille prend tout l'écran du téléphone) */
.screen.play { padding-top: 4px; gap: 8px; max-width: 900px; }
.play-head { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.play-title { margin: 0; font-size: clamp(1.15rem, 4.5vw, 1.45rem); color: var(--gold); }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.btn.tool { border-color: var(--line); color: var(--cream); background: var(--card); width: 46px; padding: 0; font-size: 1.15rem; }
.grid { display: grid; gap: 6px; width: min(100%, 78vh, 720px); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.grid.g5 { grid-template-columns: repeat(5, 1fr); }
.cell {
  position: relative; aspect-ratio: 1; border: 0; border-radius: 10px; padding: 3px; cursor: pointer;
  background: var(--cream); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 600 clamp(0.6rem, 2.6vw, 0.95rem)/1.12 system-ui, sans-serif; overflow: hidden; overflow-wrap: anywhere; hyphens: auto;
  box-shadow: 0 3px 0 #c9bba6; transition: transform 0.12s, background 0.15s;
}
.g4 .cell { font-size: clamp(0.72rem, 3.2vw, 1.05rem); }
.g3 .cell { font-size: clamp(0.85rem, 4.2vw, 1.2rem); }
.cell.fit { container-type: size; gap: 3%; font-weight: 700; line-height: 1.08; }
.cell .emo { position: relative; z-index: 1; line-height: 1; font-weight: 400; }
.cell:active { transform: scale(0.96); }
.cell.on { background: var(--violet); color: #fff; box-shadow: 0 3px 0 #4f2475; }
.cell.on::after { /* tampon */
  content: ''; position: absolute; inset: 10%; border: 3px solid rgba(255, 207, 90, 0.75); border-radius: 50%;
  transform: rotate(-12deg); animation: stamp 0.25s ease-out; pointer-events: none;
}
.cell.won { box-shadow: 0 3px 0 #4f2475, 0 0 0 3px var(--gold); }
.cell.free { background: #e6f4df; color: var(--ink); cursor: default; box-shadow: 0 3px 0 #a9c99c; }
.cell.free::after { display: none; }
.cell.free .free-navet { width: 46%; height: 46%; flex: none; }
.cell .txt { position: relative; z-index: 1; }
.status { margin: 4px 0 0; color: var(--mist); font-size: 0.9rem; }
@keyframes stamp { from { transform: rotate(-12deg) scale(1.6); opacity: 0; } to { transform: rotate(-12deg) scale(1); opacity: 1; } }

/* --- Fenêtres : victoire, impression, lien */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(12, 6, 18, 0.84); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay-box { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 24px 20px; max-width: 26rem; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.overlay-box h2 { margin: 0; }
.win .overlay-box { background: none; border: 0; }
.win-navet { width: 140px; height: 140px; animation: hop 0.6s ease-in-out infinite alternate; }
.win-word { font-size: clamp(2.4rem, 12vw, 4.2rem); font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 var(--navet); animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
.tier3 .win-word { color: var(--cream); text-shadow: 0 4px 0 var(--navet), 0 0 30px var(--gold); }
.win-sub { margin: 0; font-size: 1.05rem; }
@keyframes hop { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-18px) rotate(6deg); } }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confetti { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.confetti .bit { position: absolute; top: -60px; width: 34px; height: 34px; font-size: 28px; line-height: 1; animation-name: fall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes fall { to { transform: translateY(calc(100vh + 80px)) rotate(var(--spin, 360deg)); } }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 40; transform: translate(-50%, 40px); opacity: 0;
  background: var(--cream); color: var(--ink); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  transition: transform 0.2s, opacity 0.2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.pyment-banner {
  position: fixed; inset: 0 0 auto 0; z-index: 5; padding: 8px 12px; text-align: center;
  background: #3a2a10; color: var(--cream); font: 0.8rem system-ui, sans-serif;
}
.pyment-share { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.pyment-share button, .pyment-share a {
  background: var(--card); border: 1px solid var(--line); color: var(--cream);
  border-radius: 8px; padding: 8px 14px; font: 0.85rem system-ui, sans-serif; text-decoration: none; cursor: pointer;
}

/* --- Impression : seules les grilles sortent, deux par page A4 */
.print-area { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; color: #000; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; }
  .print-card { break-inside: avoid; page-break-inside: avoid; height: 135mm; display: flex; flex-direction: column; align-items: center; }
  .print-card h2 { color: #000; margin: 0 0 3mm; font-size: 14pt; }
  .print-card .grid { width: 112mm; gap: 1.5mm; }
  .print-card .cell { border: 0.4mm solid #000; box-shadow: none; background: #fff; color: #000; font-size: 7.5pt; border-radius: 2mm; }
  .print-card .g3 .cell { font-size: 11pt; }
  .print-card .g4 .cell { font-size: 9pt; }
  .print-card .cell.free { background: #f0f0f0; }
  .print-foot { font-size: 8pt; color: #555; margin: 2mm 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 480px) { /* téléphone : grille plus large, cases plus pleines */
  .screen.play { padding-left: 8px; padding-right: 8px; }
  .grid { gap: 4px; }
  .cell { padding: 2px; border-radius: 8px; }
}
