@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Outfit:wght@300;500;700&display=swap');

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

/* Prevent text selection */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

:root {
  --bg-dark: #0a0a0c;
  --bg-panel: #131318;
  --bg-control: #1a1a22;
  --accent-cyan: #00d4ff;
  --accent-orange: #ff6b35;
  --accent-green: #00ff88;
  --accent-red: #ff4757;
  --text-primary: #e8e8ec;
  --text-dim: #6b6b7a;
  --border: #2a2a35;
  
  /* Dynamic theme color - changes based on difficulty */
  --theme-color: var(--accent-cyan);
  --theme-glow: rgba(0, 212, 255, 0.4);
  --theme-glow-strong: rgba(0, 212, 255, 0.6);
  --theme-bg: rgba(0, 212, 255, 0.1);
}

/* Difficulty theme overrides */
[data-difficulty-theme="easy"] {
  --theme-color: var(--accent-green);
  --theme-glow: rgba(0, 255, 136, 0.4);
  --theme-glow-strong: rgba(0, 255, 136, 0.6);
  --theme-bg: rgba(0, 255, 136, 0.1);
}

[data-difficulty-theme="medium"] {
  --theme-color: var(--accent-cyan);
  --theme-glow: rgba(0, 212, 255, 0.4);
  --theme-glow-strong: rgba(0, 212, 255, 0.6);
  --theme-bg: rgba(0, 212, 255, 0.1);
}

[data-difficulty-theme="hard"] {
  --theme-color: var(--accent-red);
  --theme-glow: rgba(255, 71, 87, 0.4);
  --theme-glow-strong: rgba(255, 71, 87, 0.6);
  --theme-bg: rgba(255, 71, 87, 0.1);
}

[data-difficulty-theme="god"] {
  --theme-color: #bf00ff;
  --theme-glow: rgba(191, 0, 255, 0.4);
  --theme-glow-strong: rgba(191, 0, 255, 0.6);
  --theme-bg: rgba(191, 0, 255, 0.1);
}

/* Hue-shifting animation for buttons and titles */
@keyframes hue-shift {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(360deg); }
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 160px 20px 20px 20px;
  background-image: 
    radial-gradient(ellipse at 20% 20%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 107, 53, 0.03) 0%, transparent 50%);
}

.container {
  max-width: 800px;
  min-width: 700px;
  width: 100%;
}

/* Track Display */
.track-display {
  text-align: center;
  margin-top: 15px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  min-height: 16px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 0 10px;
}

.score-display,
.round-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  height: 48px;
}

.score-display {
  min-width: 130px;
}

.highscore-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 160px;
  height: 48px;
}

.highscore-difficulty {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--theme-color);
  font-weight: 600;
}

.highscore-label {
  color: var(--text-dim);
}

.highscore-value {
  color: var(--theme-color);
  font-weight: 700;
  font-size: 18px;
}

.score-value {
  color: var(--theme-color);
  font-weight: 700;
  font-size: 18px;
  transition: transform 0.15s ease-out;
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

.score-value.score-bump {
  animation: score-bump 0.4s ease-out;
}

@keyframes score-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); color: #fff; }
  100% { transform: scale(1); }
}

.round-value {
  color: var(--theme-color);
  font-weight: 700;
  display: inline-block;
  vertical-align: middle;
}

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

/* Small Buttons */
.btn-small {
  padding: 10px 16px;
  font-size: 11px;
  border-radius: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

/* Settings button - match height of other header elements */
.settings-btn {
  height: 48px;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.btn-small.active {
  background: var(--accent-cyan);
  color: var(--bg-dark);
  border-color: var(--accent-cyan);
}

/* Settings Panel */
.settings-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 30px;
  transition: right 0.3s ease;
  z-index: 100;
  overflow-y: auto;
}

.settings-panel.open {
  right: 0;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 99;
}

.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
}

.settings-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}

.settings-close:hover {
  color: var(--text-primary);
}

.settings-section {
  margin-bottom: 30px;
}

.settings-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Difficulty Options */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.difficulty-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: var(--bg-control);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.difficulty-option:hover {
  border-color: var(--text-dim);
}

.difficulty-option.selected {
  border-color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.1);
}

/* Difficulty-specific colors when selected */
.difficulty-option[data-difficulty="easy"].selected {
  border-color: var(--accent-green);
  background: rgba(0, 255, 136, 0.1);
}

.difficulty-option[data-difficulty="medium"].selected {
  border-color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.1);
}

.difficulty-option[data-difficulty="hard"].selected {
  border-color: var(--accent-red);
  background: rgba(255, 71, 87, 0.1);
}

.difficulty-option input {
  display: none;
}

.difficulty-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  position: relative;
  flex-shrink: 0;
}

.difficulty-option.selected .difficulty-radio {
  border-color: var(--accent-cyan);
}

.difficulty-option[data-difficulty="easy"].selected .difficulty-radio {
  border-color: var(--accent-green);
}

