/* 基础样式 */
:root {
  --primary-color: #6200ea;
  --secondary-color: #00b0ff;
  --accent-color: #ff4081;
  --dark-bg: #121212;
  --darker-bg: #0a0a0a;
  --light-bg: #f8f9fa;
  --text-light: #ffffff;
  --text-dark: #212121;
  --card-bg: rgba(30, 30, 30, 0.8);
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --border-radius: 12px;
  --toolbar-height: 60px;
}

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

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--darker-bg);
  color: var(--text-light);
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 容器样式 */
.container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 画布容器 */
.canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: var(--darker-bg);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(100, 43, 115, 0.1) 0%, rgba(4, 0, 4, 0) 90%),
    radial-gradient(circle at 90% 80%, rgba(43, 69, 115, 0.1) 0%, rgba(0, 0, 4, 0) 90%);
}

#sandCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 返回链接 */
.back-link {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-light);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}

.back-link:hover, .back-link:active {
  background: rgba(0, 0, 0, 0.7);
}

/* 工具栏 */
.toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(18, 18, 18, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  height: var(--toolbar-height);
}

.tool-group, .color-group, .action-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.tool-btn, .action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: var(--text-light);
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  gap: 4px;
}

.tool-btn i, .action-btn i {
  font-size: 16px;
}

.tool-btn.active {
  background: var(--primary-color);
  color: white;
}

.tool-btn:hover, .action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.color-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: var(--transition);
}

.color-btn.active {
  border: 2px solid white;
  transform: scale(1.1);
}

/* 设置面板 */
.settings-panel {
  position: fixed;
  top: 0;
  right: -300px;
  width: 300px;
  height: 100%;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
  transition: var(--transition);
  padding: 20px;
  overflow-y: auto;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
}

.settings-panel.active {
  right: 0;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 20px;
  cursor: pointer;
}

.setting-item {
  margin-bottom: 20px;
}

.setting-item label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.setting-item input[type="range"] {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  outline: none;
  -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
}

.setting-value {
  display: inline-block;
  margin-left: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.setting-item.checkbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-item.checkbox label {
  margin-bottom: 0;
}

.setting-item select {
  width: 100%;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  color: var(--text-light);
  outline: none;
}

/* 预设模板面板 */
.templates-panel {
  position: fixed;
  top: 15px;
  right: 15px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: 15px;
  z-index: 10;
  max-width: 300px;
}

.templates-panel h3 {
  margin-bottom: 10px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
}

.templates-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.template-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.template-btn img {
  width: 100%;
  height: 60px;
  object-fit: cover;
}

.template-btn span {
  padding: 5px;
  font-size: 12px;
  color: var(--text-light);
}

.template-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 指令面板 */
.instructions-panel {
  position: fixed;
  bottom: calc(var(--toolbar-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 10px 15px;
  border-radius: 20px;
  z-index: 5;
  text-align: center;
  transition: opacity 0.5s ease;
}

.instructions-panel p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}

/* 加载指示器 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--darker-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.1);
  border-top: 5px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

.loading-text {
  color: var(--text-light);
  font-size: 18px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 模态框 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  max-width: 90%;
  width: 350px;
  text-align: center;
}

.modal-content h3 {
  margin-bottom: 15px;
  color: var(--text-light);
}

.modal-content p {
  margin-bottom: 20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  line-height: 1.5;
}

.btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 5px;
  color: var(--text-light);
  padding: 10px 15px;
  margin: 5px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.primary-btn {
  background: var(--primary-color);
}

.primary-btn:hover {
  background: #7c42ea;
}

/* 保存预览 */
.save-preview {
  margin: 15px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

#savePreviewCanvas {
  width: 100%;
  height: 150px;
  object-fit: contain;
}

.save-options {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
}

/* 提示消息 */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 1000;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.toast.active {
  opacity: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .toolbar {
    padding: 8px 10px;
  }
  
  .tool-btn, .action-btn {
    padding: 6px 8px;
    font-size: 10px;
  }
  
  .tool-btn i, .action-btn i {
    font-size: 14px;
  }
  
  .color-btn {
    width: 25px;
    height: 25px;
  }
  
  .templates-panel {
    max-width: 250px;
  }
  
  .template-btn img {
    height: 50px;
  }
}

@media (max-width: 480px) {
  .tool-group, .color-group, .action-group {
    gap: 5px;
  }
  
  .templates-panel {
    top: 60px;
    right: 10px;
    max-width: 200px;
  }
  
  .template-btn img {
    height: 40px;
  }
  
  .template-btn span {
    font-size: 10px;
  }
}

/* 动画效果 */
@keyframes glow {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

/* 工具特效 */
.tool-btn[data-tool="pour"].active i {
  animation: float 2s ease-in-out infinite;
}

.tool-btn[data-tool="shake"].active i {
  animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(0); }
  75% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
