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

@keyframes bgPulse {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

body {
  background: #0a0a0f; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  overflow: hidden; width: 100vw; height: 100vh; touch-action: none;
}

#setup {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; z-index: 100;
  background: radial-gradient(ellipse at 50% 30%, #1a0f00 0%, #0a0a0f 70%);
  padding: 20px 20px 90px; overflow-y: auto;
}

#setup h1 {
  font-size: 38px; font-weight: 800; letter-spacing: -1px;
  background: linear-gradient(135deg, #ff6a00, #ffaa00, #ff6a00);
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
  filter: drop-shadow(0 0 20px #ff6a0044);
}
#setup .subtitle {
  font-size: 13px; color: #555; margin-top: -8px; letter-spacing: 3px;
  text-transform: uppercase;
}

#setup .controls { display: flex; gap: 12px; align-items: center; }
#setup input[type=number] {
  width: 80px; padding: 10px; font-size: 24px; text-align: center;
  background: #151520; border: 1px solid #333; color: #ff8c00; border-radius: 10px;
  font-family: 'Courier New', monospace; font-weight: bold;
}
#setup input[type=number]:focus { border-color: #ff6a00; outline: none; box-shadow: 0 0 15px #ff6a0033; }
#setup label { font-size: 13px; color: #555; text-transform: uppercase; letter-spacing: 1px; }

#setup .presets { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#setup .presets button {
  padding: 8px 16px; background: #151520; border: 1px solid #2a2a3a; color: #888;
  border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 14px;
  min-width: 48px; min-height: 44px; transition: all 0.15s;
}
#setup .presets button:hover, #setup .presets button:active {
  border-color: #ff6a00; color: #ff8c00; background: #1a1520;
  box-shadow: 0 0 10px #ff6a0022;
}

