:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #e2e8f0;
  background:
    radial-gradient(circle at 50% -12%, rgba(23, 128, 90, 0.24), transparent 55%),
    radial-gradient(circle at 10% 8%, rgba(59, 130, 246, 0.12), transparent 45%),
    radial-gradient(circle at 90% 96%, rgba(201, 162, 39, 0.13), transparent 45%),
    linear-gradient(180deg, #0c1424 0%, #0a0f1b 58%, #070b14 100%);
  background-attachment: fixed;
}

header,
main,
footer {
  width: min(90%, 960px);
  margin: 0 auto;
}

header,
footer {
  padding: 1rem 0;
  text-align: center;
  color: #cbd5e1;
}

main {
  margin-top: 3rem;
  margin-bottom: 3rem;
  padding: 2.5rem;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(15, 23, 42, 0.74)),
    radial-gradient(circle at 50% 0%, rgba(23, 128, 90, 0.16), transparent 55%);
  border-radius: 16px;
  border: 1px solid rgba(201, 162, 39, 0.18);
  box-shadow:
    0 24px 54px -28px rgba(0, 0, 0, 0.78),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.message {
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
}

.message-info {
  background: #e0f2fe;
  color: #075985;
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.35);
}

.message-success {
  background: #dcfce7;
  color: #166534;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.35);
}

.message-warning {
  background: #fef9c3;
  color: #92400e;
  box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.35);
}

.message-error {
  background: rgba(220, 38, 38, 0.15);
  color: #e2e8f0;
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35);
}

h1,
h2,
h3 {
  font-weight: 600;
  margin-top: 0;
  color: #f8fafc;
}

p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

a {
  color: #fbbf24;
  text-decoration: none;
  font-weight: 500;
}

a:hover,
a:focus {
  text-decoration: underline;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #17805a, #0f5e40);
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  box-shadow: 0 14px 30px -18px rgba(16, 185, 129, 0.8);
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 2px rgba(201, 162, 39, 0.22),
    0 16px 35px -20px rgba(16, 185, 129, 0.85);
}

button:active,
.button:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  background: #475569;
  color: rgba(226, 232, 240, 0.65);
  box-shadow: none;
}

.easter-egg-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0.5rem;
  border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.9);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  z-index: 999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.easter-egg-toggle:hover,
.easter-egg-toggle:focus {
  transform: translateY(-1px);
  box-shadow: 0 22px 46px -24px rgba(15, 23, 42, 0.8);
}

.easter-egg-toggle:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.85);
  outline-offset: 2px;
}

.easter-egg-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.play-action-container {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.table-bottom-actions {
  width: min(100%, 820px);
  margin: clamp(1.25rem, 4vw, 2.25rem) auto clamp(1.5rem, 5vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 1.15rem);
  text-align: center;
}

.table-bottom-actions__error {
  width: 100%;
  flex: 1 0 100%;
  color: #b91c1c;
  font-weight: 600;
}

.table-bottom-actions__error:empty {
  display: none;
}

.table-bottom-actions .play-action-container {
  margin-bottom: 0;
  align-items: center;
  gap: 0.75rem;
}

.action-btn.collect-highlight {
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.58), 0 18px 36px -18px rgba(245, 158, 11, 0.55);
  filter: brightness(1.08);
}

ul {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  gap: 0.75rem;
}

ul li {
  background: rgba(15, 23, 42, 0.62);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

ul li a {
  display: inline-block;
  font-weight: 600;
}

#players li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  border-left: 4px solid transparent;
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

#players li strong {
  flex: 0 0 auto;
}

#players li .status {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 0.5rem;
  margin-right: auto;
  background: rgba(148, 163, 184, 0.2);
  color: #334155;
}

#players li .ready-btn {
  flex: 0 0 auto;
  margin-left: auto;
}

#players li.player-ready {
  background: #ecfdf5;
  border-left-color: #10b981;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.25);
}

#players li.player-waiting {
  background: #fff7ed;
  border-left-color: #f97316;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.2);
}

#players li.player-ready .status {
  background: rgba(16, 185, 129, 0.2);
  color: #047857;
}

#players li.player-waiting .status {
  background: rgba(249, 115, 22, 0.2);
  color: #b45309;
}

#players li.current-turn {
  border-left-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25), inset 0 0 0 1px rgba(37, 99, 235, 0.15);
}

#players li.current-turn strong {
  color: #1d4ed8;
}

/* --- Cartes à jouer : faces réalistes ---------------------------------- */
.card-visual {
  position: relative;
  width: 96px;
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(150deg, #ffffff 0%, #fdfcf7 55%, #f3f0e7 100%);
  color: #111827;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 18px 30px -15px rgba(30, 41, 59, 0.7);
}

.card-visual.red {
  color: #dc2626;
}

.playing-card {
  container-type: size;
  overflow: hidden;
}

.pc-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-weight: 700;
  gap: 1px;
  gap: 1cqw;
}

.pc-corner--top {
  top: 4px;
  left: 5px;
  top: 4cqw;
  left: 5cqw;
}

.pc-corner--top-right {
  top: 4px;
  right: 5px;
  top: 4cqw;
  right: 5cqw;
}

.pc-corner--bottom {
  bottom: 4px;
  right: 5px;
  bottom: 4cqw;
  right: 5cqw;
  transform: rotate(180deg);
}

.pc-corner--bottom-left {
  bottom: 4px;
  left: 5px;
  bottom: 4cqw;
  left: 5cqw;
  transform: rotate(180deg);
}

.pc-corner-rank {
  font-size: 0.9rem;
  font-size: 15cqw;
  letter-spacing: -0.02em;
}

.pc-corner-suit {
  font-size: 0.8rem;
  font-size: 13cqw;
}

.pc-center {
  position: absolute;
  inset: 0;
}

.pc-pip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 1.3rem;
  font-size: 21cqw;
  line-height: 1;
}

