/* =============================================
   LOTTERY PAGE — Standalone Styles
   ============================================= */

/* ---------- Variables ---------- */
:root {
  --bg-deep: #0a0e1a;
  --bg-card: rgba(20, 28, 45, 0.85);
  --bg-card-glow: rgba(30, 40, 65, 0.95);
  --accent-gold: #f0c040;
  --accent-neon: #00f0ff;
  --accent-pink: #ff3070;
  --accent-purple: #8b5cf6;
  --accent-green: #34d399;
  --text-primary: #f0f4f8;
  --text-secondary: #8b99ae;
  --text-muted: #4a5568;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 20px;
  --glass: blur(24px);
  --transition: 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans TC', 'Outfit', sans-serif;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 240, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(255, 48, 112, 0.05) 0%, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Particle Canvas ---------- */
#particleCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Header ---------- */
.lottery-header {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 24px 20px;
  max-width: 800px;
  margin: 0 auto;
}

.back-link {
  display: inline-block;
  color: var(--accent-neon);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 6px 16px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 100px;
  transition: var(--transition);
}
.back-link:hover {
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.lottery-header h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-pink), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 10px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
}

/* ---------- Main ---------- */
.lottery-main {
  position: relative;
  z-index: 2;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- Controls ---------- */
.controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--glass);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control-row label {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.control-row select {
  flex: 1;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.control-row select:focus {
  border-color: var(--accent-neon);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.12);
}
.control-row select option {
  background: #1a2035;
  color: var(--text-primary);
}

.participant-info {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- Wheel Section ---------- */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.wheel-container {
  position: relative;
  width: min(420px, 90vw);
  height: min(420px, 90vw);
  /* 幫轉盤外圈加發光底圈 */
  filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.2))
          drop-shadow(0 0 60px rgba(0, 240, 255, 0.1));
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: filter var(--transition);
}

.wheel-pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.5rem;
  color: var(--accent-gold);
  z-index: 10;
  filter: drop-shadow(0 2px 6px rgba(240, 192, 64, 0.6));
  animation: pointerPulse 2s ease-in-out infinite;
}

@keyframes pointerPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.12); }
}

/* ---------- Spin Button ---------- */
.spin-btn {
  position: relative;
  padding: 16px 48px;
  font-size: 1.2rem;
  font-weight: 900;
  font-family: inherit;
  color: #000;
  background: linear-gradient(135deg, var(--accent-gold), #ffb020, var(--accent-gold));
  background-size: 200% 200%;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.4s ease;
  box-shadow:
    0 4px 20px rgba(240, 192, 64, 0.4),
    0 0 40px rgba(240, 192, 64, 0.15);
  overflow: hidden;
}

.spin-btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-pink), var(--accent-purple), var(--accent-neon));
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.spin-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.03);
  box-shadow:
    0 8px 30px rgba(240, 192, 64, 0.5),
    0 0 60px rgba(240, 192, 64, 0.2);
  background-position: 100% 100%;
}

.spin-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.spin-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.hidden { display: none !important; }

/* ---------- Weight Table ---------- */
.weight-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: var(--glass);
}

.weight-table-card h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.weight-table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.rank-emoji {
  font-size: 1.2rem;
}

.prob-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prob-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-neon), var(--accent-purple));
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.prob-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-neon);
  min-width: 50px;
  text-align: right;
}

/* ---------- Result Overlay ---------- */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 20px;
}
.result-overlay.open {
  display: grid;
}

.result-modal {
  position: relative;
  background: linear-gradient(145deg, rgba(20, 28, 50, 0.95), rgba(30, 20, 50, 0.95));
  border: 1px solid rgba(240, 192, 64, 0.3);
  border-radius: 28px;
  padding: 48px 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 0 80px rgba(240, 192, 64, 0.2),
    0 0 160px rgba(139, 92, 246, 0.1);
  animation: resultIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@keyframes resultIn {
  from { opacity: 0; transform: scale(0.6) translateY(40px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.trophy-icon {
  font-size: 4.5rem;
  filter: drop-shadow(0 0 20px rgba(240, 192, 64, 0.5));
  animation: trophyBounce 0.8s ease 0.3s;
  margin-bottom: 8px;
}

@keyframes trophyBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.result-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent-gold);
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(240, 192, 64, 0.3);
}

.winner-name {
  font-family: 'Outfit', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold), #fff, var(--accent-gold));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
  margin-bottom: 12px;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.winner-stats {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.result-close-btn {
  padding: 14px 40px;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: inherit;
  color: #000;
  background: linear-gradient(135deg, var(--accent-gold), #ffb020);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(240, 192, 64, 0.35);
  margin-right: 8px;
}
.result-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(240, 192, 64, 0.5);
}

.respin-btn {
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 10px;
}
.respin-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ---------- Confetti ---------- */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  opacity: 0;
  animation: confettiFall 3s ease-in-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotateZ(0deg) rotateX(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(450px) rotateZ(720deg) rotateX(360deg);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .lottery-header {
    padding: 24px 16px 12px;
  }
  .lottery-header h1 {
    font-size: 1.8rem;
  }
  .lottery-main {
    padding: 0 16px 60px;
    gap: 20px;
  }
  .controls-card {
    padding: 16px;
  }
  .control-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .wheel-container {
    width: min(320px, 85vw);
    height: min(320px, 85vw);
  }
  .spin-btn {
    padding: 14px 36px;
    font-size: 1.05rem;
  }
  .weight-table-card {
    padding: 16px;
  }
  .result-modal {
    padding: 36px 24px 28px;
  }
  .winner-name {
    font-size: 2.2rem;
  }
}
