/* ============================================
   烟花模拟器 - 全局样式
   ============================================ */

:root {
  --panel-bg: rgba(10, 10, 30, 0.85);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent: #ffd700;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b0;
  --radius: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(to bottom,
    #000510 0%,
    #020b1a 30%,
    #071428 60%,
    #0c1d35 85%,
    #12253f 100%);
  color: var(--text-primary);
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- 画布 ---- */
#fireworks-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* ---- 城市天际线 ---- */
#skyline {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 120px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.6;
  background:
    /* 建筑群剪影 */
    linear-gradient(to top, #0a0a14 0%, transparent 100%);
}

#skyline::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    /* 高楼 */
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 5% 100% / 30px 80px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 8% 100% / 20px 55px,
    linear-gradient(#0f0f20, #0f0f20) no-repeat 15% 100% / 40px 95px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 22% 100% / 25px 65px,
    linear-gradient(#101022, #101022) no-repeat 30% 100% / 35px 110px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 38% 100% / 22px 50px,
    linear-gradient(#0f0f20, #0f0f20) no-repeat 45% 100% / 45px 85px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 55% 100% / 28px 70px,
    linear-gradient(#101022, #101022) no-repeat 62% 100% / 38px 100px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 70% 100% / 24px 58px,
    linear-gradient(#0f0f20, #0f0f20) no-repeat 78% 100% / 42px 90px,
    linear-gradient(#0d0d1a, #0d0d1a) no-repeat 87% 100% / 30px 72px,
    linear-gradient(#101022, #101022) no-repeat 94% 100% / 36px 105px;
}

/* ---- 标题 ---- */
#app-header {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
  pointer-events: none;
  animation: fadeInDown 1s ease-out;
  transition: opacity 2s ease;
}

/* 沉浸式体验 - 标题淡出 */
#app-header.faded {
  opacity: 0;
}

#app-header h1 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 4px;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.5),
    0 0 30px rgba(255, 150, 50, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.8);
}

#app-header .subtitle {
  margin-top: 6px;
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ---- 控制面板 ---- */
#control-panel {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-direction: row-reverse;
}

#panel-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

#panel-toggle:hover {
  transform: rotate(90deg) scale(1.1);
  border-color: var(--accent);
}

#panel-content {
  width: 220px;
  max-height: 75vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  transition: var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#panel-content::-webkit-scrollbar {
  width: 4px;
}

#panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

#control-panel.collapsed #panel-content {
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
}

#panel-content h2 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 14px 0 8px;
}

#panel-content h2:first-child {
  margin-top: 0;
}

/* 样式选择按钮 */
#style-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.style-btn {
  padding: 7px 4px;
  font-size: 0.78rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.style-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.style-btn.active {
  background: rgba(255, 215, 0, 0.15);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}

/* 颜色选择按钮 */
#color-selector {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.color-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  font-size: 0.72rem;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.color-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.color-btn.active {
  border-color: var(--accent);
  background: rgba(255, 215, 0, 0.12);
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.color-dot.rainbow {
  background: conic-gradient(#ff0040, #ff8c00, #ffe100, #00e676, #00b0ff, #d500f9, #ff0040);
}
.color-dot.gold { background: radial-gradient(circle, #fff3b0, #ffd700, #b8860b); }
.color-dot.red { background: radial-gradient(circle, #ff8a80, #ff1744, #b71c1c); }
.color-dot.blue { background: radial-gradient(circle, #82b1ff, #2979ff, #0d47a1); }
.color-dot.green { background: radial-gradient(circle, #b9f6ca, #00e676, #1b5e20); }
.color-dot.purple { background: radial-gradient(circle, #ea80fc, #d500f9, #6a1b9a); }

/* 设置项 */
.setting-row {
  margin: 10px 0;
}

.setting-row label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-primary) !important;
  font-size: 0.82rem !important;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.action-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #ff6b35, #f7c948);
  color: #1a1a2e;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 1px;
}

.action-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.action-btn:active {
  transform: scale(0.97);
}

/* ---- 提示 ---- */
#hint {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 24px;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  pointer-events: none;
  animation: pulse 2.5s ease-in-out infinite;
  transition: opacity 0.8s ease;
}

#hint.hidden {
  opacity: 0;
}

/* ---- 星空点缀（CSS 星星） ---- */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60%;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 25% 45%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 40% 15%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 55% 35%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 70% 10%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 85% 25%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 15% 55%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 60% 50%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 90% 45%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 35% 5%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.5px 1.5px at 78% 55%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 48% 28%, rgba(255,255,255,0.5), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}

/* ---- 动画 ---- */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

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

@keyframes twinkle {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  #control-panel {
    top: auto;
    bottom: 16px;
    right: 12px;
    transform: none;
  }

  #panel-content {
    width: 190px;
    max-height: 55vh;
  }

  #app-header {
    top: 16px;
  }

  #hint {
    bottom: 80px;
    font-size: 0.78rem;
  }
}

/* ---- 减少动态偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  #hint {
    animation: none;
  }
  body::before {
    animation: none;
  }
}
