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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

h1 {
  font-size: 2rem;
  font-weight: 300;
  margin-bottom: 20px;
  color: #222;
}

h2 {
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 20px;
  color: #555;
}

.settings {
  display: flex;
  gap: 15px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

label {
  font-size: 0.9rem;
  color: #666;
}

input[type="number"] {
  width: 60px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  margin-left: 8px;
}

input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
  width: 16px;
  height: 16px;
}

input[type="text"] {
  flex: 1;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  min-width: 300px;
}

button {
  padding: 10px 20px;
  background: #333;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

button:hover {
  background: #555;
}

button:active {
  transform: translateY(1px);
}

.staff-container {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
  min-height: 200px;
}

#notation {
  overflow-x: auto;
}

.mode-section.hidden {
  display: none;
}

.input-section {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.feedback {
  padding: 15px;
  border-radius: 4px;
  margin-top: 15px;
  font-size: 0.95rem;
  min-height: 50px;
}

.feedback.success {
  background: #e8f5e9;
  color: #2e7d32;
  border-left: 4px solid #4caf50;
}

.feedback.error {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #f44336;
}

.feedback.info {
  background: #e3f2fd;
  color: #1565c0;
  border-left: 4px solid #2196f3;
}

/* 钢琴键盘样式 */
.mode-section {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.piano-container {
  overflow-x: auto;
  margin: 20px 0;
  padding: 10px 0;
}

#piano {
  display: inline-flex;
  position: relative;
  height: 200px;
  min-width: min-content;
}

.piano-key {
  cursor: pointer;
  user-select: none;
  transition: all 0.1s;
}

.piano-key.white {
  width: 50px;
  height: 200px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0 0 4px 4px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  font-size: 0.75rem;
  color: #999;
  position: relative;
  z-index: 1;
}

.key-label {
  font-size: 0.7rem;
  color: #999;
}

.key-label.middle-c {
  color: #2196f3;
  font-weight: 600;
}

.piano-key.white:hover {
  background: #f5f5f5;
}

.piano-key.white.active {
  background: #4caf50;
  color: white;
}

.piano-key.white.correct {
  background: #81c784;
  animation: keyFlashGreen 0.6s ease;
}

.piano-key.white.incorrect {
  background: #e57373;
  animation: keyFlashRed 0.6s ease;
}

.piano-key.black {
  position: absolute;
  width: 32px;
  height: 120px;
  background: #333;
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  font-size: 0.7rem;
  color: #fff;
}

.piano-key.black:hover {
  background: #555;
}

.piano-key.black.active {
  background: #4caf50;
}

.piano-key.black.correct {
  background: #66bb6a;
  animation: keyFlashGreen 0.6s ease;
}

.piano-key.black.incorrect {
  background: #ef5350;
  animation: keyFlashRed 0.6s ease;
}

@keyframes keyFlashGreen {
  0% {
    box-shadow: 0 0 0 rgba(76, 175, 80, 0.2);
    transform: translateY(0);
  }
  40% {
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.6);
    transform: translateY(-2px);
  }
  100% {
    box-shadow: 0 0 0 rgba(76, 175, 80, 0.1);
    transform: translateY(0);
  }
}

@keyframes keyFlashRed {
  0% {
    box-shadow: 0 0 0 rgba(239, 83, 80, 0.2);
    transform: translateY(0);
  }
  40% {
    box-shadow: 0 0 12px rgba(239, 83, 80, 0.6);
    transform: translateY(-2px);
  }
  100% {
    box-shadow: 0 0 0 rgba(239, 83, 80, 0.1);
    transform: translateY(0);
  }
}

/* VexFlow 样式调整 */
svg {
  display: block;
  margin: 0 auto;
}

/* 五线谱音符高亮效果 */
g.staff-note.highlight path {
  fill: #4caf50 !important;
  stroke: #4caf50 !important;
  opacity: 0.8;
}

g.staff-note {
  transition: all 0.2s ease;
}

/* 错误音符的闪烁动画 */
.wrong-note-temp {
  animation: wrongNoteBlink 0.5s ease-in-out;
}

@keyframes wrongNoteBlink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem;
  }

  .settings {
    flex-direction: column;
  }

  .input-section {
    flex-direction: column;
  }

  input[type="text"] {
    min-width: 100%;
  }

  #piano {
    transform: scale(0.8);
    transform-origin: center;
  }
}
