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

:root {
  /* Основные цвета палитры */
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0a0a1a;
  --border: #0f3460;
  --border2: #2a2a4a;
  --border3: #1a1a2e;
  --border4: #333;
  --border5: #888;
  --border6: #555;
  --text: #e0e0e0;
  --text-dim: #a0a0b0;
  --text-muted: #666;
  --text-label: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #c73650;
  --accent-running: #533483;
  --accent-running-hover: #43286a;
  --accent2: #00b4d8;
  --correct: rgba(46, 204, 113, 0.25);
  --wrong: rgba(231, 76, 60, 0.25);
  --natural-hint: rgba(255, 215, 0, 0.12);
  --fret-num: #c8a96e;
  --marker: #444;
  --string-label: #555;
  --hover-bg: rgba(233, 69, 96, 0.15);
  --glow: rgba(233, 69, 96, 0.8);
  --glow2: rgba(233, 69, 96, 0.7);
  --glow3: rgba(233, 69, 96, 0.5);
  --glow4: rgba(233, 69, 96, 0.9);
  --glow5: rgba(0, 180, 216, 0.8);
  --num-row-bg: #0f3460;
  --num-row-border-top: #16213e;
  --num-row-border-bottom: #333;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  transition: background 0.3s, color 0.3s;
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: var(--accent);
  text-align: center;
}

.settings {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  max-width: 800px;
}

.settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.setting-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}

.setting-group label {
  font-size: 0.75rem;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  white-space: nowrap;
}

.setting-group input[type="number"] {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}

.setting-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

.setting-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.setting-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.btn-start {
  background: var(--accent);
  color: #fff;
}

.btn-start:hover { background: var(--accent-hover); }

.btn-start.running {
  background: var(--accent-running);
}

.btn-start.running:hover { background: var(--accent-running-hover); }

