/* Card */

.cd-stats { font: 600 1rem/1 var(--font-display); color: var(--muted); white-space: nowrap; }
.cd-stats b { color: var(--ink); }

.cd-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------ table: card + roller */

.cd-table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 auto;
}

.cd-card-wrap {
  position: relative;
  flex: none;
  width: clamp(170px, 48vw, 232px);
  aspect-ratio: 250 / 350;
  margin-left: 24px; /* room for the multiplier sticker */
  perspective: 1100px;
  transition: opacity .15s, transform .15s;
}
.cd-card-wrap.gone { opacity: 0; transform: translateY(12px) scale(.96); }
.cd-card-wrap.deal { animation: cd-deal .5s cubic-bezier(.25, 1.3, .5, 1) both; }
@keyframes cd-deal { from { opacity: 0; transform: translate(70px, -50px) rotate(14deg) scale(.8); } }

.cd-tilt {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .2s ease-out;
}
.cd-tilt.up { animation: cd-up .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes cd-up { 40% { transform: scale(1.07) rotate(-2deg); } }

.cd-card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4, .1, .25, 1);
  cursor: default;
}
.cd-card.flipped { transform: rotateY(180deg); }
.cd-card.instant { transition: none; }
.cd-card[title] { cursor: pointer; }
.cd-app.quick .cd-card { transition-duration: .16s; }

