:root {
  --bg: #1a1a2e;
  --panel-bg: #16213e;
  --cell-bg: #0f3460;
  --cell-text: #e94560;
  --player: #4cc9f0;
  --start: #2a9d8f;
  --end: #e63946;
  --correct: #a8e6cf;
  --wrong: #ff6b6b;
  --size: 5; /* 动态控制格子数量 */
  /* ... 其他变量保持不变 ... */
  --phrase-bl: #4A9BFF; /* 清透蓝：明度微调，在深色棋盘上更醒目且不刺眼 */
  --phrase-pp: #9B5DE5; /* 沉静紫：降低 10% 视觉攻击性，与蓝/粉形成高级过渡 */
  --phrase-pk: #F472B6; /* 柔雾粉：饱和度微降，长时间游玩视觉更舒适 */
  --phrase-gr: #34D399;
  --phrase-default: #a8e6cf; /* 默认绿色 */
}
.cell.visited.phrase-bl {
  background: var(--phrase-bl) !important;
  color: #fff !important;
}
.cell.visited.phrase-pp {
  background: var(--phrase-pp) !important;
  color: #fff !important;
}
.cell.visited.phrase-pk {
  background: var(--phrase-pk) !important;
  color: #fff !important;
}
.cell.visited.phrase-gr {
  background: var(--phrase-gr) !important;
  color: #fff !important;
}

/* 默认回退样式（优先级低于分句色） */
.cell.visited {
  background: var(--phrase-default);
  color: #111;
}

/* 提示框最高优先级 */
.cell.hint {
  background: #f4d03f !important;
  color: #1a1a2e !important;
}


* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: var(--bg); color: #fff; height: 100vh; display: flex; flex-direction: column; }

header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 15px 20px;
  align-items: center;
  padding: 12px 25px;
  background: var(--panel-bg);
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* 左侧区域：Logo + 金币 */
.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
  grid-column: 1;
  grid-row: 1;
}

.logo {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--cell-text);
  white-space: nowrap;
}

/* 金币显示优化 */
.coin-display {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  padding: 8px 16px;
  border-radius: 25px;
  font-weight: bold;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.1rem;
  transition: transform 0.2s;
  white-space: nowrap;
}

#total-coins {
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  min-width: 25px;
  text-align: right;
}

/* 难度选择居中 */
.difficulty-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  grid-column: 2;
  grid-row: 1;
}

.difficulty-selector button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #2a2d45;
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  white-space: nowrap;
}

.difficulty-selector button:hover {
  background: #3a3d55;
  transform: translateY(-2px);
}

.difficulty-selector button.active {
  background: var(--cell-text);
  color: #fff;
  box-shadow: 0 3px 8px rgba(233, 69, 96, 0.4);
}

/* 右侧控制按钮区域 */
.header-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
}

.control-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.control-btn {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  background: #2a2d45;
  color: #ccc;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
  background: #3a3d55;
  transform: translateY(-2px);
  color: #fff;
}

.control-btn:disabled {
  background: #1e2135;
  color: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 特殊按钮样式 */
#hint-btn:hover:not(:disabled) {
  background: #f4d03f;
  color: #1a1a2e;
}

#undo-btn {
  background: #f4a261;
  color: #fff;
}

#undo-btn:hover:not(:disabled) {
  background: #e76f51;
}

#restart-btn:hover:not(:disabled) {
  background: #4cc9f0;
  color: #1a1a2e;
}

#volume-btn:hover:not(:disabled) {
  background: #10b981;
  color: #fff;
}

/* 金币获得动画 */
@keyframes coinBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
  100% { transform: scale(1); }
}
.coin-pop {
  animation: coinBump 0.35s ease-out;
}

