.roll-stage {
  --stage-ink: #f4efff;
  --stage-muted: #bfb2dc;
  --stage-accent: #bda4ff;
  --stage-accent-rgb: 170 132 255;
  --stage-light: #ffe398;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #47396c;
  border-radius: 17px;
  color: var(--stage-ink);
  background: radial-gradient(ellipse at 27% 64%, #30214f, transparent 64%), #141026;
  box-shadow: 0 10px 24px #1d14331a;
}
.roll-stage-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 9px 14px;
  border-bottom: 1px solid #ffffff1c;
  background: #0b091740;
  font-size: .79rem;
  font-weight: 690;
}
.roll-stage-label {
  padding: 4px 8px;
  border-radius: 5px;
  color: var(--stage-accent);
  background: rgb(var(--stage-accent-rgb) / .12);
  text-align: right;
}
.roll-stage[data-state="win"] .roll-stage-label { background: var(--stage-light); color: #332302; }
.roll-stage-body {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(125px, .76fr) minmax(0, 1.24fr);
  align-items: center;
  gap: clamp(9px, 2vw, 19px);
  padding: clamp(10px, 2vw, 19px);
}
.roll-orbit {
  position: relative;
  display: grid;
  min-height: 176px;
  place-items: center;
}
.roll-orbit::before, .roll-orbit::after, .roll-orbit-ring {
  position: absolute;
  inset: 50% auto auto 50%;
  border-radius: 50%;
  translate: -50% -50%;
  pointer-events: none;
}
.roll-orbit::before {
  content: "";
  width: 90%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgb(var(--stage-accent-rgb) / .27), transparent 67%);
}
.roll-orbit::after {
  content: "";
  width: 87%;
  aspect-ratio: 1;
  border: 1px dashed rgb(var(--stage-accent-rgb) / .36);
  box-shadow: inset 0 0 16px rgb(var(--stage-accent-rgb) / .16);
}
.roll-orbit-ring {
  width: 73%;
  aspect-ratio: 1;
  border: 2px solid rgb(var(--stage-accent-rgb) / .2);
  border-right-color: var(--stage-accent);
  border-left-color: rgb(var(--stage-accent-rgb) / .65);
  box-shadow: 0 0 18px rgb(var(--stage-accent-rgb) / .18);
  transform: rotate(-27deg);
}
.roll-core { position: relative; z-index: 1; width: min(66%, 110px); height: auto; object-fit: contain; }
img.roll-core { image-rendering: pixelated; filter: drop-shadow(0 7px 10px #160d30aa); }
.roll-stage[data-state="rolling"] .roll-orbit-ring { animation: roll-spin .65s linear infinite; }
.roll-stage[data-state="rolling"] .roll-orbit::before { animation: roll-charge .57s ease-in-out infinite alternate; }
.roll-stage[data-state="win"] .roll-orbit-ring { border-color: #ffe39880; box-shadow: 0 0 25px #ffe39850; }
.roll-stage[data-state="win"] .roll-orbit::before {
  background: radial-gradient(circle, #ffe39888, transparent 67%);
  animation: roll-bloom .8s cubic-bezier(.17,.9,.3,1) both;
}
.roll-stage[data-state="win"]::before {
  content: "";
  position: absolute;
  inset: -35% 30% -38% -24%;
  background: radial-gradient(circle, #ffe39855, transparent 61%);
  pointer-events: none;
  animation: roll-bloom .85s cubic-bezier(.17,.9,.3,1) both;
}
.roll-stage[data-state="win"] .roll-orbit::after {
  border-color: var(--stage-light);
  animation: roll-shockwave .73s ease-out both;
}
.roll-stage-copy { min-width: 0; }
.roll-stage-copy .roll-stage-title {
  margin: 0 0 4px;
  color: var(--stage-ink);
  font-size: 1.08rem;
}
.roll-stage-copy .roll-stage-subtitle { margin: 0 0 9px; color: var(--stage-muted); font-size: .78rem; }
.roll-lines { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.roll-lines > li {
  position: relative;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 7px 8px;
  overflow: hidden;
  border: 1px solid #ffffff26;
  border-radius: 7px;
  background: #080d1b80;
  color: var(--stage-ink);
}
.roll-lines > li[data-empty] { color: var(--stage-muted); }
.roll-lines > li > span:first-child { color: var(--stage-muted); font: 550 .74rem var(--mono); }
.roll-lines > li strong { overflow-wrap: anywhere; font-size: .85rem; font-weight: 650; }
.roll-grade {
  padding: 3px 5px;
  border-radius: 4px;
  background: #46668b42;
  color: #c2dbfa;
  font-size: .69rem;
  font-weight: 680;
  white-space: nowrap;
}
.roll-grade[data-grade="에픽"] { background: #58418d65; color: #e7d7ff; }
.roll-grade[data-grade="유니크"] { background: #ad67284a; color: #ffd89b; }
.roll-grade[data-grade="레전드리"] { background: #2f795d6e; color: #b0f5cc; }
.roll-stage[data-state="rolling"] .roll-lines > li:not([data-locked]) > * { opacity: .16; }
.roll-stage[data-state="rolling"] .roll-lines > li:not([data-locked])::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 12%, rgb(var(--stage-accent-rgb) / .25), transparent 83%);
  animation: roll-sweep .55s ease-in-out infinite;
}
.roll-stage:is([data-state="result"], [data-state="win"]) .roll-lines > li:not([data-locked]) {
  animation: roll-reveal .32s cubic-bezier(.15,.78,.24,1) both;
}
.roll-stage:is([data-state="result"], [data-state="win"]) .roll-lines > li:nth-child(2) { animation-delay: 55ms; }
.roll-stage:is([data-state="result"], [data-state="win"]) .roll-lines > li:nth-child(3) { animation-delay: 110ms; }
.roll-stage[data-state="win"] .roll-lines > li[data-hit] {
  border-color: #ffe398a8;
  background: #524021;
}
.roll-stage :focus-visible { outline-color: var(--stage-accent); }
@keyframes roll-spin { to { transform: rotate(333deg); } }
@keyframes roll-charge { from { transform: scale(.77); opacity: .55; } to { transform: scale(1.34); opacity: 1; } }
@keyframes roll-sweep { from { transform: translateX(-95%); } to { transform: translateX(95%); } }
@keyframes roll-reveal { from { opacity: 0; transform: translateY(-7px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes roll-bloom { from { transform: scale(.68); opacity: 1; } to { transform: scale(1.5); opacity: .55; } }
@keyframes roll-shockwave { from { transform: scale(.78); opacity: 1; } to { transform: scale(1.45); opacity: .12; } }

@media (max-width: 510px) {
  .roll-stage-body { grid-template-columns: clamp(46px, 16vw, 75px) minmax(0, 1fr); }
  .roll-orbit { align-self: start; min-height: 73px; }
  .roll-core { width: 78%; }
  .roll-lines > li { gap: 5px; min-height: 36px; padding: 6px; }
  .roll-lines > li strong { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .roll-stage, .roll-stage *, .roll-stage::before, .roll-stage *::before, .roll-stage *::after { animation: none !important; }
  .roll-stage[data-state="rolling"] .roll-lines > li:not([data-locked]) > * { opacity: 1; }
}

.roll-win {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 3vw, 18px);
  overflow: hidden;
  margin: 0 clamp(10px, 2vw, 19px) clamp(10px, 2vw, 19px);
  padding: clamp(12px, 3vw, 20px);
  border: 1px solid #dbac617e;
  border-radius: 11px;
  background: radial-gradient(ellipse at left top, #634027, transparent 75%), linear-gradient(112deg, #3d2a2d, #281b36);
  box-shadow: inset 0 1px #ffe39829;
}
.roll-win-seal {
  display: grid;
  place-items: center;
  width: clamp(38px, 8vw, 62px);
  aspect-ratio: 1;
  border: 1px solid #edbc68;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 25%, #fff2bf, #e1a64c);
  box-shadow: inset 0 0 0 3px #55321c36, 0 0 18px #e1a64c42;
}
.roll-win-seal::before {
  content: "";
  width: 56%;
  aspect-ratio: 1;
  background: #613714;
  clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
}
.roll-win-copy { overflow-wrap: anywhere; word-break: keep-all; }
.roll-win-title { color: var(--stage-light); font-size: .82rem; font-weight: 770; }
.roll-win-goals { color: #fff4dc; font-size: clamp(1.15rem, 2.6vw, 1.75rem); font-weight: 790; line-height: 1.24; }
.roll-win-attempt { margin-top: 5px; color: #ecdcc8; font-size: .84rem; }
.roll-win-attempt strong { margin-inline-end: .13em; color: var(--stage-light); font-variant-numeric: tabular-nums; }
.roll-stage .roll-win .roll-win-replay {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  scroll-margin-block: 14px;
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .85rem;
  font-weight: 680;
}
.roll-stage .roll-win .roll-win-replay:hover { border-color: var(--accent); }
.roll-win-replay span { font-size: 1.05rem; line-height: 1; }