.cd-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 6px 0 rgba(29, 27, 22, .9), 0 18px 30px -14px rgba(29, 27, 22, .45);
  border-radius: 14px;
}
.cd-back { transform: rotateY(180deg); background: #fff; border: 2.5px solid var(--ink); overflow: hidden; }
.cd-svg { display: block; width: 100%; height: 100%; }

/* the front, shared by the big card and the little ones on the shelf */
.cd-front {
  position: absolute;
  inset: 0;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
}
.cd-front > * { position: absolute; inset: 0; }
.cd-front .cd-svg { position: relative; }

/* tier materials */
[data-tier=silver] .cd-front {
  background: linear-gradient(135deg, #f4f6f9 0%, #cdd3dc 28%, #fbfcfd 48%, #b7bfca 70%, #eef1f5 100%);
}
[data-tier=gold] .cd-front {
  background: linear-gradient(135deg, #fff3c2 0%, #f0c445 28%, #fff7d6 48%, #d9a21c 72%, #ffe596 100%);
}
[data-tier=diamond] .cd-front {
  background:
    repeating-linear-gradient(60deg, rgba(255, 255, 255, .55) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(-60deg, rgba(120, 190, 255, .35) 0 2px, transparent 2px 26px),
    linear-gradient(135deg, #e6fbff 0%, #a9e6ff 28%, #ffffff 48%, #9ccfff 70%, #e3f3ff 100%);
}
[data-tier=silver] .cd-front::after,
[data-tier=gold] .cd-front::after,
[data-tier=diamond] .cd-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .75) 48%, transparent 60%);
  background-size: 300% 100%;
  animation: cd-sweep 3.2s ease-in-out infinite;
  pointer-events: none;
}
[data-tier=diamond] .cd-front::after { animation-duration: 2.2s; }
@keyframes cd-sweep { 0% { background-position: 120% 0; } 60%, 100% { background-position: -20% 0; } }

/* holo: a tint that multiplies over the white of the card and drifts */
.cd-holo {
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  background-size: 260% 260%;
  transition: opacity .3s;
}
[data-holo] .cd-holo { opacity: 1; animation: cd-holo 4s ease-in-out infinite alternate; }
@keyframes cd-holo { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }
[data-holo=glimmer] .cd-holo { background-image: linear-gradient(115deg, #fff 15%, #e6eeff 32%, #fff 48%, #fbe6ff 64%, #fff 80%, #e6fff6 95%); }
[data-holo=aqua] .cd-holo { background-image: linear-gradient(115deg, #d8fbff 10%, #9feaf2 30%, #e0fff8 50%, #8fd8f5 70%, #dcf7ff 90%); }
[data-holo=rose] .cd-holo { background-image: linear-gradient(115deg, #ffe0ec 10%, #ffb3cf 30%, #fff0f5 50%, #ffa3c4 70%, #ffe3ee 90%); }
[data-holo=emerald] .cd-holo { background-image: linear-gradient(115deg, #dcfbe6 10%, #8eeab4 30%, #e8fff0 50%, #6fdc9f 70%, #d5f9e2 90%); }
[data-holo=sunset] .cd-holo { background-image: linear-gradient(115deg, #ffe1b8 10%, #ffad9c 30%, #fff3b0 50%, #ff9fb8 70%, #ffd29a 90%); }
[data-holo=aurora] .cd-holo { background-image: linear-gradient(115deg, #b9fbc0 5%, #98f5e1 25%, #a3c4f3 45%, #f1c0e8 65%, #b9fbc0 85%); }
[data-holo=prism] .cd-holo { background-image: linear-gradient(115deg, #ffadad, #ffd6a5, #fdffb6, #caffbf, #9bf6ff, #a0c4ff, #bdb2ff, #ffc6ff, #ffadad); }
[data-holo=cosmic] .cd-holo {
  background-image:
    radial-gradient(circle at 20% 25%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, #fff 0 1px, transparent 2px),
    linear-gradient(115deg, #d8b4fe, #93c5fd, #f9a8d4, #fde68a, #a5f3fc, #c4b5fd, #f9a8d4, #d8b4fe);
  background-size: 34px 34px, 46px 46px, 260% 260%;
}

.cd-glare {
  pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 30%), rgba(255, 255, 255, .7), transparent 45%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity .25s;
}
.cd-card-wrap:hover .cd-glare { opacity: .7; }
.cd-card-wrap:hover [data-holo] .cd-glare { opacity: 1; }

.cd-flash { pointer-events: none; background: #fff; opacity: 0; }
.cd-tilt.up .cd-flash { animation: cd-flash .5s ease-out; }
@keyframes cd-flash { from { opacity: .9; } }

/* the multiplier sticker on the card's left edge */
.cd-mult {
  position: absolute;
  left: -24px;
  top: 16%;
  z-index: 3;
  padding: 5px 11px 7px;
  font: 700 1.45rem/1 var(--font-display);
  color: #fff;
  background: var(--tc, var(--t-common));
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-9deg);
  animation: cd-stick .4s cubic-bezier(.3, 1.6, .5, 1) both;
}
.cd-mult.tier-common { background: var(--accent); color: var(--ink); }
@keyframes cd-stick { from { opacity: 0; transform: rotate(-30deg) scale(1.8); } }

/* ------------------------------------------------------------ the roller next to the card */

.cd-roller {
  flex: none;
  width: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.cd-roll-label {
  font: 600 .92rem/1.2 var(--font-display);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.cd-roll-note {
  min-height: 2.8em;
  font-weight: 700;
  font-size: .92rem;
  line-height: 1.35;
  color: var(--muted);
}
.cd-roll-note.ok { color: var(--good); }
.cd-roll-note.no { color: var(--bad); }

.cd-die {
  width: 74px;
  height: 74px;
  padding: 11px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  transition: opacity .2s, outline-color .2s;
  outline: 4px solid transparent;
  outline-offset: 3px;
}
.cd-die i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
  transform: scale(.4);
}
.cd-die i.on { opacity: 1; transform: none; }
.cd-die[data-kind=silver] { background: linear-gradient(135deg, #f7f8fa, #c3cad4 45%, #f3f5f8 60%, #aeb6c2); }
.cd-die[data-kind=gold] { background: linear-gradient(135deg, #fff1b8, #edb92e 45%, #fff3c4 60%, #c8901a); }
.cd-die.idle { opacity: .35; }
.cd-die.rolling { animation: cd-shake .16s linear infinite; }
.cd-die.land { animation: cd-land .35s cubic-bezier(.3, 1.6, .5, 1); }
.cd-die.pass { outline-color: var(--good); }
.cd-die.fail { outline-color: var(--bad); }
@keyframes cd-shake {
  0% { transform: translate(-3px, 1px) rotate(-9deg); }
  25% { transform: translate(2px, -3px) rotate(6deg); }
  50% { transform: translate(3px, 2px) rotate(10deg); }
  75% { transform: translate(-2px, -2px) rotate(-5deg); }
  100% { transform: translate(-3px, 1px) rotate(-9deg); }
}
@keyframes cd-land { 0% { transform: scale(1.25); } }

.cd-slot {
  min-width: 96px;
  height: 74px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  font: 700 1.45rem/1 var(--font-display);
  white-space: nowrap;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  overflow: hidden;
}
.cd-slot.long { font-size: 1.05rem; }
.cd-slot-sym { width: 48px; height: 48px; }

/* ------------------------------------------------------------ buttons */

.cd-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 34px 0 30px;
}
.cd-options { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 22px; }
.cd-quick { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; color: var(--muted); cursor: pointer; user-select: none; }
.cd-quick input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }

/* ------------------------------------------------------------ result */

.cd-result-head { text-align: center; margin-bottom: 10px; }
.cd-name { font: 600 1.3rem/1.2 var(--font-display); }
.cd-value { font: 700 clamp(2.6rem, 10vw, 3.6rem)/1.05 var(--font-display); letter-spacing: -.02em; margin: 4px 0; }
.cd-standing { color: var(--muted); font-weight: 700; }
.cd-standing b { color: var(--t-legendary); }

.cd-steps { list-style: none; margin: 0 0 14px; padding: 0; }
.cd-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1.5px dashed var(--line);
  animation: cd-step .25s ease both;
}
.cd-steps li:last-child { border-bottom: 0; }
.cd-steps .k { flex: none; width: 7.2em; font: 600 .95rem/1.2 var(--font-display); color: var(--muted); }
.cd-steps .v { flex: 1; min-width: 0; }
.cd-steps .ok { color: var(--good); }
.cd-steps .no { color: var(--bad); font-weight: 700; }
@keyframes cd-step { from { opacity: 0; transform: translateX(-8px); } }

.cd-math { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--soft); border-radius: 14px; overflow: hidden; }
.cd-math td { padding: 7px 12px; }
.cd-math td:nth-child(2) { color: var(--muted); font-weight: 700; }
.cd-math td:last-child { text-align: right; font: 600 1rem/1.2 var(--font-display); white-space: nowrap; }
.cd-math tr.none { opacity: .45; }
.cd-math tfoot td { border-top: 2px solid var(--ink); font: 700 1.2rem/1.2 var(--font-display); padding-top: 10px; padding-bottom: 10px; }

/* ------------------------------------------------------------ recent pulls */

.cd-recent h2 { font: 600 1.4rem/1.2 var(--font-display); margin: 8px 0 14px; }
.cd-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 16px 12px; }
.cd-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: 600 .9rem/1 var(--font-display);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.cd-mini:hover { transform: translateY(-4px) rotate(-2deg); }
.cd-mini:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 10px; }
.cd-mini-card { position: relative; width: 100%; aspect-ratio: 250 / 350; }
.cd-mini-card .cd-front,
.cd-back-flat { border-width: 2px; border-radius: 8px; box-shadow: 0 3px 0 var(--ink); }
.cd-back-flat { position: absolute; inset: 0; border: 2px solid var(--ink); overflow: hidden; background: #fff; }
.cd-mini-card.big { width: min(180px, 38vw); }
.cd-mini-card.big .cd-front,
.cd-mini-card.big .cd-back-flat { border-width: 2.5px; border-radius: 12px; box-shadow: 0 5px 0 var(--ink); }
.cd-pair { display: flex; justify-content: center; gap: 16px; margin: 4px 0 22px; }

/* ------------------------------------------------------------ odds */

.cd-odds { width: 100%; border-collapse: collapse; font-size: .95rem; }
.cd-odds td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.cd-odds td:first-child { font-weight: 700; }
.cd-odds td:nth-child(2) { color: var(--muted); font-weight: 700; }
.cd-odds td:last-child { text-align: right; }
.cd-odds-sym { width: 22px; height: 22px; vertical-align: -5px; margin-right: 4px; }
.modal h3 { font: 600 1.1rem/1.2 var(--font-display); margin: 20px 0 6px; }

@media (max-width: 560px) {
  .cd-table { gap: 12px; }
  .cd-card-wrap { margin-left: 18px; }
  .cd-roller { width: 96px; }
  .cd-mult { left: -18px; font-size: 1.2rem; }
  .cd-steps .k { width: 6.2em; }
  .cd-math td { padding: 6px 8px; }
}