.pc-pip--flip {
  transform: translate(-50%, -50%) rotate(180deg);
}

.pc-ace {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  font-size: 52cqw;
  text-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

.pc-court {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pc-court-frame {
  width: 62%;
  height: 64%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2%;
  border: 2px solid currentColor;
  border-radius: 8px;
  border-radius: 6cqw;
  background:
    linear-gradient(135deg, rgba(212, 175, 55, 0.22), rgba(212, 175, 55, 0) 45%),
    repeating-linear-gradient(45deg, rgba(15, 23, 42, 0.05) 0 3px, transparent 3px 9px);
}

.pc-court-letter {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-size: 32cqw;
  font-weight: 700;
  line-height: 1;
}

.pc-court-suit {
  font-size: 1rem;
  font-size: 15cqw;
  line-height: 1;
}

.error-message,
.messages .error,
.messages .errorlist,
.errorlist {
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.15);
  color: #e2e8f0;
  border: 1px solid rgba(220, 38, 38, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.errorlist li {
  background: transparent;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

form {
  display: grid;
  gap: 1rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(2, 6, 23, 0.42);
  color: #f8fafc;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #c9a227;
  background: rgba(2, 6, 23, 0.58);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.22);
}

/* --- Game table layout -------------------------------------------------- */

#table,
.table {
  --table-gold-ring: 0 0 0 3px #c9a227;
  --table-wood-ring: 0 0 0 clamp(10px, 2vw, 16px) #53331c;
  --table-wood-edge: 0 0 0 calc(clamp(10px, 2vw, 16px) + 2px) rgba(15, 23, 42, 0.4);
  position: relative;
  margin: clamp(2.5rem, 7vw, 4rem) auto;
  width: min(100%, 820px);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: clamp(1.75rem, 5vw, 3.25rem);
  /* Feutrine de casino, éclairée par le haut, avec rebord acajou et liseré doré */
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%),
    radial-gradient(circle at 50% 50%, #17805a 0%, #0f5e40 52%, #07402a 82%, #052e1e 100%);
  box-shadow:
    var(--table-gold-ring),
    var(--table-wood-ring),
    var(--table-wood-edge),
    inset 0 0 70px rgba(0, 0, 0, 0.45),
    0 34px 80px -34px rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: box-shadow 0.35s ease, filter 0.35s ease;
}

#table::before,
.table::before {
  content: "";
  position: absolute;
  inset: clamp(1.25rem, 4vw, 2.4rem);
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.38);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

#player-decks {
  position: absolute;
  inset: clamp(0.75rem, 6vw, 3rem);
  pointer-events: none;
}

#player-decks .player-deck {
  --deck-padding-y: clamp(0.45rem, 1.4vw, 0.85rem);
  --deck-padding-x: clamp(0.6rem, 2vw, 1.15rem);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  width: clamp(120px, 32vw, 214px);
  min-height: calc(clamp(68px, 18vw, 96px) + var(--deck-padding-y) * 2);
  padding: var(--deck-padding-y) var(--deck-padding-x);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.86);
  color: #f8fafc;
  box-shadow: 0 22px 38px -26px rgba(15, 23, 42, 0.8);
  pointer-events: auto;
  z-index: 5;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

#player-decks .player-deck .deck-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(0.5rem, 1.6vw, 0.95rem);
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  height: 100%;
}

#player-decks .player-deck.current-turn {
  /* Halo jaune-orange bien visible, avec pulsation, pour la personne qui doit
     jouer. (La valeur statique sert aussi de repli en mouvement réduit.) */
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.9),
    0 0 22px 4px rgba(249, 115, 22, 0.6),
    0 28px 60px -26px rgba(249, 115, 22, 0.5);
  transform: translate(-50%, -50%) scale(1.05);
  animation: turnHaloPulse 1.35s ease-in-out infinite;
}

@keyframes turnHaloPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(251, 191, 36, 0.9),
      0 0 20px 3px rgba(249, 115, 22, 0.55),
      0 28px 60px -26px rgba(249, 115, 22, 0.5);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(253, 224, 71, 1),
      0 0 34px 8px rgba(249, 115, 22, 0.8),
      0 28px 60px -26px rgba(249, 115, 22, 0.5);
  }
}

#player-decks .player-deck.current-turn:hover,
#player-decks .player-deck.current-turn:focus-within {
  transform: translate(-50%, -50%) scale(1.06);
}

#player-decks .player-deck.current-turn .deck-count {
  color: #fde68a;
}

#player-decks .player-deck.player-deck-solo {
  left: 50%;
  top: 78%;
  transform: translate(-50%, -50%);
}

#player-decks .player-deck:hover,
#player-decks .player-deck:focus-within {
  box-shadow: 0 26px 52px -28px rgba(59, 130, 246, 0.55);
  transform: translate(-50%, -50%) scale(1.03);
}

#player-decks .player-deck.player-deck-self-clickable {
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, outline 0.2s ease;
}

#player-decks .player-deck.player-deck-self-clickable:focus {
  outline: none;
}

#player-decks .player-deck.player-deck-self-clickable:hover,
#player-decks .player-deck.player-deck-self-clickable:focus-visible {
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.6),
    0 30px 68px -28px rgba(245, 158, 11, 0.55),
    0 22px 38px -26px rgba(15, 23, 42, 0.72);
  transform: translate(-50%, -50%) scale(1.07);
}

#player-decks .player-deck.player-deck-self-clickable:focus-visible {
  outline: 3px solid rgba(251, 191, 36, 0.9);
  outline-offset: 6px;
}

#player-decks .player-deck.player-deck-self-clickable:active {
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.55),
    0 24px 54px -30px rgba(245, 158, 11, 0.5),
    0 22px 38px -26px rgba(15, 23, 42, 0.68);
  transform: translate(-50%, -50%) scale(1.02);
}

#player-decks .player-deck .deck-card {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  height: 100%;
}

