/* ========================================
   VARIABLES & RESET
======================================== */
:root {
  --primary: #dc2626;
  --primary-dark: #b91c1c;
  --secondary: #f59e0b;
  --accent: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #fcd34d;
  --dark: #1a1a2e;
  --dark-light: #16213e;
  --light: #fef3c7;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: rgba(220, 38, 38, 0.2);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Poppins",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: linear-gradient(135deg, #dc2626 0%, #f59e0b 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ========================================
   HOME BUTTON
======================================== */
.home-button {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.home-button:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.home-button svg {
  flex-shrink: 0;
}

/* ========================================
   ANIMATED BACKGROUND
======================================== */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: linear-gradient(135deg, #dc2626 0%, #f59e0b 100%);
  top: -10%;
  left: -10%;
  animation-delay: 0s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  bottom: -10%;
  right: -10%;
  animation-delay: 7s;
}

.blob-3 {
  width: 450px;
  height: 450px;
  background: linear-gradient(135deg, #ef4444 0%, #fb923c 100%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: 14s;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -50px) scale(1.1);
  }
  66% {
    transform: translate(-20px, 30px) scale(0.9);
  }
}

/* ========================================
   CONTAINER
======================================== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* ========================================
   HEADER
======================================== */
.header {
  padding: 40px 0 30px;
  text-align: center;
  animation: slideDown 0.8s ease-out;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
}

.logo-icon {
  font-size: 64px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.header h1 {
  font-size: 56px;
  font-weight: 800;
  color: white;
  text-shadow: 
    0 0 10px rgba(220, 38, 38, 0.5),
    0 0 20px rgba(245, 158, 11, 0.3),
    0 4px 20px rgba(0, 0, 0, 0.3);
  letter-spacing: -1px;
}

.subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
  margin-top: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ========================================
   MONEY DISPLAY
======================================== */
.money-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
  animation: fadeInUp 0.8s ease-out 0.1s both;
}

.money-card {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  padding: 20px 25px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.money-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
}

.money-card.tickets::before {
  background: linear-gradient(90deg, var(--secondary) 0%, var(--accent) 100%);
}

.money-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
}

.money-amount {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.convert-btn,
.reset-button {
  padding: 15px 20px;
  background: white;
  border: 2px solid var(--primary);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.convert-btn {
  color: var(--secondary);
  border-color: var(--secondary);
}

.convert-btn:hover {
  background: var(--secondary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.reset-button {
  color: var(--danger);
}

.reset-button:hover {
  background: var(--danger);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================
   CONFIG CARD
======================================== */
.config-container,
.conversion-container {
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.config-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.config-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: repeating-linear-gradient(
    45deg,
    var(--primary),
    var(--primary) 10px,
    var(--secondary) 10px,
    var(--secondary) 20px
  );
}

.config-header {
  text-align: center;
  margin-bottom: 35px;
}

.config-header h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.config-header p {
  color: var(--text-light);
  font-size: 16px;
}

.config-section {
  margin-bottom: 35px;
}

/* ========================================
   RADIO CARDS
======================================== */
.radio-grid {
  display: grid;
  gap: 15px;
}

.budget-grid {
  grid-template-columns: repeat(2, 1fr);
}

.radio-card {
  cursor: pointer;
}

.radio-card input[type="radio"] {
  display: none;
}

.radio-content {
  padding: 20px;
  border-radius: 12px;
  border: 3px solid #e5e7eb;
  background: #fafafa;
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.radio-content::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
  border-radius: 12px;
}

.radio-card input:checked + .radio-content::before {
  opacity: 1;
}

.radio-card input:checked + .radio-content {
  border-color: transparent;
  background: white;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.25);
  transform: scale(1.02);
}

.radio-icon,
.radio-label,
.radio-description {
  position: relative;
  z-index: 1;
}

.radio-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.radio-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  display: block;
}

.radio-description {
  font-size: 13px;
  color: var(--text-light);
}

/* ========================================
   TICKET SELECTOR
======================================== */
.ticket-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin: 30px 0;
}

.ticket-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--secondary);
  background: white;
  color: var(--secondary);
  font-size: 32px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.2);
}

