/* Tape-Clowns — chapiteau rayé en haut, bandeau score/temps, plateau 3x3,
   voile de départ par-dessus le plateau, classement en ligne en dessous.
   Polices : celles de l'appareil pour l'instant (aucune requête vers Google).
   Les polices d'origine (Bowlby One, Nunito) seront hébergées sur le site. */
:root {
  --night: #13262d;
  --floor: #1d3a42;
  --mound: #6b4a2f;
  --mound-top: #8f6842;
  --hole: #071014;
  --red: #e0402f;
  --tent: #f5ede0;
  --gold: #f4b62e;
  --blue: #2f6fd0;
  --pink: #ff7aa8;
  --orange: #ff8a3d;
  --ink: #f5ede0;
  --muted: #9db3b6;
  --veil: rgba(10, 22, 27, 0.84);
  --display: "Bowlby One", "Arial Black", Impact, "Helvetica Neue", sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: var(--gold); }
a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.canopy {
  height: 22px;
  background: repeating-linear-gradient(90deg, var(--red) 0 26px, var(--tent) 26px 52px);
  border-bottom: 4px solid var(--gold);
  margin-top: env(safe-area-inset-top, 0px);
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding-block: 12px 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Lien de retour vers le hub et solde de pièces */
.retour {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
  font-size: 14px;
}
.retour a { text-decoration: none; padding: 6px 0; }
.solde {
  background: var(--floor);
  border-radius: 99px;
  padding: 5px 12px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2rem, 9vw, 2.7rem);
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--tent);
  text-shadow: 0 3px 0 var(--red);
  text-wrap: balance;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.hud > div {
  background: var(--floor);
  border-radius: 12px;
  padding: 8px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lab {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud b {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
#timerCell.low b { color: var(--red); }

.bar {
  height: 8px;
  border-radius: 99px;
  background: var(--floor);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gold);
  transition: width 0.1s linear;
}
.bar.low i { background: var(--red); }

.board {
  position: relative;
  background: var(--floor);
  border-radius: 18px;
  padding: 10px;
  overflow: hidden;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.hole {
  --face: var(--tent);
  --hair: var(--orange);
  --hat: var(--blue);
  --brim: #1f4a99;
  --nose: var(--red);
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hole.gold {
  --face: #fff3c4;
  --hair: #ffffff;
  --hat: var(--gold);
  --brim: #b8860b;
}
.hole.bad {
  --face: #cfd5d6;
  --hair: #2a2a33;
  --hat: #17171c;
  --brim: var(--red);
  --nose: #17171c;
}
.back {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 6%;
  height: 32%;
  border-radius: 50%;
  background: var(--hole);
  border: 4px solid var(--mound-top);
}
.win {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  bottom: 18%;
  overflow: hidden;
}
.clown {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 82%;
  transform: translate(-50%, 106%);
  transform-origin: 50% 100%;
  transition: transform 0.14s ease-out;
}
.hole.up .clown { transform: translate(-50%, 0); }
.hole.up.hit .clown { transform: translate(-50%, 4%) rotate(-7deg) scale(0.94, 0.86); }
.hole.gold .clown { filter: drop-shadow(0 0 7px rgba(244, 182, 46, 0.85)); }
.hole.bad .clown { filter: drop-shadow(0 0 7px rgba(224, 64, 47, 0.8)); }
.hole.mole .clown { filter: drop-shadow(0 0 8px rgba(255, 159, 181, 0.9)); }
.clown .mo { display: none; }
.hole.mole .clown .cl { display: none; }
.hole.mole .clown .mo { display: block; }
.mo-ear, .mo-head { fill: #a38572; }
.mo-in { fill: #f3a9bb; }
.mo-paw { fill: #f3a9bb; stroke: #a38572; stroke-width: 2; }
.mo-blush { fill: #ff7aa8; opacity: 0.45; }
.mo-snout { fill: #f6c3cf; }
.mo-nose { fill: #e0668a; }
.mo-shine { fill: #ffffff; opacity: 0.8; }
.mo-eyes { fill: #1a1410; }
.mo-glint { fill: #ffffff; }
.mo-xeyes { display: none; fill: none; stroke: #1a1410; stroke-width: 3.2; stroke-linecap: round; }
.mo-mouth { fill: none; stroke: #7a3b4d; stroke-width: 2.4; stroke-linecap: round; }
.mo-tooth { fill: #ffffff; }
.hole.hit .mo-eyes { display: none; }
.hole.hit .mo-xeyes { display: block; }
.lip {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 6%;
  height: 18%;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  background: linear-gradient(var(--mound-top), var(--mound));
}

.clown svg { display: block; width: 100%; height: auto; overflow: visible; }
.face { fill: var(--face); }
.hair { fill: var(--hair); }
.hat { fill: var(--hat); }
.brim { fill: var(--brim); }
.pom { fill: var(--red); }
.nose { fill: var(--nose); }
.ruffle { fill: var(--red); }
.cheek { fill: var(--pink); opacity: 0.55; }
.mouth { fill: none; stroke: var(--red); stroke-width: 5; stroke-linecap: round; }
.eyes { fill: #1a1410; }
.hole.bad .eyes { fill: #ff3b2a; }
.brows { display: none; fill: none; stroke: #1a1410; stroke-width: 4.5; stroke-linecap: round; }
.mouth-bad { display: none; fill: #17171c; stroke: var(--red); stroke-width: 2; stroke-linejoin: round; }
.hole.bad .brows, .hole.bad .mouth-bad { display: block; }
.hole.bad .mouth { display: none; }
.xeyes { display: none; fill: none; stroke: #1a1410; stroke-width: 3.2; stroke-linecap: round; }
.stars { display: none; fill: var(--gold); }
.stars path { transform-box: fill-box; transform-origin: center; animation: spin 0.5s linear infinite; }
.hole.hit .eyes { display: none; }
.hole.hit .xeyes { display: block; }
.hole.hit .stars { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.pts {
  position: absolute;
  left: 50%;
  top: 14%;
  z-index: 3;
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: rise 0.65s ease-out forwards;
}
@keyframes rise {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -36px); }
}
.pts.neg { color: var(--red); }
.board.shake { animation: shake 0.3s linear; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--veil);
  display: flex;
  align-items: center;
  padding: 16px;
  overflow: auto;
}
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  max-width: 290px;
  width: 100%;
  margin: auto;
}
.card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.05;
  text-wrap: balance;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.4;
}
.card .gainline { color: var(--gold); font-weight: 800; }
.card button, .card .bouton {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 1.25rem;
  color: #2b1d00;
  background: var(--gold);
  border: 0;
  border-radius: 99px;
  padding: 12px 34px;
  box-shadow: 0 4px 0 #a97a10;
  cursor: pointer;
  text-decoration: none;
}
.card button:disabled { opacity: 0.6; cursor: progress; }
.card button:active:not(:disabled), .card .bouton:active { transform: translateY(2px); box-shadow: 0 2px 0 #a97a10; }
.card button:focus-visible, .card .bouton:focus-visible { outline: 3px solid var(--tent); outline-offset: 3px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mute {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--floor);
  color: var(--tent);
  cursor: pointer;
}
.mute svg { width: 24px; height: 24px; }
.mute .slash { display: none; stroke: var(--red); }
.mute.off { color: var(--muted); }
.mute.off .slash { display: block; }
.mute:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.rank { display: flex; flex-direction: column; gap: 10px; }
.rank h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.35rem;
}
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--floor);
  border-radius: 10px;
  padding: 8px 12px;
}
.row.me { background: #2a4f58; box-shadow: inset 0 0 0 2px var(--gold); }
.row .n {
  font-family: var(--display);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.row.premier .n { color: var(--gold); }
.row .p {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .s {
  font-family: var(--display);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.sep { text-align: center; color: var(--muted); font-weight: 800; line-height: 1; }
.empty { color: var(--muted); font-weight: 600; padding: 10px 2px; }
.note { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.4; }

.foot {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.legal {
  border-top: 1px solid var(--floor);
  padding-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.legal p { margin: 0; flex-basis: 100%; }

@media (prefers-reduced-motion: reduce) {
  .clown { transition-duration: 0.01s; }
  .pts { animation-duration: 0.01s; }
  .stars path { animation: none; }
  .board.shake { animation: none; }
  .bar i { transition: none; }
}