.difficulty-option[data-difficulty="hard"].selected .difficulty-radio {
  border-color: var(--accent-red);
}

.difficulty-option[data-difficulty="god"].selected .difficulty-radio {
  border-color: #bf00ff;
}

.difficulty-option.selected .difficulty-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--accent-cyan);
  border-radius: 50%;
}

.difficulty-option[data-difficulty="easy"].selected .difficulty-radio::after {
  background: var(--accent-green);
}

.difficulty-option[data-difficulty="hard"].selected .difficulty-radio::after {
  background: var(--accent-red);
}

.difficulty-option[data-difficulty="god"].selected .difficulty-radio::after {
  background: #bf00ff;
}

.difficulty-info {
  flex: 1;
}

.difficulty-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.difficulty-desc {
  font-size: 12px;
  color: var(--text-dim);
}

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin: 25px 0;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-control);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-option:hover {
  border-color: var(--text-dim);
}

.mode-option.selected {
  border-color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.1);
}

.mode-radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  position: relative;
  flex-shrink: 0;
}

.mode-option.selected .mode-radio {
  border-color: var(--accent-cyan);
}

.mode-option.selected .mode-radio::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--accent-cyan);
  border-radius: 50%;
}

.mode-name {
  font-weight: 500;
  font-size: 14px;
}

/* Loading Indicator */
.loading-indicator {
  display: none;
  justify-content: center;
  align-items: center;
  margin: 15px 0;
  height: 24px;
}

.loading-indicator.visible {
  display: flex;
}

.loading-text {
  color: var(--text-dim);
  font-size: 14px;
  animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: var(--bg-control);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.volume-icon {
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
}

.volume-icon:hover {
  color: var(--text-primary);
}

.volume-control input[type="range"] {
  flex: 1;
}

.volume-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-cyan);
  min-width: 40px;
  text-align: right;
}

/* Main Panel */
.main-panel {
  background: var(--bg-panel);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 40px;
  padding-bottom: 50px;
  position: relative;
  overflow: visible;
}

.main-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--theme-color), transparent);
  opacity: 0.5;
}

/* EQ Visualization */
.eq-visualization {
  height: 120px;
  min-width: 660px;
  background: var(--bg-control);
  border-radius: 12px;
  margin-bottom: 30px;
  position: relative;
  overflow: visible;
  border: 1px solid var(--border);
}

.eq-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid-line {
  position: absolute;
  width: 1px;
  height: 100%;
  background: var(--border);
}

.grid-line::after {
  content: attr(data-freq);
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-dim);
  white-space: nowrap;
}

.eq-curve {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Controls */
.controls-section {
  display: grid;
  gap: 24px;
}

.control-row {
  display: flex;
  gap: 20px;
  align-items: center;
}

.control-group {
  flex: 1;
}

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--theme-color);
  font-size: 12px;
}

.param-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.param-controls .control-group {
  flex: none;
}

/* Range Inputs */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-control);
  border-radius: 3px;
  outline: none;
  border: 1px solid var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--theme-color);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 15px var(--theme-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 0 25px var(--theme-glow-strong);
}

.guess-slider::-webkit-slider-thumb {
  background: var(--theme-color) !important;
  box-shadow: 0 0 15px var(--theme-glow) !important;
}

.guess-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 25px var(--theme-glow-strong) !important;
}

/* Buttons */
.button-row {
  display: flex;
  gap: 15px;
  margin-top: 30px;
}

.btn {
  flex: 1;
  padding: 16px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background: var(--theme-color);
  color: var(--bg-dark);
  box-shadow: 0 4px 20px var(--theme-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--theme-glow-strong);
}