/* Visual mode tabs (Fuse / Bricks) */
.visual-mode-tabs {
  display: flex; gap: 0; border-radius: 12px; overflow: hidden;
  border: 2px solid #ff6a0044; background: #0d0d14;
  margin-bottom: 8px;
}
.visual-mode-tab {
  padding: 12px 28px; background: transparent; color: #666; border: none;
  cursor: pointer; font-family: inherit; font-size: 16px; min-height: 48px;
  transition: all 0.2s; font-weight: 600; letter-spacing: 1px;
}
.visual-mode-tab.active {
  background: linear-gradient(135deg, #ff6a0033, #ff8c0022);
  color: #ff8c00; text-shadow: 0 0 10px #ff6a0044;
}
.visual-mode-tab:not(.active):hover { background: #1a1a25; color: #aaa; }

/* Brick mode color overrides */
[data-vmode="bricks"] .visual-mode-tabs { border-color: #0ea5e944; }
[data-vmode="bricks"] .visual-mode-tab.active {
  background: linear-gradient(135deg, #0ea5e933, #06b6d422);
  color: #22d3ee; text-shadow: 0 0 10px #0ea5e944;
}
[data-vmode="bricks"] #setup {
  background: radial-gradient(ellipse at 50% 30%, #001a2e 0%, #0a0a0f 70%);
}
[data-vmode="bricks"] #startBtn {
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  box-shadow: 0 4px 30px #0ea5e944;
}
[data-vmode="bricks"] .mode-tab.active { background: #0ea5e933; color: #22d3ee; border-color: #0ea5e9; }
[data-vmode="bricks"] #countdown {
  bottom: auto; top: 30px;
  text-shadow: 0 0 20px #0ea5e966, 0 0 40px #06b6d433;
}
[data-vmode="bricks"] #countdown.final {
  color: #22d3ee;
  text-shadow: 0 0 30px #0ea5e988, 0 0 60px #06b6d466, 0 0 100px #0ea5e933;
}

/* Mode tabs */
.mode-tabs {
  display: flex; gap: 0; border-radius: 10px; overflow: hidden;
  border: 1px solid #2a2a3a; background: #111118;
}
.mode-tab {
  padding: 10px 22px; background: transparent; color: #666; border: none;
  cursor: pointer; font-family: inherit; font-size: 14px; min-height: 44px;
  transition: all 0.2s; font-weight: 500;
}
.mode-tab.active {
  background: linear-gradient(135deg, #ff6a00, #ff8c00);
  color: #000; font-weight: 700;
}
.mode-tab:not(.active):hover { background: #1a1a25; color: #aaa; }

/* Mode panels */
.mode-panel { display: none; width: 100%; max-width: 500px; text-align: center; }
.mode-panel.active { display: block; }

#customInput {
  width: 100%; padding: 14px; font-size: 15px; background: #151520;
  border: 1px solid #2a2a3a; color: #ddd; border-radius: 10px;
  font-family: inherit; resize: none; min-height: 70px; line-height: 1.4;
}
#customInput:focus { border-color: #ff6a00; outline: none; box-shadow: 0 0 20px #ff6a0022; }
#customInput::placeholder { color: #444; }

.custom-hint { color: #444; font-size: 12px; margin-top: 6px; line-height: 1.4; }

#themePreview {
  margin-top: 8px; padding: 10px 14px; background: #111118; border: 1px solid #2a2a3a;
  border-radius: 10px; font-size: 13px; color: #888; display: none;
}
#themePreview.visible { display: block; }
#themePreview .preview-label { color: #555; font-size: 11px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
#themePreview .preview-emojis { font-size: 26px; letter-spacing: 6px; }

#generateBtn {
  margin-top: 10px; padding: 11px 24px; font-size: 14px;
  background: linear-gradient(135deg, #1a1520, #201525);
  border: 1px solid #ff6a0066; color: #ff8c00; border-radius: 8px;
  cursor: pointer; font-family: inherit; min-height: 44px;
  transition: all 0.15s;
}
#generateBtn:hover { background: #201525; border-color: #ff6a00; box-shadow: 0 0 15px #ff6a0033; }
#generateBtn:active { transform: scale(0.98); }
#generateBtn:disabled { opacity: 0.4; cursor: wait; }
#generateErr { color: #ff4444; font-size: 13px; margin-top: 6px; display: none; }

#startBtn {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  padding: 20px 52px; font-size: 24px;
  background: linear-gradient(135deg, #ff6a00, #ff8c00);
  color: #000; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800; text-transform: uppercase;
  letter-spacing: 3px; min-height: 64px;
  box-shadow: 0 -4px 30px #ff6a0044;
  animation: flicker 2s ease-in-out infinite;
}
#startBtn:active { opacity: 0.9; }

#fuseCanvas { position: absolute; inset: 0; z-index: 10; }

@keyframes countPulse {
  0%, 100% { text-shadow: 0 0 20px #ff6a0066, 0 0 40px #ff440033; }
  50% { text-shadow: 0 0 40px #ff6a00aa, 0 0 80px #ff440066, 0 0 120px #ff220033; }
}
@keyframes countGlow {
  0% { filter: brightness(1) drop-shadow(0 0 10px #ff6a0044); }
  50% { filter: brightness(1.2) drop-shadow(0 0 25px #ff6a0088); }
  100% { filter: brightness(1) drop-shadow(0 0 10px #ff6a0044); }
}
@keyframes finalPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}

#countdown {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  z-index: 50; padding: 10px 28px; border-radius: 16px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 48px; font-weight: 900;
  font-family: 'Courier New', monospace;
  color: #fff;
  text-shadow: 0 0 20px #ff6a0066, 0 0 40px #ff440033;
  text-align: center; letter-spacing: 6px;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  animation: countGlow 2s ease-in-out infinite;
  white-space: nowrap;
}
#countdown.visible { opacity: 1; }
#countdown.final {
  animation: finalPulse 0.5s ease-in-out infinite, countGlow 1s ease-in-out infinite;
  color: #ff4400;
  text-shadow: 0 0 30px #ff000088, 0 0 60px #ff440066, 0 0 100px #ff000033;
  background: rgba(0,0,0,0.7);
}

#pauseOverlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,0.5); display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
}
#pauseOverlay.visible { display: flex; }
#pauseOverlay span {
  font-size: 48px; font-weight: 800; color: #fff;
  letter-spacing: 6px; text-transform: uppercase;
  opacity: 0.7;
}

#backBtn {
  position: fixed; top: 60px; left: 16px; z-index: 80;
  padding: 10px 16px; font-size: 18px; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2); color: #aaa; border-radius: 8px;
  cursor: pointer; font-family: inherit; display: none; min-height: 48px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#backBtn:active { background: rgba(255,255,255,0.15); }

#restartBtn {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 80; padding: 16px 44px; font-size: 20px;
  background: linear-gradient(135deg, #ff6a00, #ff8c00);
  color: #000; font-weight: 800;
  border: none; border-radius: 12px;
  cursor: pointer; font-family: inherit; display: none;
  text-transform: uppercase; letter-spacing: 3px; min-height: 56px;
  box-shadow: 0 4px 30px #ff6a0044;
}
#restartBtn:active { transform: translate(-50%, -50%) scale(0.97); }

#rerunBtn {
  position: fixed; top: 60px; right: 16px; z-index: 80;
  padding: 10px 16px; font-size: 18px; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2); color: #aaa; border-radius: 8px;
  cursor: pointer; font-family: inherit; display: none; min-height: 48px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#rerunBtn:active { background: rgba(255,255,255,0.15); }

#themeName {
  position: absolute; top: 16px; right: 16px; z-index: 80;
  font-size: 13px; color: #444; display: none; pointer-events: none;
  letter-spacing: 1px; text-transform: uppercase;
}
