/* CSS Reset & Variables */
:root {
  --bg-primary: #0a0712;
  --bg-secondary: #120e24;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-hover-border: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f3f1f6;
  --text-secondary: #9f9baa;
  --text-muted: #5e5a6a;
  
  --accent-primary: #a855f7;
  --accent-secondary: #ec4899;
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  --accent-glow: rgba(168, 85, 247, 0.35);

  --font-display: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', sans-serif;

  /* Lotto Ball Colors */
  --ball-color-yellow-light: #ffeb3b;
  --ball-color-yellow-dark: #fbc02d;
  --ball-color-blue-light: #4fc3f7;
  --ball-color-blue-dark: #0288d1;
  --ball-color-red-light: #ff8a80;
  --ball-color-red-dark: #d32f2f;
  --ball-color-gray-light: #cfd8dc;
  --ball-color-gray-dark: #78909c;
  --ball-color-green-light: #a5d6a7;
  --ball-color-green-dark: #2e7d32;
}

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

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

/* Background Decoration */
.background-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
}

.orb-1 {
  top: -10%;
  right: 10%;
  width: 450px;
  height: 450px;
  background: var(--accent-primary);
  animation: floatOrb 15s infinite alternate ease-in-out;
}

.orb-2 {
  bottom: 10%;
  left: -5%;
  width: 500px;
  height: 500px;
  background: var(--accent-secondary);
  animation: floatOrb 20s infinite alternate-reverse ease-in-out;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 40px) scale(1.15); }
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 900px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  flex-grow: 1;
}

/* Header */
.app-header {
  text-align: center;
  position: relative;
  margin-bottom: 10px;
}

.logo-area {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-secondary);
  filter: drop-shadow(0 0 8px rgba(236, 72, 153, 0.6));
  animation: pulseLogo 3s infinite ease-in-out;
}

@keyframes pulseLogo {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(236, 72, 153, 0.6)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 16px rgba(236, 72, 153, 0.9)); }
}

.app-header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.2rem;
  letter-spacing: 2px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 300;
  letter-spacing: 0.5px;
}

.utility-toolbar {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

/* Cards & Glassmorphism */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 30px;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card:hover {
  border-color: var(--card-hover-border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.generator-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 35px;
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}

/* Lotto Balls Layout */
.balls-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  width: 100%;
  min-height: 120px;
}

.ball-wrapper {
  perspective: 1000px;
}

.ball {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  user-select: none;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), inset 0 -4px 10px rgba(0, 0, 0, 0.3), inset 0 4px 10px rgba(255, 255, 255, 0.4);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ball::after {
  content: '';
  position: absolute;
  top: 10%;
  left: 15%;
  width: 35%;
  height: 25%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 80%);
  border-radius: 50%;
  transform: rotate(-15deg);
}

.ball.placeholder {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  box-shadow: none;
  color: var(--text-muted);
  font-weight: 300;
}

.bonus-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 0 5px;
}

.bonus-divider svg {
  width: 24px;
  height: 24px;
}

/* Ball Color Themes */
.ball.y1-10 {
  background: radial-gradient(circle at 35% 35%, var(--ball-color-yellow-light) 0%, var(--ball-color-yellow-dark) 85%);
  color: #3e2723;
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
}

.ball.b11-20 {
  background: radial-gradient(circle at 35% 35%, var(--ball-color-blue-light) 0%, var(--ball-color-blue-dark) 85%);
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ball.r21-30 {
  background: radial-gradient(circle at 35% 35%, var(--ball-color-red-light) 0%, var(--ball-color-red-dark) 85%);
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.ball.g31-40 {
  background: radial-gradient(circle at 35% 35%, var(--ball-color-gray-light) 0%, var(--ball-color-gray-dark) 85%);
  color: #1a252c;
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
}

.ball.gr41-45 {
  background: radial-gradient(circle at 35% 35%, var(--ball-color-green-light) 0%, var(--ball-color-green-dark) 85%);
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Ball Drop/Pop Animation */
.ball-pop {
  animation: ballPopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ballPopIn {
  0% {
    transform: scale(0) rotate(-220deg) translateY(-80px);
    opacity: 0;
  }
  60% {
    transform: scale(1.2) rotate(15deg);
  }
  100% {
    transform: scale(1) rotate(0deg) translateY(0);
    opacity: 1;
  }
}

/* Action Area */
.action-area {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 40px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 8px 30px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(168, 85, 247, 0.5);
}

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

.btn-primary:disabled {
  background: #3c324e;
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.btn-text:hover {
  color: var(--accent-secondary);
  background: rgba(236, 72, 153, 0.08);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: scale(1.05);
}

/* Analysis Grid Layout */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

/* Stats Card */
.stats-card h2, .history-card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.stats-card h2 svg, .history-card h2 svg {
  width: 20px;
  height: 20px;
  color: var(--accent-primary);
}

.stats-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  padding: 40px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

/* History Card */
.card-header-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header-between h2 {
  margin-bottom: 0;
}

.history-list-wrapper {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Scrollbar for history */
.history-list-wrapper::-webkit-scrollbar {
  width: 6px;
}

.history-list-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.history-list-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.history-list-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 40px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: 14px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* History Item */
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 12px 16px;
  transition: all 0.3s ease;
  animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.history-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.hist-balls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hist-ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.hist-ball.y1-10 { background: radial-gradient(circle, var(--ball-color-yellow-light) 0%, var(--ball-color-yellow-dark) 100%); color: #3e2723; }
.hist-ball.b11-20 { background: radial-gradient(circle, var(--ball-color-blue-light) 0%, var(--ball-color-blue-dark) 100%); color: #ffffff; }
.hist-ball.r21-30 { background: radial-gradient(circle, var(--ball-color-red-light) 0%, var(--ball-color-red-dark) 100%); color: #ffffff; }
.hist-ball.g31-40 { background: radial-gradient(circle, var(--ball-color-gray-light) 0%, var(--ball-color-gray-dark) 100%); color: #1a252c; }
.hist-ball.gr41-45 { background: radial-gradient(circle, var(--ball-color-green-light) 0%, var(--ball-color-green-dark) 100%); color: #ffffff; }

.hist-bonus-divider {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: bold;
}

.hist-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hist-date {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-display);
}

.hist-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.hist-delete-btn:hover {
  color: var(--accent-secondary);
  background: rgba(236, 72, 153, 0.1);
}

.hist-delete-btn svg {
  width: 16px;
  height: 16px;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px;
  width: 100%;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 300;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .app-container {
    padding: 20px 15px;
    gap: 20px;
  }
  
  .app-header h1 {
    font-size: 1.8rem;
  }
  
  .utility-toolbar {
    position: static;
    transform: none;
    margin-top: 12px;
    display: flex;
    justify-content: center;
  }

  .card {
    padding: 20px;
  }

  .balls-container {
    gap: 8px;
    min-height: 90px;
  }

  .ball {
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
  }

  .btn {
    width: 100%;
    padding: 14px 28px;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .history-item {
    padding: 10px;
  }
  
  .hist-balls {
    gap: 4px;
  }
  
  .hist-ball {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }
}
