/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: Segoe UI, Microsoft YaHei, system-ui, sans-serif;
  margin: 0;
  padding: 0;
  background: #f8f9fa;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 2px solid #e9ecef;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.scale-type-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.scale-type-group label {
  font-weight: 500;
}

.scale-type-group select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.scale-hint {
  font-size: 0.85rem;
  color: #666;
  font-style: italic;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

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

.slider {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: #ccc;
  border-radius: 24px;
  transition: background-color 0.2s;
}

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

input:checked + .slider {
  background-color: #2196F3;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.stats {
  font-size: 0.95rem;
  color: #555;
}

/* Main content */
.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Keys grid */
.keys-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.key-item {
  position: relative;
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.4;
}

.key-item.current {
  opacity: 1;
  transform: scale(1.2);
  border-color: #2196F3;
  background: #e3f2fd;
  color: #1976D2;
  z-index: 2;
}

.key-item.visited {
  opacity: 0.6;
}

.key-item.visited::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.8rem;
  color: #4CAF50;
}

/* Current question */
.current-question {
  text-align: center;
  margin: 2rem 0;
}

.question-title {
  font-size: 3rem;
  font-weight: bold;
  color: #1976D2;
  margin: 0.5rem 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.hint {
  color: #666;
  font-size: 0.9rem;
  margin: 1rem 0;
}

/* Answer section */
.answer-section {
  margin: 2rem 0;
  padding: 2rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: opacity 0.3s ease;
}

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

.staff-container {
  text-align: center;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.note-names {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
  color: #333;
  letter-spacing: 1px;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #2196F3;
}

/* Footer */
.app-footer {
  background: white;
  border-top: 2px solid #e9ecef;
  padding: 1.5rem 2rem;
}

.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid #ddd;
  background: white;
  color: #333;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.btn:hover:not(:disabled) {
  border-color: #bbb;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn.primary {
  background: #2196F3;
  color: white;
  border-color: #2196F3;
}

.btn.primary:hover:not(:disabled) {
  background: #1976D2;
  border-color: #1976D2;
}

.btn.danger {
  background: #f44336;
  color: white;
  border-color: #f44336;
}

.btn.danger:hover:not(:disabled) {
  background: #d32f2f;
  border-color: #d32f2f;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.modal-content p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: #333;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Responsive design */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  .controls-left,
  .controls-center,
  .controls-right {
    text-align: center;
  }

  .app-main {
    padding: 1rem;
  }

  .keys-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
  }

  .key-item {
    font-size: 1.1rem;
    padding: 0.8rem;
  }

  .question-title {
    font-size: 2.2rem;
  }

  .nav-buttons {
    gap: 0.8rem;
  }

  .btn {
    min-width: 80px;
    padding: 0.6rem 1rem;
  }
}

@media (max-width: 480px) {
  .keys-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .question-title {
    font-size: 1.8rem;
  }
  
  .stats {
    font-size: 0.85rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles */
.btn:focus,
select:focus,
input:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}

.key-item:focus {
  outline: 2px solid #2196F3;
  outline-offset: 2px;
}