:root {
  --glass-bg: rgba(24, 25, 29, 0.72);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text-main: #f7f7f5;
  --text-muted: rgba(247, 247, 245, 0.68);
  --accent: #ff6b35;
  --accent-gold: #ffd166;
  --shadow-soft: 0 12px 36px rgba(15, 16, 20, 0.22);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #eae8e3;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  user-select: none;
}

#scene-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

/* Pure clean frame mode for deterministic video capture */
body.video-mode .hud-top,
body.video-mode .hud-bottom,
body.video-mode .sound-pill,
body.video-mode .restore-ui-btn,
body.video-mode .modal-backdrop {
  display: none !important;
}

.hidden {
  display: none !important;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(165%);
  -webkit-backdrop-filter: blur(18px) saturate(165%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
}

/* Sound Unlock Floating Pill */
.sound-pill {
  position: fixed;
  top: 94px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.55);
  background: linear-gradient(135deg, rgba(32, 28, 26, 0.88), rgba(52, 34, 24, 0.88));
  color: #fff8eb;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(255, 90, 32, 0.28);
  white-space: nowrap;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
  animation: dotPulse 1.8s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}

/* Top HUD */
.hud-top {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  z-index: 20;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 18px;
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff6d6 0%, #ff8c42 36%, #e63900 74%, #6b1400 100%);
  box-shadow: inset 0 2px 5px rgba(255,255,255,0.75), 0 3px 10px rgba(255, 87, 34, 0.45);
  flex-shrink: 0;
}

.brand-meta h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-meta p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.now-playing-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  border-radius: 18px;
}

.zone-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.11);
  display: grid;
  place-items: center;
  font-size: 19px;
  flex-shrink: 0;
}

.zone-info {
  flex: 1;
  min-width: 0;
}

.zone-kicker {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

#zone-song-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#zone-song-title.mystery-mask {
  color: var(--accent-gold);
}

.mini-tag-btn {
  border: 1px solid rgba(255, 209, 102, 0.45);
  background: rgba(255, 209, 102, 0.14);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.mini-tag-btn:hover {
  background: rgba(255, 209, 102, 0.28);
}

.restore-ui-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 25;
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Bottom Dock */
.hud-bottom {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.zone-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.zone-chips::-webkit-scrollbar {
  display: none;
}

.zone-chip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(28, 30, 35, 0.64);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.84);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.zone-chip:hover {
  background: rgba(45, 48, 56, 0.84);
}

.zone-chip.active {
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  border-color: rgba(255, 230, 160, 0.65);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.36);
}

.dock-panel {
  border-radius: 20px;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff6b35, #ff9248);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: var(--text-main);
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.18);
}

.time-label {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 32px;
  text-align: center;
}

.timeline-slider {
  flex: 1;
  height: 5px;
  accent-color: var(--accent);
  cursor: pointer;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.select-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.select-pill select {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.select-pill select option {
  background: #1e2025;
  color: #ffffff;
}

.accent-pill-btn {
  margin-left: auto;
  border: 1px solid rgba(255, 209, 102, 0.5);
  background: rgba(255, 209, 102, 0.16);
  color: var(--accent-gold);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.accent-pill-btn:hover {
  background: rgba(255, 209, 102, 0.28);
}

/* Composer Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 11, 14, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: min(520px, 100%);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.modal-desc code {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-gold);
}

.preset-templates {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.tpl-btn {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
}

.tpl-btn:hover {
  background: rgba(255,255,255,0.18);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid label,
.textarea-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.form-grid input,
.form-grid select,
.textarea-label textarea {
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  color: #ffffff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ghost-btn {
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--text-main);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.primary-btn {
  border: none;
  background: linear-gradient(135deg, #ff6b35, #f7931e);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 640px) {
  .hud-top {
    flex-direction: column;
    gap: 7px;
  }
  .sound-pill {
    top: 134px;
    font-size: 12.5px;
    padding: 8px 15px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .accent-pill-btn {
    margin-left: 0;
  }
}
