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

:root {
  --gold: #eab308;
  --gold-dim: #ca8a04;
}

html, body {
  font-family: 'Source Sans 3', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.app-container.dark {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252542;
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0b0;
  --border-color: #3a3a5a;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #0f0f1a 100%);
}

.app-container.light {
  --bg-primary: #faf8f5;
  --bg-secondary: #f0ebe3;
  --bg-tertiary: #e5ddd3;
  --text-primary: #2a2520;
  --text-secondary: #6a6560;
  --border-color: #d0c8c0;
  background: linear-gradient(135deg, #faf8f5 0%, #f0ebe3 50%, #faf8f5 100%);
}

.particles-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.particle {
  position: absolute;
  bottom: 30%;
  font-size: 24px;
  animation: floatUp 2s ease-out forwards;
  opacity: 0;
}

@keyframes floatUp {
  0% { 
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% { 
    transform: translateY(-300px) rotate(360deg) scale(0);
    opacity: 0;
  }
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.header-content {
  text-align: left;
}

.app-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(20px, 4vw, 32px);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.piano-icon {
  font-size: 1.2em;
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.app-subtitle a {
  color: var(--gold);
  text-decoration: none;
}

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.2s;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Song Library */
.song-library {
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.song-cards {
  display: flex;
  gap: 12px;
  padding: 4px;
}

.song-card {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  min-width: 140px;
}

.song-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-dim);
}

.song-card.active {
  border-color: var(--gold);
}

.song-title {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.song-artist {
  font-size: 11px;
  color: var(--text-secondary);
}

.song-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--gold);
  margin-top: 8px;
}

/* Playback Controls */
.playback-controls {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border-color);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.controls-row.secondary {
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn.stop {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.control-btn.play {
  width: 56px;
  height: 56px;
  color: #000;
  box-shadow: 0 4px 20px rgba(234, 179, 8, 0.4);
}

.control-btn:hover {
  transform: scale(1.1);
}

.progress-container {
  flex: 1;
  padding: 0 8px;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  transition: width 0.1s linear;
  border-radius: 4px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.speed-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.speed-btn.active {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}

.toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}

/* Piano Section */
.piano-section {
  display: flex;
  justify-content: center;
  padding: 20px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.piano-container {
  --key-width: clamp(28px, 5vw, 48px);
}

.piano-frame {
  background: linear-gradient(180deg, #3a3020 0%, #2a2015 100%);
  padding: 16px 16px 8px;
  border-radius: 8px 8px 4px 4px;
  box-shadow: 
    0 8px 32px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

.piano-keyboard {
  position: relative;
  display: flex;
  height: clamp(140px, 25vw, 200px);
  background: #1a1510;
  padding: 4px 4px 0;
  border-radius: 2px;
}

.white-key {
  flex: 0 0 var(--key-width);
  height: 100%;
  background: linear-gradient(180deg, #fafafa 0%, #e8e4dc 80%, #d4d0c8 100%);
  border: 1px solid #aaa;
  border-radius: 0 0 4px 4px;
  margin-right: 2px;
  cursor: pointer;
  transition: all 0.05s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  position: relative;
  z-index: 1;
}

.white-key:last-child {
  margin-right: 0;
}

.white-key:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f0ece4 80%, #e0dcd4 100%);
}

.white-key:active,
.white-key.active {
  transform: translateY(2px);
  box-shadow: inset 0 4px 8px rgba(0,0,0,0.15);
}

.key-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #666;
  font-weight: 500;
}

.black-key {
  position: absolute;
  width: calc(var(--key-width) * 0.6);
  height: 60%;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 80%, #0a0a0a 100%);
  border: none;
  border-radius: 0 0 3px 3px;
  cursor: pointer;
  z-index: 2;
  transition: all 0.05s;
  box-shadow: 
    0 4px 8px rgba(0,0,0,0.5),
    inset 0 -2px 4px rgba(255,255,255,0.1);
}

.black-key:hover {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 80%, #1a1a1a 100%);
}

.black-key:active,
.black-key.active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Control Panel */
.control-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.control-group input[type="range"] {
  width: 80px;
  accent-color: var(--gold);
}

.control-group input[type="color"] {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.control-group select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}

/* Info Panel */
.info-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.now-playing,
.quick-tips {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border-color);
}

.now-playing h3,
.quick-tips h3 {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.current-note {
  font-family: 'JetBrains Mono', monospace;
  font-size: 48px;
  font-weight: 700;
  text-align: center;
}

.quick-tips p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Footer */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 16px;
  text-align: center;
}

.footer-keys {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-bottom: 12px;
  height: 20px;
}

.footer-key {
  width: 12px;
  border-radius: 0 0 2px 2px;
}

.footer-key.white {
  background: linear-gradient(180deg, #eee 0%, #ccc 100%);
  height: 100%;
}

.footer-key.black {
  background: #333;
  height: 60%;
  margin: 0 -4px;
  z-index: 1;
}

.app-footer p {
  font-size: 12px;
  color: var(--text-secondary);
}

.app-footer a {
  color: var(--gold);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .app-header {
    padding: 16px;
  }

  .main-content {
    padding: 12px;
    gap: 12px;
  }

  .song-card {
    min-width: 120px;
    padding: 12px 16px;
  }

  .control-btn.play {
    width: 48px;
    height: 48px;
  }

  .info-panel {
    grid-template-columns: 1fr;
  }

  .piano-container {
    --key-width: 24px;
  }

  .piano-keyboard {
    height: 120px;
  }

  .control-panel {
    gap: 12px;
  }

  .controls-row.secondary {
    gap: 8px;
  }

  .speed-control {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Touch improvements */
@media (hover: none) {
  .white-key:hover,
  .black-key:hover {
    background: inherit;
  }
}