.btn-secondary {
  background: var(--bg-control);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-secondary:active,
.btn-secondary.active {
  background: var(--accent-orange);
  color: var(--bg-dark);
  border-color: var(--accent-orange);
}

.btn-submit {
  background: linear-gradient(135deg, var(--accent-cyan), #00b8cc);
  color: var(--bg-dark);
  box-shadow: 0 4px 20px rgba(0, 255, 255, 0.3);
  animation: hue-shift 12s linear infinite;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(0, 255, 255, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Feedback */
.feedback {
  margin-top: 20px;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  font-weight: 500;
  display: none;
}

.feedback.correct {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
  display: block;
  animation: feedback-appear 0.3s ease-out;
}

.feedback.incorrect {
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid var(--accent-orange);
  color: var(--accent-orange);
  display: block;
  animation: feedback-appear 0.3s ease-out;
}

@keyframes feedback-appear {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-detail {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  margin-top: 8px;
  opacity: 0.8;
}

/* Screens */
.start-screen {
  text-align: center;
  padding: 60px 40px;
}

.end-screen {
  text-align: center;
}

.end-screen-content {
  padding: 20px 40px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* End screen sequence animation */
@keyframes fade-slide-in {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.end-screen .final-score-box {
  animation: fade-slide-in 0.5s ease-out forwards;
}

.end-screen .end-message {
  opacity: 0;
  animation: fade-slide-in 0.5s ease-out 0.3s forwards;
}

.end-screen .mode-selector {
  opacity: 0;
  animation: fade-slide-in 0.5s ease-out 1.2s forwards;
}

.end-screen .btn-primary {
  opacity: 0;
  animation: fade-slide-in 0.5s ease-out 1.2s forwards;
}

/* Ko-fi widget container */
.kofi-container {
  margin-top: 25px;
  display: flex;
  justify-content: center;
}

/* Ko-fi on home screen - outside the box, like track display */
.kofi-home {
  margin-top: 5px;
}

.end-screen .kofi-container {
  opacity: 0;
  animation: fade-slide-in 0.5s ease-out 1.2s forwards;
}

.main-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent-cyan), #00b8cc);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: hue-shift 12s linear infinite;
}

.start-screen p {
  color: var(--text-dim);
  margin-bottom: 30px;
  line-height: 1.6;
}

.end-message {
  font-size: 14px;
  margin-bottom: 20px;
  color: var(--text-dim);
}

.final-score-box {
  background: var(--bg-control);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 32px;
  margin: 20px 0 24px 0;
  text-align: center;
  width: 294px;
}

.final-score-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}

.final-score {
  font-weight: 700;
  font-size: 32px;
  color: var(--theme-color);
  margin: 0;
  animation: score-glow 2.5s ease-in-out infinite;
}

@keyframes score-glow {
  0%, 100% {
    text-shadow: 0 0 8px var(--theme-glow);
  }
  50% {
    text-shadow: 0 0 20px var(--theme-glow-strong);
  }
}

.final-score.perfect-score {
  font-size: 40px;
  color: var(--accent-cyan);
  animation: pulse-scale 1.5s ease-in-out infinite;
}

@keyframes pulse-scale {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
  }
  50% {
    transform: scale(1.05);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
  }
}

.game-screen {
  display: none;
}

/* Sample Indicator */
.sample-indicator {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
}

.sample-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s;
}

.sample-dot.active {
  background: var(--theme-color);
  box-shadow: 0 0 10px var(--theme-color);
}

.sample-dot.completed {
  background: var(--accent-green);
}

.sample-dot.wrong {
  background: var(--accent-orange);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Mobile Styles */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    min-width: unset;
    width: 100%;
  }

  .header {
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
  }

  .score-display,
  .round-display {
    padding: 8px 10px;
    font-size: 12px;
    min-width: unset;
  }

  /* High score centered on top */
  .highscore-display {
    order: 1;
    width: 100%;
    justify-content: center;
  }

  /* Round, Score, Settings on bottom row */
  .header-controls {
    order: 2;
  }

  .settings-btn {
    order: 3;
  }

  .main-panel {
    padding: 20px 15px;
    padding-bottom: 30px;
  }

  .eq-visualization {
    min-width: unset;
    width: 100%;
    height: 100px;
    margin-bottom: 20px;
  }

  .grid-line::after {
    font-size: 7px;
    bottom: -16px;
  }

  /* Bigger slider track */
  input[type="range"] {
    height: 12px;
  }

  /* Much bigger slider thumb for touch */
  input[type="range"]::-webkit-slider-thumb {
    width: 32px;
    height: 32px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
  }

  .guess-slider::-webkit-slider-thumb {
    width: 36px;
    height: 36px;
  }

  .guess-slider::-moz-range-thumb {
    width: 36px;
    height: 36px;
  }

  .control-label {
    font-size: 10px;
    margin-bottom: 12px;
  }

  .control-value {
    font-size: 11px;
  }

  /* Bigger buttons */
  .btn {
    padding: 18px 20px;
    font-size: 14px;
  }

  .button-row {
    flex-direction: column;
    gap: 10px;
  }

  .btn-small {
    padding: 12px 14px;
    font-size: 10px;
  }

  /* Mode selector */
  .mode-selector {
    flex-direction: column;
    gap: 10px;
  }

  .mode-option {
    justify-content: center;
  }

  /* Start/End screens */
  .start-screen {
    padding: 30px 20px;
  }

  .end-screen-content {
    padding: 15px 20px 30px 20px;
  }

  .main-title {
    font-size: 24px;
  }

  .final-score {
    font-size: 36px;
  }

  /* Settings panel full width on mobile */
  .settings-panel {
    width: 100%;
    right: -100%;
  }

  /* Feedback */
  .feedback {
    padding: 15px;
    font-size: 14px;
  }

  .feedback-detail {
    font-size: 11px;
  }
}

/* Footer */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  padding: 15px 30px;
  color: #3d3d42;
  font-size: 12px;
  opacity: 0.6;
  pointer-events: none;
}

.site-footer span {
  pointer-events: auto;
}