/* ========== 移动端适配 ========== */
@media (max-width: 1024px) {
  header {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
    padding: 12px 15px;
  }

  .header-left {
    grid-column: 1;
    grid-row: 1;
    justify-content: center;
  }

  .difficulty-selector {
    grid-column: 1;
    grid-row: 2;
    flex-wrap: wrap;
  }

  .header-controls {
    grid-column: 1;
    grid-row: 3;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .control-row {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .logo {
    font-size: 1.3rem;
  }

  .coin-display {
    padding: 6px 12px;
    font-size: 1rem;
  }

  #total-coins {
    font-size: 1.1rem;
  }

  .difficulty-selector button {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .control-btn {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .header-controls {
    gap: 6px;
  }

  .control-row {
    gap: 8px;
  }
}

/* 原有样式保留... */
.container {
  display: flex; flex: 1; padding: 15px; gap: 15px;
  max-width: 1400px; margin: 0 auto; width: 100%;
}
.left-panel, .right-panel { width: 220px; background: var(--panel-bg); padding: 15px; border-radius: 8px; }

/* 左侧面板曲目列表 - 可滚动版本 */
.song-list {
  list-style: none;
  margin: 10px 0;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 5px;
  scrollbar-width: thin;
  scrollbar-color: #4a4d65 #2a2d45;
}

.song-list::-webkit-scrollbar {
  width: 6px;
}

.song-list::-webkit-scrollbar-track {
  background: #2a2d45;
  border-radius: 3px;
}

.song-list::-webkit-scrollbar-thumb {
  background: #4a4d65;
  border-radius: 3px;
}

.song-list::-webkit-scrollbar-thumb:hover {
  background: #5a5d75;
}

.song-list li {
  padding: 10px 12px;
  margin: 4px 0;
  background: #2a2d45;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-list li:hover {
  background: #3a3d55;
  transform: translateX(3px);
}

.song-list li.active {
  background: var(--cell-text);
  color: #fff;
  font-weight: bold;
}

.info-box p, .stats p, .guide li { margin: 8px 0; font-size: 0.9rem; }
#next-note { font-size: 1.4rem; font-weight: bold; color: var(--player); }
progress { width: 100%; height: 10px; margin: 5px 0; }

.game-area {
  flex: 1; display: flex; justify-content: center; align-items: center;
  position: relative; background: #0d1b2a; border-radius: 8px; padding: 20px;
}
.maze-board {
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  grid-template-rows: repeat(var(--size), 1fr);
  gap: 4px; width: min(80vw, 600px); height: min(80vw, 600px);
}
.cell {
  background: var(--cell-bg); color: #aaa; font-weight: bold;
  display: flex; justify-content: center; align-items: center;
  border-radius: 6px; position: relative; transition: all 0.2s;
  font-size: clamp(0.6rem, 2vw, 1rem);
}
.cell.start { background: var(--start); color: #fff; }
.cell.end { background: var(--end); color: #fff; }
.cell.visited { background: var(--correct); color: #111; }
.cell.wrong { animation: shake 0.4s; background: var(--wrong); }
.cell.player::after {
  content: '🧍'; position: absolute; font-size: clamp(1rem, 4vw, 1.8rem);
  animation: pop 0.3s ease-out;
}

.message {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); padding: 10px 20px; border-radius: 20px;
  font-size: 1.1rem; z-index: 10;
}
.message.hidden { display: none; }

.audio-init {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 999;
  display: flex; justify-content: center; align-items: center;
}
.init-box { text-align: center; padding: 30px; background: var(--panel-bg); border-radius: 10px; cursor: pointer; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

@media (max-width: 768px) {
  .container { flex-direction: column; align-items: center; }
  .left-panel, .right-panel { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
  .maze-board { width: 90vw; height: 90vw; }
}

/* 提示路径（黄色）- 提高优先级确保显示 */
.cell.hint {
  background: #f4d03f !important;
  color: #1a1a2e !important;
  font-weight: bold;
  box-shadow: inset 0 0 0 2px #e6c200; /* 加边框增强辨识度 */
}

/* 已走路径（绿色）- 强制覆盖黄色 */
.cell.visited {
  background: var(--correct) !important;
  color: #111 !important;
  box-shadow: none;
}

/* 确保起点/终点不被其他样式干扰 */
.cell.start { background: var(--start) !important; color: #fff !important; }
.cell.end { background: var(--end) !important; color: #fff !important; }

/* 积分显示区域 */
.score-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 10px;
}
.score-box p {
  margin: 5px 0;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
}
#current-score, #best-score {
  font-size: 1.1rem;
}
/* 通关得分动画 */
@keyframes scorePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); color: #fff; }
  100% { transform: scale(1); }
}
.score-pop {
  animation: scorePop 0.5s ease-out;
}

/* 模态框样式 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal.hidden {
  display: none;
}
.modal-content {
  background: var(--panel-bg);
  padding: 30px 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--cell-text);
  max-width: 90%;
  width: 400px;
  animation: modalPop 0.3s ease-out;
}
@keyframes modalPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.modal-content h3 {
  color: var(--cell-text);
  margin-bottom: 15px;
  font-size: 1.5rem;
}
.modal-content p {
  margin: 10px 0;
  font-size: 1rem;
  color: #ccc;
}
.modal-content strong {
  color: var(--wrong);
  font-size: 1.2rem;
}
.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}
.btn-primary, .btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}
.btn-primary {
  background: var(--cell-text);
  color: #fff;
}
.btn-primary:hover {
  background: #ff6b6b;
  transform: translateY(-2px);
}
.btn-secondary {
  background: #2a2d45;
  color: #ccc;
}
.btn-secondary:hover {
  background: #3a3d55;
  color: #fff;
}

/* 金币显示样式 */
.coin-display {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; padding: 6px 14px; border-radius: 20px; font-weight: bold;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.2s;
}
#total-coins {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  min-width: 20px;
  text-align: right;
}

/* 金币获得动画 */
@keyframes coinBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
  100% { transform: scale(1); }
}
.coin-pop { animation: coinBump 0.35s ease-out; }

/* 移动端头部自适应 */
@media (max-width: 768px) {
  header { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .controls { justify-content: center; width: 100%; }
  .coin-display { font-size: 0.85rem; padding: 5px 10px; }
}