#player-decks .player-deck .deck-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  flex: 1 1 auto;
  text-align: left;
  min-width: 0;
}

#player-decks .player-deck h3 {
  margin: 0;
  font-size: clamp(0.95rem, 2.3vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: inherit;
  line-height: 1.3;
}

#player-decks .player-deck .deck-count {
  margin: 0;
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  color: rgba(226, 232, 240, 0.8);
  font-weight: 500;
  line-height: 1.3;
}

/* Dos de carte : bleu royal, croisillons dorés et cadre intérieur */
.card-back {
  position: relative;
  width: clamp(56px, 16vw, 84px);
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  background-color: #1e3a8a;
  background-image:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 62%),
    repeating-linear-gradient(45deg, rgba(201, 162, 39, 0.32) 0 1.5px, transparent 1.5px 9px),
    repeating-linear-gradient(-45deg, rgba(201, 162, 39, 0.32) 0 1.5px, transparent 1.5px 9px);
  border: 3px solid #f8fafc;
  box-shadow: 0 12px 25px -12px rgba(15, 23, 42, 0.9);
}

.card-back::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 8px;
  border: 1.5px solid rgba(201, 162, 39, 0.75);
  pointer-events: none;
}

/* Épaisseur du paquet : plus un joueur a de cartes, plus la pile est haute */
.deck-card {
  position: relative;
}

.deck-card[data-stack="0"] .card-back {
  opacity: 0.5;
  filter: grayscale(0.5);
  box-shadow: none;
}

.deck-card[data-stack="2"] .card-back {
  box-shadow:
    -4px 3px 0 -1px #e2e8f0,
    -4px 3px 0 0 rgba(15, 23, 42, 0.45),
    0 12px 25px -12px rgba(15, 23, 42, 0.9);
}

.deck-card[data-stack="3"] .card-back {
  box-shadow:
    -4px 3px 0 -1px #e2e8f0,
    -4px 3px 0 0 rgba(15, 23, 42, 0.45),
    -8px 6px 0 -1px #cbd5e1,
    -8px 6px 0 0 rgba(15, 23, 42, 0.35),
    0 12px 25px -12px rgba(15, 23, 42, 0.9);
}

.deck-card .player-avatar {
  position: absolute;
  top: -8px;
  left: -10px;
  z-index: 2;
  box-shadow: 0 3px 8px -2px rgba(15, 23, 42, 0.5);
}

.deck-count-badge {
  position: absolute;
  bottom: -6px;
  right: -8px;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.78rem;
  box-shadow: 0 4px 10px -4px rgba(15, 23, 42, 0.7);
}

.slap-overlay {
  position: absolute;
  inset: clamp(0.65rem, 3.5vw, 2rem);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  pointer-events: none;
  z-index: 20;
  padding: clamp(1rem, 4vw, 1.75rem);
  gap: clamp(0.45rem, 2vw, 0.75rem);
  opacity: 0;
}

.slap-overlay-visible {
  opacity: 1;
}

.slap-overlay-content {
  display: grid;
  gap: clamp(0.4rem, 1.8vw, 0.7rem);
  max-width: clamp(220px, 58%, 320px);
}

.slap-overlay-content h3 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.how-to-play-button {
  position: fixed;
  bottom: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  z-index: 150;
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  background: linear-gradient(135deg, #17805a, #0f5e40);
  box-shadow: 0 24px 44px -20px rgba(16, 185, 129, 0.65);
}

.how-to-play-button:hover,
.how-to-play-button:focus-visible {
  box-shadow:
    0 0 0 4px rgba(201, 162, 39, 0.18),
    0 28px 50px -22px rgba(16, 185, 129, 0.65);
}

.how-to-play-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 5vw, 2.75rem);
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
  z-index: 200;
}

.how-to-play-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease, visibility 0s linear 0s;
}

.how-to-play-dialog {
  position: relative;
  width: min(100%, 640px);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.97), rgba(15, 23, 42, 0.93)),
    radial-gradient(circle at 24% 0%, rgba(23, 128, 90, 0.18), transparent 50%);
  color: #e2e8f0;
  border-radius: 22px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid rgba(201, 162, 39, 0.2);
  box-shadow: 0 32px 70px -34px rgba(0, 0, 0, 0.9);
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}

.how-to-play-dialog::-webkit-scrollbar {
  width: 0.55rem;
}

.how-to-play-dialog::-webkit-scrollbar-track {
  background: transparent;
}

.how-to-play-dialog::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.how-to-play-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: #f8fafc;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: none;
}

.how-to-play-close:hover,
.how-to-play-close:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  color: #fbbf24;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.22);
}

.how-to-play-dialog h2 {
  margin: 0 0 0.75rem 0;
  font-size: clamp(1.65rem, 4vw, 2.1rem);
}

.how-to-play-dialog h3 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.2rem, 3.2vw, 1.45rem);
  color: #fbbf24;
}

.how-to-play-section + .how-to-play-section {
  margin-top: 1.75rem;
  padding-top: 1.35rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.how-to-play-section p {
  margin-bottom: 0.85rem;
}

.how-to-play-dialog ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.how-to-play-dialog li {
  position: relative;
  padding: 0.85rem 1rem 0.85rem 1.9rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.56);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.how-to-play-dialog li::before {
  content: "";
  position: absolute;
  top: 1.05rem;
  left: 0.95rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #c9a227);
}

.how-to-play-dialog strong {
  color: #f8fafc;
}

.how-to-play-dialog code {
  font-family: "Fira Code", "SFMono-Regular", "Consolas", monospace;
  background: rgba(2, 6, 23, 0.55);
  color: #fde68a;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  font-size: 0.95em;
}

.how-to-play-dialog p:last-child {
  margin-bottom: 0;
}

.slap-overlay-winner {
  margin: 0;
  font-size: clamp(1rem, 2.6vw, 1.2rem);
}

.slap-overlay-winner strong {
  color: #fbbf24;
  font-weight: 700;
}

.slap-overlay-candidates-title {
  margin: 0.15rem 0 0;
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.85);
}

