.reel-frame {
  position: relative;
  z-index: 2;
  width: min(560px, 100%);
}

.reel-frame.slide-in {
  animation: reel-slide-in 0.35s ease;
}

@keyframes reel-slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.reel-window {
  position: relative;
  width: 100%;
  height: calc(var(--reel-row-h, 64px) * 7);
  overflow: hidden;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 32px rgba(255, 215, 0, 0.15);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 22%, black 78%, transparent 100%);
}

.reel-window.is-empty::after {
  content: 'Tidak ada peserta';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.95rem;
}

.reel-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.reel-row {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: transform, opacity, filter;
}

.reel-row.is-center {
  color: var(--gold);
  font-size: clamp(1.3rem, 3.2vw, 1.6rem);
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
}

.reel-highlight {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--reel-row-h, 64px);
  transform: translateY(-50%);
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  box-shadow: inset 0 0 24px rgba(255, 215, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  pointer-events: none;
}

.reel-arrow {
  color: var(--gold);
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

.btn-stop {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red-1), var(--red-2));
  color: var(--white);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 0 30px rgba(255, 23, 68, 0.5);
  animation: stop-pulse 1s ease-in-out infinite;
}

@keyframes stop-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Distinct look once STOP has actually been pressed, so the operator can
   tell the click registered instead of the button looking identical to its
   idle "click me" pulse for the ~6s it takes the reel to settle. A ring
   spins around it instead of the button just pulsing/dimming, so the shape
   itself visibly changes, not just its color. */
.btn-stop.is-stopping {
  animation: stop-processing 1.3s ease-in-out infinite;
  cursor: not-allowed;
}

.btn-stop.is-stopping::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.9);
  border-right-color: rgba(255, 255, 255, 0.35);
  animation: stop-ring-spin 0.8s linear infinite;
}

@keyframes stop-ring-spin {
  to { transform: rotate(360deg); }
}

@keyframes stop-processing {
  0%, 100% { transform: scale(0.96); box-shadow: 0 0 30px rgba(255, 23, 68, 0.5); }
  50% { transform: scale(0.99); box-shadow: 0 0 12px rgba(255, 23, 68, 0.25); }
}

/*
 * min-width: 0 everywhere down this chain — flex items default to
 * min-width:auto, which means "never shrink below your content's natural
 * size". .nama-display's content is nowrap text, so its natural size for a
 * long name is however wide that text is; without min-width:0 breaking that
 * default at every level, a long name doesn't get ellipsis-truncated — it
 * pushes .preview-name, .preview-container, and .reel-panel wider than the
 * page instead.
 */
.preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.preview-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 2.6em;
  width: 100%;
  min-width: 0;
}

.nama-display {
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
  text-align: center;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 12px;
  box-sizing: border-box;
}

.unit-display {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  min-height: 1.3em;
}

/*
 * Two identical animations under different class names, alternated in JS
 * instead of remove+forced-reflow+add on a single class — restarting the
 * same animation name needs a synchronous layout read (offsetWidth) to
 * work, and doing that every animation frame while spinning caused visible
 * jank. Switching between "pop-a"/"pop-b" starts fresh each time without
 * forcing a reflow.
 */
.preview-name.pop-a {
  animation: current-name-pop 0.28s ease;
}

.preview-name.pop-b {
  animation: current-name-pop-alt 0.28s ease;
}

@keyframes current-name-pop {
  0% { transform: scale(1.4); opacity: 0.35; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes current-name-pop-alt {
  0% { transform: scale(1.4); opacity: 0.35; }
  100% { transform: scale(1); opacity: 1; }
}

/* Winner reveal: bigger text + a distinct pop-in, layered on top of
   whichever pop-a/pop-b animation was already mid-flight. */
.preview-name.is-winner .nama-display {
  font-size: clamp(2.4rem, 5vw, 3rem);
}

.preview-name.is-winner {
  animation: winner-zoom-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes winner-zoom-in {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Speed indicator ---------- */

.speed-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(280px, 90%);
}

.speed-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.speed-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.speed-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.15s linear, background 0.25s ease;
}

.speed-bar.level-fast {
  background: linear-gradient(90deg, var(--red-1), var(--red-2));
}

.speed-bar.level-medium {
  background: linear-gradient(90deg, #FFD93D, #FFB300);
}

.speed-bar.level-slow {
  background: linear-gradient(90deg, #6BCB77, var(--green-1));
}

.speed-bar.level-stopped {
  width: 0% !important;
  background: var(--gold);
}

.speed-indicator.is-stopped .speed-track {
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.6);
}

/* ---------- Ticker ---------- */

.ticker {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  padding: 6px 0;
}

.ticker-text {
  display: inline-flex;
  gap: 36px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  animation: ticker-scroll linear infinite;
  animation-duration: 20s;
}

.ticker.is-paused .ticker-text {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.shake {
  animation: reel-impact 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes reel-impact {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.97) rotate(-1deg); }
  50% { transform: scale(1.02) rotate(0.7deg); }
  72% { transform: scale(0.99) rotate(-0.3deg); }
  100% { transform: scale(1) rotate(0deg); }
}
