/* =============================================================
   GAME: Liar's Dice — teal felt table, leather cups, crimson neon
   ============================================================= */
.board-liarsdice {
  --ld-glow: #ff3b5c;
  --ld-teal: #2ee6c9;
  --ld-die: min(calc((100vw - 130px) / 5), 54px);
  width: min(calc(100vw - 44px), 680px);
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
}
.ld-table {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 14px 10px 12px; border-radius: 28px;
  background:
    repeating-radial-gradient(circle at 40% 30%, rgba(255, 255, 255, .012) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 42%, #12605f, #0a3a3c 55%, #05191c);
  box-shadow: 0 0 0 2px var(--ld-glow), 0 0 30px rgba(255, 59, 92, .35), inset 0 0 0 6px rgba(0, 0, 0, .25), inset 0 0 50px rgba(0, 0, 0, .6);
}

/* ----- small 2D dice (cups, bids, history) ----- */
.ld-mini {
  --m: 18px;
  display: inline-grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center; flex: none;
  width: var(--m); height: var(--m); padding: calc(var(--m) * .14); border-radius: calc(var(--m) * .22);
  background: linear-gradient(145deg, #ffffff, #e4ecf0); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15), 0 1px 2px rgba(0, 0, 0, .4);
  vertical-align: middle; transition: transform .2s, opacity .3s, box-shadow .2s;
}
.ld-mini i { width: 78%; aspect-ratio: 1; border-radius: 50%; background: #10282b; }
.ld-mini.f1 i { width: 96%; background: var(--ld-glow); }
.ld-mini.tiny { --m: 12px; margin-right: 2px; }
.ld-mini.ghost { background: rgba(255, 255, 255, .55); box-shadow: none; }
.ld-mini.hit { transform: translateY(-3px) scale(1.12); box-shadow: 0 0 0 2px var(--ld-glow), 0 0 12px rgba(255, 59, 92, .9); }
.ld-mini.dim { opacity: .35; }
.ld-mini.lost { animation: ld-lost 1.1s ease-in .3s forwards; }
@keyframes ld-lost { to { transform: translateY(14px) scale(.2) rotate(40deg); opacity: 0; } }

/* ----- opponents ----- */
.ld-seats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ld-seat {
  position: relative; width: calc((100% - 16px) / 3); max-width: 156px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; border-radius: 14px; background: rgba(0, 0, 0, .28); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  transition: box-shadow .2s, opacity .3s;
}
.ld-seats[data-n="4"] .ld-seat { width: calc((100% - 24px) / 4); }
.ld-seats[data-n="5"] .ld-seat { max-width: 200px; }
.ld-seat.turn { box-shadow: 0 0 0 2px var(--seat), 0 0 18px color-mix(in srgb, var(--seat) 55%, transparent); }
.ld-seat.out { opacity: .38; filter: grayscale(.8); }
.ld-seat.loser { box-shadow: 0 0 0 2px var(--ld-glow), 0 0 18px rgba(255, 59, 92, .6); }
.ld-ava { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px var(--seat, #fff); background: var(--surface-2); }
.ld-ava svg, .ld-ava img { display: block; width: 100%; height: 100%; }
.ld-name { font-weight: 800; font-size: .85rem; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ld-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 6px; max-width: 100%; min-width: 0; }
.ld-cnt { display: inline-flex; align-items: center; font-weight: 800; font-size: .78rem; color: var(--muted); }
.ld-cup-wrap { position: relative; width: 100%; height: 36px; display: grid; place-items: end center; }
/* leather dice cup */
.ld-cup {
  position: absolute; left: 50%; bottom: 2px; width: 40px; height: 32px; margin-left: -20px; z-index: 1;
  clip-path: polygon(14% 0, 86% 0, 100% 100%, 0 100%); border-radius: 4px;
  background: linear-gradient(90deg, #5a0f1f, #b0233f 40%, #e0405c 55%, #8e1830 80%, #4a0a18);
  transition: transform .5s cubic-bezier(.3, 1.3, .5, 1), opacity .4s;
}
.ld-cup::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .35); }
.ld-seat.shake .ld-cup { animation: ld-shake .8s ease-in-out; }
@keyframes ld-shake {
  0%, 100% { transform: none; }
  15% { transform: translateX(-4px) rotate(-8deg); }
  35% { transform: translateX(4px) rotate(8deg); }
  55% { transform: translateX(-3px) rotate(-6deg); }
  75% { transform: translateX(2px) rotate(4deg); }
}
.ld-seat.open .ld-cup { transform: translate(18px, -18px) rotate(28deg); opacity: 0; }
.ld-reveal { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; padding-bottom: 2px; }
.ld-reveal .ld-mini { --m: 17px; animation: ld-pop .35s ease-out both; }
@keyframes ld-pop { from { transform: scale(.4); opacity: 0; } }
.ld-bubble {
  position: absolute; top: -6px; right: -4px; z-index: 2; display: none; align-items: center; gap: 2px;
  padding: 2px 7px; border-radius: 10px 10px 10px 2px; font: 800 .85rem var(--font-body); color: #10282b;
  background: #f4fffd; box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}
.ld-bubble.show { display: inline-flex; animation: ld-pop .25s ease-out; }
.ld-bubble.last { box-shadow: 0 0 0 2px var(--seat, var(--ld-teal)), 0 2px 10px rgba(0, 0, 0, .5); }
.ld-bubble.call { color: #fff; background: var(--ld-glow); }
.ld-bubble .ld-mini { --m: 15px; }
.ld-bubble .ld-x { opacity: .6; font-size: .75rem; }

/* ----- centre: current bid, reveal count, history ----- */
.ld-center { text-align: center; min-height: 128px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ld-bid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ld-bid p { margin: 0; }
.ld-callline { font-weight: 700; font-size: .88rem; color: #bff7ee; }
.ld-bigbid { display: inline-flex; align-items: center; gap: 8px; font: 800 2.1rem/1.1 var(--font-head); color: #fff; text-shadow: 0 0 14px rgba(46, 230, 201, .6); }
.ld-bigbid .ld-mini { --m: 36px; }
.ld-bigbid .ld-x { font-size: 1.3rem; opacity: .7; }
.ld-bigbid.ld-empty { font: 700 1rem var(--font-body); color: var(--muted); text-shadow: none; min-height: 40px; }
.ld-sub { font-size: .78rem; color: var(--muted); }
.ld-count { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: #ffd0d8; }
.ld-count strong { font: 800 1.7rem var(--font-head); color: #fff; min-width: 1.4em; text-shadow: 0 0 12px rgba(255, 59, 92, .9); }
.ld-verdict { max-width: 460px; font-weight: 800; color: #fff; padding: 4px 12px; border-radius: 10px; background: rgba(255, 59, 92, .18); box-shadow: inset 0 0 0 1px rgba(255, 59, 92, .6); animation: ld-pop .3s ease-out; }
.ld-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 100%; }
.ld-hist[hidden] { display: none; }
.ld-hist li {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: .78rem; font-weight: 800;
  background: rgba(0, 0, 0, .3); box-shadow: inset 3px 0 0 var(--seat);
}
.ld-hist li .ld-mini { --m: 14px; }
.ld-hist li .ld-x { opacity: .6; }
.ld-hist li:last-child { background: rgba(255, 255, 255, .12); }
.ld-hname { color: var(--muted); font-weight: 700; margin-right: 2px; max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- you ----- */
.ld-me { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px 4px; border-radius: 16px; background: rgba(0, 0, 0, .22); transition: box-shadow .2s; }
.ld-me.turn { box-shadow: 0 0 0 2px var(--seat), 0 0 18px rgba(183, 104, 255, .45); }
.ld-me.out { opacity: .5; }
.ld-me-head { position: relative; display: flex; align-items: center; gap: 8px; }
.ld-me-head .ld-ava { width: 32px; height: 32px; }
.ld-me .ld-bubble { position: static; }
.ld-mydice { display: flex; justify-content: center; gap: 8px; min-height: var(--ld-die); }
.ld-die { display: block; transition: opacity .3s, transform .3s; }
.ld-die[hidden] { display: none; }
.ld-face { --c: calc(var(--ld-die) * .72); position: relative; width: var(--ld-die); height: var(--ld-die); display: grid; place-items: center; perspective: calc(var(--ld-die) * 5); border-radius: 22%; transition: box-shadow .2s, background .2s; }
.ld-face::before { content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 22%; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .6), transparent); }
.ld-cube { position: relative; width: var(--c); height: var(--c); transform-style: preserve-3d; transition: transform .74s cubic-bezier(.2, .75, .3, 1.06); transition-delay: calc(var(--k, 0) * 30ms); }
.ld-die.instant .ld-cube { transition: none; }
.ld-side {
  position: absolute; inset: 0; padding: 15%; border-radius: 19%; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center;
  background: radial-gradient(circle at 30% 25%, #ffffff, #eef6f7 55%, #c4d8db);
  box-shadow: inset 0 0 0 1px rgba(10, 40, 45, .2), inset -2px -3px 5px rgba(20, 60, 70, .28), inset 2px 2px 4px #fff;
}
.ld-side.f1 { transform: translateZ(calc(var(--c) / 2)); }
.ld-side.f6 { transform: rotateY(180deg) translateZ(calc(var(--c) / 2)); }
.ld-side.f3 { transform: rotateY(90deg) translateZ(calc(var(--c) / 2)); }
.ld-side.f4 { transform: rotateY(-90deg) translateZ(calc(var(--c) / 2)); }
.ld-side.f2 { transform: rotateX(90deg) translateZ(calc(var(--c) / 2)); }
.ld-side.f5 { transform: rotateX(-90deg) translateZ(calc(var(--c) / 2)); }
.ld-side i { width: 74%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #2b5a60, #061c20 70%); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .8); }
.ld-side.f1 i { width: 92%; background: radial-gradient(circle at 40% 35%, #ff8a9c, #b3122f 70%); }
.ld-die.rolling .ld-face { animation: ld-toss .8s ease-out both; animation-delay: calc(var(--k, 0) * 30ms); }
@keyframes ld-toss { 0% { transform: translateY(-22px) scale(.8); opacity: .3; } 40% { transform: translateY(-10px); opacity: 1; } 70% { transform: translateY(1px); } 85% { transform: translateY(-3px); } 100% { transform: none; } }
.ld-die.match .ld-face { box-shadow: inset 0 0 0 2px rgba(46, 230, 201, .6); background: rgba(46, 230, 201, .1); }
.ld-die.hit .ld-face { box-shadow: 0 0 0 2px var(--ld-glow), 0 0 14px rgba(255, 59, 92, .8); background: rgba(255, 59, 92, .15); transform: translateY(-3px); }
.ld-die.dim { opacity: .4; }
.ld-die.lost { animation: ld-lost 1.1s ease-in .3s forwards; }

/* ----- bid picker ----- */
.ld-picker {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 8px; border-radius: 16px;
  background: var(--bg); box-shadow: inset 0 0 0 1px rgba(46, 230, 201, .35); transition: opacity .2s;
}
.ld-picker.idle { opacity: .55; }
.ld-faces { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.ld-faces[hidden], .ld-qty[hidden] { display: none; }
.ld-facebtn {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s, transform .15s, opacity .15s;
}
.ld-facebtn .ld-mini { --m: 28px; }
.ld-facebtn:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--ld-teal); }
.ld-facebtn[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ld-teal), 0 0 14px rgba(46, 230, 201, .6); transform: translateY(-2px); background: rgba(46, 230, 201, .18); }
.ld-facebtn:disabled { opacity: .3; cursor: default; }
.ld-facebtn:focus-visible, .ld-step:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ld-qty { display: inline-flex; align-items: center; gap: 6px; }
.ld-step {
  width: 44px; height: 44px; border: 0; border-radius: 12px; cursor: pointer; font: 800 1.4rem/1 var(--font-body); color: var(--ink);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.ld-step:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--ld-teal); }
.ld-step:disabled { opacity: .3; cursor: default; }
.ld-qval { min-width: 2.2em; text-align: center; font: 800 1.6rem var(--font-head); color: #fff; }
.ld-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ld-acts .btn[hidden] { display: none; }
.ld-bidbtn { min-width: 150px; }
.ld-bidchip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 8px; background: rgba(0, 0, 0, .25); }
.ld-bidchip .ld-mini { --m: 18px; }
.ld-bidchip .ld-x { opacity: .7; font-size: .8em; }
.ld-liar { background: linear-gradient(135deg, #ff3b5c, #c4123a); box-shadow: 0 6px 22px rgba(255, 59, 92, .4); }
.ld-next { min-width: 180px; }
.ld-note { margin: 0; min-height: 1.4em; text-align: center; color: var(--muted); font-weight: 600; font-size: .92rem; }

@media (max-width: 520px) {
  .ld-table { padding: 10px 6px; border-radius: 22px; gap: 10px; }
  .ld-seats { gap: 6px; }
  .ld-seat, .ld-seats[data-n="4"] .ld-seat { width: calc((100% - 12px) / 3); }
  .ld-seats[data-n="4"] .ld-seat { width: calc((100% - 6px) / 2); max-width: 150px; }
  .ld-ava { width: 34px; height: 34px; }
  .ld-seat { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 5px; row-gap: 0; padding: 6px 5px 4px; }
  .ld-seat .ld-ava { width: 28px; height: 28px; }
  .ld-seat .ld-meta { flex-direction: column; align-items: flex-start; }
  .ld-seat .ld-name { font-size: .8rem; }
  .ld-seat .ld-cup-wrap { grid-column: 1 / -1; height: 28px; }
  .ld-seat .ld-cup { left: 24px; width: 32px; height: 25px; margin-left: -16px; }
  .ld-seat .ld-bubble { top: auto; bottom: 5px; right: 4px; }
  .ld-seat.open .ld-bubble { display: none; }
  .ld-center { min-height: 112px; }
  .ld-hist li:nth-last-child(n + 7) { display: none; }
  .ld-reveal .ld-mini { --m: 15px; }
  .ld-bigbid { font-size: 1.8rem; }
  .ld-bigbid .ld-mini { --m: 30px; }
  .ld-facebtn { width: 42px; height: 42px; }
  .ld-acts .btn { flex: 1 1 100px; min-width: 0; padding-left: 12px; padding-right: 12px; }
  .ld-bidbtn { flex-basis: 100%; }
}