.slap-overlay-candidates {
  margin: 0.25rem auto 0;
  padding-left: 1.25rem;
  text-align: left;
  font-size: clamp(0.9rem, 2.1vw, 1.05rem);
  color: rgba(248, 250, 252, 0.95);
}

.slap-overlay-candidates li {
  margin: 0.15rem 0;
}

.slap-overlay-candidates li.is-winner {
  color: #fbbf24;
  font-weight: 600;
}


.slap-overlay-animate {
  animation: slapOverlayReveal 1.6s ease-in-out forwards;
}

.room-options-access {
  margin: 1.5rem 0 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.room-options-trigger {
  padding-inline: 1.6rem;
  padding-block: 0.7rem;
  font-size: 1rem;
}

.room-options-trigger--readonly,
.room-options-trigger--readonly:hover,
.room-options-trigger--readonly:focus {
  cursor: help;
}

.room-options-trigger-hint {
  font-size: 0.9rem;
  color: #94a3b8;
}

body.room-options-lock {
  overflow: hidden;
}

.room-options-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.room-options-modal[hidden] {
  display: none !important;
}

.room-options-modal--open {
  display: flex;
}

.room-options-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.room-options-modal__panel {
  position: relative;
  width: min(90vw, 520px);
  max-height: 90vh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.97), rgba(15, 23, 42, 0.93)),
    radial-gradient(circle at 24% 0%, rgba(23, 128, 90, 0.16), transparent 50%);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 2.2rem 2.4rem;
  border: 1px solid rgba(201, 162, 39, 0.2);
  box-shadow: 0 28px 48px -24px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.room-options-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.room-options-modal__close {
  background: none;
  color: #f8fafc;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.45rem;
  line-height: 1;
  box-shadow: none;
}

.room-options-modal__close:hover,
.room-options-modal__close:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  color: #fbbf24;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.22);
}

.room-options-intro {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.room-options-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.room-options-form--readonly .room-options-switch,
.room-options-form--readonly .room-options-counter {
  opacity: 0.75;
}

.room-options-note {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.room-options-note.is-hidden {
  display: none;
}

.room-options-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.room-options-section__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fbbf24;
}

.room-options-choices {
  display: grid;
  gap: 0.9rem;
}

.room-options-choices[hidden],
.room-options-choices[data-deck-count-container][hidden] {
  display: none !important;
}

.room-options-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 0.8rem;
}

.room-options-choice input {
  margin-top: 1.05rem;
  transform: scale(1.1);
}

.room-options-choice__texts {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.56);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  color: #e2e8f0;
}

.room-options-choice__label {
  font-weight: 600;
  color: inherit;
}

.room-options-choice__description {
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.45;
}

.room-options-choice input:checked + .room-options-choice__texts {
  border-color: #c9a227;
  background: rgba(23, 128, 90, 0.2);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.14);
  color: #f8fafc;
}

.room-options-choice input:checked + .room-options-choice__texts .room-options-choice__description {
  color: #d1fae5;
}

.room-options-choice input:focus-visible + .room-options-choice__texts {
  border-color: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.24);
}

.room-options-switches {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.room-options-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.56);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.room-options-switch__texts {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: clamp(55%, 60%, 70%);
}

.room-options-switch__label {
  font-weight: 600;
  color: #f8fafc;
}

.room-options-switch__description {
  font-size: 0.85rem;
  color: #94a3b8;
}

.room-options-switch__control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.room-options-switch__control input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.room-options-switch__slider {
  width: 3rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.55);
  position: relative;
  transition: background 0.2s ease;
}

