/* ===== La Boîte de Jambon : table vue de dessus ===== */

.hb {
  --hw: clamp(64px, min(21vw, 15dvh), 104px);  /* largeur des cartes en main */
  --tw: clamp(30px, min(9vw, 6.4dvh), 54px);  /* largeur des cartes sur la table */
  position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}

/* ---- cartes (3D : face / dos) ---- */
.pc3d { --w: 50px; position: relative; flex: none; width: var(--w); height: calc(var(--w) * 1.45); perspective: 700px; }
.pc3d .inner { position: absolute; inset: 0; transform-style: preserve-3d; }
.pc3d.down .inner { transform: rotateY(180deg); }
.pc3d .side { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.pc3d .rear { transform: rotateY(180deg); }
.pc {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  border-radius: calc(var(--w) * .14); border: calc(var(--w) * .055) solid #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.pc.face.plus { background: linear-gradient(160deg, #3fd68b, #1f9d62); }
.pc.face.zero { background: linear-gradient(160deg, #ffd04a, #e8a30c); }
.pc.face.minus { background: linear-gradient(160deg, #ff6b6b, #d63636); }
.pc .oval {
  position: absolute; inset: 20% 6%; background: #fff; border-radius: 50%; transform: rotate(-24deg);
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 calc(var(--w) * .02) rgba(0, 0, 0, .1);
}
.pc .num { transform: rotate(24deg); font-size: calc(var(--w) * .5); font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.pc.plus .num { color: #1f9d62; }
.pc.zero .num { color: #d79000; }
.pc.minus .num { color: #d63636; }
.pc .corner { position: absolute; font-size: calc(var(--w) * .2); font-weight: 600; color: #fff; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, .3); }
.pc .tl { left: calc(var(--w) * .07); top: calc(var(--w) * .05); }
.pc .br { right: calc(var(--w) * .07); bottom: calc(var(--w) * .05); transform: rotate(180deg); }
.pc.sp {
  background: radial-gradient(circle at 50% 30%, #3b3466, #14122a 70%); border-color: var(--gold);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--w) * .05);
}
.pc .sp-icon { font-size: calc(var(--w) * .5); }
.pc .sp-name { font-size: calc(var(--w) * .15); color: var(--gold); text-align: center; line-height: 1.1; padding: 0 4%; font-weight: 600; }
.pc.back {
  background: repeating-linear-gradient(45deg, #b3263f 0 7px, #961d34 7px 14px);
}
.pc .back-oval {
  position: absolute; inset: 22% 10%; border: calc(var(--w) * .03) solid rgba(255, 255, 255, .85); border-radius: 50%;
  background: rgba(255, 255, 255, .14); transform: rotate(-24deg); display: grid; place-items: center; font-size: calc(var(--w) * .38);
}

/* ---- en-tête ---- */
.hb-hud {
  position: relative; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: calc(8px + env(safe-area-inset-top)) 10px 4px;
}
.hb-role, .hb-round, .hb-menu {
  font: inherit; font-size: .95rem; color: var(--text); background: rgba(0, 0, 0, .38); border: 1px solid var(--line);
  border-radius: 999px; padding: .35rem .8rem; backdrop-filter: blur(6px);
}
.hb-role { cursor: pointer; font-weight: 600; }
.hb-role.good { border-color: var(--good); color: #8dffc0; }
.hb-role.bad { border-color: var(--bad); color: #ff9c9c; }
.hb-menu { cursor: pointer; width: 40px; height: 36px; padding: 0; font-size: 1.1rem; }
.hb-ticker {
  position: absolute; z-index: 7; top: calc(52px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -10px);
  max-width: 92%; text-align: center; font-size: .88rem; padding: .4rem .9rem; border-radius: 14px;
  background: rgba(20, 16, 40, .92); border: 1px solid var(--gold); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
}
.hb-ticker.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- la scène et la table ---- */
.hb-stage { position: relative; flex: 1; min-height: 0; max-width: 1100px; width: 100%; margin: 0 auto; }
.hb-table {
  position: absolute; left: 8%; right: 8%; top: 8%; bottom: 14%; border-radius: 50%;
  background: linear-gradient(#8a5a35, #5c3820); padding: 11px;
  box-shadow: 0 16px 0 #3a2212, 0 26px 40px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .25);
}
.hb-felt {
  width: 100%; height: 100%; border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, .13), transparent 60%),
    repeating-radial-gradient(circle at 50% 45%, rgba(255, 255, 255, .03) 0 2px, transparent 2px 6px),
    linear-gradient(#27407a, #16264f);
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, .55);
}

/* ---- sièges ---- */
.hb-seats, .hb-slots { position: absolute; inset: 0; pointer-events: none; }
.seat { position: absolute; transform: translate(-50%, -50%); width: 92px; text-align: center; z-index: 3; transition: opacity .3s; }
.seat.off { opacity: .45; }
.seat-top { position: relative; display: inline-block; }
.seat-avatar {
  width: clamp(38px, 11vw, 54px); height: clamp(38px, 11vw, 54px); border-radius: 50%; display: grid; place-items: center;
  font-size: clamp(1.2rem, 5.2vw, 1.8rem); border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0, 0, 0, .5); position: relative; z-index: 1;
}
.seat.me .seat-avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 207, 90, .35), 0 4px 10px rgba(0, 0, 0, .5); }
.seat.thinking .seat-avatar { animation: think 1.6s ease-in-out infinite; }
@keyframes think { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .22), 0 4px 10px rgba(0, 0, 0, .5); } }
.seat-badge {
  position: absolute; right: -8px; bottom: -4px; z-index: 2; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 4px;
  display: none; place-items: center; font-size: .75rem; font-weight: 700; background: #44476a; border: 2px solid #fff;
}
.seat-badge.done { display: grid; background: var(--good); }
.seat-badge.wait { display: grid; }
.seat-name {
  font-size: .78rem; font-weight: 500; line-height: 1.15; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-shadow: 0 1px 3px #000; max-width: 92px;
}
.seat-name em { color: var(--gold); }
.seat-role { font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; text-shadow: 0 1px 2px #000; }
.seat-role.bad { color: #ff9c9c; }
.seat-role.good { color: #8dffc0; }
.seat-cards { position: absolute; left: 50%; top: -12px; width: 0; height: 22px; z-index: 0; }
.mini-back {
  position: absolute; left: -8px; top: 0; width: 16px; height: 23px; border-radius: 3px; border: 1.5px solid #fff;
  background: repeating-linear-gradient(45deg, #b3263f 0 3px, #961d34 3px 6px);
  transform: rotate(calc(var(--i) * 14deg)) translateX(calc(var(--i) * 6px)); transform-origin: 50% 160%;
}

/* ---- cartes posées devant les sièges ---- */
.slot { position: absolute; transform: translate(-50%, -50%); width: var(--tw); height: calc(var(--tw) * 1.45); }
.slot .pc3d { transform: perspective(380px) rotateX(24deg); }
.slot .mine .pc { box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgba(0, 0, 0, .5); }

/* ---- centre : la boîte et la pioche ---- */
.hb-center {
  position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); z-index: 2;
  width: min(54%, 300px); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.hb-tinrow { display: flex; align-items: center; gap: 10px; width: 100%; }
.hb-tin {
  flex: 1; min-width: 0; border-radius: 16px; padding: 6px 6px 8px;
  background: linear-gradient(#f4f6fa, #b6c0cf 45%, #8794a8); border: 3px solid #fff;
  box-shadow: 0 10px 0 #5d687b, 0 18px 24px rgba(0, 0, 0, .5);
  transform: perspective(700px) rotateX(22deg);
}
.tin-lid {
  display: flex; justify-content: space-between; align-items: center; padding: 2px 10px; margin-bottom: 5px;
  border-radius: 8px; background: linear-gradient(#e0475b, #a6283b); color: #fff; font-weight: 700; font-size: clamp(.7rem, 2.4vw, .95rem); letter-spacing: .14em;
}
.tin-count { letter-spacing: .02em; font-weight: 600; }
.tin-slices {
  display: flex; flex-direction: column-reverse; gap: 4px; padding: 6px; border-radius: 9px;
  background: #2b1a20; box-shadow: inset 0 4px 10px rgba(0, 0, 0, .7);
}
.tin-row { display: flex; gap: 4px; }
.sl {
  flex: 1; height: clamp(12px, 2.9dvh, 22px); border-radius: 4px 4px 8px 8px; background: #3e2a31; border: 1px dashed #6e4f58;
}
.sl.on {
  background: linear-gradient(#ffc7cc 0 25%, #ff8f9c 25% 80%, #e35d70);
  border: 1px solid #ffd9dd; box-shadow: inset 0 -3px 0 rgba(150, 30, 55, .35), 0 1px 3px rgba(0, 0, 0, .5);
}
.hb-deck { position: relative; flex: none; width: var(--tw); height: calc(var(--tw) * 1.45); margin-right: 2px; }
.hb-deck .pc3d { position: absolute; left: 0; top: 0; }
.hb-deck .pc3d:nth-child(1) { translate: 0 4px; }
.hb-deck .pc3d:nth-child(2) { translate: 0 2px; }
.deck-count {
  position: absolute; z-index: 2; left: 50%; bottom: -10px; transform: translateX(-50%); min-width: 22px; text-align: center;
  background: #000b; border: 1px solid var(--line); border-radius: 10px; font-size: .72rem; padding: 0 5px;
}
.hb-delta {
  position: absolute; left: 50%; top: -10px; transform: translate(-50%, 0); opacity: 0; pointer-events: none; white-space: nowrap; z-index: 4;
  font-size: clamp(1.3rem, 5vw, 2rem); font-weight: 700; text-shadow: 0 2px 8px #000;
}
.hb-delta.up { color: #7dffb5; }
.hb-delta.down { color: #ff8b8b; }
.hb-delta.flat { color: #ddd; }
.hb-chips { display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 24px; font-size: .78rem; white-space: nowrap; }
.hb-chips .mini { min-width: 1.5rem; margin: 0; padding: 0 .2rem; font-size: .78rem; }
.chips-lbl { color: var(--muted); margin-right: 2px; }
.chips-sum { font-weight: 700; margin-left: 4px; }
.chips-sum.up { color: #7dffb5; }
.chips-sum.down { color: #ff8b8b; }
.mini {
  display: inline-block; min-width: 1.7rem; text-align: center; border-radius: 6px; padding: .02rem .3rem; margin: 0 .08rem;
  font-weight: 700; font-size: .85rem; color: #fff; border: 1.5px solid #fff;
}
.mini.plus { background: #1f9d62; }
.mini.zero { background: #e0a00a; }
.mini.minus { background: #d63636; }

/* ---- bas : pouvoirs, main, action ---- */
.hb-dock {
  position: relative; z-index: 6; padding: 0 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(5, 6, 20, .75) 35%);
}
.hb-specials { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.hb-specials.empty { display: none; }
.sp-chip {
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--text); cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 4px 11px 4px 7px; border-radius: 999px; border: 2px solid var(--gold);
  background: linear-gradient(135deg, #4b3a1c, #2b2236); box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
  animation: shimmer 2.8s ease-in-out infinite;
}
.sp-chip:disabled { opacity: .45; animation: none; cursor: default; }
.sp-chip-icon { font-size: 1.15rem; }
@keyframes shimmer { 50% { box-shadow: 0 0 14px rgba(255, 207, 90, .6); } }
.hb-hand {
  display: flex; justify-content: center; align-items: flex-end; padding: 8px 0 22px;
  min-height: calc(var(--hw) * 1.45 + 34px);
}
.hcard { margin: 0 calc(var(--hw) * var(--ov, -.1)); cursor: pointer; transform-origin: 50% 140%; transition: translate .15s ease; }
.hcard:hover { translate: 0 -16px; }
.hcard .pc { box-shadow: 0 6px 14px rgba(0, 0, 0, .55); }
.hb-hand.locked .hcard { pointer-events: none; filter: saturate(.75) brightness(.85); }
.hb-action { min-height: 46px; display: flex; justify-content: center; align-items: center; }
.hint { margin: 0; text-align: center; color: #d9d6ee; font-size: .9rem; text-shadow: 0 1px 2px #000; }
.hb-action .btn.big { max-width: 420px; }
.hb-dock.after .hb-hand { opacity: .55; }
.over-actions { display: flex; gap: .6rem; align-items: center; justify-content: center; }

/* ---- couches ---- */
.hb-flight { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.hb-flight .pc3d { will-change: transform; }
.hb-sheets { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.hb-sheets.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 18, .62); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 84%; overflow: auto;
  background: linear-gradient(#262b57, #161a37); border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .7rem;
  animation: slideUp .32s cubic-bezier(.2, .9, .3, 1);
}
.sheet h2, .sheet h3, .sheet p { margin: 0; }
.sheet h3 { font-size: .9rem; color: var(--muted); font-weight: 500; }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 4px; }
@keyframes slideUp { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.role-card { text-align: center; padding: .6rem; border-radius: 18px; border: 2px solid; }
.role-card.good { border-color: var(--good); background: rgba(53, 194, 122, .12); }
.role-card.bad { border-color: var(--bad); background: rgba(239, 75, 75, .13); }
.role-kicker { color: var(--muted); font-size: .85rem; }
.role-title { font-size: 2.2rem; font-weight: 700; margin: .2rem 0; }
.role-card.good .role-title { color: #8dffc0; }
.role-card.bad .role-title { color: #ff9c9c; }
.role-mates { margin-top: .5rem !important; color: #ddd; }
.who { display: inline-block; background: rgba(255, 255, 255, .1); border-radius: 999px; padding: .1rem .6rem; margin: .15rem; font-size: .9rem; }

.sp-detail { text-align: center; display: flex; flex-direction: column; gap: .4rem; }
.sp-big { font-size: 3rem; }
.targets { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.target {
  font: inherit; color: var(--text); cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .35rem .8rem .35rem .4rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
}
.target:hover { background: rgba(255, 255, 255, .2); }

.peek-row { display: flex; justify-content: center; gap: 10px; padding: 10px 0; }
.mk-row { display: flex; flex-wrap: wrap; gap: 12px; min-height: 60px; align-items: flex-start; }
.mk-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mk-card { background: none; border: 0; padding: 0; cursor: pointer; }
.mk-arrows { display: flex; align-items: center; gap: 2px; }
.mk-n { font-weight: 700; color: var(--gold); min-width: 1rem; text-align: center; }
.journal { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.menu-actions { display: flex; gap: .6rem; justify-content: space-between; }

.recap-wrap { overflow-x: auto; }
.recap { border-collapse: collapse; width: 100%; font-size: .9rem; }
.recap th, .recap td { padding: .35rem .5rem; text-align: center; white-space: nowrap; }
.recap th:first-child, .recap td:first-child { text-align: left; }
.recap tr.total td { border-top: 1px solid var(--line); font-weight: 700; }
.tag { font-size: .68rem; border-radius: 999px; padding: .05rem .45rem; margin-left: .4rem; }
.tag.good { background: var(--good); }
.tag.bad { background: var(--bad); }

/* ---- fin de partie ---- */
.hb-overlay {
  position: absolute; inset: 0; z-index: 40; display: none; place-items: center; padding: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(15, 18, 45, .75), rgba(3, 4, 14, .92));
}
.hb-overlay.open { display: grid; animation: fade .4s; }
.over-card {
  position: relative; z-index: 2; text-align: center; max-width: 440px; width: 100%; padding: 24px 20px;
  background: linear-gradient(#2a3066, #181c3d); border: 2px solid var(--gold); border-radius: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: popIn .6s cubic-bezier(.2, 1.3, .4, 1);
}
.hb-overlay.lose .over-card { border-color: #7a7fa8; }
.over-card h1 { font-size: 1.7rem; margin: .2rem 0 .4rem; }
.over-card p { margin: .2rem 0; }
.over-emoji { font-size: 3.4rem; }
.over-sub { font-weight: 600; color: var(--gold); }
.over-roles { margin: .8rem 0; }
.who.bad { box-shadow: inset 0 0 0 1px var(--bad); }
.who.good { box-shadow: inset 0 0 0 1px var(--good); }
.over-btns { display: flex; gap: .6rem; justify-content: center; margin-top: .6rem; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px; opacity: .95;
  animation: fall 3.4s linear infinite;
}
@keyframes fall { to { transform: translate(var(--dx), 110dvh) rotate(720deg); } }

/* ---- grands écrans ---- */
@media (min-width: 900px) {
  .hb-table { left: 8%; right: 8%; }
  .seat { width: 120px; }
  .seat-name { font-size: .9rem; max-width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .seat.thinking .seat-avatar, .sp-chip, .confetti i, .hc { animation: none !important; }
}

/* ---- Déchiqueteuse : marques et éliminés ---- */
.seat-shreds {
  position: absolute; left: -12px; bottom: -6px; z-index: 2; display: none; padding: 0 6px; height: 20px; line-height: 18px;
  border-radius: 10px; font-size: .72rem; font-weight: 700; background: #5b1d2c; border: 2px solid #ff8b8b; white-space: nowrap;
}
.seat-shreds.on { display: block; }
.seat.dead { opacity: .75; }
.seat.dead .seat-avatar { filter: grayscale(1) brightness(.55); border-color: #888; box-shadow: none; }
.seat.dead .seat-name { text-decoration: line-through; color: var(--muted); }
.seat.dead .seat-cards { display: none; }
.seat-badge.dead { display: grid; background: #222; font-size: .85rem; }
.seat-fx {
  position: absolute; left: 50%; top: -6px; z-index: 5; white-space: nowrap; font-weight: 700; font-size: .95rem; color: #ff9c9c;
  text-shadow: 0 2px 6px #000; transform: translateX(-50%); animation: fxUp 2.8s ease-out forwards;
}
@keyframes fxUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -6px) scale(1.2); }
  80% { opacity: 1; transform: translate(-50%, -24px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}
.target em { color: #ff9c9c; }

/* ---- boîte secrète, cible de la carte posée, bouton de révélation ---- */
.tin-goal { text-align: center; font-size: clamp(.66rem, 2.2vw, .8rem); font-weight: 600; color: #2d3447; margin-top: 5px; }
.tin-slices { position: relative; }
.tin-slices.locked::after {
  content: '🔒'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.3rem; border-radius: 9px;
  background: rgba(20, 12, 16, .55);
}
.slot-tag {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 3px; white-space: nowrap; z-index: 2;
  font-size: .68rem; font-weight: 700; color: var(--gold); text-shadow: 0 1px 3px #000;
}
.action-col { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.reveal-btn {
  background: rgba(255, 207, 90, .12); border: 1px solid var(--gold); color: var(--gold); font-weight: 600; padding: .45rem 1.1rem;
}
.reveal-btn:hover:not(:disabled) { background: rgba(255, 207, 90, .25); }
.mini.sp { background: #2b2548; border-color: var(--gold); }

/* ---- révélation finale : toutes les cartes de la boîte se retournent ---- */
.hb-final {
  position: absolute; inset: 0; z-index: 35; display: none; place-items: center; padding: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(15, 18, 45, .9), rgba(3, 4, 14, .96));
}
.hb-final.open { display: grid; animation: fade .3s; }
.fin-card { width: 100%; max-width: 520px; text-align: center; display: flex; flex-direction: column; gap: .7rem; align-items: center; }
.fin-card h2 { font-size: 1.4rem; margin: 0; }
.fin-card p { margin: 0; }
.fin-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-height: 44dvh; overflow: hidden; padding: 4px; }
.fin-sum { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .3rem; }
.fin-total { font-size: 3rem; font-weight: 700; line-height: 1; min-width: 3.5rem; }
.fin-total.ok { color: #7dffb5; }
.fin-total.neg { color: #ff8b8b; }
.fin-goal { flex-basis: 100%; font-weight: 600; color: var(--muted); }
.fin-goal.ok { color: #7dffb5; font-size: 1.15rem; }
.fin-goal.ko { color: #ff8b8b; font-size: 1.15rem; }
