/* 基础样式 */
:root {
  --primary-color: #6200ea;
  --secondary-color: #00b0ff;
  --accent-color: #ff4081;
  --bg-color: #121212;
  --text-color: #ffffff;
  --panel-bg: rgba(30, 30, 40, 0.8);
  --success-color: #00c853;
  --warning-color: #ffd600;
  --danger-color: #ff1744;
}

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

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  height: 100vh;
  width: 100vw;
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 返回链接 */
.back-link {
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text-color);
  padding: 8px 15px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.back-link:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: var(--primary-color);
}

/* 开始屏幕 */
.start-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: var(--bg-color);
  z-index: 100;
  padding: 20px;
  text-align: center;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(98, 0, 234, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 176, 255, 0.15) 0%, transparent 50%);
}

.title {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 10px rgba(98, 0, 234, 0.3);
}

.subtitle {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.8;
}

.upload-container {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 300px;
}

.upload-btn {
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
  display: inline-block;
}

.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(98, 0, 234, 0.4);
}

.upload-hint {
  font-size: 0.9rem;
  opacity: 0.6;
  margin-bottom: 1rem;
}

.preview-container {
  width: 100%;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ball-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--secondary-color);
  box-shadow: 0 0 15px rgba(0, 176, 255, 0.5);
  margin-bottom: 1rem;
}

.confirm-btn {
  background: var(--success-color);
  color: #000;
  padding: 8px 16px;
  border: none;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0, 200, 83, 0.4);
}

.start-btn {
  background: linear-gradient(45deg, var(--accent-color), var(--secondary-color));
  color: #fff;
  padding: 15px 40px;
  border: none;
  border-radius: 30px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 20px rgba(255, 64, 129, 0.5);
}

.start-note {
  font-size: 0.9rem;
  opacity: 0.6;
}

/* 游戏画布 */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-color: var(--bg-color);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(98, 0, 234, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 176, 255, 0.05) 0%, transparent 50%);
}

/* 游戏控制面板 */
.game-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 500px;
  padding: 0 20px;
}

.control-row {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 10px;
}

.control-btn {
  flex: 1;
  background: var(--panel-bg);
  color: var(--text-color);
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  margin: 0 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

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

.draw-tools {
  display: flex;
  justify-content: center;
  background: var(--panel-bg);
  border-radius: 30px;
  padding: 5px;
  margin-bottom: 15px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
}

.tool-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-color);
  padding: 8px 5px;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.tool-btn.active {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 10px rgba(98, 0, 234, 0.3);
}

/* 设置面板 */
.settings-panel {
  position: relative;
  width: 100%;
}

.settings-toggle {
  background: var(--panel-bg);
  border: none;
  color: var(--text-color);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0 auto;
}

.settings-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.settings-icon {
  font-size: 1.5rem;
}

.settings-menu {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border-radius: 10px;
  padding: 15px;
  width: 100%;
  max-width: 300px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  opacity: 1;
  transform-origin: bottom center;
}

.settings-menu.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px) scale(0.9);
  pointer-events: none;
}

.setting-item {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
}

.setting-item label {
  width: 70px;
  font-size: 0.9rem;
}

.setting-item input[type="range"] {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  outline: none;
  border-radius: 5px;
}

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

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

.setting-item.checkbox input {
  width: 20px;
  height: 20px;
}

.reset-btn, .change-ball-btn {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  border: none;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
}

.reset-btn:hover, .change-ball-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 绘制提示 */
.drawing-instructions {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  padding: 10px 20px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  z-index: 10;
}

.drawing-instructions p {
  margin-right: 15px;
  font-size: 0.9rem;
}

.drawing-instructions span {
  font-weight: bold;
  color: var(--secondary-color);
}

.done-btn {
  background: var(--success-color);
  color: #000;
  padding: 5px 15px;
  border: none;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.done-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0, 200, 83, 0.4);
}

.hidden {
  display: none !important;
}

/* 响应式调整 - 增强移动设备支持 */
@media (max-width: 600px) {
  .title {
    font-size: 2.2rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .upload-container {
    max-width: 250px;
  }

  .upload-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .start-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
  }

  .control-btn, .tool-btn {
    font-size: 0.8rem;
    padding: 8px 5px;
  }

  .drawing-instructions {
    flex-direction: column;
    padding: 10px;
    top: 15px;
  }

  .drawing-instructions p {
    margin-right: 0;
    margin-bottom: 10px;
    font-size: 0.85rem;
  }

  .done-btn {
    padding: 4px 12px;
    font-size: 0.85rem;
  }

  /* 增大触摸目标区域 */
  .control-btn, .tool-btn, .settings-toggle {
    min-height: 44px; /* 最小触摸目标高度 */
  }

  /* 优化设置面板 */
  .settings-menu {
    max-width: 280px;
    padding: 12px;
  }

  .setting-item label {
    font-size: 0.85rem;
  }

  /* 优化返回链接 */
  .back-link {
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}

/* 小屏幕高度优化 */
@media (max-height: 500px) {
  .game-controls {
    bottom: 5px;
  }

  .control-row {
    margin-bottom: 3px;
  }

  .draw-tools {
    margin-bottom: 3px;
    padding: 3px;
  }

  .settings-menu {
    bottom: 45px;
  }

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

/* 超小屏幕优化 */
@media (max-width: 360px) {
  .title {
    font-size: 1.8rem;
  }

  .control-btn, .tool-btn {
    font-size: 0.75rem;
    padding: 6px 3px;
  }

  .draw-tools {
    border-radius: 20px;
  }

  .tool-btn {
    border-radius: 15px;
  }
}

/* 横屏模式优化 */
@media (max-height: 450px) and (orientation: landscape) {
  .game-controls {
    bottom: 5px;
    flex-direction: row;
    align-items: flex-end;
    max-width: 100%;
    padding: 0 10px;
  }

  .control-row {
    width: auto;
    margin-right: 5px;
    margin-bottom: 0;
  }

  .draw-tools {
    width: auto;
    margin-bottom: 0;
    margin-right: 5px;
  }

  .settings-panel {
    width: auto;
  }

  .settings-menu {
    bottom: auto;
    top: -200px;
    right: 0;
    left: auto;
    transform: none;
  }

  .settings-menu.hidden {
    transform: translateY(20px) scale(0.9);
  }
}