.room-options-switch__slider::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  left: 0.25rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.room-options-switch__control input:checked + .room-options-switch__slider {
  background: linear-gradient(135deg, #17805a, #0f5e40);
}

.room-options-switch__control input:checked + .room-options-switch__slider::after {
  transform: translateX(1.35rem);
}

.room-options-switch__control input:disabled + .room-options-switch__slider {
  background: rgba(148, 163, 184, 0.32);
  cursor: not-allowed;
}

.room-options-switch__control input:disabled + .room-options-switch__slider::after {
  box-shadow: none;
}

.room-options-counters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.room-options-counter {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.56);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.room-options-counter__content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.room-options-counter__texts {
  flex: 1 1 240px;
  min-width: min(240px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.room-options-counter__label {
  font-weight: 600;
  color: #f8fafc;
}

.room-options-counter__description {
  font-size: 0.85rem;
  color: #94a3b8;
}

.room-options-counter__settings {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.room-options-counter__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
}

.room-options-counter__toggle-label {
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.room-options-counter__controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(2, 6, 23, 0.48);
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
  transition: opacity 0.2s ease;
}

.room-options-counter__btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(135deg, #17805a, #0f5e40);
  box-shadow: 0 12px 26px -18px rgba(16, 185, 129, 0.8);
}

.room-options-counter__btn:disabled,
.room-options-form--readonly .room-options-counter__btn {
  cursor: not-allowed;
  background: #475569;
  box-shadow: none;
}

.room-options-counter__value {
  min-width: 2.4rem;
  text-align: center;
  font-weight: 600;
  color: #fde68a;
  background: rgba(15, 23, 42, 0.72);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.room-options-counter--sudden-death {
  background: linear-gradient(180deg, rgba(127, 29, 29, 0.42), rgba(15, 23, 42, 0.64));
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.28);
}

.room-options-counter--sudden-death .room-options-counter__toggle-label {
  color: #b91c1c;
}

.room-options-counter--sudden-death .room-options-counter__controls {
  opacity: 0.45;
}

.room-options-counter--sudden-death .room-options-counter__value {
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.62);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
}

.room-options-form--readonly .room-options-counter__toggle {
  cursor: default;
}

.room-options-footer {
  margin: 0;
  font-size: 0.85rem;
  color: #475569;
}

.room-options-modal--readonly .room-options-counter__controls,
.room-options-modal--readonly .room-options-switch__control {
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .room-options-modal__panel {
    width: 92vw;
    padding: 1.6rem 1.75rem;
  }

  .room-options-switch {
    flex-direction: column;
    align-items: flex-start;
  }

  .room-options-switch__texts {
    max-width: 100%;
  }

  .room-options-switch__control {
    width: 100%;
    justify-content: flex-end;
  }

  .room-options-counter__content {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .room-options-counter__texts {
    flex-basis: auto;
    min-width: 0;
  }

  .room-options-counter__settings {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .room-options-counter__toggle {
    justify-content: space-between;
  }

  .room-options-counter__controls {
    align-self: flex-end;
  }
}

#player-decks .player-deck.slap-deck-error {
  animation: slapDeckError 0.55s ease-out;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.45), 0 22px 38px -26px rgba(15, 23, 42, 0.8);
}

#center-pile {
  position: relative;
  width: clamp(118px, 28vw, 240px);
  height: clamp(150px, 30vw, 208px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  color: #e2e8f0;
  text-align: center;
  padding: 0.75rem;
  transition: box-shadow 0.35s ease, background 0.35s ease;
}

.center-pile-clickable {
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.center-pile-clickable:hover,
.center-pile-clickable:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45),
    0 22px 38px -26px rgba(37, 99, 235, 0.55);
}

.center-pile-clickable:focus-visible {
  outline: none;
}

#penalty-pile {
  position: absolute;
  /* Placé dans la zone libre en bas à droite : les adversaires occupent l'arc
     supérieur et le joueur local le bas-centre, donc rien ne le chevauche. */
  top: 66%;
  left: 72%;
  transform: translate(-50%, -50%);
  width: clamp(72px, 16vw, 96px);
  height: clamp(104px, 22vw, 132px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#penalty-pile.penalty-empty {
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.18);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

#penalty-pile .penalty-count {
  position: absolute;
  bottom: 4px;
  right: 8px;
  color: #f8fafc;
  font-weight: 600;
  font-size: 0.9rem;
}

#center-pile p {
  margin: 0;
}

#center-pile.center-empty {
  color: #cbd5f5;
}

#center-pile.pending-collect {
  background: rgba(245, 158, 11, 0.18);
  color: #fef3c7;
  box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.45), 0 0 0 4px rgba(253, 230, 138, 0.18);
}

#center-pile.slap-pending::after {
  content: '';
  position: absolute;
  inset: -0.45rem;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.4);
  animation: slapPendingBorderPulse 1.6s ease-in-out infinite;
}

.center-pile {
  position: relative;
  width: 100%;
  height: 100%;
}

.center-pile .card-visual {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(92px, 24vw, 132px);
  box-shadow: 0 24px 36px -24px rgba(15, 23, 42, 0.9);
  transition: transform 0.3s ease;
}

/* Cartes enfouies (identité inconnue du client) : légèrement assombries, elles
   ne montrent que leur tranche pour donner l'épaisseur du tas. */
.center-pile .card-visual.center-card--buried {
  filter: brightness(0.9);
}

/* Arrivée d'une nouvelle carte sur le tas */
.center-pile .card-enter {
  animation: cardEnter 0.32s cubic-bezier(0.2, 0.8, 0.3, 1.1);
}

@keyframes cardEnter {
  from {
    transform: translate(-50%, -90%) scale(1.14);
    opacity: 0;
  }
}

@keyframes slapOverlayReveal {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  12% {
    opacity: 1;
    transform: scale(1);
  }
  80% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.96);
  }
}

@keyframes slapDeckError {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  20% {
    transform: translate(calc(-50% - 6px), calc(-50% + 2px));
  }
  40% {
    transform: translate(calc(-50% + 6px), calc(-50% - 2px));
  }
  60% {
    transform: translate(calc(-50% - 5px), calc(-50% + 1px));
  }
  80% {
    transform: translate(calc(-50% + 4px), calc(-50% - 1px));
  }
}

@keyframes slapPendingBorderPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.32);
    opacity: 0.85;
  }
  60% {
    box-shadow: 0 0 0 14px rgba(250, 204, 21, 0.14);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0);
    opacity: 0.85;
  }
}

/* Le halo de réussite passe par un filtre pour préserver le rebord de la table. */
@keyframes slapSuccessPulse {
  0% {
    filter: drop-shadow(0 0 0 rgba(16, 185, 129, 0.7));
  }
  55% {
    filter: drop-shadow(0 0 34px rgba(16, 185, 129, 0.6));
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(16, 185, 129, 0));
  }
}

@keyframes slapFailShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-10px);
  }
  40%,
  80% {
    transform: translateX(10px);
  }
}

#table.slap-pending,
.table.slap-pending {
  box-shadow:
    var(--table-gold-ring),
    var(--table-wood-ring),
    0 0 0 calc(clamp(10px, 2vw, 16px) + 5px) rgba(250, 204, 21, 0.45),
    inset 0 0 70px rgba(0, 0, 0, 0.45),
    0 0 46px -8px rgba(250, 204, 21, 0.55),
    0 34px 80px -34px rgba(15, 23, 42, 0.85);
}

#table.slap-pending::before,
.table.slap-pending::before {
  border-color: rgba(250, 204, 21, 0.68);
  box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.32);
  animation: slapPendingBorderPulse 1.6s ease-in-out infinite;
}

#table.slap-success,
.table.slap-success {
  animation: slapSuccessPulse 0.9s ease-out;
}

