:root {
  --bg-color: #0f172a; /* Slate 900 */
  --text-primary: #f8fafc; /* Slate 50 */
  --text-secondary: #94a3b8; /* Slate 400 */
  
  --primary: #f43f5e; /* Rose 500 */
  --primary-hover: #e11d48; /* Rose 600 */
  --primary-glow: rgba(244, 63, 94, 0.4);
  
  --card-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
  --card-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(12px);

  --font-family: 'Outfit', 'Noto Sans TC', sans-serif;
  
  --tier-low: #10b981; /* Emerald 500 */
  --tier-medium: #f59e0b; /* Amber 500 */
  --tier-high: #8b5cf6; /* Violet 500 */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Background Animated Blobs */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: rgba(244, 63, 94, 0.3);
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: rgba(139, 92, 246, 0.25);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 50px) scale(1.1); }
  100% { transform: translate(-50px, 100px) scale(0.9); }
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 500px;
  height: 100dvh;
  min-height: 600px;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateY(20px);
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.screen.hidden {
  display: flex; /* keep it in DOM but visually hidden */
}

.content-wrapper {
  text-align: center;
  width: 100%;
}

/* Typography */
h1.logo-title {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #f43f5e, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.section-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.section-title.small {
  font-size: 1.5rem;
  margin-bottom: 0;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

/* Distance Selection Slider */
.distance-selector {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}

.filter-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-switch:hover {
  background: rgba(255, 255, 255, 0.08);
}

.filter-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-switch input[type="checkbox"]:checked {
  background: var(--primary);
}

.filter-switch input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  top: 1px;
  left: 1px;
  background: white;
  transition: all 0.3s cubic-bezier(0.3, 1.5, 0.7, 1);
}

.filter-switch input[type="checkbox"]:checked::before {
  left: 15px;
}

.filter-switch label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
}

.filter-switch:has(input:checked) label {
  color: var(--text-primary);
}

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

#distance-value {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.2rem;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  max-width: 250px;
  background: rgba(255, 255, 255, 0.1);
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  width: 100%;
  max-width: 300px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 10px 25px -5px var(--primary-glow);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -5px var(--primary-glow), 0 0 15px var(--primary-glow);
}

.primary-btn:active {
  transform: translateY(2px);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn.ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem;
  margin-top: 1.5rem;
}

.btn.ghost:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Loading Indicator */
#loading-indicator {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#loading-indicator.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Tier Selection Cards */
.tier-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.tier-card {
  background: var(--card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 1.5rem;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 1.25rem;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.tier-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  transition: background 0.3s;
}

.tier-card[data-tier="low"]::before { background: var(--tier-low); }
.tier-card[data-tier="medium"]::before { background: var(--tier-medium); }
.tier-card[data-tier="high"]::before { background: var(--tier-high); }

.tier-card:hover {
  transform: translateY(-4px) scale(1.02);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.tier-icon {
  grid-row: 1 / span 2;
  font-size: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
}

.tier-card h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.tier-card .price-range {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  grid-column: 2;
}

.tier-card .card-desc {
  grid-column: 2;
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 0.25rem;
}

/* Roulette View */
.top-bar {
  position: absolute;
  top: 2rem;
  left: 0;
  width: 100%;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.roulette-container {
  position: relative;
  width: 320px;
  height: 320px;
  margin: 3rem auto;
  filter: drop-shadow(0 0 30px rgba(0, 0, 0, 0.5));
}

@media (min-width: 400px) {
  .roulette-container {
    width: 360px;
    height: 360px;
  }
}

.wheel-pointer {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 44px;
  background: var(--primary);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  z-index: 20;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

#roulette-wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid var(--text-primary);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
  transition: transform cubic-bezier(0.1, 2.7, 0.1, 1) 0s;
}

.spin-btn {
  margin-top: 2rem;
  font-size: 1.25rem;
  padding: 1.25rem 2.5rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--primary-glow); }
  70% { box-shadow: 0 0 0 15px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-color);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  transform: scale(0.9) translateY(20px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.winner-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#winner-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.winner-meta {
  font-size: 1rem;
  color: var(--tier-medium);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.winner-address {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Onboarding Modal Specifics */
.onboarding-content {
  text-align: left;
  max-width: 450px;
}

.onboarding-steps {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
}

.onboarding-steps li {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.onboarding-steps span {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  box-shadow: 0 0 10px var(--primary-glow);
}

.modal-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-bottom: 1.5rem;
}

.modal-overlay.onboarding-overlay {
  background: rgba(0, 0, 0, 0.9);
}
