/* === BASE === */

html { font-size: clamp(13px, 1.1vw, 19px); }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
}

nav, main, #toast { position: relative; z-index: 1; }

/* === TOP BAR (même structure que retrouvez) === */
.top-bar {
  position: relative;
  flex-shrink: 0;
}
.top-bar-left  { display: flex; align-items: center; z-index: 1; }
.top-bar-right {
  gap: 0.75rem;
  z-index: 1;
}

.top-bar-center p {
  margin-top: 0.1rem;
}

.back-button {
  text-decoration: none;
  white-space: nowrap;
}

/* === MAIN === */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* === SCREENS === */
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen.hidden { display: none !important; }

/* === LOBBY === */
.lobby-wrap {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 3rem 1.5rem;
  max-width: 700px;
  width: 100%;
  text-align: center;
}
.lobby-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f1f5f9;
}
.lobby-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
}
.lobby-card {
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 1.25rem;
  padding: 2rem 1.5rem;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.lobby-card:hover {
  transform: translateY(-4px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 28px rgba(236, 172, 74, 0.12);
}

/* Grille 2 cartes (local/en ligne) */
.lobby-card h3 { font-size: 1.2rem; font-weight: 800; color: #B6D8F2; }
.lobby-card p  { font-size: 0.83rem; color: #64748b; line-height: 1.5; }

/* === SÉLECTEUR MODE LOCAL — style homepage === */
.mode-select-wrap {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 2.5rem 1.5rem;
  max-width: 1100px;
  width: 100%;
}
.mode-select-intro { text-align: center; }
.mode-select-intro h2 { font-size: 1.4rem; font-weight: 800; color: #f1f5f9; }
.mode-select-intro p  { font-size: 0.82rem; color: #cbd5e1; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); margin-top: 0.3rem; }

.multi-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  width: 100%;
  max-width: 960px;
}
@media (max-width: 820px) { .multi-mode-grid { grid-template-columns: repeat(2, 1fr); max-width: 640px; } }
@media (max-width: 520px) { .multi-mode-grid { grid-template-columns: 1fr; } }

.player-count-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  width: 100%;
  max-width: 560px;
}
.player-count-card {
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 1rem;
  padding: 1.75rem 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  color: #f1f5f9;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.player-count-card:hover {
  transform: translateY(-4px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 28px rgba(236, 172, 74, 0.12);
}
@media (max-width: 520px) { .player-count-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .multi-mode-grid { grid-template-columns: 1fr; } }

.multi-mode-card {
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 1rem;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.multi-mode-card:hover {
  transform: translateY(-4px);
  background: rgba(15, 31, 52, 0.65);
  border-color: rgba(236, 172, 74, 0.65);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 0 28px rgba(236, 172, 74, 0.12);
}
.multi-mode-card:hover .multi-mode-btn { background: #9dc8e8; }

.multi-mode-tag {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  width: fit-content;
}
.multi-mode-card h3 { font-size: 1.05rem; font-weight: 800; color: #B6D8F2; line-height: 1.2; }
.multi-mode-card p  { font-size: 0.8rem; color: #94a3b8; line-height: 1.65; flex: 1; }
.multi-mode-btn {
  display: block;
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  background: #B6D8F2;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 0.5rem;
  text-align: center;
  transition: background 0.2s;
  font-family: inherit;
}

/* === ONLINE LOBBY (redesign) === */
.online-lobby-wrap { max-width: 860px; }

.lobby-subtitle {
  font-size: 0.88rem;
  color: #cbd5e1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  margin-top: -1.25rem;
}

.online-choices {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 1.5rem;
  width: 100%;
}

.online-choice-card {
  background: rgba(10, 22, 40, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(170, 190, 215, 0.18);
  border-radius: 1.25rem;
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.create-card:hover { border-color: #2563eb; box-shadow: 0 8px 28px rgba(37,99,235,0.2); }
.join-card:hover   { border-color: #059669; box-shadow: 0 8px 28px rgba(5,150,105,0.2); }

.online-choice-card h3 { font-size: 1.25rem; font-weight: 800; color: #B6D8F2; }
.online-choice-card > p { font-size: 0.83rem; color: #64748b; line-height: 1.65; flex: 1; }

.online-choice-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  flex-shrink: 0;
  padding: 0 0.25rem;
}

.online-choice-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  font-size: 0.97rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 0.25rem;
}
.create-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
}
.create-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,99,235,0.5); }
.join-btn {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  box-shadow: 0 4px 16px rgba(5,150,105,0.35);
}
.join-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(5,150,105,0.5); }

.join-code-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}
.join-code-input {
  width: 100%;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  color: #f1f5f9;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  text-align: center;
  font-family: inherit;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.15s;
}
.join-code-input:focus { border-color: #059669; }
.join-code-input::placeholder { color: #334155; letter-spacing: 0.12em; }

.online-error {
  font-size: 0.82rem;
  color: #f87171;
  min-height: 1em;
  text-align: center;
}

/* Garde la compatibilité si startGameBtn utilise online-action-btn */
.online-action-btn {
  padding: 0.65rem 1.25rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
.online-action-btn:hover { background: #1d4ed8; }
.online-action-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.back-to-lobby-btn {
  background: #B6D8F2;
  border: none;
  border-radius: 0.6rem;
  color: #0f172a;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(182, 216, 242, 0.25);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.back-to-lobby-btn:hover { background: #9dc8e8; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(182, 216, 242, 0.35); }

.wr-leave-btn {
  background: #dc2626;
  border: 2px solid #ef4444;
  border-radius: 0.6rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 2.25rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.45);
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.wr-leave-btn:hover {
  background: #ef4444;
  border-color: #fca5a5;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.55);
}

/* === WAITING ROOM — MODE SELECTOR === */
.wr-mode-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  text-align: center;
}

/* Cartes mode dans la waiting room (taille réduite) */
.wr-mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
  max-width: 720px;
}
@media (max-width: 680px) { .wr-mode-grid { grid-template-columns: repeat(2, 1fr); } }

.wr-card {
  padding: 1.25rem 1rem;
}
.wr-card h3 { font-size: 0.9rem; }
.wr-card p  { font-size: 0.75rem; }
.wr-card .multi-mode-btn  { font-size: 0.75rem; padding: 0.45rem 0.75rem; }

.wr-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.wr-card:not(:disabled):hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  border-color: #475569;
  border-top-color: #B6D8F2;
}
.wr-card:not(:disabled):hover .multi-mode-btn { background: #9dc8e8; }

/* === SALLE D'ATTENTE === */
.waiting-sub  { font-size: 0.9rem; color: #94a3b8; }
.waiting-code {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: #B6D8F2;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 1rem;
  padding: 1rem 2rem;
}
.waiting-hint { font-size: 0.82rem; color: #475569; }
.copiable { cursor: pointer; user-select: none; transition: opacity 0.15s, border-color 0.15s; }
.copiable:hover { opacity: 0.85; border-color: #60a5fa; }
.copy-hint { font-size: 0.78rem; color: #22c55e; min-height: 1.1em; font-weight: 600; }
.wr-invite-btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.6rem 1.3rem;
  background: rgba(182, 216, 242, 0.08);
  color: #B6D8F2;
  border: 1px solid #3b5a7a;
  border-radius: 0.6rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.wr-invite-btn:hover { background: rgba(182, 216, 242, 0.16); border-color: #60a5fa; }

/* === WAITING ROOM EN LIGNE === */
.wr-code-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.wr-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr));
  gap: 1rem;
  width: 100%;
}

.wr-player-slot {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.9rem;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.wr-player-slot.wr-slot-empty {
  border-style: dashed;
  opacity: 0.5;
}

.wr-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: #0f172a;
  border: 1px solid #334155;
}
.wr-badge.p0 { color: #60a5fa; border-color: #1d3a5f; }
.wr-badge.p1 { color: #f87171; border-color: #5f1d1d; }
.wr-badge.p2 { color: #34d399; border-color: #0f4a35; }
.wr-badge.p3 { color: #c4b5fd; border-color: #4c2f7a; }
.wr-badge-empty { color: #475569; }

.wr-name-input {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: inherit;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  outline: none;
  width: 100%;
  max-width: 180px;
  padding: 0.1rem 0.25rem;
  border-radius: 2px;
  color: inherit;
  cursor: default;
}
.wr-name-input:not(:disabled) {
  cursor: text;
  border-bottom-color: currentColor;
  opacity: 0.9;
}
.wr-name-input:not(:disabled):focus {
  background: rgba(255,255,255,0.05);
  opacity: 1;
}
.wr-name-input:disabled::placeholder { color: #475569; }
.wr-name-input:not(:disabled)::placeholder { color: #334155; }

.wr-status {
  font-size: 0.88rem;
  color: #64748b;
  text-align: center;
}

/* Avancement : badge du lobby (parties locales) et choix de l'hôte en salle d'attente */
.lobby-avc { margin-top: -1.25rem; }
.wr-avc {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
}
.wr-avc-btn { font-size: 0.82rem; }
.wr-avc-text { color: #B6D8F2; }

#startGameBtn {
  max-width: 280px;
  width: 100%;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
}
#startGameBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* === DRAW WAITING === */
.draw-waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 2rem;
}
.draw-wait-hint {
  font-size: 0.95rem;
  color: #475569;
  text-align: center;
  font-weight: 600;
}

.loading-text {
  margin: auto;
  color: #94a3b8;
  font-size: 1.1rem;
}

/* === TURN BANNER === */
.turn-banner {
  padding: 0.7rem 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  transition: background 0.3s, border-color 0.3s;
}
.p0-bg { background: #0f1f3d; color: #60a5fa; border-bottom: 2px solid #2563eb; }
.p1-bg { background: #1f0f0f; color: #f87171; border-bottom: 2px solid #dc2626; }
.p2-bg { background: #0f2a20; color: #34d399; border-bottom: 2px solid #059669; }
.p3-bg { background: #221a35; color: #c4b5fd; border-bottom: 2px solid #7c3aed; }

/* === ARENA === */
.arena {
  flex: 1;
  display: flex;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  min-height: 0;
}

/* === ALT ZONE === */
.alt-zone {
  flex: 0 0 18.75rem;
  display: flex;
  flex-direction: column;
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 1rem;
  overflow: hidden;
}

.alt-cat-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
}

.alt-pick-hint {
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  color: #94a3b8;
  flex-shrink: 0;
  border-bottom: 1px solid #334155;
}

.alt-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.alt-char-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid #0f172a;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  color: #e2e8f0;
  width: 100%;
}
.alt-char-btn:last-child { border-bottom: none; }
.alt-char-btn:hover { background: #0f172a; }

.alt-char-img {
  width: 3rem;
  height: 3rem;
  border-radius: 0.5rem;
  object-fit: cover;
  object-position: top center;
  border: 2px solid #334155;
  flex-shrink: 0;
}

.alt-char-name {
  font-size: 0.92rem;
  font-weight: 600;
}

/* === DRAW ZONE === */
.draw-zone {
  flex: 0 0 18.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 1rem;
  padding: 1.5rem 1.25rem;
  gap: 1.25rem;
}

.draw-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}
.draw-hint {
  font-size: 0.95rem;
  color: #94a3b8;
  text-align: center;
  line-height: 1.4;
}

.draw-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  width: 100%;
}
.draw-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,99,235,0.5); }
.draw-btn:active { transform: translateY(0); }

.drawn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.drawn-img-wrap {
  width: 11.25rem;
  height: 11.25rem;
  border-radius: 1rem;
  overflow: hidden;
  border: 3px solid #475569;
  background: #0f172a;
  flex-shrink: 0;
}
.drawn-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.drawn-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f1f5f9;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: break-word;
}
.drawn-prompt {
  font-size: 0.88rem;
  color: #94a3b8;
  text-align: center;
}

.drawn-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}
.cat-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #cbd5e1;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cat-btn:hover {
  background: #1e293b;
  border-color: #60a5fa;
  color: #f1f5f9;
}
.cat-btn .cat-icon { width: 2.125rem; height: 2.125rem; border-radius: 5px; }

/* === PLAYER BOARDS === */
.boards {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16.25rem, 1fr));
  gap: 1rem;
  min-height: 0;
}

.board {
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  /* Les tailles internes suivent la largeur réelle du plateau (unités cqi),
     quel que soit le nombre de joueurs ou la taille de l'écran. */
  container-type: inline-size;
}

.board-header {
  padding: 0.6rem 1.9rem;
  font-size: clamp(0.88rem, 4cqi, 1.1rem);
  font-weight: 800;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.p0 { color: #60a5fa; border-bottom: 2px solid #2563eb; }
.p1 { color: #f87171; border-bottom: 2px solid #dc2626; }
.p2 { color: #34d399; border-bottom: 2px solid #059669; }
.p3 { color: #c4b5fd; border-bottom: 2px solid #7c3aed; }

.player-name {
  min-width: 0;
  overflow-wrap: anywhere;
  outline: none;
  border-bottom: 1px dashed transparent;
  cursor: text;
  border-radius: 2px;
  padding: 0 3px;
}
.player-name:hover { border-bottom-color: currentColor; opacity: 0.85; }
.player-name:focus { border-bottom-color: currentColor; background: rgba(255,255,255,0.06); }

.name-edit-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.35;
  padding: 0.15rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
  position: absolute;
  right: 0.6rem;
}
.name-edit-btn:hover { opacity: 0.8; }

.slots {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.slot {
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 2cqi, 0.75rem);
  padding: clamp(0.55rem, 2.6cqi, 1.2rem) clamp(0.55rem, 2.2cqi, 1rem);
  border-bottom: 1px solid #0f172a;
  min-height: 0;
}
.slot:last-child { border-bottom: none; }
.slot.filled { background: rgba(15, 23, 42, 0.3); }
.slot.empty  { background: rgba(30, 41, 59, 0.3); }

.cat-icon {
  width: 2.8125rem;
  height: 2.8125rem;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  vertical-align: middle;
}

.slot-cat {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 1.5cqi, 0.65rem);
  font-size: clamp(0.74rem, 2.9cqi, 1.15rem);
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: clamp(7.5rem, 36cqi, 15.625rem);
  flex-shrink: 0;
  line-height: 1.15;
}
.slot-cat .cat-icon { width: clamp(1.6rem, 7cqi, 2.8125rem); height: clamp(1.6rem, 7cqi, 2.8125rem); }
.slot-char {
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 1.8cqi, 0.8rem);
  flex: 1;
  min-width: 0;
  padding-left: clamp(0.25rem, 2.5cqi, 1.25rem);
  animation: fadeIn 0.2s ease;
}
.slot-img {
  width: clamp(2.25rem, 9cqi, 3.75rem);
  height: clamp(2.25rem, 9cqi, 3.75rem);
  border-radius: 0.5rem;
  object-fit: cover;
  object-position: top center;
  border: 2px solid #334155;
  flex-shrink: 0;
}
.slot-char-name {
  font-size: clamp(0.8rem, 3.3cqi, 1.15rem);
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: break-word;
}
.slot-empty {
  color: #334155;
  font-size: 0.9rem;
}

/* 3-4 plateaux côte à côte : colonnes plus étroites (le contenu s'adapte via cqi) */
.boards[data-count="3"] { grid-template-columns: repeat(auto-fit, minmax(13.125rem, 1fr)); }
.boards[data-count="4"] { grid-template-columns: repeat(auto-fit, minmax(11.25rem, 1fr)); }

/* À 3-4 joueurs : zone de tirage un peu plus fine, cases étirées sur toute la hauteur
   du plateau et personnages plus grands pour profiter de la place libérée. */
.arena:has(.boards[data-count="3"]) .draw-zone,
.arena:has(.boards[data-count="4"]) .draw-zone { flex-basis: 15.5rem; }
.boards[data-count="3"] .slot,
.boards[data-count="4"] .slot { flex: 1 1 auto; }
.boards[data-count="3"] .slot-cat,
.boards[data-count="4"] .slot-cat { font-size: clamp(0.8rem, 3.8cqi, 1.15rem); width: clamp(7.5rem, 38cqi, 15.625rem); }
.boards[data-count="3"] .slot-cat .cat-icon,
.boards[data-count="4"] .slot-cat .cat-icon { width: clamp(1.8rem, 9cqi, 2.8125rem); height: clamp(1.8rem, 9cqi, 2.8125rem); }
.boards[data-count="3"] .slot-img,
.boards[data-count="4"] .slot-img { width: clamp(2.75rem, min(18cqi, 9vh), 5.5rem); height: clamp(2.75rem, min(18cqi, 9vh), 5.5rem); }
.boards[data-count="3"] .slot-char-name,
.boards[data-count="4"] .slot-char-name { font-size: clamp(0.92rem, 4.6cqi, 1.3rem); }

/* Plateau étroit : la catégorie passe au-dessus du personnage pour laisser toute la largeur au nom */
@container (max-width: 19rem) {
  .boards[data-count] .slot { flex-wrap: wrap; row-gap: 0.35rem; align-content: center; }
  .boards[data-count] .slot-cat { width: 100%; font-size: 0.8rem; }
  .boards[data-count] .slot-cat .cat-icon { width: 1.6rem; height: 1.6rem; }
  .boards[data-count] .slot-char { flex-basis: 100%; padding-left: 0; }
  .boards[data-count] .slot-img { width: clamp(2.75rem, min(20cqi, 7vh), 4rem); height: clamp(2.75rem, min(20cqi, 7vh), 4rem); }
  .boards[data-count] .slot-char-name { font-size: 0.98rem; }
}

/* === REVEAL WRAP === */
.reveal-wrap {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: center;
  border-top: 1px solid #334155;
  flex-shrink: 0;
  background: #0f172a;
}
.reveal-btn {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  border-radius: 0.75rem;
  padding: 0.9rem 3rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(217,119,6,0.4);
  letter-spacing: 0.02em;
}
.reveal-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(217,119,6,0.55); }

/* === RESULT SCREEN === */
#resultScreen {
  align-items: center;
  padding: 1.5rem clamp(0.75rem, 2vw, 1.5rem);
  gap: 1.75rem;
  overflow-y: auto;
}

.result-content {
  width: 100%;
  max-width: 125rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  container: results / inline-size;
}

.result-boards {
  --cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1.5rem);
  width: 100%;
}
.result-boards[data-count="1"] { --cols: 1; }
.result-boards[data-count="3"] { --cols: 3; }
.result-boards[data-count="4"] { --cols: 4; }
/* Nombre de colonnes selon la place réellement disponible, en rem (qui suit la taille
   fluide de la racine) : un plateau a besoin d'environ 20rem pour rester lisible. */
@container results (max-width: 84rem) { .result-boards[data-count="4"] { --cols: 2; } }
@container results (max-width: 63rem) { .result-boards[data-count="3"] { --cols: 1; } }
@container results (max-width: 42rem) { .result-boards[data-count] { --cols: 1; } }

.result-board {
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px solid #334155;
  border-radius: 1rem;
  overflow: hidden;
  transition: box-shadow 0.3s;
  min-width: 0;
  container-type: inline-size;
}
.result-board.winner {
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217,119,6,0.25), 0 8px 32px rgba(0,0,0,0.5);
}
.result-board.loser { opacity: 0.65; }

.result-board-header {
  padding: 0.7rem 1rem;
  font-size: clamp(0.95rem, 4cqi, 1.2rem);
  font-weight: 800;
  text-align: center;
  border-bottom: 1px solid #334155;
  overflow-wrap: anywhere;
}

.result-slots { display: flex; flex-direction: column; }

.result-slot {
  padding: clamp(0.45rem, 1.8cqi, 0.7rem) clamp(0.6rem, 2.5cqi, 1rem);
  border-bottom: 1px solid #0f172a;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(0.45rem, 2cqi, 0.75rem);
}
.result-slot:last-child { border-bottom: none; }

.result-slot-cat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.72rem, 2.6cqi, 0.9rem);
  font-weight: 700;
  color: #cbd5e1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: clamp(8rem, 28cqi, 12rem);
  flex-shrink: 0;
  line-height: 1.15;
}
.result-slot-cat .cat-icon { width: clamp(1.6rem, 6cqi, 2.8125rem); height: clamp(1.6rem, 6cqi, 2.8125rem); }
.result-slot-char {
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 1.8cqi, 0.7rem);
  flex: 1;
  min-width: 0;
}
.result-slot-char img {
  width: clamp(2.25rem, 7.5cqi, 3.25rem);
  height: clamp(2.25rem, 7.5cqi, 3.25rem);
  border-radius: 0.5rem;
  object-fit: cover;
  object-position: top center;
  border: 2px solid #334155;
  flex-shrink: 0;
}
.result-slot-char span {
  font-size: clamp(0.85rem, 3cqi, 1.05rem);
  font-weight: 600;
  color: #f1f5f9;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: break-word;
}
.result-slot-score {
  font-size: clamp(0.75rem, 2.6cqi, 0.9rem);
  color: #cbd5e1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  white-space: nowrap;
  flex-shrink: 0;
}
.result-slot-score strong {
  color: #fbbf24;
  font-size: clamp(0.88rem, 3.1cqi, 1.05rem);
  font-weight: 800;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

.result-total {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  background: rgba(15, 23, 42, 0.3);
  text-align: center;
  border-top: 1px solid #334155;
}
.result-total strong {
  color: #fbbf24;
  font-size: 1.25rem;
}

/* Plateau de résultat étroit : catégorie sur sa propre ligne, puis personnage + score */
@container (max-width: 32rem) {
  .result-slot { flex-wrap: wrap; row-gap: 0.3rem; }
  .result-slot-cat { width: 100%; font-size: 0.74rem; }
  .result-slot-cat .cat-icon { width: 1.5rem; height: 1.5rem; }
  .result-slot-char span { font-size: 0.92rem; }
  .result-slot-score { font-size: 0.8rem; }
}

.result-verdict {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: -0.02em;
  text-shadow: 0 0 40px rgba(251,191,36,0.35);
  line-height: 1.2;
}
.result-verdict.draw { color: #94a3b8; text-shadow: none; }
.result-diff {
  font-size: 1rem;
  font-weight: 600;
  color: #cbd5e1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  margin-top: 0.3rem;
  letter-spacing: 0;
}

.replay-btn {
  background: #1e293b;
  color: #f1f5f9;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid #475569;
  border-radius: 0.75rem;
  padding: 0.75rem 2.5rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.replay-btn:hover { background: #334155; border-color: #64748b; }

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.result-actions > * { flex-shrink: 0; }

.replay-btn-secondary {
  background: #B6D8F2;
  color: #0f172a;
  border: none;
  box-shadow: 0 4px 12px rgba(182, 216, 242, 0.25);
}
.replay-btn-secondary:hover { background: #9dc8e8; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(182, 216, 242, 0.35); }

.reveal-waiting {
  font-size: 0.9rem;
  color: #475569;
  font-weight: 600;
  text-align: center;
}

/* === UTILITAIRE === */

/* === HELP BUTTON === */
.help-btn {
  border: 1px solid #3b5a7a;
}

/* === MODAL === */
.modal-overlay {
  z-index: 2000;
}

@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.modal-box {
  border-radius: 1.25rem;
  padding: 2rem;
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-box h3 {
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.modal-box p {
  font-size: 0.87rem;
  line-height: 1.7;
  margin-bottom: 0.4rem;
}

.modal-box strong { color: #e2e8f0; }
.modal-box em { color: #94a3b8; font-style: normal; }
.modal-close {
  font-size: 1.1rem;
  color: #475569;
  padding: 0.25rem;
  line-height: 1;
}

.modal-stat-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.3rem 0; font-size: 0.87rem;
}
.modal-stat-row img { width: 2rem; height: 2rem; border-radius: 0.4rem; object-fit: cover; border: 1px solid #334155; flex-shrink: 0; }
.modal-stat-row .ms-label { color: #94a3b8; flex: 1; }
.modal-stat-row .ms-coef  { color: #fbbf24; font-weight: 700; }
.modal-warn {
  background: rgba(217,119,6,0.07);
  border: 1px solid rgba(217,119,6,0.3);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  color: #fde68a;
  line-height: 1.65;
  margin-top: 0.5rem;
}
.modal-warn strong { color: #fbbf24; }

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1e293b;
  color: #f1f5f9;
  padding: 0.9rem 1.75rem;
  border-radius: 0.85rem;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid #334155;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  max-width: 420px;
  text-align: center;
  pointer-events: none;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-warning { border-color: #d97706; color: #fbbf24; background: #1c1204; }
.toast-info    { border-color: #2563eb; color: #93c5fd; }

/* === QUI SUIS-JE ? (écran intégré dans le duel) === */
.qsj-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  min-height: 0;
  overflow: hidden;
}

/* Disposition à 3-4 joueurs : mystère en haut, panneaux en grille en dessous */
.qsj-layout-multi {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.qsj-mystery-top {
  flex-shrink: 0;
  border-bottom: 1px solid #334155;
}
.qsj-mystery-top .qsj-mystery { padding: 1rem 1.5rem; }
.qsj-panels-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  min-height: 0;
  overflow-y: auto;
}
.qsj-panels-grid .qsj-panel {
  border-right: 1px solid #334155;
  border-bottom: 1px solid #334155;
}
.qsj-panels-grid .qsj-panel:nth-child(2n) { border-right: none; }

/* Panels joueurs */
.qsj-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.qsj-panel-header {
  padding: 1rem 1.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  flex-shrink: 0;
}
.qsj-history {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.qsj-guess-item {
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  font-size: 1rem;
  font-weight: 600;
}
.qsj-guess-item.correct {
  background: rgba(34,197,94,0.12);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,0.25);
}
.qsj-guess-item.wrong {
  background: rgba(248,113,113,0.08);
  color: #f87171;
  border: 1px solid rgba(248,113,113,0.15);
}
.qsj-input-area {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
}
.qsj-input-inner { position: relative; }
.qsj-input {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.65rem;
  padding: 0.95rem 1.1rem;
  color: #f1f5f9;
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.qsj-input:focus { border-color: #60a5fa; }
.qsj-input:disabled { opacity: 0.4; cursor: not-allowed; }
.qsj-btn {
  width: 100%;
  padding: 0.85rem;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  border: none;
  border-radius: 0.65rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.qsj-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.qsj-btn-p0 { background: #2563eb; color: #fff; }
.qsj-btn-p0:not(:disabled):hover { background: #1d4ed8; }
.qsj-btn-p1 { background: #dc2626; color: #fff; }
.qsj-btn-p1:not(:disabled):hover { background: #b91c1c; }
.qsj-btn-p2 { background: #059669; color: #fff; }
.qsj-btn-p2:not(:disabled):hover { background: #047857; }
.qsj-btn-p3 { background: #7c3aed; color: #fff; }
.qsj-btn-p3:not(:disabled):hover { background: #6d28d9; }

/* Zone mystère centrale */
.qsj-mystery {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1.5rem;
  gap: 0.85rem;
  min-height: 0;
  overflow-y: auto;
}
/* Barre de timer */
.qsj-timer-track {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.qsj-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2563eb, #B6D8F2);
  border-radius: 2px;
  transform-origin: left;
}
@keyframes qsj-timer {
  from { width: 100%; }
  to   { width: 0%; }
}

/* Liste des indices */
.qsj-clue-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.qsj-wait-hint {
  text-align: center;
  color: #475569;
  font-size: 1rem;
  padding: 1.25rem 0;
}
.qsj-clue {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.8rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.6rem;
  font-size: 0.88rem;
}
.qsj-clue.revealed { animation: popIn 0.3s ease; }
.qsj-clue-icon { width: 1.6rem; height: 1.6rem; object-fit: contain; flex-shrink: 0; }
.qsj-clue-icon-blank { width: 1.6rem; height: 1.6rem; background: #334155; border-radius: 0.3rem; flex-shrink: 0; }
.qsj-clue-label { flex: 1; color: #64748b; font-weight: 600; font-size: 0.84rem; }
.qsj-clue.revealed .qsj-clue-label { color: #94a3b8; }
.qsj-clue-value { color: #f1f5f9; font-weight: 700; text-align: right; }
.hidden-clue .qsj-clue-label { color: #334155; }
.hidden-clue .qsj-clue-value { color: #334155; }

/* À 3-4 joueurs : indices en grille 5 colonnes × 2 lignes pour laisser
   plus de place verticale aux panneaux de guess en dessous. */
.qsj-mystery-top .qsj-clue-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
.qsj-mystery-top .qsj-wait-hint { grid-column: 1 / -1; }
.qsj-mystery-top .qsj-clue {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
  padding: 0.5rem 0.35rem;
  font-size: 0.72rem;
}
.qsj-mystery-top .qsj-clue-icon,
.qsj-mystery-top .qsj-clue-icon-blank { width: 1.3rem; height: 1.3rem; }
.qsj-mystery-top .qsj-clue-label {
  flex: none;
  font-size: 0.62rem;
  white-space: normal;
  line-height: 1.2;
}
.qsj-mystery-top .qsj-clue-value {
  text-align: center;
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
}
@media (max-width: 700px) {
  .qsj-mystery-top .qsj-clue-list { grid-template-columns: repeat(2, 1fr); }
}

.qsj-reveal-info {
  font-size: 0.88rem;
  color: #475569;
  text-align: center;
  flex-shrink: 0;
}
.qsj-answer-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.85rem 2rem;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 0.7rem;
  color: #94a3b8;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.qsj-answer-btn:hover { border-color: #B6D8F2; color: #f1f5f9; }

/* Résultat QSJ */
.qsj-result-reveal {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1rem;
  padding: 1.25rem 1.75rem;
  margin: 0.75rem 0;
}
.qsj-result-reveal img {
  width: 5rem;
  height: 5rem;
  border-radius: 0.75rem;
  object-fit: cover;
  object-position: top center;
  border: 2px solid #475569;
  flex-shrink: 0;
}
.qsj-result-name { font-size: 1.4rem; font-weight: 900; color: #B6D8F2; }
.qsj-result-sub  { font-size: 0.82rem; color: #64748b; margin-top: 0.2rem; }

/* Dropdown autocomplétion (partagé avec QSJ) — s'ouvre vers le haut pour rester dans l'écran */
.char-dropdown {
  position: absolute;
  bottom: 100%;
  top: auto;
  left: 0;
  right: 0;
  margin-bottom: 0.35rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.6rem;
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.35);
}
.char-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-size: 1rem;
  color: #e2e8f0;
  transition: background 0.1s;
}
.char-dropdown-item:hover,
.char-dropdown-item.highlighted { background: #0f172a; }
.char-dropdown-item img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.35rem;
  object-fit: cover;
  object-position: top center;
  border: 1px solid #334155;
  flex-shrink: 0;
}

/* === ENCHÈRES (écran intégré au duel) === */
.auction-budgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 1rem;
  padding: 1rem 1.5rem;
  flex-shrink: 0;
}
.auction-budget-card {
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.auction-budget-card.leading {
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.auction-budget-name { font-size: 0.95rem; font-weight: 800; }
.auction-budget-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  min-height: 1.75rem;
}
.auction-char-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.3rem;
  object-fit: cover;
  object-position: top center;
  border: 1px solid #334155;
}
.auction-budget-amount { font-size: 1rem; font-weight: 700; color: #fbbf24; }
.auction-budget-count  { font-size: 0.72rem; color: #64748b; }

.auction-arena {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  min-height: 0;
  align-items: center;
  justify-content: center;
}
.auction-char-card {
  flex: 0 0 16.25rem;
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.auction-char-progress {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  border-bottom: 1px solid #334155;
}
.auction-char-img-wrap { width: 100%; height: 13.75rem; overflow: hidden; background: #0f172a; }
.auction-char-img-wrap img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.auction-char-name { font-size: 1.3rem; font-weight: 800; text-align: center; padding: 0.75rem 1rem; }

.auction-bid-panel {
  flex: 0 0 21.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.auction-timer-track { width: 100%; height: 6px; background: #1e293b; border-radius: 3px; overflow: hidden; }
.auction-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d97706, #fbbf24);
  border-radius: 3px;
  transform-origin: left;
}
.auction-price-label { font-size: 0.8rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.auction-current-price { font-size: 2.2rem; font-weight: 900; color: #fbbf24; }
.auction-current-leader { font-size: 0.95rem; font-weight: 700; color: #94a3b8; min-height: 1.4em; }
.auction-raise-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #0f172a;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.auction-raise-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(217, 119, 6, 0.5); }
.auction-raise-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.auction-custom { display: flex; gap: 0.5rem; width: 100%; }
.auction-custom-input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
}
.auction-custom-input:focus { outline: none; border-color: #f59e0b; }
.auction-custom-input::-webkit-inner-spin-button,
.auction-custom-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.auction-custom-input { -moz-appearance: textfield; appearance: textfield; }
.auction-custom-input:disabled { opacity: 0.35; }
.auction-custom-btn {
  padding: 0.7rem 1.1rem;
  background: transparent;
  border: 1px solid #d97706;
  border-radius: 0.75rem;
  color: #fbbf24;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.auction-custom-btn:not(:disabled):hover { background: rgba(217, 119, 6, 0.15); }
.auction-custom-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.auction-hint { font-size: 0.82rem; color: #f87171; min-height: 1.1em; text-align: center; }
.auction-no-chars { padding: 1rem; color: #475569; font-size: 0.88rem; text-align: center; }

/* === CONCOURS DE RIRES === */
/* Carte de choix du mode : pleine largeur, texte à gauche et choix du nombre de manches à droite */
.laugh-mode-card {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  cursor: default;
}
.laugh-mode-text { flex: 1; display: flex; flex-direction: column; gap: 0.65rem; }
.laugh-rounds { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.laugh-rounds-label { font-size: 0.72rem; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; }
.laugh-rounds-btns { display: flex; gap: 0.6rem; }
.laugh-rounds-btns .multi-mode-btn { margin-top: 0; border: none; cursor: pointer; min-width: 4rem; padding: 0.8rem 1.3rem; font-size: 1rem; }
.laugh-rounds-btns .multi-mode-btn:not(:disabled):hover { background: #9dc8e8; }
.laugh-rounds-btns .multi-mode-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.multi-mode-card.laugh-mode-card:hover .multi-mode-btn { background: #B6D8F2; }
.multi-mode-card.laugh-mode-card:hover .multi-mode-btn:not(:disabled):hover { background: #9dc8e8; }

.laugh-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  padding: 1rem 1.5rem;
  flex-shrink: 0;
}
.laugh-score-card {
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 0.9rem;
  padding: 0.7rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.laugh-score-card.active {
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.laugh-score-name {
  font-size: 0.95rem;
  font-weight: 800;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}
.laugh-score-name[contenteditable]:focus { border-bottom-style: dashed; }
.laugh-score-total  { font-size: 1.1rem; font-weight: 800; color: #fbbf24; }
.laugh-score-status { font-size: 0.72rem; color: #64748b; min-height: 1.1em; }

.laugh-arena {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  min-height: 0;
  align-items: center;
  justify-content: center;
}
.laugh-char-card {
  flex: 0 0 16.25rem;
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid #334155;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.laugh-char-progress {
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  border-bottom: 1px solid #334155;
}
.laugh-char-img-wrap { width: 100%; height: 13.75rem; overflow: hidden; background: #0f172a; }
.laugh-char-img-wrap img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.laugh-char-name  { font-size: 1.3rem; font-weight: 800; text-align: center; padding: 0.75rem 1rem; }

.laugh-panel {
  flex: 0 0 26rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
}
.laugh-panel-title { font-size: 1.3rem; font-weight: 800; color: #f1f5f9; }
.laugh-name-inline { font-weight: 800; border-bottom: none; }
.laugh-hint  { font-size: 0.88rem; color: #94a3b8; line-height: 1.55; }
.laugh-wait  { font-size: 0.95rem; color: #94a3b8; }
.laugh-error { font-size: 0.88rem; color: #f87171; line-height: 1.5; }
.laugh-error code { color: #fbbf24; }

.laugh-main-btn {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #0f172a;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.laugh-main-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(217, 119, 6, 0.5); }
.laugh-secondary-btn {
  width: 100%;
  padding: 0.7rem 1.2rem;
  background: #1e293b;
  color: #e2e8f0;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.laugh-secondary-btn:not(:disabled):hover { background: #334155; border-color: #64748b; }
.laugh-secondary-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.laugh-btn-row { display: flex; gap: 0.6rem; width: 100%; }
.laugh-btn-row > * { flex: 1; }
.laugh-playing { border-color: #fbbf24 !important; color: #fbbf24; }

.laugh-rec-dot {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
  flex-shrink: 0;
}
@keyframes laugh-pulse { 50% { opacity: 0.3; transform: scale(0.8); } }

/* Indicateur au-dessus de la frise : décompte, puis « ● ENREGISTREMENT » bien visible */
.laugh-status {
  width: 100%;
  padding: 0.6rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #334155;
  background: rgba(30, 41, 59, 0.6);
  color: #94a3b8;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}
.laugh-status-rec {
  background: #dc2626;
  border-color: #f87171;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 24px rgba(220, 38, 38, 0.45);
}
.laugh-status-rec .laugh-rec-dot {
  background: #fff;
  box-shadow: none;
  animation: laugh-pulse 1s ease-in-out infinite;
}

/* Frise audio façon logiciel de montage */
.laugh-wave {
  width: 100%;
  height: 7rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #334155;
  border-radius: 0.6rem;
}

.laugh-big-score { font-size: 4.5rem; font-weight: 900; color: #fbbf24; line-height: 1; }
.laugh-big-score::after { content: '/100'; font-size: 1.1rem; color: #64748b; margin-left: 0.25rem; }
.laugh-detail { font-size: 0.78rem; color: #94a3b8; }
.laugh-env { width: 100%; height: 3.5rem; background: rgba(15, 23, 42, 0.6); border: 1px solid #1e293b; border-radius: 0.5rem; }
.laugh-env-small { height: 2rem; flex: 1; min-width: 0; }

.laugh-reveal-list, .laugh-summary { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }
.laugh-reveal-row, .laugh-summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid #334155;
  border-radius: 0.7rem;
  animation: fadeIn 0.3s ease;
  text-align: left;
}
.laugh-reveal-row > .laugh-name-inline { flex: 0 0 6.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.laugh-reveal-score, .laugh-summary-score { font-size: 1.4rem; font-weight: 900; color: #fbbf24; min-width: 2.5rem; text-align: right; }
.laugh-rank { font-size: 0.9rem; font-weight: 800; color: #64748b; width: 1.2rem; }
.laugh-summary-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.laugh-play-mini {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: #1e293b;
  color: #B6D8F2;
  border: 1px solid #334155;
  cursor: pointer;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.laugh-play-mini:hover { background: #334155; }

/* === RESPONSIVE === */
@media (max-width: 700px) {
  .arena { flex-direction: column; overflow-y: auto; }
  .draw-zone { flex: none; width: 100%; }
  .boards, .boards[data-count] { grid-template-columns: 1fr; flex: none; }
  .online-choices { grid-template-columns: 1fr; }
  .online-choice-divider { padding: 0.5rem 0; }
  .qsj-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1fr; overflow-y: auto; }
  .qsj-layout-multi { overflow-y: auto; }
  .qsj-panels-grid { grid-template-columns: 1fr; overflow-y: visible; }
  .qsj-panels-grid .qsj-panel { border-right: none; }
  .auction-arena { flex-direction: column; overflow-y: auto; }
  .auction-char-card, .auction-bid-panel { flex: none; width: 100%; }
}

/* === TÉLÉPHONE — PARTIE (duel / duel alternatif) ===
   Carte tirée compacte en haut, tous les plateaux côte à côte en dessous pour
   voir sa compo en jouant. Le contenu des cases se simplifie selon la largeur. */
@media (max-width: 700px) {
  .turn-banner { padding: 0.55rem 1rem; font-size: 1rem; }
  .arena { flex: none; overflow: visible; padding: 0.6rem; gap: 0.6rem; }

  .draw-zone { padding: 0.75rem; gap: 0.5rem; }
  .drawn-card {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    grid-template-areas: "img name" "img prompt" "act act";
    column-gap: 0.75rem;
    row-gap: 0.2rem;
    align-items: center;
  }
  .drawn-img-wrap { grid-area: img; width: 5.5rem; height: 5.5rem; border-width: 2px; }
  .drawn-name { grid-area: name; text-align: left; align-self: end; font-size: 1.1rem; }
  .drawn-prompt { grid-area: prompt; text-align: left; align-self: start; font-size: 0.8rem; }
  .drawn-actions { grid-area: act; display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; margin-top: 0.5rem; }
  .cat-btn { font-size: 0.85rem; padding: 0.5rem 0.55rem; gap: 0.4rem; }
  .cat-btn .cat-icon { width: 1.6rem; height: 1.6rem; }

  .alt-zone { flex: none; width: 100%; }
  .alt-cat-header { padding: 0.6rem 0.9rem; }
  .alt-pick-hint { padding: 0.45rem 0.9rem; }
  .alt-char-btn { padding: 0.5rem 0.9rem; }
  .alt-char-img { width: 2.6rem; height: 2.6rem; }

  .boards[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .boards[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .boards[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .boards, .boards[data-count] { gap: 0.35rem; }
  .board { border-radius: 0.7rem; }
  .board-header { padding: 0.4rem 1.3rem 0.4rem 0.4rem; font-size: 0.8rem; }
  .name-edit-btn { right: 0.3rem; }
  .board-header .player-name { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .slots { flex: none; overflow: visible; }
  .boards[data-count] .slot { flex: none; min-height: 3.2rem; }

  /* Plateau étroit : icône de catégorie seule, puis image + nom */
  @container (max-width: 14rem) {
    .boards[data-count] .slot { flex-wrap: nowrap; padding: 0.35rem 0.3rem; gap: 0.3rem; }
    .boards[data-count] .slot-cat { width: auto; font-size: 0; gap: 0; }
    .boards[data-count] .slot-cat .cat-icon { width: 1.35rem; height: 1.35rem; }
    .boards[data-count] .slot-char { flex: 1 1 0; min-width: 0; padding-left: 0; gap: 0.3rem; }
    .boards[data-count] .slot-img { width: 2.1rem; height: 2.1rem; }
    .boards[data-count] .slot-char-name { font-size: 0.72rem; }
  }
  /* Très étroit (3-4 joueurs) : l'image passe au-dessus du nom */
  @container (max-width: 9.5rem) {
    .boards[data-count] .slot-char { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
    .boards[data-count] .slot-img { width: 1.9rem; height: 1.9rem; }
    .boards[data-count] .slot-char-name { font-size: 0.64rem; line-height: 1.15; }
    /* Nom éditable (16px pour éviter le zoom iOS) : sans crayon, sur une ligne */
    .board-header { padding: 0.4rem 0.3rem; }
    .name-edit-btn { display: none; }
  }

  .reveal-wrap { padding: 0.9rem 1rem; }
  .reveal-btn { padding: 0.8rem 1.5rem; font-size: 1rem; }
}

/* === TÉLÉPHONE — ENCHÈRES : budgets sur une ligne, perso compact, bouton visible sans défiler === */
@media (max-width: 700px) {
  .auction-budgets { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 0.35rem; padding: 0.6rem; }
  .auction-budget-card { padding: 0.45rem 0.3rem; gap: 0.2rem; border-radius: 0.7rem; min-width: 0; }
  .auction-budget-name { font-size: 0.78rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auction-budget-chars { min-height: 0; gap: 0.15rem; }
  .auction-char-icon { width: 1.3rem; height: 1.3rem; }
  .auction-budget-amount { font-size: 0.8rem; }
  .auction-budget-count { font-size: 0.65rem; }
  .auction-arena { flex: none; justify-content: flex-start; padding: 0.6rem; gap: 0.75rem; }
  .auction-bid-panel { background: rgba(15, 23, 42, 0.75); border: 1px solid #334155; border-radius: 1rem; padding: 0.9rem 0.75rem; }
  .auction-char-card { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .auction-char-progress { flex-basis: 100%; }
  .auction-char-img-wrap { width: 6.5rem; height: 6.5rem; flex-shrink: 0; }
  .auction-char-name { flex: 1; font-size: 1.2rem; text-align: left; }
  .auction-current-price { font-size: 1.8rem; }
}

/* === TÉLÉPHONE — CONCOURS DE RIRES : scores sur une ligne, perso compact, panneau en dessous === */
@media (max-width: 700px) {
  .laugh-mode-card { flex-direction: column; align-items: stretch; }
  .laugh-rounds-btns .multi-mode-btn { flex: 1; }

  .laugh-scores { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 0.35rem; padding: 0.6rem; }
  .laugh-score-card { padding: 0.45rem 0.3rem; border-radius: 0.7rem; }
  .laugh-score-name { font-size: 1rem; } /* 16px mini : pas de zoom iOS en modifiant le nom */
  .laugh-score-total { font-size: 0.85rem; }
  .laugh-score-status { font-size: 0.62rem; }

  .laugh-arena { flex: none; flex-direction: column; justify-content: flex-start; padding: 0.6rem; gap: 0.75rem; }
  .laugh-char-card { flex: none; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .laugh-char-progress { flex-basis: 100%; }
  .laugh-char-img-wrap { width: 4.5rem; height: 4.5rem; flex-shrink: 0; }
  .laugh-char-name  { flex: 1; text-align: left; font-size: 1.1rem; }

  .laugh-panel { flex: none; width: 100%; background: rgba(15, 23, 42, 0.75); border: 1px solid #334155; border-radius: 1rem; padding: 0.9rem 0.75rem; }
  .laugh-wave { height: 5.5rem; }
  .laugh-big-score { font-size: 3.5rem; }
  .laugh-reveal-row > .laugh-name-inline { flex-basis: 5rem; }
}