#table.slap-fail,
.table.slap-fail {
  animation: slapFailShake 0.42s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  #table.slap-success,
  .table.slap-success,
  #table.slap-fail,
  .table.slap-fail,
  #table.slap-pending,
  .table.slap-pending,
  #table.slap-pending::before,
  .table.slap-pending::before,
  #center-pile.slap-pending::after,
  .slap-overlay-animate,
  #player-decks .player-deck.slap-deck-error {
    animation: none;
  }
}

@media (max-width: 900px) {
  #table,
  .table {
    width: min(100%, 720px);
  }
}

@media (max-width: 720px) {
  #table,
  .table {
    width: 100%;
    padding: clamp(1.25rem, 6.5vw, 1.75rem);
  }

  #player-decks .player-deck {
    --deck-padding-y: clamp(0.45rem, 2.2vw, 0.75rem);
    --deck-padding-x: clamp(0.6rem, 3.6vw, 1rem);
    width: clamp(112px, 33vw, 152px);
  }

  #player-decks .player-deck .deck-content {
    gap: clamp(0.45rem, 2.6vw, 0.8rem);
  }

  .card-back {
    width: clamp(42px, 13vw, 60px);
  }

  /* Tas central plus compact sur mobile : il ne doit pas venir chevaucher les
     paquets du haut et du bas (notamment à deux joueurs). */
  #center-pile {
    width: clamp(96px, 24vw, 150px);
    height: clamp(118px, 30vw, 168px);
  }

  .center-pile .card-visual {
    width: clamp(74px, 19vw, 108px);
  }

  /* Sur mobile le nom reste sur une seule ligne pour que les paquets ne
     grandissent pas en hauteur et ne soient pas recouverts par la carte jouée. */
  #player-decks .player-deck .deck-name {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  /* Emplacement de pénalité plus discret tant qu'il est vide. */
  #penalty-pile {
    width: clamp(52px, 13vw, 74px);
    height: clamp(74px, 18vw, 102px);
  }

  #penalty-pile.penalty-empty {
    background: rgba(15, 23, 42, 0.12);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  }
}

@media (max-width: 540px) {
  #table,
  .table {
    margin: clamp(1.5rem, 5vw, 2rem) auto;
  }

  #player-decks .player-deck {
    --deck-padding-y: clamp(0.5rem, 4.8vw, 0.75rem);
    --deck-padding-x: clamp(0.65rem, 5.5vw, 1.05rem);
    width: clamp(120px, 58vw, 140px);
  }

  #player-decks .player-deck .deck-content {
    gap: clamp(0.45rem, 4vw, 0.75rem);
  }

  #player-decks .player-deck h3 {
    font-size: clamp(0.9rem, 4vw, 1rem);
  }

  #player-decks .player-deck .deck-count {
    font-size: clamp(0.8rem, 3.5vw, 0.9rem);
  }
}

@media (max-width: 640px) {
  main {
    padding: 1.75rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
  }

  button,
  .button {
    width: 100%;
  }

  .how-to-play-button {
    width: auto;
    min-width: 0;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    bottom: 1rem;
    right: 1rem;
  }

  .how-to-play-overlay {
    padding: 1.25rem;
  }

  .how-to-play-dialog {
    width: min(100%, 92vw);
    padding: 1.5rem;
    border-radius: 18px;
  }

  .how-to-play-close {
    top: 0.75rem;
    right: 0.75rem;
  }
}

/* The Hand Slap Animation */
.slap-hand-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 5rem;
  z-index: 999;
  pointer-events: none;
  animation: slapDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  margin-top: -3.5rem;
  margin-left: -2.5rem;
}

.slap-hand-effect.success { filter: drop-shadow(0 0 25px #10b981); }
.slap-hand-effect.fail { filter: drop-shadow(0 0 25px #ef4444); opacity: 0.85; }
/* Main neutre affichée immédiatement au moment où l'on tape. */
.slap-hand-effect.pending { filter: drop-shadow(0 0 22px rgba(248, 250, 252, 0.8)); }

@keyframes slapDown {
  0% {
    transform: scale(3.5) translateY(-40px);
    opacity: 0;
  }
  30% {
    transform: scale(0.9) translateY(5px);
    opacity: 1;
  }
  50% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 0;
  }
}

/* --- Bulle Info (?) --- */
.info-bubble-btn {
    position: fixed;
    bottom: clamp(1rem, 3vw, 2rem);
    left: clamp(1rem, 3vw, 2rem); /* Placé à gauche pour la symétrie avec ton easter-egg à droite ! */
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #475569, #1e293b);
    color: white;
    font-size: 1.6rem;
    font-weight: 700;
    border: none;
    box-shadow: 0 12px 25px -8px rgba(15, 23, 42, 0.7);
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.info-bubble-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.15);
    box-shadow: 0 18px 35px -8px rgba(15, 23, 42, 0.85);
}

/* --- Onglets de la Modale --- */
.info-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid rgba(148, 163, 184, 0.25);
    padding-bottom: 0.75rem;
}

.info-tab-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: none;
}

.info-tab-btn:hover {
    background: rgba(148, 163, 184, 0.14);
    color: #f8fafc;
    transform: none;
    box-shadow: none;
}

.info-tab-btn.active {
    color: #fbbf24;
    background: rgba(201, 162, 39, 0.14);
}

.credits-text {
    font-size: 1.25rem;
    color: #cbd5e1;
    margin-top: 1rem;
}

/* ======================================================================
   Refonte visuelle du jeu : composants ajoutés
   ====================================================================== */

