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

:root {
  --bg-gradient-1: #0a0a0a;
  --bg-gradient-2: #1a1a1a;
  --bg-gradient-3: #0f0f0f;
  --machine-bg-1: rgba(255, 255, 255, 0.06);
  --machine-bg-2: rgba(255, 255, 255, 0.02);
  --machine-bg-3: rgba(255, 255, 255, 0.04);
  --machine-border: rgba(255, 255, 255, 0.1);
  --container-bg: rgba(0, 0, 0, 0.4);
  --container-border: rgba(255, 255, 255, 0.08);
  --glass-reflection: rgba(255, 255, 255, 0.04);
  --text-primary: #fff;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-muted: rgba(255, 255, 255, 0.3);
  --text-faint: rgba(255, 255, 255, 0.2);
  --ball-bg-1: #fff;
  --ball-bg-2: #e0e0e0;
  --ball-bg-3: #bbb;
  --ball-text: #111;
  --ball-empty-bg-1: #2a2a2a;
  --ball-empty-bg-2: #1a1a1a;
  --ball-empty-bg-3: #111;
  --ball-empty-text: #444;
  --ball-rolling-bg-1: #666;
  --ball-rolling-bg-2: #555;
  --ball-rolling-bg-3: #444;
  --ball-revealed-bg-1: #fff;
  --ball-revealed-bg-2: #f0f0f0;
  --ball-revealed-bg-3: #ddd;
  --ball-revealed-text: #000;
  --progress-bg: rgba(255, 255, 255, 0.1);
  --progress-bar: #fff;
  --btn-bg: rgba(255, 255, 255, 0.05);
  --btn-border: rgba(255, 255, 255, 0.2);
  --btn-hover-bg: rgba(255, 255, 255, 0.1);
  --btn-hover-border: rgba(255, 255, 255, 0.3);
  --btn-active-bg: #fff;
  --btn-active-text: #000;
  --info-bg: rgba(255, 255, 255, 0.03);
  --info-border: rgba(255, 255, 255, 0.05);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --glow-color: rgba(255, 255, 255, 0.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

header {
  margin-bottom: 30px;
  position: relative;
}

.title {
  font-size: 1.4rem;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.title-thai {
  display: none;
}

/* Glass machine container */
.machine {
  background: linear-gradient(180deg,
    var(--machine-bg-1) 0%,
    var(--machine-bg-2) 50%,
    var(--machine-bg-3) 100%);
  border: 1px solid var(--machine-border);
  border-radius: 20px;
  padding: 30px 20px;
  backdrop-filter: blur(10px);
  box-shadow:
    0 8px 32px var(--shadow-color),
    inset 0 1px 0 var(--glass-reflection);
  transition: all 0.3s ease;
}

.machine::before {
  display: none;
}

/* Ball container with glass effect */
.ball-container {
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  border-radius: 16px;
  padding: 25px 15px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Glass reflection */
.ball-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, var(--glass-reflection) 0%, transparent 100%);
  border-radius: 16px 16px 0 0;
  pointer-events: none;
}

.number-display {
  display: flex;
  justify-content: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

/* 3D Balls */
.ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 1.4rem;
  font-weight: 600;
  background: linear-gradient(145deg, var(--ball-bg-1) 0%, var(--ball-bg-2) 50%, var(--ball-bg-3) 100%);
  color: var(--ball-text);
  position: relative;
  transition: all 0.3s ease;
  box-shadow:
    0 4px 15px var(--shadow-color),
    inset 0 -3px 6px rgba(0, 0, 0, 0.15),
    inset 0 3px 6px rgba(255, 255, 255, 0.9);
}

/* Ball shine/reflection */
.ball::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 12px;
  width: 12px;
  height: 8px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  transform: rotate(-25deg);
}

.ball.empty {
  background: linear-gradient(145deg, var(--ball-empty-bg-1) 0%, var(--ball-empty-bg-2) 50%, var(--ball-empty-bg-3) 100%);
  color: var(--ball-empty-text);
  box-shadow:
    0 4px 15px var(--shadow-color),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.ball.empty::before {
  background: rgba(255, 255, 255, 0.08);
}

/* Rolling - gray balls floating */
.ball.rolling {
  animation: float 0.5s ease-in-out infinite;
  background: linear-gradient(145deg, var(--ball-rolling-bg-1) 0%, var(--ball-rolling-bg-2) 50%, var(--ball-rolling-bg-3) 100%);
  color: #222;
  box-shadow:
    0 4px 20px var(--glow-color),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    inset 0 3px 6px rgba(255, 255, 255, 0.4);
}

.ball.rolling::before {
  background: rgba(255, 255, 255, 0.5);
}

/* Revealed - contrasting balls */
.ball.revealed {
  animation: popUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  background: linear-gradient(145deg, var(--ball-revealed-bg-1) 0%, var(--ball-revealed-bg-2) 50%, var(--ball-revealed-bg-3) 100%);
  color: var(--ball-revealed-text);
  box-shadow:
    0 4px 20px var(--glow-color),
    inset 0 -3px 6px rgba(0, 0, 0, 0.1),
    inset 0 3px 6px rgba(255, 255, 255, 0.9);
}

.ball.revealed::before {
  background: rgba(255, 255, 255, 0.6);
}

@keyframes float {
  0%, 100% { transform: translateY(-3px) rotate(-3deg); }
  50% { transform: translateY(3px) rotate(3deg); }
}

@keyframes popUp {
  0% { transform: scale(0.6) translateY(15px); opacity: 0; }
  60% { transform: scale(1.08) translateY(-3px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Status */
.led-display {
  padding: 12px 0;
  margin-bottom: 15px;
}

.led-text {
  color: var(--text-secondary);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  text-transform: uppercase;
  transition: color 0.3s ease;
}

.led-text.processing {
  animation: pulse 1s ease-in-out infinite;
}

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

/* Progress bar */
.progress-container {
  width: 100%;
  height: 2px;
  background: var(--progress-bg);
  border-radius: 1px;
  margin-bottom: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.progress-container.visible {
  opacity: 1;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--progress-bar);
  border-radius: 1px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--glow-color);
}

/* Button */
.generate-btn {
  width: 100%;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 16px 30px;
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  backdrop-filter: blur(5px);
}

.generate-btn:hover:not(:disabled) {
  background: var(--btn-hover-bg);
  border-color: var(--btn-hover-border);
}

.generate-btn:active:not(:disabled) {
  background: var(--btn-active-bg);
  color: var(--btn-active-text);
}

.generate-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Hide decorations */
.decorations {
  display: none;
}

/* Info section */
.info-section {
  margin-top: 30px;
  padding: 20px;
  background: var(--info-bg);
  border-radius: 12px;
  border: 1px solid var(--info-border);
  transition: all 0.3s ease;
}

.info-section h3 {
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 400;
  margin-bottom: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.info-section p {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.7;
  font-weight: 300;
}

/* Footer */
footer {
  margin-top: 25px;
  color: var(--text-faint);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  transition: color 0.3s ease;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    max-width: 100%;
  }

  .title {
    font-size: 1.1rem;
    letter-spacing: 0.25em;
  }

  .machine {
    padding: 25px 15px;
    border-radius: 16px;
  }

  .ball-container {
    padding: 20px 12px;
    border-radius: 12px;
  }

  .ball {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }

  .ball::before {
    top: 6px;
    left: 10px;
    width: 10px;
    height: 6px;
  }

  .number-display {
    gap: 8px;
  }

  .generate-btn {
    font-size: 0.75rem;
    padding: 14px 24px;
  }
}

@media (max-width: 360px) {
  .ball {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .ball::before {
    top: 5px;
    left: 8px;
    width: 8px;
    height: 5px;
  }

  .number-display {
    gap: 6px;
  }

  .title {
    font-size: 1rem;
  }
}

/* Touch devices */
@media (hover: none) {
  .generate-btn:hover:not(:disabled) {
    background: var(--btn-bg);
    border-color: var(--btn-border);
  }

  .generate-btn:active:not(:disabled) {
    background: var(--btn-active-bg);
    color: var(--btn-active-text);
  }
}
