/* 基础样式 */
:root {
  --primary-color: #3a1c71;
  --secondary-color: #d76d77;
  --accent-color: #ffaf7b;
  --text-color: #333;
  --light-text: #fff;
  --dark-bg: #121212;
  --light-bg: #f8f9fa;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --border-radius: 12px;
  --fish-size: min(300px, 70vw);
  --fish-shadow-size: calc(var(--fish-size) * 1.1);
}

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

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: linear-gradient(135deg, var(--primary-color), #6d327c);
  color: var(--light-text);
  min-height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.app-container {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  overflow: hidden;
}

/* 返回链接 */
.back-link {
  position: absolute;
  top: 15px;
  right: 15px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10;
  transition: var(--transition);
}

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

/* 主界面 */
.main-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* 木鱼容器 */
.fish-container {
  position: relative;
  width: var(--fish-size);
  height: var(--fish-size);
  margin-bottom: 40px;
  perspective: 1000px;
  overflow: visible;
}

.fish-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.2s ease-out;
}

.wooden-fish {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 1;
}

.fish-image {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url('../assets/images/木鱼.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transform-origin: center bottom;
  transition: transform 0.1s ease-out;
  z-index: 1;
}

.fish-shadow {
  position: absolute;
  width: var(--fish-shadow-size);
  height: var(--fish-shadow-size);
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 70%);
  border-radius: 50%;
  z-index: -1;
}

.character-container {
  position: absolute;
  width: 90%;
  height: 90%;
  top: 5%;
  left: 5%;
  z-index: 0;
  transition: transform 0.3s ease;
  mask-image: url('../assets/images/木鱼.png');
  -webkit-mask-image: url('../assets/images/木鱼.png');
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-position: center;
  -webkit-mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
}

.character-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.95;
}

/* 敲击区域 */
.tap-area {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
  z-index: 10;
}

/* 计数器和连击显示 */
.counter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
  text-align: center;
}

.merit-counter {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.counter-value {
  margin-right: 5px;
}

.counter-label {
  font-size: 1.5rem;
  font-weight: 500;
}

.combo-display {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-color);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-shadow: 0 0 10px rgba(255, 175, 123, 0.7);
}

.combo-display.active {
  opacity: 1;
  transform: scale(1);
}

.combo-count {
  margin-right: 5px;
}

/* 文字动画区域 */
.text-animation-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

.floating-text {
  position: absolute;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(0);
  animation: float-up 1.5s ease-out forwards;
  pointer-events: none;
}

/* 现代风格文字 */
.modern-text {
  font-weight: 300;
  letter-spacing: 1px;
  animation: float-side 1.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* 游戏风格文字 */
.game-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pop-up 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.game-value {
  font-size: 1.5em;
  font-weight: 900;
  margin-bottom: -5px;
}

.game-label {
  font-size: 0.8em;
  opacity: 0.9;
}

/* 文字动画 */
@keyframes float-up {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(-40px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-60px) scale(0.8);
  }
}

@keyframes float-side {
  0% {
    opacity: 0;
    transform: translateX(-20px) scale(0.9);
  }
  15% {
    opacity: 1;
    transform: translateX(5px) scale(1.05);
  }
  30% {
    transform: translateX(-3px) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(0) translateY(-10px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(10px) translateY(-50px) scale(0.9);
  }
}

@keyframes pop-up {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
  60% {
    transform: scale(0.9);
  }
  80% {
    transform: scale(1) translateY(-20px);
    opacity: 1;
  }
  100% {
    transform: scale(0.8) translateY(-60px);
    opacity: 0;
  }
}

/* 粒子效果画布 */
.particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* 控制面板 */
.control-panel {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  width: 100%;
  max-width: 400px;
  z-index: 5;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--border-radius);
  color: white;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  flex: 1;
  max-width: 120px;
}

.control-btn:hover, .control-btn:active {
  background-color: rgba(255, 255, 255, 0.25);
}

.btn-icon {
  font-size: 1.5rem;
  margin-bottom: 5px;
}

.btn-text {
  font-size: 0.9rem;
}

/* 设置面板 */
.settings-panel, .upload-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 400px;
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  overflow: hidden;
}

.settings-panel.active, .upload-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.settings-header, .upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.settings-header h2, .upload-header h2 {
  color: var(--text-color);
  font-size: 1.2rem;
  font-weight: 500;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #999;
  cursor: pointer;
  transition: var(--transition);
}

.close-btn:hover {
  color: #333;
}

.settings-content, .upload-content {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
  color: var(--text-color);
}

.settings-group {
  margin-bottom: 20px;
}

.settings-group h3 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 10px;
  color: #666;
}

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

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

/* 滑块样式 */
input[type="range"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 50%;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  outline: none;
}

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

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