.ticket-btn:hover:not(:disabled) {
  background: var(--secondary);
  color: white;
  transform: scale(1.1);
  box-shadow: 0 6px 15px rgba(245, 158, 11, 0.4);
}

.ticket-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ticket-display {
  text-align: center;
}

.ticket-count {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}

.ticket-cost {
  font-size: 18px;
  color: var(--text-light);
  font-weight: 600;
}

.ticket-cost span {
  color: var(--secondary);
  font-weight: 700;
}

/* ========================================
   BUTTONS
======================================== */
.start-button {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.3);
  margin-bottom: 15px;
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.4);
}

.start-button:active {
  transform: translateY(0);
}

.skip-button {
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--text-light);
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.skip-button:hover {
  background: #f3f4f6;
  border-color: var(--text-light);
  color: var(--text);
}

/* ========================================
   GAMES GRID
======================================== */
.games-container {
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.game-card {
  background: white;
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  transition: var(--transition);
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(
    90deg,
    var(--primary),
    var(--primary) 5px,
    var(--secondary) 5px,
    var(--secondary) 10px
  );
}

.game-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(220, 38, 38, 0.25);
}

.game-icon {
  font-size: 64px;
  margin-bottom: 15px;
  animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-card h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.game-card p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.6;
  min-height: 42px;
}

.game-info {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.info-badge {
  padding: 6px 14px;
  background: #fef3c7;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  border: 2px solid var(--accent);
}

.info-badge.win {
  background: #d1fae5;
  color: var(--success);
  border-color: var(--success);
}

.play-button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.play-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

/* ========================================
   STATS SECTION
======================================== */
.funfair-stats-section {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  padding: 30px;
  border-radius: 12px;
  margin-top: 30px;
  border: 3px solid var(--accent);
}

.funfair-stats-section h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 25px;
  text-align: center;
}

.funfair-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}

.funfair-stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  border: 2px solid transparent;
  transition: var(--transition);
}

.funfair-stat-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.funfair-stat-icon {
  font-size: 28px;
}

.funfair-stat-info {
  display: flex;
  flex-direction: column;
}

.funfair-stat-label {
  font-size: 11px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.funfair-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* ========================================
   FOOTER
======================================== */
.footer {
  padding: 30px 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
  font-size: 15px;
  font-weight: 500;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ========================================
   CUSTOM POPUP
======================================== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.popup-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.popup-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  border: 4px solid transparent;
  position: relative;
  overflow: hidden;
}

.popup-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: repeating-linear-gradient(
    45deg,
    var(--primary),
    var(--primary) 10px,
    var(--secondary) 10px,
    var(--secondary) 20px
  );
}

.popup-overlay.show .popup-card {
  transform: scale(1);
  animation: popupBounce 0.5s ease;
}

@keyframes popupBounce {
  0% {
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.popup-icon {
  font-size: 72px;
  margin-bottom: 20px;
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

.popup-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 15px;
}

.popup-message {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: 30px;
  line-height: 1.6;
}

.popup-button {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.popup-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.popup-button:active {
  transform: translateY(0);
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-aspect-ratio: 1/1) {
  .home-button {
    top: 10px;
    left: 10px;
    padding: 10px 16px;
    font-size: 13px;
  }

  .home-button svg {
    width: 18px;
    height: 18px;
  }

  .header h1 {
    font-size: 40px;
  }

  .logo-icon {
    font-size: 48px;
  }

  .config-card {
    padding: 25px;
  }

  .config-header h2 {
    font-size: 24px;
  }

  .budget-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .games-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .money-display {
    flex-wrap: wrap;
  }

  .money-card {
    min-width: 100%;
  }

  .convert-btn,
  .reset-button {
    flex: 1;
    min-width: 120px;
  }
}