/* BINGO! — direction artistique pop-art / bande dessinée. */

:root {
  --ink: #141414;
  --paper: #fff8ec;
  --yellow: #ffd21f;
  --orange: #ff8a00;
  --red: #e6222e;
  --red-deep: #9c1019;
  --blue: #57a8ff;
  --blue-pale: #dceeff;
  --white: #ffffff;
  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  /* trame de points demi-teinte */
  background-image: radial-gradient(rgba(20, 20, 20, 0.13) 1.6px, transparent 1.7px);
  background-size: 14px 14px;
  min-height: 100dvh;
}

.hidden { display: none !important; }

h1, h2, h3, .comic, .btn, .logo-text {
  font-family: "Bangers", "Nunito", cursive;
  font-weight: 400;
  letter-spacing: 1.5px;
}

/* ---------- Topbar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: var(--border);
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}
#game-meta { font-weight: 800; }

/* ---------- Logo : étoile + BINGO! ---------- */
.logo {
  position: relative;
  width: 72px;
  height: 72px;
  flex: none;
}
.logo .star svg { width: 100%; height: 100%; display: block; }
.logo-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  transform: rotate(-8deg);
  background: linear-gradient(180deg, #ff6b5e, var(--red-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px var(--ink);
  filter: drop-shadow(1.5px 2px 0 var(--ink));
}
.logo-big {
  width: min(60vw, 240px);
  height: min(60vw, 240px);
  margin: 8px auto 4px;
}
.logo-big .logo-text { font-size: clamp(2rem, 12vw, 3.4rem); }

main { padding: 14px; max-width: 1080px; margin: 0 auto; }

.screen { display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* ---------- Panneaux ---------- */
.panel {
  background: var(--white);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  width: 100%;
}
.panel h2 { margin: 0 0 10px; font-size: 1.6rem; transform: rotate(-1deg); }

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 720px;
}
@media (min-width: 720px) {
  .panels { grid-template-columns: 1fr 1fr; }
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 960px;
  align-items: start;
}
@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

/* ---------- Formulaires ---------- */
label { display: block; margin-bottom: 10px; font-weight: 800; }
label.chk { display: flex; align-items: center; gap: 8px; }
input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  font: inherit;
  font-weight: 700;
  border: var(--border);
  border-radius: 10px;
  background: var(--white);
}
input.code { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-size: 1.3rem; }