body {
  color: #e2e8f0;
  background:
    radial-gradient(circle at 50% -12%, rgba(23, 128, 90, 0.24), transparent 55%),
    radial-gradient(circle at 10% 8%, rgba(59, 130, 246, 0.12), transparent 45%),
    radial-gradient(circle at 90% 96%, rgba(201, 162, 39, 0.13), transparent 45%),
    linear-gradient(180deg, #0c1424 0%, #0a0f1b 58%, #070b14 100%);
  background-attachment: fixed;
}

/* Ambiance casino sombre partagée par toutes les pages. */
body.game-room {
  color: #e2e8f0;
  background:
    radial-gradient(circle at 50% -12%, rgba(23, 128, 90, 0.24), transparent 55%),
    radial-gradient(circle at 10% 8%, rgba(59, 130, 246, 0.12), transparent 45%),
    radial-gradient(circle at 90% 96%, rgba(201, 162, 39, 0.13), transparent 45%),
    linear-gradient(180deg, #0c1424 0%, #0a0f1b 58%, #070b14 100%);
  background-attachment: fixed;
}

/* La page de jeu n'affiche pas la « carte » blanche de contenu : la table
   ronde repose directement sur le fond sombre. */
body.game-room main {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

body.game-room header,
body.game-room footer {
  color: #cbd5e1;
}

body.game-room header a,
body.game-room header h1 a {
  color: #f8fafc;
}

body.game-room .room-title {
  color: #f1f5f9;
}

/* Liste des joueurs (avant le lancement) accordée au fond sombre. */
body.game-room #players li {
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

body.game-room #players li.player-ready {
  background: rgba(16, 185, 129, 0.16);
  border-left-color: #10b981;
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.32);
}

body.game-room #players li.player-waiting {
  background: rgba(249, 115, 22, 0.15);
  border-left-color: #f97316;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.3);
}

body.game-room #players li .status {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

body.game-room #players li.player-ready .status {
  background: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
}

body.game-room #players li.player-waiting .status {
  background: rgba(249, 115, 22, 0.22);
  color: #fdba74;
}

body.game-room #players li.current-turn {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4), inset 0 0 0 1px rgba(59, 130, 246, 0.25);
}

body.game-room #players li.current-turn strong {
  color: #93c5fd;
}

/* --- Avatars des joueurs ------------------------------------------------ */
.player-avatar {
  --avatar-hue: 210;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: linear-gradient(
    140deg,
    hsl(var(--avatar-hue), 68%, 52%),
    hsl(var(--avatar-hue), 72%, 36%)
  );
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  user-select: none;
}

/* --- Titre de salle + code copiable ------------------------------------ */
.room-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.room-code-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.3rem 1rem;
  border-radius: 12px;
  background: #0f172a;
  color: #fbbf24;
  box-shadow: 0 10px 24px -14px rgba(15, 23, 42, 0.8);
  cursor: pointer;
}

.room-code-badge__code {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.room-code-badge__hint {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(226, 232, 240, 0.75);
}

.room-code-badge:hover .room-code-badge__hint,
.room-code-badge:focus-visible .room-code-badge__hint {
  color: #e2e8f0;
}

.room-code-badge.copied {
  background: #065f46;
  color: #d1fae5;
}

/* --- Bouton son (muet / actif) ------------------------------------------ */
.sound-toggle-btn {
  position: fixed;
  bottom: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #475569, #1e293b);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 25px -8px rgba(15, 23, 42, 0.7);
  z-index: 150;
}

.sound-toggle-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.sound-toggle-btn.sound-muted {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

.sound-toggle-btn svg {
  width: 1.5rem;
  height: 1.5rem;
  pointer-events: none;
}

/* --- Bouton d'aide : rappel des essais du défi figure -------------------- */
.face-hint-toggle-btn {
  position: fixed;
  /* Juste au-dessus du bouton de son (même colonne, en bas à droite). */
  bottom: calc(clamp(1rem, 3vw, 2rem) + 4.25rem);
  right: clamp(1rem, 3vw, 2rem);
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #b45309, #7c2d12);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 25px -8px rgba(15, 23, 42, 0.7);
  z-index: 150;
}

.face-hint-toggle-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.face-hint-toggle-btn.is-off {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

.face-hint-toggle-btn svg {
  width: 1.4rem;
  height: 1.4rem;
  pointer-events: none;
}

/* Masque entièrement la pop-up du défi figure (titre + rappel des essais). */
body.hide-face-hint .face-challenge-badge {
  display: none;
}

/* --- Nom du joueur sur son paquet --------------------------------------- */
/* Le nom s'affiche en entier (jusqu'à deux lignes) tant qu'il y a la place ;
   il n'est tronqué qu'en dernier recours. */
#player-decks .player-deck .deck-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* En mode compact (beaucoup de joueurs) on reste sur une seule ligne. */
#player-decks.decks-crowded .player-deck:not(.player-deck-self) .deck-name {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

#player-decks .player-deck.deck-empty {
  opacity: 0.55;
  filter: saturate(0.5);
}

#player-decks .player-deck.player-deck-self {
  background: rgba(15, 23, 42, 0.92);
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.35),
    0 22px 38px -26px rgba(15, 23, 42, 0.8);
}

/* Quand c'est NOTRE tour, notre propre paquet doit aussi porter le contour
   « tour en cours » : sans cette règle (3 classes, plus spécifique), l'anneau
   doré de .player-deck-self l'emportait et masquait l'indication de tour. */
#player-decks .player-deck.player-deck-self.current-turn {
  box-shadow:
    0 0 0 3px rgba(251, 191, 36, 0.9),
    0 0 22px 4px rgba(249, 115, 22, 0.6),
    0 28px 60px -26px rgba(249, 115, 22, 0.5);
}

/* Joueur attendu sur un défi figure */
#player-decks .player-deck.deck-challenged {
  animation: challengedPulse 1.15s ease-in-out infinite;
}

@keyframes challengedPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(249, 115, 22, 0.75),
      0 0 18px -4px rgba(249, 115, 22, 0.65),
      0 22px 38px -26px rgba(15, 23, 42, 0.8);
  }
  50% {
    box-shadow:
      0 0 0 5px rgba(249, 115, 22, 0.55),
      0 0 30px -2px rgba(249, 115, 22, 0.85),
      0 22px 38px -26px rgba(15, 23, 42, 0.8);
  }
}

