:root {
    --bg-color: #1a1a1a;
    --panel-bg: #252525;
    --text-color: #f0f0f0;
    
    /* Vector Fretboard Theme */
    --fretboard-bg: #2d2d2d;
    --fret-wire: #555;
    --string-color: #777;
    --inlay-color: #a1a1a1;
    
    --primary-color: #646cff; 
    --primary-hover: #535bf2;
    
    --correct-color: #00e676; /* Bright Green */
    --root-color: #00a859; /* Darker Green for Root */
    --incorrect-color: #ff1744; /* Bright Red */
    --note-bg: #fff;
    --note-text: #000;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 3.1rem;
    background: linear-gradient(to right, #646cff, #90caf9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: #888;
    font-size: 1.1rem;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    background: var(--panel-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid #333;
    width: 100%;
    max-width: 750px;
}

.settings-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.actions-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
    /* Ensure buttons wrap on very small screens if needed, or stay in row */
    flex-wrap: wrap; 
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1; /* Allow items to grow */
    min-width: 200px; /* Minimum width for inputs */
}

label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
}

/* Ensure inputs take full width of their container */
select {
    width: 100%;
    /* ... rest of existing select styles ... */
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    background: #333;
    border: 1px solid #444;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    /* min-width: 160px; REMOVED to allow resizing down if needed, but min-width on parent handles it */
    cursor: pointer;
    transition: all 0.2s;
     appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Make buttons equal width in the actions group */
.actions-group .btn {
    flex: 1;
    min-width: 60px; /* Prevent crushing */
}

@media (max-width: 600px) {
    .settings-group {
        flex-direction: column;
    }
    
    .control-item {
        width: 100%;
        min-width: unset;
    }
}

select:hover {
    border-color: #666;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(100, 108, 255, 0.2);
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
    height: 48px; /* Match inputs */
    display: flex;
    align-items: center;
    justify-content: center;
}

.secondary {
    background: #333;
    color: white;
    border: 1px solid #444;
}

.secondary:hover {
    background: #444;
    transform: translateY(-1px);
}

.secondary:active {
    transform: translateY(0);
}

.icon-btn {
    padding: 0 1rem;
    background: #333;
    color: white;
    border: 1px solid #444;
    font-size: 1.25rem;
}

.icon-btn:hover {
    background: #444;
}

.icon-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Fretboard */
.fretboard-container {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0;
}

.fretboard-wrapper {
    min-width: 100%;
    width: fit-content;
    display: flex;
    justify-content: center;
}

.fretboard {
    display: flex;
    background: var(--fretboard-bg);
    border-radius: 4px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.fret {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    position: relative;
    width: 65px;
    height: 240px;
    border-right: 2px solid var(--fret-wire);
}

.fret:first-child {
    width: 25px;
    background: #222;
    border-right: 4px solid #666; /* Nut */
}

/* Strings */
.string-segment {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px; /* Allocate vertical space for hit area */
}

.string-line {
    width: 120%;
    height: 2px;
    background: var(--string-color);
    position: absolute;
    left: -10%;
    z-index: 1;
}

/* String Weights (Top to Bottom visually = High E to Low E in CSS logical order? )
   Actually standard is High E top (string 1) -> Low E bottom (string 6). */
/* Let's be consistent: Child 1 = High E */
.fret .string-segment:nth-child(1) .string-line { height: 1px; opacity: 0.6; }
.fret .string-segment:nth-child(2) .string-line { height: 1.5px; opacity: 0.7; }
.fret .string-segment:nth-child(3) .string-line { height: 2px; opacity: 0.8; }
.fret .string-segment:nth-child(4) .string-line { height: 2.5px; opacity: 0.9; }
.fret .string-segment:nth-child(5) .string-line { height: 3px; }
.fret .string-segment:nth-child(6) .string-line { height: 4px; }


/* Note Interaction */
.note-hitbox {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    position: absolute;
    z-index: 10;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.note-hitbox:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Markers */
.note-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--note-bg);
    color: var(--note-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Active States */
/* Used for Scale Mode (simple toggle) AND Triad Mode (active selection) */
.note-hitbox.correct .note-marker,
.note-hitbox.selected .note-marker {
    background: var(--correct-color);
    color: #003300;
    opacity: 1;
    transform: scale(1);
}

.note-hitbox.root-note .note-marker {
    background: #ffd700; /* Gold */
    color: #000;
    font-weight: 800;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    border: 1px solid #fff;
}

/* Found State (Triad Mode - Completed Sets) */
.note-hitbox.found .note-marker {
    background: transparent;
    border: 2px solid var(--correct-color);
    color: var(--correct-color);
    opacity: 1;
    transform: scale(1);
    box-shadow: none;
}

/* Found Root Note: Gold Outline */
.note-hitbox.found.root-note .note-marker {
    border: 2px solid #ffd700;
    color: #ffd700;
    box-shadow: none;
}

/* If a found note is selected again */
.note-hitbox.found.selected .note-marker {
    background: var(--correct-color);
    color: #003300;
    border: 2px solid var(--correct-color);
}

/* If a found root note is selected again */
.note-hitbox.found.selected.root-note .note-marker {
    background: #ffd700;
    color: #000;
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.note-hitbox.incorrect .note-marker {
    background: var(--incorrect-color);
    color: white;
    opacity: 1;
    transform: scale(1);
}

/* Inlays */
.inlay {
    position: absolute;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--inlay-color);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.inlay.double-top { top: 25%; }
.inlay.double-bottom { top: 75%; }

/* Status */
.status-message {
    font-size: 1.5rem;
    font-weight: 600;
    color: #666;
    background: #252525;
    padding: 1rem 2rem;
    border-radius: 50px;
    border: 1px solid #333;
}

#target-scale-name {
    color: var(--primary-color);
    white-space: nowrap;
}
