/* Sic bo: a crimson felt with the dice shaker at the top, the full layout
   (small / big, doubles and triples, totals, combinations, single numbers)
   whose winning areas light up, and the six seats along the rail.
   Loaded after kit.css. */

.kt-sic {
  --felt: #5a1520;
  --felt-hi: #80232f;
  --felt-deep: #300910;
  --lit: #ffe08a;
  --die: 22px;
}

.sic-felt {
  aspect-ratio: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px 26px;
  border-radius: 20px 20px 34px 34px;
}

.kt-sic .table-rim,
.kt-sic .table-rim::before {
  border-radius: 30px 30px 40px 40px;
}

/* ---------- shaker, history, result ---------- */

.sc-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 150px;
}

.shaker {
  position: relative;
  width: 170px;
  height: 140px;
}

.dish {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(60% 60% at 50% 40%, #e9d9b0, #b89a5c 70%, #6d5328);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.55), inset 0 -4px 8px rgba(0, 0, 0, 0.35);
}

.sc-dice {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.sc-dice .sc-d {
  width: 34px;
  transform: rotate(var(--r, 0deg));
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.sc-d {
  display: block;
  width: var(--die);
  line-height: 0;
}

.sc-d svg {
  width: 100%;
  height: auto;
}

/* the glass dome over the dice */
.dome {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 22px;
  height: 104px;
  border-radius: 50% 50% 14px 14px / 70% 70% 14px 14px;
  background:
    radial-gradient(40% 30% at 35% 25%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 -6px 14px rgba(255, 255, 255, 0.15);
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 0.55s ease;
}

/* Before the dome is lifted the dice are hidden behind a frosted dome. */
.shaker:not(.open) .dome {
  background:
    radial-gradient(40% 30% at 35% 25%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(180deg, rgba(120, 40, 50, 0.92), rgba(70, 18, 26, 0.95));
}

.shaker.open .dome {
  transform: translateY(-70px) scale(0.92);
  opacity: 0;
}

.shaker.shake {
  animation: sc-shake 0.16s ease-in-out infinite alternate;
}

@keyframes sc-shake {
  0% { transform: translate(-5px, 1px) rotate(-4deg); }
  100% { transform: translate(5px, -2px) rotate(4deg); }
}

.sc-result {
  justify-self: start;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 110px;
  padding: 8px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 224, 138, 0.5);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ivory);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.sc-result[data-show="1"] {
  opacity: 1;
  transform: none;
}

.sc-result b {
  font-family: "Bodoni Moda", serif;
  font-size: 40px;
  line-height: 1;
  color: var(--lit);
}

.sc-result span {
  font-size: 13px;
  font-weight: 700;
}

.sc-history {
  justify-self: end;
  width: min(100%, 290px);
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 106, 0.3);
}

.sc-history .hs-head {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--brass-hi);
}

.hs-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hs-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ivory);
}

.hs-list li:nth-child(n + 9) {
  display: none;
}

.hs-d {
  display: flex;
  gap: 1px;
  --die: 13px;
}

.hs-list b {
  min-width: 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hs-list em {
  font-style: normal;
  font-weight: 800;
  font-size: 11px;
  padding: 0 4px;
  border-radius: 4px;
  color: #fff;
  background: #3f6fb5;
}

.hs-list li[data-k="b"] em { background: #c0392b; }
.hs-list li[data-k="t"] em { background: #a07b1c; }

.hs-list .hs-empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

/* ---------- layout ---------- */

.sc-board {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 2px solid rgba(255, 224, 138, 0.55);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.12);
}

.sc-top,
.sc-totals,
.sc-combos,
.sc-singles {
  display: grid;
  gap: 4px;
}

.sc-top {
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 2fr 1fr 1fr 1fr 1fr 2fr;
}

.sc-totals {
  grid-template-columns: repeat(14, minmax(0, 1fr));
}

.sc-combos {
  grid-template-columns: repeat(15, minmax(0, 1fr));
}

.sc-singles {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.sc-spot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 56px;
  padding: 6px 2px 16px;
  border: 1px solid rgba(255, 224, 138, 0.45);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--ivory);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}

.sc-spot:hover:not(:disabled) {
  background: rgba(255, 224, 138, 0.12);
}

.sc-spot:disabled {
  cursor: default;
}

.sc-spot .spot-pay {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  font-size: 9.5px;
  font-weight: 700;
  color: rgba(255, 224, 138, 0.8);
  text-align: center;
  white-space: nowrap;
}

.sc-han {
  font-family: "Noto Serif JP", "Hiragino Mincho ProN", serif;
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
  color: var(--lit);
}

.sc-name {
  font-weight: 700;
  font-size: 12.5px;
  text-align: center;
}

.sc-sub {
  font-size: 10.5px;
  color: var(--muted);
}

.sc-num {
  font-family: "Bodoni Moda", serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--lit);
}

