/* liarsdice — 吹牛（大話骰） */

.app {
  max-width: 900px;
  padding-bottom: 32px;
}

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px auto;
  max-width: 640px;
}
.hud-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.hud-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }
.hud-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── Table ─────────────────────────────────────────────── */
.table {
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.08), transparent 70%),
    linear-gradient(180deg, #7a2632, #4f1520);
  border: 3px solid #8b5a2b;
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.4), var(--shadow-sm);
  margin-bottom: 12px;
  color: #fdf1e6;
}

.table-mid {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(0, 1.6fr) minmax(130px, 1fr);
  gap: 8px;
  margin: 4px 0;
  min-height: 230px;
}

/* ── AI seats ──────────────────────────────────────────── */
.seat.ai-seat {
  background: rgba(0,0,0,0.2);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
  min-width: 0;
}
.seat.active { border-color: #ffd54f; box-shadow: 0 0 14px rgba(255,213,79,0.45); }
.seat.out { opacity: 0.4; filter: grayscale(0.8); }
.seat.lost-die { border-color: #ff8a80; box-shadow: 0 0 14px rgba(255,82,82,0.5); }
.seat-head { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.seat-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.seat-name { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }
.persona-tag {
  font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.15);
}

/* Cup (骰盅) */
.cup-wrap { position: relative; height: 66px; width: 80px; display: flex; justify-content: center; align-items: flex-end; }
.cup {
  width: 62px; height: 58px;
  border-radius: 18px 18px 8px 8px / 26px 26px 8px 8px;
  background:
    radial-gradient(ellipse at 35% 25%, rgba(255,255,255,0.35), transparent 45%),
    linear-gradient(180deg, #3e2723, #1b0f0c);
  border-bottom: 5px solid #c9a227;
  box-shadow: 0 4px 8px rgba(0,0,0,0.45);
  transition: transform 0.45s cubic-bezier(.3,1.4,.5,1);
}
.cup.lifted { transform: translateY(-14px) rotate(-14deg); }
.cup.shaking { animation: cup-shake 0.6s ease-in-out; }
@keyframes cup-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  15% { transform: translate(-5px, -6px) rotate(-8deg); }
  35% { transform: translate(5px, -2px) rotate(8deg); }
  55% { transform: translate(-4px, -5px) rotate(-6deg); }
  75% { transform: translate(3px, -1px) rotate(4deg); }
}
.dice-badge {
  position: absolute; right: -8px; bottom: -4px;
  background: #fff; color: #4f1520;
  border-radius: 999px; padding: 1px 7px;
  font-size: 12px; font-weight: 800;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Speech bubble */
.bubble {
  position: relative;
  background: #fff;
  color: #222;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 15px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  opacity: 0.7;
}
.bubble[hidden] { display: none; }
.bubble.latest, .bubble.call { opacity: 1; }
.bubble::before {
  content: ""; position: absolute; left: 50%; top: -6px; margin-left: -6px;
  border: 6px solid transparent; border-top: 0; border-bottom-color: #fff;
}
.bubble.call { background: #e53935; color: #fff; font-size: 17px; }
.bubble.call::before { border-bottom-color: #e53935; }
.bubble.pop { animation: banner-pop 0.3s cubic-bezier(.2,1.4,.5,1); }

.reveal-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 100%; }
.reveal-row[hidden] { display: none; }
.reveal-row .dface { animation: flip-in 0.35s ease backwards; }
@keyframes flip-in { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

/* ── Center ────────────────────────────────────────────── */
.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
}
.status-line { font-size: 14px; font-weight: 700; text-align: center; min-height: 20px; opacity: 0.92; }
.status-line.mine { color: #ffd54f; }
.dots i { font-style: normal; animation: dot-blink 1.2s infinite; opacity: 0.2; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink { 30% { opacity: 1; } }

.bid-display {
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-md);
  padding: 6px 18px 8px;
  text-align: center;
  min-width: 170px;
}
.bid-label { font-size: 11px; opacity: 0.8; letter-spacing: 1px; }
.bid-big { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; }
.bid-big b { font-size: 44px; font-weight: 900; color: #ffd54f; line-height: 1; font-variant-numeric: tabular-nums; }
.bid-big .x { font-size: 18px; font-weight: 800; }
.bid-big .none { font-size: 32px; opacity: 0.5; }
.bid-by { font-size: 12px; opacity: 0.85; }
.info-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.info-chip {
  background: rgba(0,0,0,0.3);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 800;
}
.info-chip.wild { color: #b9f6ca; }
.info-chip.wild.zhai { color: #fff; background: #c62828; }
.bid-log {
  font-size: 12px; opacity: 0.85;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px;
  max-width: 100%;
}
.log-item { display: inline-flex; align-items: center; gap: 2px; }
.log-item.last { color: #ffd54f; font-weight: 800; }
.bid-log .arrow { opacity: 0.6; }

.result-banner {
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.45);
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.result-banner.final { box-shadow: 0 0 18px rgba(255,215,0,0.5); }
.banner-head { font-size: 19px; font-weight: 900; }
.banner-sub { font-size: 13px; margin-top: 2px; display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.banner-delta { font-size: 16px; font-weight: 900; margin-top: 4px; }
.banner-delta.win { color: #b9f6ca; }
.banner-delta.lose { color: #ff8a80; }
.banner-final { font-size: 18px; font-weight: 900; margin-top: 6px; }
.banner-final.win { color: #ffd54f; }
.banner-final.lose { color: #ff8a80; }
.banner-rank { font-size: 12px; opacity: 0.9; margin-top: 2px; }
@keyframes banner-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Me ────────────────────────────────────────────────── */
.me-seat {
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 6px 4px 10px;
  border-top: 1px dashed rgba(255,255,255,0.25);
}
.me-seat.active { border-color: rgba(255,213,79,0.7); }
.me-seat.lost-die { border-color: #ff8a80; }
.me-head { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: 13px; min-height: 30px; }
.me-count { opacity: 0.85; font-size: 12px; }
.bubble.me-bubble::before { display: none; }
.my-tray {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 92px;
  perspective: 600px;
}
.my-dice { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; padding: 10px 0; }
.big-cup {
  position: absolute;
  left: 50%; top: 0;
  width: 220px; height: 92px;
  margin-left: -110px;
  border-radius: 40px 40px 12px 12px / 50px 50px 12px 12px;
  border-bottom-width: 7px;
  pointer-events: none;
  opacity: 0;
}
.big-cup.gone { display: none; }
/* cup sits over the dice while shaking, then lifts away */
.big-cup.lift-anim { animation: big-cup-lift 1.1s ease forwards; }
@keyframes big-cup-lift {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0); }
  12%  { transform: translate(-6px, -4px) rotate(-3deg); }
  24%  { transform: translate(6px, -2px) rotate(3deg); }
  36%  { transform: translate(-4px, -3px) rotate(-2deg); }
  48%  { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(0, -90px) rotate(-10deg); }
}

/* ── Dice: shared pip layout (3×3 grid), 1 and 4 have red pips ─ */
.dface, .die3d .face {
  background: #fefefe;
  border: 2px solid #d8d8d8;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  box-sizing: border-box;
}
.dface .pip, .die3d .face .pip {
  width: 70%; height: 70%;
  background: #222;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  display: block;
}
.pf1 .pip, .pf4 .pip, .die3d .face.pf1 .pip, .die3d .face.pf4 .pip { background: #c0392b; }
.pf1 .pip:nth-child(1) { grid-area: 2 / 2; width: 100%; height: 100%; }
.pf2 .pip:nth-child(1) { grid-area: 1 / 1; }
.pf2 .pip:nth-child(2) { grid-area: 3 / 3; }
.pf3 .pip:nth-child(1) { grid-area: 1 / 1; }
.pf3 .pip:nth-child(2) { grid-area: 2 / 2; }
.pf3 .pip:nth-child(3) { grid-area: 3 / 3; }
.pf4 .pip:nth-child(1) { grid-area: 1 / 1; }
.pf4 .pip:nth-child(2) { grid-area: 1 / 3; }
.pf4 .pip:nth-child(3) { grid-area: 3 / 1; }
.pf4 .pip:nth-child(4) { grid-area: 3 / 3; }
.pf5 .pip:nth-child(1) { grid-area: 1 / 1; }
.pf5 .pip:nth-child(2) { grid-area: 1 / 3; }
.pf5 .pip:nth-child(3) { grid-area: 2 / 2; }
.pf5 .pip:nth-child(4) { grid-area: 3 / 1; }
.pf5 .pip:nth-child(5) { grid-area: 3 / 3; }
.pf6 .pip:nth-child(1) { grid-area: 1 / 1; }
.pf6 .pip:nth-child(2) { grid-area: 1 / 3; }
.pf6 .pip:nth-child(3) { grid-area: 2 / 1; }
.pf6 .pip:nth-child(4) { grid-area: 2 / 3; }
.pf6 .pip:nth-child(5) { grid-area: 3 / 1; }
.pf6 .pip:nth-child(6) { grid-area: 3 / 3; }

/* Flat faces */
.dface { width: 26px; height: 26px; padding: 3px; border-radius: 6px; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.dface.xs { width: 18px; height: 18px; padding: 2px; border-width: 1px; border-radius: 4px; display: inline-grid; vertical-align: middle; }
.dface.lg { width: 44px; height: 44px; padding: 5px; border-radius: 9px; display: inline-grid; }
.dface.counted { box-shadow: 0 0 0 2px #ffd54f, 0 0 10px rgba(255,213,79,0.8); }
.dface.dim { opacity: 0.4; }

/* 3D cube (your dice) — no `filter` on .die3d: it would flatten preserve-3d */
.die3d {
  --size: 50px;
  --rot: none;
  width: var(--size);
  height: var(--size);
  position: relative;
  transform-style: preserve-3d;
  transform: var(--rot);
}
.die3d .face {
  position: absolute;
  inset: 0;
  padding: 7px;
  backface-visibility: hidden;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.12);
}
.die3d .face.c1 { transform: translateZ(calc(var(--size) / 2)); }
.die3d .face.c2 { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.die3d .face.c3 { transform: rotateY(90deg)  translateZ(calc(var(--size) / 2)); }
.die3d .face.c4 { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); }
.die3d .face.c5 { transform: rotateX(90deg)  translateZ(calc(var(--size) / 2)); }
.die3d .face.c6 { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); }
.die3d.rolling { animation: die-tumble 0.9s cubic-bezier(.2,.7,.3,1) backwards; }
@keyframes die-tumble {
  from { transform: translateY(-26px) rotateX(540deg) rotateY(380deg); }
  to   { transform: var(--rot); }
}
.die3d.counted .face { border-color: #ffd54f; box-shadow: inset 0 0 0 2px #ffd54f, 0 0 10px rgba(255,213,79,0.7); }
/* opacity on the preserve-3d cube itself would flatten it (wrong face shown) — dim the faces */
.die3d.dim .face { opacity: 0.45; }

/* ── Controls ──────────────────────────────────────────── */
.controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}
.controls[hidden] { display: none; }
.bid-controls { flex-direction: column; align-items: center; gap: 8px; }
.ctl-row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 6px; }
.step-btn { min-width: 40px; font-size: 20px; font-weight: 900; padding: 4px 10px; }
.q-val { min-width: 56px; text-align: center; font-size: 15px; font-weight: 700; }
.q-val b { font-size: 26px; font-variant-numeric: tabular-nums; margin-right: 2px; }
.face-picker { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.face-btn { padding: 4px; min-width: 0; line-height: 0; border-radius: 9px; }
.face-btn .dface { width: 34px; height: 34px; padding: 4px; }
.face-btn.selected { outline: 3px solid #ffb300; outline-offset: 1px; }
.face-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.controls .btn.primary {
  min-width: 120px;
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 800;
}
.controls .btn.primary:disabled { background: var(--btn-disabled); color: rgba(255,255,255,0.6); cursor: not-allowed; }
.call-btn { min-width: 92px; font-weight: 900; background: linear-gradient(180deg, #ffb300, #e65100); color: #fff; border: none; }
.call-btn:disabled { background: var(--btn-disabled); color: rgba(255,255,255,0.6); cursor: not-allowed; }
.prob-toggle { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--text-muted); }
.prob-hint { font-size: 13px; color: var(--text-muted); text-align: center; }
.prob-hint[hidden] { display: none; }
.btn.shake { animation: info-shake 0.3s ease; }
@keyframes info-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.legend { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .table { padding: 8px 6px; }
  .table-mid { grid-template-columns: 96px minmax(0, 1fr) 96px; gap: 4px; min-height: 210px; }
  .seat.ai-seat { padding: 6px 3px; }
  .seat-head { flex-direction: column; gap: 2px; }
  .seat-meta { align-items: center; }
  .avatar { width: 34px; height: 34px; font-size: 20px; }
  .cup-wrap { width: 64px; height: 56px; }
  .cup { width: 50px; height: 46px; }
  .dface { width: 20px; height: 20px; padding: 2px; border-width: 1px; border-radius: 4px; }
  .reveal-row { gap: 3px; }
  .bid-display { min-width: 0; padding: 4px 10px 6px; }
  .bid-big b { font-size: 34px; }
  .dface.lg { width: 34px; height: 34px; }
  .die3d { --size: 40px; }
  .die3d .face { padding: 5px; }
  .my-dice { gap: 10px; }
  .big-cup { width: 180px; margin-left: -90px; }
  .hud-value { font-size: 18px; }
  .face-btn .dface { width: 30px; height: 30px; }
  .bubble { font-size: 13px; padding: 3px 7px; }
}
@media (max-width: 380px) {
  .table-mid { grid-template-columns: 84px minmax(0, 1fr) 84px; }
  .face-picker { gap: 4px; }
  .face-btn .dface { width: 26px; height: 26px; }
  .die3d { --size: 34px; }
}

/* Light mode: accent-gold HUD numbers on white were ~1.7:1 contrast. Darken the active accent
   (works with every profile accent colour); :where() keeps specificity at .hud-value so
   win/lose-coloured values still override it. Dark mode keeps the bright accent. */
:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }
