/* ============================================================
 * Pengundian TEP 2026 — stage visual
 * ============================================================ */

:root {
  --ud-navy-950: #050E1F;
  --ud-navy-900: #081531;
  --ud-navy-800: #0C1F45;
  --ud-navy-700: #122B5C;
  --ud-gold-500: #D4A853;
  --ud-gold-400: #E3C16F;
  --ud-gold-200: #F7ECCB;
  --ud-ink-100: #E2E8F0;
  --ud-ink-300: #94A3B8;
  --ud-ink-500: #64748B;
  --ud-success: #34D399;
  --ud-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --ud-serif: "Fraunces", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

.ud-body {
  font-family: var(--ud-sans);
  color: var(--ud-ink-100);
  background: var(--ud-navy-950);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* ---- Atmosphere ---- */
.ud-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ud-atmosphere__glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
}
.ud-atmosphere__glow--a {
  width: 55vw;
  height: 55vw;
  top: -18%;
  left: -12%;
  background: radial-gradient(circle, rgba(18, 43, 92, 0.9) 0%, transparent 70%);
}
.ud-atmosphere__glow--b {
  width: 45vw;
  height: 45vw;
  bottom: -10%;
  right: -8%;
  background: radial-gradient(circle, rgba(212, 168, 83, 0.22) 0%, transparent 70%);
}
.ud-atmosphere__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}

/* ---- Top bar ---- */
.ud-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px 8px;
  flex-wrap: wrap;
}
.ud-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ud-brand__logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  padding: 3px;
  box-shadow: 0 0 0 1px rgba(212, 168, 83, 0.4);
}
.ud-brand__kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ud-gold-400);
  font-weight: 600;
}
.ud-brand__title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.ud-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ud-meta__pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(212, 168, 83, 0.14);
  color: var(--ud-gold-200);
  border: 1px solid rgba(212, 168, 83, 0.28);
}
.ud-meta__pill--muted {
  background: rgba(255,255,255,0.05);
  color: var(--ud-ink-300);
  border-color: rgba(255,255,255,0.08);
}

/* ---- Stage ---- */
.ud-stage {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100dvh - 120px);
  justify-content: center;
}

.ud-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ud-gold-400);
  font-weight: 700;
}
.ud-headline {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.1;
}
.ud-headline__serif {
  font-family: var(--ud-serif);
  font-weight: 700;
  font-style: italic;
  color: var(--ud-gold-400);
}
.ud-lead {
  margin: 0 0 28px;
  max-width: 520px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ud-ink-300);
}
.ud-lead strong { color: var(--ud-gold-200); font-weight: 600; }

/* ---- Reel ---- */
.ud-reel-wrap {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr minmax(0, 720px) 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  /* Reserve vertical space so spin/winner visuals don't shove controls. */
  min-height: 240px;
  flex-shrink: 0;
}

.ud-reel {
  position: relative;
  border-radius: 28px;
  padding: 3px;
  background:
    linear-gradient(135deg, rgba(212,168,83,0.85) 0%, rgba(18,43,92,0.2) 40%, rgba(212,168,83,0.55) 100%);
  box-shadow:
    0 0 0 1px rgba(212,168,83,0.2),
    0 30px 80px rgba(0,0,0,0.45),
    0 0 60px rgba(212,168,83,0.12);
}
.ud-reel__frame {
  border-radius: 25px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(212,168,83,0.12) 0%, transparent 55%),
    linear-gradient(180deg, #0C1F45 0%, #081531 100%);
  padding: 36px 28px 40px;
  min-height: 240px;
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.ud-reel__frame::before,
.ud-reel__frame::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,83,0.45), transparent);
}
.ud-reel__frame::before { top: 18px; }
.ud-reel__frame::after  { bottom: 18px; }

.ud-reel__label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ud-gold-400);
  font-weight: 700;
  margin-bottom: 14px;
  transition: color 0.3s;
}
.ud-reel__name {
  font-family: var(--ud-serif);
  font-size: clamp(28px, 5.4vw, 56px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: #fff;
  max-width: 100%;
  word-break: break-word;
  transition: transform 0.08s linear, filter 0.08s linear, opacity 0.08s linear;
  text-shadow: 0 4px 30px rgba(0,0,0,0.35);
  min-height: 1.2em;
  max-height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ud-body[data-phase="idle"] .ud-reel__name {
  color: rgba(255, 255, 255, 0.35);
  text-shadow: none;
}
.ud-reel__sub {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ud-ink-300);
  max-width: 90%;
  line-height: 1.4;
  min-height: 1.4em;
}

/* Spinning state */
.ud-body[data-phase="spinning"] .ud-reel__name {
  filter: blur(1.5px);
  transform: scale(0.98);
  opacity: 0.92;
}
.ud-body[data-phase="spinning"] .ud-reel {
  animation: ud-pulse 0.9s ease-in-out infinite;
}
.ud-body[data-phase="spinning"] .ud-reel__label {
  color: #fff;
}
.ud-body[data-phase="spinning"] .ud-reel__label::after {
  content: " · mengacak";
  opacity: 0.7;
}

/* Decelerating */
.ud-body[data-phase="stopping"] .ud-reel__name {
  filter: blur(0.4px);
}

/* Winner reveal */
.ud-body[data-phase="winner"] .ud-reel {
  background:
    linear-gradient(135deg, #E3C16F 0%, #D4A853 35%, #F7ECCB 70%, #D4A853 100%);
  box-shadow:
    0 0 0 1px rgba(247,236,203,0.5),
    0 30px 90px rgba(212,168,83,0.35),
    0 0 100px rgba(212,168,83,0.28);
  animation: ud-winner-glow 1.6s ease-out;
}
.ud-body[data-phase="winner"] .ud-reel__frame {
  background:
    radial-gradient(100% 90% at 50% 0%, rgba(212,168,83,0.25) 0%, transparent 55%),
    linear-gradient(180deg, #122B5C 0%, #081531 100%);
}
.ud-body[data-phase="winner"] .ud-reel__name {
  color: var(--ud-gold-200);
  filter: none;
  transform: scale(1);
  animation: ud-name-pop 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.ud-body[data-phase="winner"] .ud-reel__label {
  color: var(--ud-success);
}
.ud-body[data-phase="winner"] .ud-reel__sub {
  color: var(--ud-gold-200);
}

@keyframes ud-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(212,168,83,0.25), 0 30px 80px rgba(0,0,0,0.45), 0 0 40px rgba(212,168,83,0.1); }
  50% { box-shadow: 0 0 0 1px rgba(212,168,83,0.55), 0 30px 80px rgba(0,0,0,0.45), 0 0 80px rgba(212,168,83,0.28); }
}
@keyframes ud-winner-glow {
  /* Glow only — avoid transform on reel so stage geometry stays put. */
  0%   { box-shadow: 0 0 0 1px rgba(247,236,203,0.2), 0 20px 60px rgba(212,168,83,0.15), 0 0 40px rgba(212,168,83,0.12); }
  60%  { box-shadow: 0 0 0 1px rgba(247,236,203,0.65), 0 34px 100px rgba(212,168,83,0.45), 0 0 120px rgba(212,168,83,0.4); }
  100% { box-shadow: 0 0 0 1px rgba(247,236,203,0.5), 0 30px 90px rgba(212,168,83,0.35), 0 0 100px rgba(212,168,83,0.28); }
}
@keyframes ud-name-pop {
  0% { transform: scale(0.85); opacity: 0.4; filter: blur(4px); }
  100% { transform: scale(1); opacity: 1; filter: none; }
}

/* Ghost name columns */
.ud-reel-ghost {
  height: 200px;
  overflow: hidden;
  mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent);
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}
.ud-body[data-phase="spinning"] .ud-reel-ghost,
.ud-body[data-phase="stopping"] .ud-reel-ghost {
  opacity: 0.45;
}
.ud-reel-ghost__track {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: ud-scroll 4.5s linear infinite;
}
.ud-reel-ghost--right .ud-reel-ghost__track {
  animation-duration: 5.2s;
  animation-direction: reverse;
}
.ud-reel-ghost__item {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 8px;
  text-align: left;
}
.ud-reel-ghost--right .ud-reel-ghost__item { text-align: right; }

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

@media (max-width: 900px) {
  .ud-reel-wrap { grid-template-columns: 1fr; }
  .ud-reel-ghost { display: none; }
}

/* ---- Controls ----
 * Stack all action buttons in one fixed slot so Start/Stop/Again swap
 * without reflow. Geometry stays identical across idle/spin/winner.
 */
.ud-controls {
  position: relative;
  width: min(100%, 280px);
  height: 54px;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.ud-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
  padding: 0 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: box-shadow 0.2s ease, background 0.2s, opacity 0.2s, filter 0.15s ease;
  justify-content: center;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 54px;
  min-width: 0;
  box-sizing: border-box;
}
.ud-btn[hidden] {
  display: none !important;
}
.ud-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ud-btn:not(:disabled):hover { filter: brightness(1.06); }
.ud-btn:not(:disabled):active { filter: brightness(0.96); }

.ud-btn--start {
  background: linear-gradient(135deg, #E3C16F 0%, #D4A853 50%, #B38A2B 100%);
  color: var(--ud-navy-900);
  box-shadow: 0 12px 32px rgba(212, 168, 83, 0.35);
}
.ud-btn--start:not(:disabled):hover {
  box-shadow: 0 16px 40px rgba(212, 168, 83, 0.5);
}

.ud-btn--stop {
  background: linear-gradient(135deg, #F87171 0%, #DC2626 100%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(220, 38, 38, 0.35);
  animation: ud-stop-pulse 1.2s ease-in-out infinite;
}
@keyframes ud-stop-pulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(220, 38, 38, 0.35); }
  50% { box-shadow: 0 12px 40px rgba(220, 38, 38, 0.6), 0 0 0 6px rgba(220,38,38,0.12); }
}

.ud-btn--again {
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.18);
}
.ud-btn--again:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(212,168,83,0.45);
  color: var(--ud-gold-200);
}

.ud-hint {
  margin: 0 0 22px;
  font-size: 12px;
  color: var(--ud-ink-500);
  letter-spacing: 0.04em;
}

/* ---- History ---- */
.ud-history {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto 40px;
  padding: 0 24px;
}
.ud-history__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 10px;
}
.ud-history__head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ud-gold-400);
  font-weight: 700;
}
.ud-history__meta {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-shrink: 0;
}
.ud-history__meta span {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ud-ink-300);
  font-size: 13px;
}
.ud-history__clear {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ud-gold-400);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ud-history__clear:hover {
  color: var(--ud-gold-200);
}
.ud-history__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ud-history__item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  animation: ud-hist-in 0.4s ease-out;
}
@keyframes ud-hist-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.ud-history__rank {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(212,168,83,0.15);
  color: var(--ud-gold-400);
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.ud-history__name {
  font-weight: 700;
  color: #fff;
  font-size: 14.5px;
  text-align: left;
}
.ud-history__kawasan {
  font-size: 12px;
  color: var(--ud-ink-300);
  text-align: left;
  margin-top: 2px;
}
.ud-history__time {
  font-size: 11px;
  color: var(--ud-ink-500);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Confetti ---- */
.ud-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.ud-confetti__piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0.9;
  animation: ud-fall linear forwards;
}
@keyframes ud-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ---- Footer ---- */
.ud-foot {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 16px 24px 28px;
  font-size: 12px;
  color: var(--ud-ink-500);
}

@media (max-width: 640px) {
  .ud-top { padding: 14px 16px 4px; }
  .ud-stage { padding: 12px 16px 32px; min-height: calc(100dvh - 160px); }
  .ud-reel-wrap { min-height: 200px; }
  .ud-reel__frame { padding: 28px 18px 32px; min-height: 200px; height: 200px; }
  .ud-controls { width: 100%; height: 54px; }
  .ud-history__item { grid-template-columns: 32px 1fr; }
  .ud-history__time { grid-column: 2; text-align: left; }
}
