:root {
  --primary-color: #4f46e5;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --history-bg: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-premium: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  
  /* Lotto Ball Colors */
  --ball-1-10: #fbc400;
  --ball-11-20: #69c8f2;
  --ball-21-30: #ff7239;
  --ball-31-40: #aaaaaa;
  --ball-41-45: #b0d840;
}

[data-theme='dark'] {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --history-bg: #0f172a;
  --shadow-premium: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
}

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

body {
  font-family: 'Pretendard', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Texture Effect */
.background-texture {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.05;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

[data-theme='dark'] .background-texture {
  opacity: 0.1;
  filter: invert(1);
}

.container {
  max-width: 500px;
  width: 100%;
  background: var(--card-bg);
  padding: 40px;
  border-radius: 24px;
  box-shadow: var(--shadow-premium);
  text-align: center;
  z-index: 1;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  position: relative;
}

.theme-toggle {
  background: var(--history-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--border-color);
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--primary-color);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 40px;
}

/* Ball Styles */
.ball-container {
  display: flex;
  justify-content: center;
  gap: 12px;
  min-height: 60px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.placeholder {
  color: var(--text-secondary);
  font-style: italic;
}

.ball {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: white;
  font-size: 1.1rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.1);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.ball.color-yellow { background-color: var(--ball-1-10); }
.ball.color-blue { background-color: var(--ball-11-20); }
.ball.color-red { background-color: var(--ball-21-30); }
.ball.color-gray { background-color: var(--ball-31-40); }
.ball.color-green { background-color: var(--ball-41-45); }

@keyframes popIn {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Button Styles */
.action-section {
  margin-bottom: 40px;
}

.generate-button {
  position: relative;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  width: 100%;
}

.generate-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.generate-button:active {
  transform: translateY(1px);
}

.btn-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.generate-button:hover .btn-glow {
  opacity: 1;
}

/* History Styles */
.history-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 30px;
  text-align: left;
}

.history-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.history-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background-color: var(--history-bg);
  margin-bottom: 8px;
  animation: slideIn 0.3s ease-out both;
  transition: background-color 0.3s ease;
}

@keyframes slideIn {
  0% { transform: translateX(-10px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

.history-ball {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: 700;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.clear-btn:hover {
  color: var(--text-primary);
}

/* Scrollbar Styles */
.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.history-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
