@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

html,
body {
  margin: 0;
  background: transparent;
  overflow: hidden;
}

.roulette {
  --accent: #ffb020;
  --accent-soft: rgba(255, 176, 32, 0.18);
  --card: rgba(18, 18, 24, 0.86);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --scale: 1;

  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.4em;
  box-sizing: border-box;
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: calc(22px * var(--scale));
  color: var(--text);
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
}
.roulette[data-pos='top'] { align-items: flex-start; }
.roulette[data-pos='bottom'] { align-items: flex-end; }

.spin {
  position: relative;
  width: 24em;
  padding: 1em 1.2em 1.2em;
  border-radius: 1.1em;
  background: var(--card);
  box-shadow: 0 0.6em 2em rgba(0, 0, 0, 0.35), inset 0 0 0 2px var(--accent);
  box-sizing: border-box;
  animation: enter 460ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.spin.leaving { animation: leave 320ms ease-in both; }
.spin.landed { animation: enter 460ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both, glow 1.4s ease-out; }

.head {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  margin-bottom: 0.7em;
  line-height: 1.3;
}
.nick {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.15em;
  font-weight: 700;
}
.times {
  flex: none;
  margin-left: auto;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Three rows visible, the centre one is the pointer slot. */
.reel {
  --row: 2.3em;
  position: relative;
  height: calc(var(--row) * 3);
  overflow: hidden;
  border-radius: 0.7em;
  background: rgba(255, 255, 255, 0.04);
  font-size: 1.6em;
  -webkit-mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
  mask-image: linear-gradient(transparent, #000 30%, #000 70%, transparent);
}
.reel::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: var(--row);
  height: var(--row);
  border-radius: 0.45em;
  box-shadow: inset 0 0 0 2px var(--accent);
  background: var(--accent-soft);
}
.strip { will-change: transform; }
.row {
  height: var(--row);
  line-height: var(--row);
  padding: 0 0.6em;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--muted);
}
.row.hit { color: var(--accent); }
.landed .row.hit { animation: pop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4); }

/* Tally for several spins from one gift, revealed after the reel lands. */
.tally {
  display: grid;
  gap: 0.35em 1em;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 420ms ease, margin-top 420ms ease, opacity 300ms 120ms ease;
}
.tally.two { grid-template-columns: 1fr 1fr; }
.listed .tally { max-height: 16em; margin-top: 0.9em; opacity: 1; }
.tally li {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  font-size: 1.2em;
  line-height: 1.35;
}
.tally .label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.tally .n {
  flex: none;
  margin-left: auto;
  color: var(--accent);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(0.8em) scale(0.92); }
  to { opacity: 1; transform: none; }
}
@keyframes leave {
  to { opacity: 0; transform: translateY(-0.5em) scale(0.97); }
}
@keyframes glow {
  0% { box-shadow: 0 0 0 rgba(0, 0, 0, 0), 0 0.6em 2em rgba(0, 0, 0, 0.35), inset 0 0 0 2px var(--accent); }
  30% { box-shadow: 0 0 2.6em var(--accent-soft), 0 0.6em 2em rgba(0, 0, 0, 0.35), inset 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 rgba(0, 0, 0, 0), 0 0.6em 2em rgba(0, 0, 0, 0.35), inset 0 0 0 2px var(--accent); }
}
@keyframes pop {
  50% { transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
  .spin, .spin.leaving, .spin.landed, .landed .row.hit { animation-duration: 1ms; }
  .tally { transition: none; }
}