.question-area {
  text-align: center;
  margin-bottom: 30px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.string-label {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.note-display {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.note-display .note-letter {
  display: inline-block;
  min-width: 1.2em;
  text-align: center;
}

.fretboard-container {
  width: 100%;
  max-width: 750px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.fretboard {
  display: flex;
  flex-direction: column;
  min-width: 650px;
  position: relative;
}

.fret-num-row {
  display: flex;
  align-items: center;
  height: 28px;
  position: relative;
  flex: 1;
}

.fret-num-row .fret-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 3px solid var(--border2);
  border-right: 1px solid var(--border3);
}

.string-label-small {
  width: 40px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
}

.fret-string {
  display: flex;
  align-items: center;
  height: 48px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border3);
}

.string-label {
  width: 40px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--string-label);
  flex-shrink: 0;
  z-index: 3;
  transition: color 0.3s;
}

.fret-segment {
  flex: 1;
  height: 100%;
  border-left: 3px solid var(--border2);
  border-right: 1px solid var(--border3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.fret-segment:hover {
  background: var(--hover-bg);
}

.fret-segment.open {
  border-left: 6px solid var(--border5);
  cursor: pointer;
  transition: background 0.15s;
}

.fret-segment.open:hover {
  background: var(--hover-bg);
}

.fret-segment.correct {
  background: var(--correct) !important;
}

.fret-segment.wrong {
  background: var(--wrong) !important;
}

.fret-segment.natural-hint {
  background: var(--natural-hint);
}

.fret-segment.open.natural-hint {
  background: var(--natural-hint);
}

.fret-number {
  position: absolute;
  bottom: -22px;
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}

.fret-number.bottom-only {
  position: relative;
  bottom: auto;
  font-size: 0.85rem;
  color: var(--fret-num);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.fret-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--marker);
  pointer-events: none;
}

.fret-marker.double {
  top: 35%;
}

.fret-marker.double.bottom {
  top: auto;
  bottom: 35%;
}

.string-line {
  position: absolute;
  left: 40px;
  right: 0;
  height: 2px;
  background: var(--border6);
  pointer-events: none;
  z-index: 1;
  transition: background 0.3s, box-shadow 0.3s;
}

.fret-string.active .string-line {
  background: var(--glow4);
  box-shadow: 0 0 10px var(--glow2);
  height: 3px;
}

.fret-string.active .string-label {
  color: var(--accent);
  font-weight: 700;
}

.note-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  z-index: 2;
  position: relative;
  transition: all 0.4s ease;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.note-dot.question {
  background: var(--accent);
  box-shadow: 0 0 25px var(--glow), 0 2px 8px rgba(0, 0, 0, 0.5);
  animation: pulse 1.5s infinite;
}

.note-dot.answer {
  background: var(--accent2);
  box-shadow: 0 0 25px var(--glow5), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.note-dot.hidden {
  opacity: 0;
  transform: scale(0.5);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 15px var(--glow3); }
  50% { box-shadow: 0 0 25px var(--glow); }
}

.answer-area {
  text-align: center;
  min-height: 60px;
  margin-bottom: 20px;
}

.answer-text {
  font-size: 1.4rem;
  color: var(--accent2);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
}

.answer-text.visible {
  opacity: 1;
}

.progress {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 10px;
}

.timer-bar {
  width: 100%;
  max-width: 750px;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 100%;
  transition: width linear;
}

.timer-bar-fill.answer-phase {
  background: var(--accent2);
}

.score {
  font-size: 1rem;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Палитры */
.palette-section {
  width: 100%;
  margin-top: 4px;
}

.palette-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.palette-btn {
  width: 36px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.palette-btn:hover {
  transform: scale(1.15);
}

.palette-btn.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.palette-btn .tooltip {
  display: none;
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
}

.palette-btn:hover .tooltip {
  display: block;
}

.palette-custom-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 6px;
  justify-content: center;
}

.palette-custom-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.palette-custom-panel {
  display: none;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.palette-custom-panel.visible {
  display: flex;
}

.color-pick-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.color-pick-group label {
  font-size: 0.65rem;
  color: var(--text-label);
  text-transform: uppercase;
}

.color-pick-group input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  padding: 1px;
}

.palette-apply-btn {
  padding: 4px 16px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 600;
  margin-top: 4px;
}

.palette-apply-btn:hover {
  background: var(--accent-hover);
}

.controls-row {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

/* Мобильные устройства */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 1.4rem;
    margin-bottom: 12px;
  }

  .settings {
    padding: 12px 16px;
    gap: 12px;
  }

  .setting-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .setting-group label {
    font-size: 0.9rem;
  }

  .setting-group input[type="number"] {
    width: 100px;
  }

  .fretboard {
    gap: 2px;
    padding: 8px;
  }

  .fret-string {
    height: 28px;
  }

  .string-label {
    width: 30px;
    font-size: 0.9rem;
  }

  .fret-segment {
    height: 24px;
    font-size: 0.7rem;
  }

  .fret-segment .note-name {
    font-size: 0.65rem;
  }

  .fret-segment .dot {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }

  .fret-labels {
    gap: 2px;
    height: 20px;
  }

  .fret-labels span {
    font-size: 0.6rem;
  }

  .question-area {
    padding: 12px 16px;
  }

  .question-text {
    font-size: 1.2rem;
  }

  .progress {
    font-size: 0.9rem;
  }

  .answer-area {
    min-height: 40px;
    margin-bottom: 12px;
  }

  .answer-text {
    font-size: 1.1rem;
  }

  .score {
    font-size: 0.9rem;
  }

  button {
    padding: 10px 20px;
    font-size: 0.95rem;
  }
}

/* Очень маленькие экраны */
@media (max-width: 380px) {
  h1 {
    font-size: 1.2rem;
  }

  .fret-string {
    height: 24px;
  }

  .fret-segment {
    height: 20px;
    font-size: 0.65rem;
  }

  .fret-segment .note-name {
    font-size: 0.6rem;
  }

  .fret-segment .dot {
    width: 16px;
    height: 16px;
    font-size: 0.55rem;
  }

  .fret-labels {
    height: 18px;
  }

  .fret-labels span {
    font-size: 0.55rem;
  }
}
