/* shibada — 十八豆 */

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

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.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;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-value.win  { color: #34a853; }
.hud-value.lose { color: #ef5350; }
.hud-value.small { font-size: 14px; line-height: 26px; }
.hud-value.hud-pulse { animation: hud-pulse 0.5s ease; }
@keyframes hud-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); color: gold; }
  100% { transform: scale(1); }
}

/* ── Table (dark felt) ─────────────────────────────────── */
.table {
  background:
    radial-gradient(ellipse at center, rgba(255,255,255,0.07), transparent 70%),
    linear-gradient(180deg, #123d2a, #0b2a1c);
  border: 3px solid #6d4421;
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5), var(--shadow-sm);
  margin-bottom: 12px;
}
.seat { padding: 6px 4px; }
.seat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #e8f5e9;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.hand-badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255,255,255,0.9);
  color: #333;
  animation: banner-pop 0.3s cubic-bezier(.2,1.4,.5,1);
}
.hand-badge[hidden] { display: none; }
.hand-badge.b-bg { background: #757575; color: #fff; }
.hand-badge.b-high { background: #42a5f5; color: #fff; }
.hand-badge.b-eighteen { background: linear-gradient(135deg, #ff7043, #e53935); color: #fff; }
.hand-badge.b-yise { background: linear-gradient(135deg, #ffd700, #b8860b); color: #3a2500; box-shadow: 0 0 10px rgba(255,215,0,0.7); }

.seat-status {
  text-align: center;
  min-height: 20px;
  font-size: 14px;
  font-weight: 700;
  color: #c8e6c9;
  font-variant-numeric: tabular-nums;
}
.seat-status b { color: #ffd54f; font-size: 16px; }
.seat-status.miss { color: #ffcc80; }

/* ── Tray + dice cup ───────────────────────────────────── */
.tray {
  position: relative;
  border-radius: 999px / 60%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.28), rgba(0,0,0,0.08) 65%, transparent 72%);
  padding: 18px 8px;
  overflow: hidden;
}
.cup {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(78%, 340px);
  height: 100%;
  transform: translate(-50%, -115%);
  border-radius: 46% 46% 18% 18% / 60% 60% 22% 22%;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.12) 0 6px, transparent 6px 14px),
    linear-gradient(180deg, #a0662e, #6b3d16 70%, #4a280c);
  border-bottom: 5px solid #3b1f08;
  box-shadow: 0 8px 18px rgba(0,0,0,0.5), inset 0 6px 10px rgba(255,255,255,0.15);
  transition: transform 0.18s ease-in;
  pointer-events: none;
  z-index: 2;
}
.tray.cup-down .cup { transform: translate(-50%, 0); }
.tray.shaking .cup { animation: cup-shake 0.13s linear infinite; }
@keyframes cup-shake {
  0%   { transform: translate(-50%, 0) rotate(0); }
  25%  { transform: translate(calc(-50% - 7px), -3px) rotate(-3deg); }
  50%  { transform: translate(-50%, 1px) rotate(0); }
  75%  { transform: translate(calc(-50% + 7px), -3px) rotate(3deg); }
  100% { transform: translate(-50%, 0) rotate(0); }
}

/* ── 3D dice (adapted from sicbo) ──────────────────────── */
.dice-row {
  --die: 54px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  min-height: calc(var(--die) + 16px);
}
.die-slot {
  width: var(--die);
  height: var(--die);
  perspective: 500px;
  border-radius: 12px;
  transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
.die {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(.18,.7,.25,1);
  /* DO NOT add `filter` here — it flattens preserve-3d (see sicbo). */
}
.die .face {
  position: absolute;
  inset: 0;
  background: #fefefe;
  border: 2px solid #d8d8d8;
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  padding: calc(var(--die) * 0.11);
  box-sizing: border-box;
  backface-visibility: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.die .face .pip {
  width: calc(var(--die) * 0.16);
  height: calc(var(--die) * 0.16);
  background: #222;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  display: block;
}
/* Chinese dice: the 1 and the 4 are red */
.die .face.f1 .pip, .die .face.f4 .pip { background: #c0392b; }
.die .face.f1 .pip:nth-child(1) { grid-area: 2 / 2; width: calc(var(--die) * 0.24); height: calc(var(--die) * 0.24); }

.die .face.f2 .pip:nth-child(1) { grid-area: 1 / 1; }
.die .face.f2 .pip:nth-child(2) { grid-area: 3 / 3; }

.die .face.f3 .pip:nth-child(1) { grid-area: 1 / 1; }
.die .face.f3 .pip:nth-child(2) { grid-area: 2 / 2; }
.die .face.f3 .pip:nth-child(3) { grid-area: 3 / 3; }

.die .face.f4 .pip:nth-child(1) { grid-area: 1 / 1; }
.die .face.f4 .pip:nth-child(2) { grid-area: 1 / 3; }
.die .face.f4 .pip:nth-child(3) { grid-area: 3 / 1; }
.die .face.f4 .pip:nth-child(4) { grid-area: 3 / 3; }

.die .face.f5 .pip:nth-child(1) { grid-area: 1 / 1; }
.die .face.f5 .pip:nth-child(2) { grid-area: 1 / 3; }
.die .face.f5 .pip:nth-child(3) { grid-area: 2 / 2; }
.die .face.f5 .pip:nth-child(4) { grid-area: 3 / 1; }
.die .face.f5 .pip:nth-child(5) { grid-area: 3 / 3; }

.die .face.f6 .pip:nth-child(1) { grid-area: 1 / 1; }
.die .face.f6 .pip:nth-child(2) { grid-area: 1 / 3; }
.die .face.f6 .pip:nth-child(3) { grid-area: 2 / 1; }
.die .face.f6 .pip:nth-child(4) { grid-area: 2 / 3; }
.die .face.f6 .pip:nth-child(5) { grid-area: 3 / 1; }
.die .face.f6 .pip:nth-child(6) { grid-area: 3 / 3; }

/* Cube face transforms — after the pip rules */
.die .face.f1 { transform: translateZ(calc(var(--die) / 2)); }
.die .face.f2 { transform: rotateY(180deg) translateZ(calc(var(--die) / 2)); }
.die .face.f3 { transform: rotateY(90deg)  translateZ(calc(var(--die) / 2)); }
.die .face.f4 { transform: rotateY(-90deg) translateZ(calc(var(--die) / 2)); }
.die .face.f5 { transform: rotateX(90deg)  translateZ(calc(var(--die) / 2)); }
.die .face.f6 { transform: rotateX(-90deg) translateZ(calc(var(--die) / 2)); }

/* Roll states (applied on the non-3D slot so the cube stays intact) */
.die-slot.ghost { opacity: 0.25; }
.die-slot.miss { opacity: 0.55; }
.die-slot.pair { opacity: 0.4; transform: scale(0.9); }
.die-slot.scoring { transform: translateY(-6px); box-shadow: 0 10px 16px -6px rgba(255, 213, 79, 0.9); }
.die-slot.yise { transform: translateY(-6px); box-shadow: 0 0 18px 4px rgba(255, 215, 0, 0.75); }
.die-slot.landed .face { animation: die-land-flash 0.32s cubic-bezier(.2,1.4,.5,1); }
@keyframes die-land-flash {
  0%   { box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
  40%  { box-shadow: 0 0 12px gold, 0 1px 2px rgba(0,0,0,0.15); }
  100% { box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
}

/* ── Result banner ─────────────────────────────────────── */
.result-banner {
  text-align: center;
  margin: 8px auto;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.4);
  color: #fff;
  animation: banner-pop 0.35s cubic-bezier(.2,1.4,.5,1);
}
.result-banner[hidden] { display: none; }
.banner-head { font-size: 24px; font-weight: 900; }
.banner-sub  { font-size: 13px; opacity: 0.9; margin-top: 2px; }
.result-banner.win  .banner-head { color: #ffd54f; }
.result-banner.lose .banner-head { color: #ff8a80; }
.result-banner.push .banner-head { color: #e0e0e0; }
.result-banner.big { box-shadow: 0 0 18px rgba(255,215,0,0.6); }
@keyframes banner-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Betting ───────────────────────────────────────────── */
.bet-info {
  text-align: center;
  font-size: 15px;
  color: var(--text-strong);
  margin: 4px 0 8px;
}
.bet-info b { color: var(--accent); font-variant-numeric: tabular-nums; }
.bet-info.shake { animation: info-shake 0.3s ease; }
@keyframes info-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.chip-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 10px;
}
.chip-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px dashed #fff;
  background: radial-gradient(circle at 30% 30%, #f39c12, #b9770e);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
}
.chip-btn[data-chip="50"]  { background: radial-gradient(circle at 30% 30%, #16a085, #0e6655); }
.chip-btn[data-chip="100"] { background: radial-gradient(circle at 30% 30%, #2980b9, #1b4f72); }
.chip-btn[data-chip="500"] { background: radial-gradient(circle at 30% 30%, #8e44ad, #5b2c6f); }
.chip-btn.allin {
  background: linear-gradient(135deg, #ffd700, #b8860b);
  color: #1a1a1a;
  font-size: 14px;
  border-style: solid;
  border-color: #fff5b8;
}
.chip-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 10px rgba(0,0,0,0.35); }
.chip-btn.active {
  transform: translateY(-3px) scale(1.08);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Action buttons ────────────────────────────────────── */
.action-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}
.action-row .btn { min-width: 110px; }
.action-row .btn.primary {
  background: linear-gradient(180deg, #e74c3c, #c0392b);
  color: #fff;
  border: none;
  font-weight: 700;
  animation: sbd-glow 1.6s ease-in-out infinite alternate;
}
@keyframes sbd-glow {
  0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
  100% { box-shadow: 0 0 18px 4px rgba(255, 215, 0, 0.6); }
}
.action-row .btn.primary:disabled {
  background: var(--btn-bg);
  color: var(--text-muted);
  cursor: not-allowed;
  animation: none;
}

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

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 520px) {
  .dice-row { --die: 46px; gap: 14px; }
  .chip-btn { width: 48px; height: 48px; font-size: 13px; }
  .hud-value { font-size: 18px; }
  .seat-status { font-size: 13px; }
}
@media (max-width: 360px) {
  .dice-row { --die: 40px; gap: 10px; }
}

/* Unicode die glyphs are drawn small by most fonts */
.dg { font-size: 1.45em; line-height: 1; vertical-align: -0.12em; letter-spacing: 1px; }

/* 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); }