/* 开关样式 */
.toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

/* 下拉菜单样式 */
.settings-select {
  background-color: rgba(255, 255, 255, 0.1);
  color: #333;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  padding: 6px 10px;
  width: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

.settings-select:hover, .settings-select:focus {
  background-color: rgba(255, 255, 255, 0.2);
  outline: none;
}

.settings-select option {
  background-color: white;
  color: #333;
}

/* 上传区域样式 */
.upload-area {
  width: 100%;
  height: 200px;
  border: 2px dashed #ddd;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  background-color: rgba(255, 255, 255, 0.05);
}

.upload-area:hover {
  border-color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.1);
}

.upload-area.highlight {
  border-color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 15px rgba(255, 175, 123, 0.5);
}

.upload-area.has-image .upload-placeholder {
  display: none;
}

.upload-area.loading {
  pointer-events: none;
  border-color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.1);
  animation: pulse 1.5s infinite;
}

.upload-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 1.2rem;
  z-index: 5;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #999;
  padding: 20px;
  text-align: center;
  z-index: 1;
}

.upload-note {
  font-size: 0.8rem;
  color: #888;
  margin-top: 5px;
  font-style: italic;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  color: #bbb;
}

.upload-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: none;
  z-index: 0;
  mask-image: url('../assets/images/木鱼.png');
  -webkit-mask-image: url('../assets/images/木鱼.png');
  mask-size: 90% auto;
  -webkit-mask-size: 90% auto;
  mask-position: center;
  -webkit-mask-position: center;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
}

.upload-preview.active {
  display: block;
}

.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.action-btn {
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
}

.cancel-btn {
  background-color: #f1f1f1;
  color: #666;
}

.cancel-btn:hover {
  background-color: #e1e1e1;
}

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

.confirm-btn:hover {
  background-color: #2a0f5e;
}

/* 遮罩层 */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

/* 动画效果 */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

/* 连击效果样式 */
.combo-effect {
  position: absolute;
  pointer-events: none;
  z-index: 4;
}

.combo-effect-text {
  font-size: 2rem;
  font-weight: 900;
  color: #ffaf7b;
  text-shadow: 0 0 10px rgba(255, 175, 123, 0.7),
               0 0 20px rgba(255, 175, 123, 0.5);
  white-space: nowrap;
}

/* 响应式调整 */
@media (max-width: 768px) {
  :root {
    --fish-size: min(250px, 70vw);
  }

  .merit-counter {
    font-size: 2rem;
  }

  .combo-display {
    font-size: 1.5rem;
  }

  .control-panel {
    gap: 10px;
  }

  .control-btn {
    padding: 8px;
  }

  .btn-icon {
    font-size: 1.3rem;
  }

  .btn-text {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  :root {
    --fish-size: min(200px, 65vw);
  }

  .app-container {
    padding: 15px;
  }

  .back-link {
    top: 10px;
    right: 10px;
    font-size: 12px;
    padding: 6px 10px;
  }

  .merit-counter {
    font-size: 1.8rem;
  }

  .counter-label {
    font-size: 1.2rem;
  }

  .combo-display {
    font-size: 1.3rem;
  }
}

/* 呼吸效果 */
.breathing-effect {
  animation: breathing 4s ease-in-out infinite;
}

@keyframes breathing {
  0%, 100% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.4);
  }
}

/* 敲击动画 */
.tap-animation {
  animation: tap 0.2s ease-out;
}

@keyframes tap {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

/* DMC风格连击效果 */
.dmc-combo {
  position: absolute;
  font-family: 'Impact', 'Anton', 'Bebas Neue', 'Noto Sans SC', sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.7),
               0 0 10px rgba(255, 255, 255, 0.7),
               0 0 20px rgba(255, 255, 255, 0.4);
  animation: dmc-appear 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transform-origin: center;
  z-index: 10;
}

.milestone-text {
  font-size: 40px !important;
  text-align: center;
}

.rank-text {
  font-size: 1.5em;
  display: block;
  line-height: 0.9;
}

.rank-label {
  font-size: 0.6em;
  display: block;
  letter-spacing: 2px;
}

.combo-text {
  font-size: 24px;
}

@keyframes dmc-appear {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-5deg);
    filter: blur(5px);
  }
  10% {
    opacity: 1;
    transform: scale(1.5) rotate(5deg);
    filter: blur(0);
  }
  20% {
    transform: scale(1.2) rotate(-3deg);
  }
  30% {
    transform: scale(1.3) rotate(2deg);
  }
  40% {
    transform: scale(1.1) rotate(-1deg);
  }
  50% {
    transform: scale(1.2) rotate(0);
  }
  70% {
    opacity: 1;
    transform: scale(1.1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.8);
    filter: blur(3px);
  }
}