/* --- Boutons du jeu ------------------------------------------------------ */
#slap-btn {
  background: linear-gradient(145deg, #ef4444, #b91c1c);
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.9rem 2.6rem;
  box-shadow: 0 16px 34px -16px rgba(220, 38, 38, 0.85);
}

#slap-btn:disabled {
  background: #fca5a5;
  box-shadow: none;
}

#slap-btn.slap-armed:not(:disabled) {
  animation: slapArmedPulse 1.3s ease-in-out infinite;
}

@keyframes slapArmedPulse {
  0%,
  100% {
    box-shadow:
      0 16px 34px -16px rgba(220, 38, 38, 0.85),
      0 0 0 0 rgba(239, 68, 68, 0.55);
  }
  55% {
    box-shadow:
      0 16px 34px -16px rgba(220, 38, 38, 0.85),
      0 0 0 14px rgba(239, 68, 68, 0);
  }
}

#play-card-btn {
  background: linear-gradient(145deg, #10b981, #047857);
  box-shadow: 0 16px 34px -16px rgba(16, 185, 129, 0.8);
  font-weight: 700;
}

#play-card-btn:disabled {
  background: #a7f3d0;
  color: rgba(6, 78, 59, 0.55);
  box-shadow: none;
}

/* --- Toast « À vous de jouer » ------------------------------------------ */
.turn-toast {
  position: absolute;
  top: 11%;
  left: 50%;
  z-index: 30;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #451a03;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  white-space: nowrap;
  box-shadow: 0 14px 30px -12px rgba(245, 158, 11, 0.8);
  pointer-events: none;
  animation: turnToastPop 2.2s cubic-bezier(0.2, 0.9, 0.3, 1.1) forwards;
}

@keyframes turnToastPop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px) scale(0.8);
  }
  12%,
  78% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px) scale(0.92);
  }
}

/* --- Confettis de victoire ----------------------------------------------- */
.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
  pointer-events: none;
  z-index: 40;
}

.confetti-piece {
  position: absolute;
  top: -14px;
  left: var(--x, 50%);
  width: var(--size, 8px);
  height: calc(var(--size, 8px) * 0.45);
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall var(--fall, 3s) linear var(--delay, 0s) forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0.85;
    transform: translateY(88vmin) rotate(var(--rot, 360deg));
  }
}

.winner-crown {
  font-size: clamp(2.6rem, 7vw, 4rem);
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(251, 191, 36, 0.55));
  animation: crownBounce 1.2s ease-in-out infinite alternate;
}

@keyframes crownBounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-8px);
  }
}

/* --- Badges du tas central ----------------------------------------------- */
.center-count-badge {
  position: absolute;
  /* Juste sous le tas : hors des cartes, et au-dessus du paquet du joueur du
     bas (qui est repoussé plus bas). */
  top: calc(100% + 0.3rem);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 600;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.78);
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 30;
}

.face-challenge-badge {
  position: absolute;
  top: -5.0rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  padding: 0.45rem 1.1rem;
  border-radius: 14px;
  background: rgba(69, 26, 3, 0.92);
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fde68a;
  white-space: nowrap;
  z-index: 15;
  box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.face-challenge-badge strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.face-challenge-badge span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff7ed;
}

/* --- Distribution en début de partie -------------------------------------- */
#table.game-starting .player-deck {
  animation: deckDeal 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.15) backwards;
}

#table.game-starting .player-deck:nth-child(2) { animation-delay: 0.08s; }
#table.game-starting .player-deck:nth-child(3) { animation-delay: 0.16s; }
#table.game-starting .player-deck:nth-child(4) { animation-delay: 0.24s; }
#table.game-starting .player-deck:nth-child(5) { animation-delay: 0.32s; }
#table.game-starting .player-deck:nth-child(6) { animation-delay: 0.4s; }
#table.game-starting .player-deck:nth-child(7) { animation-delay: 0.48s; }
#table.game-starting .player-deck:nth-child(8) { animation-delay: 0.56s; }

@keyframes deckDeal {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
}

/* --- Mode compact : beaucoup de joueurs / petits écrans ------------------- */
#player-decks.decks-crowded .player-deck:not(.player-deck-self) {
  width: clamp(92px, 24vw, 124px);
}

#player-decks.decks-crowded .player-deck:not(.player-deck-self) .card-back {
  width: clamp(38px, 9vw, 54px);
}

#player-decks.decks-crowded .player-deck:not(.player-deck-self) h3 {
  font-size: clamp(0.8rem, 2vw, 0.95rem);
}

@media (max-width: 720px) {
  /* Sur mobile, TOUS les paquets adverses adoptent le format compact, quel que
     soit le nombre de joueurs : le joueur local (en bas) reste seul en grand. */
  #player-decks .player-deck:not(.player-deck-self) {
    width: auto;
    min-width: 0;
    min-height: 0;
    height: auto;
    padding: 0.45rem 0.5rem;
    border-radius: 14px;
  }

  #player-decks .player-deck:not(.player-deck-self) .deck-content {
    gap: 0.35rem;
  }

  #player-decks .player-deck:not(.player-deck-self) .deck-info {
    display: none;
  }

  #player-decks .player-deck:not(.player-deck-self) .deck-count-badge {
    display: inline-flex;
  }

  #player-decks .player-deck:not(.player-deck-self) .card-back {
    width: clamp(30px, 8vw, 42px);
  }

  #player-decks .player-deck:not(.player-deck-self) .player-avatar {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
  }
}

/* --- Accessibilité : mouvement réduit -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .turn-toast,
  .confetti-piece,
  .winner-crown,
  .center-pile .card-enter,
  #slap-btn.slap-armed:not(:disabled),
  #player-decks .player-deck.deck-challenged,
  #player-decks .player-deck.current-turn,
  #table.game-starting .player-deck {
    animation: none;
  }

  .turn-toast {
    opacity: 1;
  }
}