.error { color: var(--red-deep); font-weight: 800; min-height: 1.2em; text-align: center; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block;
  font-size: 1.25rem;
  padding: 10px 20px;
  margin-top: 6px;
  color: var(--ink);
  background: var(--yellow);
  border: var(--border);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn-pow {
  background: var(--yellow);
  color: var(--ink);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.hint { color: #555; font-size: 0.9rem; }

/* ---------- Grille ---------- */
.grid {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}
.cell-input {
  min-width: 0;
  width: 100%;
  height: 100px;
  resize: none;
  padding: 6px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  border: var(--border);
  border-radius: 10px;
  box-shadow: 3px 3px 0 rgba(20, 20, 20, 0.85);
  background: var(--white);
}
.cell-input.free {
  background: var(--yellow);
  font-family: "Bangers", cursive;
  letter-spacing: 1px;
}

/* ---------- Cases de jeu ---------- */
.cell {
  position: relative;
  min-width: 0;
  min-height: 100px;
  border: var(--border);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 3px 3px 0 rgba(20, 20, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 17px 4px 6px;
  cursor: pointer;
  font: inherit;
  overflow: hidden;
}
button.cell:active { transform: scale(0.97); }
.cell-label {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  font-weight: 800;
  font-size: clamp(0.75rem, 2.6vw, 0.95rem);
  line-height: 1.15;
  text-align: center;
  word-break: normal;
  overflow-wrap: anywhere;
}
.cell.checked {
  background: var(--blue-pale);
}
.cell.free {
  background: var(--yellow);
  cursor: default;
}
.cell.free .cell-label { font-family: "Bangers", cursive; letter-spacing: 1px; }

/* Tampon POW sur les cases cochées */
.stamp {
  position: absolute;
  inset: 8%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Bangers", cursive;
  font-size: clamp(0.9rem, 4vw, 1.5rem);
  color: var(--white);
  text-shadow: 1px 2px 0 var(--ink);
  background: radial-gradient(circle at 35% 30%, var(--red) 0%, var(--red-deep) 100%);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  transform: rotate(-12deg);
  animation: stamp-pop 0.28s cubic-bezier(0.2, 2.4, 0.4, 1);
  pointer-events: none;
}
@keyframes stamp-pop {
  0% { transform: rotate(-40deg) scale(2.4); opacity: 0; }
  70% { transform: rotate(-8deg) scale(0.92); opacity: 1; }
  100% { transform: rotate(-12deg) scale(1); }
}

/* ---------- Joueurs ---------- */
.players { list-style: none; margin: 0 0 12px; padding: 0; }
.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--white);
  font-weight: 800;
}
.player.me { background: #fff3bf; }
.badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ready { background: var(--blue); }
.badge.writing { background: var(--yellow); }

/* ---------- Classement ---------- */
.ranking { margin: 0 0 12px; padding-left: 28px; font-weight: 800; }
.ranking li { padding: 2px 0; }
.ranking li.winner {
  font-family: "Bangers", cursive;
  font-size: 1.5rem;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #ff6b5e, var(--red-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px var(--ink);
}
.ranking-big {
  list-style-position: inside;
  padding-left: 0;
  box-shadow: var(--shadow);
  border: var(--border);
  border-radius: 16px;
  background: var(--white);
  width: 100%;
  max-width: 420px;
}
.panel-inline { display: block; }

#final-grids {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 960px;
}
.mini-grid-panel { box-shadow: 4px 4px 0 var(--ink); }
.mini-title { margin: 0 0 8px; font-size: 1.3rem; }
.grid-mini { gap: 4px; max-width: none; }
.cell.mini {
  box-shadow: 2px 2px 0 rgba(20, 20, 20, 0.8);
  border-width: 2px;
  border-radius: 6px;
  height: auto;
}
.cell.mini .cell-label { font-size: 0.6rem; }

.comic-title {
  font-size: clamp(2.2rem, 10vw, 4rem);
  transform: rotate(-2deg);
  background: linear-gradient(180deg, #ff6b5e, var(--red-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
  filter: drop-shadow(4px 5px 0 rgba(20, 20, 20, 0.85));
  text-align: center;
}

/* ---------- Explosion BINGO ! ---------- */
#bingo-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background:
    radial-gradient(ellipse at center, rgba(255, 248, 236, 0.25) 0%, rgba(20, 20, 20, 0.55) 100%);
}
#bingo-overlay.shake { animation: screen-shake 0.4s linear; }
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-10px, 6px); }
  40% { transform: translate(8px, -8px); }
  60% { transform: translate(-6px, -5px); }
  80% { transform: translate(6px, 7px); }
}

