:root {
  /* Default Dark Theme Variables */
  --bg-gradient-start: #1a1a2e;
  --bg-gradient-end: #0f0f1a;
  --text-color: #ffffff;
  --text-secondary: #a5a5a5;
  --container-bg: rgba(255, 255, 255, 0.05);
  --container-border: rgba(255, 255, 255, 0.1);
  --container-shadow: rgba(0, 0, 0, 0.5);
  --header-text-gradient: linear-gradient(to right, #fff, #a5a5a5);
  --placeholder-color: #555;
  --btn-border: #fff;
  --btn-text: #fff;
  --btn-hover-bg: #fff;
  --btn-hover-text: #1a1a2e;
  --btn-shadow: rgba(255, 255, 255, 0.5);
  --ball-size: 60px;
  --footer-text: #555;
  --machine-border: rgba(255, 255, 255, 0.2);
  --machine-bg: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
  /* Light Theme Variables */
  --bg-gradient-start: #fdfbfb;
  --bg-gradient-end: #ebedee;
  --text-color: #1a1a2e;
  --text-secondary: #555555;
  --container-bg: rgba(255, 255, 255, 0.6);
  --container-border: rgba(0, 0, 0, 0.1);
  --container-shadow: rgba(0, 0, 0, 0.1);
  --header-text-gradient: linear-gradient(to right, #1a1a2e, #4a4a6a);
  --placeholder-color: #888;
  --btn-border: #1a1a2e;
  --btn-text: #1a1a2e;
  --btn-hover-bg: #1a1a2e;
  --btn-hover-text: #ffffff;
  --btn-shadow: rgba(26, 26, 46, 0.3);
  --footer-text: #888;
  --machine-border: rgba(0, 0, 0, 0.1);
  --machine-bg: rgba(255, 255, 255, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: radial-gradient(circle at center, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.app-container {
  background: var(--container-bg);
  backdrop-filter: blur(10px);
  padding: 3rem;
  border-radius: 20px;
  box-shadow: 0 20px 50px var(--container-shadow);
  text-align: center;
  width: 90%;
  max-width: 600px;
  border: 1px solid var(--container-border);
  position: relative;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
  box-shadow: none;
}

.theme-toggle:hover {
  transform: rotate(30deg) scale(1.1);
  background: rgba(128, 128, 128, 0.1);
  box-shadow: none;
  color: var(--text-color);
}

.theme-toggle::before {
  display: none;
}

header h1 {
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
  background: var(--header-text-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

header p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.1rem;
  transition: color 0.3s ease;
}

/* Machine Styles */
.machine-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.lotto-machine {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 4px solid var(--machine-border);
  background: var(--machine-bg);
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.machine-glass {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 30%;
  height: 20%;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
  z-index: 2;
  pointer-events: none;
}

.mixing-balls {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Tiny mixing balls */
.mix-ball {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  background: radial-gradient(circle at 30% 30%, #ff7272, #cc4e4e);
  transform: translate(-50%, -50%);
  opacity: 0;
}

/* Keyframes for mixing - Crazy Shake */
@keyframes mixMove {
  0% { transform: translate(-50%, -50%) translate(0, 0); }
  25% { transform: translate(-50%, -50%) translate(40px, -60px); }
  50% { transform: translate(-50%, -50%) translate(-50px, 30px); }
  75% { transform: translate(-50%, -50%) translate(60px, 50px); }
  100% { transform: translate(-50%, -50%) translate(-20px, -20px); }
}

.mix-ball.active {
  opacity: 1;
  animation: mixMove 0.4s infinite alternate ease-in-out;
}

.balls-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  min-height: 80px;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.placeholder-text {
  color: var(--placeholder-color);
  font-style: italic;
  animation: pulse 2s infinite;
}

/* Ball Styles */
.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  position: relative;
  box-shadow: 
    inset -10px -10px 20px rgba(0,0,0,0.5),
    inset 10px 10px 20px rgba(255,255,255,0.4),
    0 10px 20px rgba(0,0,0,0.4);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
  opacity: 0;
  /* transform: translateY(20px) scale(0.8); REMOVED for JS control */
  transform: scale(0);
}

.ball.revealed {
  animation: popOut 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Ball Colors */
.ball.range-1 { background: radial-gradient(circle at 30% 30%, #fbc400, #c79a00); }
.ball.range-2 { background: radial-gradient(circle at 30% 30%, #69c8f2, #3b9ac4); }
.ball.range-3 { background: radial-gradient(circle at 30% 30%, #ff7272, #cc4e4e); }
.ball.range-4 { background: radial-gradient(circle at 30% 30%, #aaaaaa, #777777); }
.ball.range-5 { background: radial-gradient(circle at 30% 30%, #b0d840, #8cb02c); }

/* Mix Ball Colors (Smaller versions) */
.mix-ball.range-1 { background: radial-gradient(circle at 30% 30%, #fbc400, #c79a00); }
.mix-ball.range-2 { background: radial-gradient(circle at 30% 30%, #69c8f2, #3b9ac4); }
.mix-ball.range-3 { background: radial-gradient(circle at 30% 30%, #ff7272, #cc4e4e); }
.mix-ball.range-4 { background: radial-gradient(circle at 30% 30%, #aaaaaa, #777777); }
.mix-ball.range-5 { background: radial-gradient(circle at 30% 30%, #b0d840, #8cb02c); }


button#generate-btn {
  background: transparent;
  color: var(--btn-text);
  border: 2px solid var(--btn-border);
  padding: 15px 40px;
  font-size: 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

button#generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button#generate-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: var(--btn-hover-bg);
  z-index: -1;
  transition: width 0.3s ease;
}

button#generate-btn:not(:disabled):hover {
  color: var(--btn-hover-text);
  box-shadow: 0 0 20px var(--btn-shadow);
}

button#generate-btn:not(:disabled):hover::before {
  width: 100%;
}

button#generate-btn:active {
  transform: scale(0.95);
}

footer {
  margin-top: 2rem;
  color: var(--footer-text);
  font-size: 0.9rem;
}

/* Animations */
@keyframes popOut {
  0% { opacity: 0; transform: translateY(-50px) scale(0.5); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

@media (max-width: 600px) {
  .app-container {
    width: 95%;
    padding: 2rem 1rem;
  }
  
  :root {
    --ball-size: 50px;
  }
  
  .balls-container {
    gap: 10px;
  }
  
  header h1 {
    font-size: 2.2rem;
  }
}