.sc-dice1,
.sc-dice2,
.sc-dice3 {
  display: flex;
  gap: 2px;
}

.sc-stack {
  flex-direction: column;
}

.sc-small,
.sc-big {
  min-height: 112px;
}

.sc-tri {
  display: grid;
  gap: 4px;
}

.sc-tri .sc-anyTriple {
  min-height: 40px;
}

.sc-tri-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
}

.sc-triple {
  min-height: 34px;
  padding: 4px 1px 13px;
  --die: 12px;
}

.sc-combo {
  min-height: 70px;
  --die: 18px;
}

.sc-single {
  min-height: 52px;
  --die: 28px;
}

.sc-double {
  --die: 20px;
}

/* chips on a spot: yours with the amount, NPCs' as dots */
.sc-chips {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  pointer-events: none;
}

.sc-chips .kchip {
  min-width: 22px;
  height: 22px;
  font-size: 9px;
}

.sc-chips i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.75);
}

.sc-spot.win {
  background: rgba(255, 224, 138, 0.3);
  box-shadow: 0 0 0 2px var(--lit), 0 0 16px rgba(255, 224, 138, 0.7);
  animation: sc-lit 0.7s ease-in-out 3 alternate;
}

@keyframes sc-lit {
  from { background: rgba(255, 224, 138, 0.12); }
  to { background: rgba(255, 224, 138, 0.45); }
}

.sc-spot.lose {
  opacity: 0.45;
}

.sic-felt .results {
  margin: 0;
}

.ab-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .kt-sic {
    --die: 16px;
  }

  .sic-felt {
    padding: 12px 8px 26px;
  }

  .sc-head {
    grid-template-columns: 1fr auto;
    grid-template-areas: "shaker result" "hist hist";
    gap: 8px;
  }

  .shaker { grid-area: shaker; width: 140px; height: 118px; }
  .sc-result { grid-area: result; }
  .sc-history { grid-area: hist; justify-self: stretch; width: auto; }

  .dome {
    height: 86px;
  }

  .sc-dice .sc-d {
    width: 28px;
  }

  .hs-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px 6px;
  }

  .hs-list li {
    font-size: 11px;
  }

  .hs-d {
    --die: 10px;
  }

  .sc-top {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-areas:
      "small small odd even big big"
      "tri tri tri tri tri tri"
      "d1 d2 d3 d4 d5 d6";
  }

  .sc-top [data-spot="small"] { grid-area: small; }
  .sc-top [data-spot="big"] { grid-area: big; }
  .sc-top [data-spot="odd"] { grid-area: odd; }
  .sc-top [data-spot="even"] { grid-area: even; }
  .sc-top [data-spot="double1"] { grid-area: d1; }
  .sc-top [data-spot="double2"] { grid-area: d2; }
  .sc-top [data-spot="double3"] { grid-area: d3; }
  .sc-top [data-spot="double4"] { grid-area: d4; }
  .sc-top [data-spot="double5"] { grid-area: d5; }
  .sc-top [data-spot="double6"] { grid-area: d6; }

  .sc-tri {
    grid-area: tri;
    grid-template-columns: 1.6fr repeat(6, minmax(0, 1fr));
  }

  .sc-tri-grid {
    display: contents;
  }

  .sc-small,
  .sc-big {
    min-height: 70px;
  }

  .sc-han {
    font-size: 24px;
  }

  .sc-name {
    font-size: 11px;
  }

  .sc-anyTriple .sc-name {
    font-size: 9px;
    line-height: 1.2;
    word-break: keep-all;
  }

  .sc-totals {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .sc-combos {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .sc-combo {
    min-height: 56px;
    --die: 15px;
  }

  .sc-single {
    --die: 22px;
  }

  .sc-triple {
    --die: 9px;
  }

  .sc-double {
    --die: 15px;
  }

  .sc-spot .spot-pay {
    font-size: 8.5px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .shaker.shake,
  .sc-spot.win {
    animation: none;
  }

  .dome {
    transition: none;
  }
}