#bingo-star-slot {
  position: absolute;
  width: min(100vw, 900px);
  aspect-ratio: 1.5;
  animation: star-in 0.45s cubic-bezier(0.2, 1.8, 0.4, 1);
  pointer-events: none;
}
#bingo-star-slot img { width: 100%; height: 100%; object-fit: contain; }
@keyframes star-in {
  0% { transform: scale(2.6) rotate(20deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(-4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

#bingo-text {
  position: relative;
  font-family: "Bangers", cursive;
  font-size: clamp(4rem, 24vw, 11rem);
  letter-spacing: 3px;
  transform: rotate(-6deg);
  background: linear-gradient(180deg, #ff8a7a 0%, var(--red) 45%, var(--red-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 4px var(--ink);
  filter: drop-shadow(7px 9px 0 rgba(20, 20, 20, 0.9));
  animation: bingo-in 0.55s cubic-bezier(0.2, 1.7, 0.4, 1);
}
@keyframes bingo-in {
  0% { transform: scale(3.2) rotate(-20deg); opacity: 0; }
  55% { transform: scale(0.9) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-6deg); }
}

#bingo-winner {
  position: relative;
  margin-top: 10px;
  background: var(--white);
  border: var(--border);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 22px;
  font-weight: 800;
  font-size: 1.05rem;
  transform: rotate(-2deg);
  animation: bingo-in 0.55s 0.1s cubic-bezier(0.2, 1.7, 0.4, 1) backwards;
}

/* Traits radiaux derrière l'explosion illustrée. */
.speedlines {
  position: absolute;
  inset: 0;
  background: repeating-conic-gradient(from 8deg, transparent 0deg 12deg, rgba(255, 248, 236, .18) 12deg 13deg, transparent 13deg 24deg);
  pointer-events: none;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) rotate(-1deg);
  z-index: 60;
  background: var(--ink);
  color: var(--white);
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 12px;
  border: 3px solid var(--white);
  box-shadow: 4px 4px 0 rgba(20, 20, 20, 0.5);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #bingo-overlay.shake { animation: none; }
  .stamp { display: none; }
}

/* Couverture et cartouches de la planche. */
body { background-image: radial-gradient(rgba(20, 20, 20, .07) 1px, transparent 1.2px); }
main { padding: 24px 18px 40px; }
.home-cover { width: 100%; max-width: 820px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); align-items: center; gap: 12px; }
.cover-copy { text-align: center; }
.issue-label { display: inline-block; padding: 5px 12px; border: 2px solid var(--ink); background: var(--ink); color: var(--paper); font-size: .75rem; letter-spacing: 2px; }
.cover-copy h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 8px 0; letter-spacing: 1px; }
.cover-copy h1 span { color: var(--red-deep); }
.cover-copy p { margin: 8px 0; }
.cover-caption { font-size: .85rem; color: #555; }
.logo-big { width: 190px; height: 190px; }
.mascot { display: block; width: 100%; height: auto; object-fit: contain; pointer-events: none; }
.mascot-welcome { max-width: 340px; justify-self: center; }
.panel { min-width: 0; border-radius: 7px; padding: 20px; }
.panel h2 { margin-bottom: 18px; }
.panel .panel-tag { display: table; padding: 7px 14px; background: var(--yellow); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); transform: rotate(-2deg); }
.panel .tag-blue, .btn-blue { background: var(--blue); }
#form-join { background: #eef7ff; }
#form-create .btn, #form-join .btn { width: 100%; }
label.chk input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--blue); }
:focus-visible { outline: 3px solid #095bb0; outline-offset: 4px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.lobby-companion { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.lobby-companion .mascot { width: 100px; }
.speech-bubble { background: var(--paper); border: 2px solid var(--ink); border-radius: 16px 16px 16px 0; padding: 12px; font-family: Bangers, cursive; font-size: 1.4rem; }
.cell.checked:not(.free)::after { content: "✓"; position: absolute; top: 0; right: 3px; font-size: .8rem; color: #095bb0; font-weight: 800; pointer-events: none; }
.cell.mini { min-height: 54px; padding: 10px 3px 3px; }
.cell.mini .cell-label { font-size: .7rem; }
.player .p-name { overflow-wrap: anywhere; min-width: 0; }
.player { flex-wrap: wrap; }
.mascot-victory { width: min(55vw, 230px); margin-top: -14px; }
.ranking-big { padding: 18px; }
.ranking-big li { padding: 10px; border-bottom: 2px solid var(--ink); }
.ranking-big li:last-child { border-bottom: 0; }
.ranking-big li.winner { background: var(--yellow); color: var(--ink); -webkit-text-stroke: 0; }
#bingo-winner { max-width: calc(100vw - 36px); text-align: center; border-radius: 8px; }
#btn-dismiss-bingo { position: relative; margin-top: 20px; background: var(--paper); }
#bingo-text { -webkit-text-stroke-width: 2px; }
#go-effect { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; font-family: Bangers, cursive; font-size: clamp(6rem, 28vw, 13rem); color: var(--yellow); -webkit-text-stroke: 3px var(--ink); text-shadow: 6px 6px 0 var(--ink); animation: bingo-in .35s ease-out; }
@media (max-width: 600px) {
  main { padding: 16px 12px 32px; }
  .home-cover { grid-template-columns: minmax(0, 1fr) 105px; gap: 0; }
  .logo-big { width: 135px; height: 135px; }
  .logo-big .logo-text { font-size: 2.3rem; }
  .issue-label { font-size: .6rem; letter-spacing: 1px; }
  .cover-copy h1 { font-size: 1.65rem; }
  .cover-copy p { font-size: .85rem; }
  .cover-caption { display: none; }
  .panel { padding: 12px; }
  .grid { gap: 4px; }
  .cell { min-height: 110px; border-width: 2px; border-radius: 5px; box-shadow: 2px 2px 0 var(--ink); }
  .cell-input { height: 110px; font-size: .8rem; border-width: 2px; border-radius: 5px; }
  #topbar { padding: 6px 10px; }
  #game-meta { min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  #go-effect { animation: none; }
  #bingo-text, #bingo-winner, #bingo-star-slot { animation: none; }
}

/* Propositions partagées et mascotte visible pendant la partie. */
.proposal-form { padding-bottom: 18px; border-bottom: 2px dashed var(--ink); }
.proposal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.proposal-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 2px solid var(--ink); border-radius: 6px; padding: 10px; }
.proposal-list li > div { min-width: 0; overflow-wrap: anywhere; }
.proposal-author { display: block; color: #555; margin-top: 3px; }
#proposal-progress { font-weight: 800; }
.game-companion { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.game-companion .mascot { width: 140px; }
.lobby-companion .mascot { width: 140px; }
@media (max-width: 600px) {
 .proposal-list li { flex-wrap: wrap; }
 .game-companion .mascot, .lobby-companion .mascot { width: 120px; }
}
