/* Brutalist Black on White - Balenciaga-inspired */

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

html {
    height: 100%;
    background-color: #fff;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #fff;
    color: #000;
    font-weight: 400;
    letter-spacing: 0.02em;
    height: 100%;
    overflow: hidden;
}

.app-container {
    display: grid;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* Desktop/Tablet: stacked layout (fretboard on top, controls below) */
@media (min-width: 769px) {
    .app-container {
        grid-template-rows: 3fr 2fr;
        grid-template-columns: 1fr;
        padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
        gap: 1.5rem;
    }

    #fretboard-panel {
        order: 1;
        min-height: 0;
    }

    #controls-panel {
        order: 2;
        display: flex;
        flex-wrap: nowrap;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
    }

    #controls-panel h2 {
        display: none;
    }

    .controls-scroll-area {
        display: contents;
    }

    /* Mode section, chord list, and info panel each take 1/3 width */
    #controls-panel > .mode-section,
    #controls-panel > .control-group,
    .controls-scroll-area > .mode-section,
    .controls-scroll-area > .control-group {
        flex: 1 1 33.333%;
        min-width: 0;
        margin-bottom: 0;
    }

    #info-panel {
        overflow: hidden;
    }

}

/* Mobile: side-by-side (fretboard left, controls right) */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 100%;
        padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
        gap: 0.5rem;
        height: 100%;
    }

    #fretboard-panel {
        order: 1;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        padding: 0 !important;
    }

    /* Larger marker text in mobile */
    #fretboard-panel .marker text {
        font-size: 20px !important;
    }

    #controls-panel {
        order: 2;
        height: 100%;
        max-height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow-y: hidden;
        padding: 0 !important;
        border: none !important;
        background-color: transparent !important;
    }

    #controls-panel h2 {
        display: none;
    }

    .controls-scroll-area {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
    }

    #info-panel {
        flex-shrink: 0;
        margin-bottom: 0;
    }

    /* Mode section — compact */
    .mode-section {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .mode-section > label {
        font-size: 0.75rem;
        margin-bottom: 0.375rem;
    }

    /* Radio labels — smaller hit targets (moved after base definition, see below mobile block) */

    /* Selects — compact */
    select {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Control group labels — tighter */
    .control-group > label {
        margin-bottom: 0.375rem;
    }

    /* Control group spacing */
    .control-group {
        margin-bottom: 0.5rem;
    }

    /* Toggle text (7ths, rel, Notes, Sound) */
    .toggle-text {
        padding: 0.35rem 0.625rem;
    }

    /* Scale chord list — compact */
    .scale-chords-list {
        gap: 0.2rem;
    }

    .scale-chord-item {
        padding: 0.25rem 0.4rem;
    }

    .scale-chord-item .numeral {
        font-size: 0.5625rem;
        width: 3rem;
    }

    .scale-chord-item .chord-name {
        font-size: 0.625rem;
    }

    /* Chord list items — compact */
    .chord-list-item {
        padding: 0.35rem 0.5rem;
        font-size: 0.625rem;
    }

    /* Chord list actions (Add/Clear) */
    .btn {
        padding: 0.35rem 0.75rem;
    }

    /* Info panel — compact */
    #info-panel {
        padding: 0.5rem;
    }

    .info-title {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
        padding-bottom: 0.25rem;
    }

    .info-grid-interval,
    .info-grid-note {
        font-size: 0.6875rem;
    }

    /* Remove mode-controls internal border in mobile */
    .mode-section .mode-controls {
        border-left: none !important;
        border-top: none !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
        margin-top: 0.5rem !important;
        padding-top: 0 !important;
    }

    /* In f.scale mode, show matching scales above scale chords */
    .find-mode-active .mode-controls {
        display: flex;
        flex-direction: column;
    }
    .find-mode-active .mode-controls #scale-chord-builder {
        order: 2;
        margin-top: 0.75rem;
    }
    .find-mode-active .mode-controls #find-controls {
        order: 1;
    }
}

/* Tablet: apply mobile mode-section behavior (no border) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Remove mode-controls internal border in tablet */
    .mode-section .mode-controls {
        border-left: none !important;
        border-top: none !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
        margin-top: 0.5rem !important;
        padding-top: 0 !important;
    }
}

/* Primary content */
#fretboard-panel {
    background-color: #f5f5f5;
    border: 1px solid #000;
    padding: 0.5rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fretboard-panel svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
}

#controls-panel {
    background-color: #fff;
    border: 1px solid #000;
    padding: 2rem;
}

#controls-panel h2 {
    margin-bottom: 2rem;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #000;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group > label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.625rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #000;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-family: inherit;
    letter-spacing: 0.1em;
    background-color: #fff;
    color: #000;
    border: 1px solid #000;
    border-radius: 0;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    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='black' 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 0.75rem center;
    background-size: 1rem;
}

select:focus {
    outline: none;
    background-color: #000;
    color: #fff;
    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");
}

select:hover {
    background-color: #000;
    color: #fff;
    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");
}

/* Universal scrolling behavior for mode toggle buttons */
.mode-toggle,
.radio-group {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.radio-group {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
}

/* Primary controls - medium border */
.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border: 2px solid #000;
    margin-right: -2px;
    position: relative;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Only apply hover on devices with precise pointing (not touch) */
@media (hover: hover) {
    .radio-label:hover {
        background-color: #000;
        color: #fff;
    }
}

.radio-label input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Radio buttons - checked state via class */
.radio-label.checked {
    background-color: #000;
    color: #fff;
}

@media (max-width: 768px) {
    .radio-label {
        padding: 0.4rem 0.6rem;
        font-size: 0.5625rem;
    }
}

/* Toggle row for 7ths checkbox */
.toggle-row {
    margin-bottom: 0.75rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-text {
    padding: 0.5rem 1rem;
    border: 1px solid #000;
}

@media (hover: hover) {
    .toggle-label:hover .toggle-text {
        background-color: #000;
        color: #fff;
    }
}

/* Toggle buttons - checked state via class */
.toggle-label.checked .toggle-text {
    background-color: #000;
    color: #fff;
}

/* Scale chord builder */
#scale-chord-builder {
    transition: opacity 0.2s;
}

#scale-chord-builder > label {
    margin-bottom: 0.25rem;
}

#scale-chord-builder.disabled {
    opacity: 0.35;
    pointer-events: none;
}

#scale-chord-builder > .btn-add,
#type-group > .btn-add {
    margin-top: 0.5rem;
}

#scale-chord-builder > .btn-add + .btn-add {
    margin-top: 0.25rem;
}

.scale-chords-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    border: 1px solid #000;
    padding: 0.25rem;
}

.scale-chord-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.1s, color 0.1s;
    text-align: left;
    color: #000;
}

@media (hover: hover) {
    .scale-chord-item:hover {
        background-color: #000;
        color: #fff;
    }
}

.scale-chord-item.selected {
    background-color: #000;
    color: #fff;
}

.scale-chord-item .numeral {
    font-size: 0.625rem;
    text-transform: none;
    letter-spacing: 0.1em;
    width: 4.5rem;
    flex-shrink: 0;
}

.scale-chord-item .chord-name {
    font-size: 0.75rem;
    font-weight: 400;
}

.scale-chords-note {
    font-size: 0.625rem;
    color: #666;
    font-style: italic;
}

/* Prog mode navigation */
.prog-nav {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

.prog-nav-btn {
    flex: 1;
    padding: 0.45rem 0;
    font-size: 0.65rem;
    color: #000;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
}

.prog-nav-btn:hover {
    background: #000;
    color: #fff;
}

.prog-nav-btn:active {
    background: #333;
    color: #fff;
}

.prog-fav-btn {
    flex: none;
    width: 2.25rem;
}

.prog-fav-btn.active {
    background: #000;
    color: #fff;
}

/* Prog builder */
.prog-builder-row {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    margin-bottom: 0.25rem;
}

.prog-numeral-select,
.prog-quality-select {
    min-width: 0;
    padding: 0.3rem;
    border: 1px solid #000;
    background-color: #fff;
    font-size: 0.75rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: none;
}

.prog-numeral-select {
    flex: 1.2;
}

.prog-quality-select {
    flex: 1;
}

.prog-chord-readout {
    flex: 0 0 3.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
}

.prog-row-move {
    flex: 0 0 1.5rem;
    height: 1.5rem;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 0.6rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prog-row-move:hover:not(:disabled) {
    background: #000;
    color: #fff;
}

.prog-row-move:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.prog-row-delete {
    flex: 0 0 1.5rem;
    height: 1.5rem;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prog-row-delete:hover {
    background: #000;
    color: #fff;
}

.prog-builder-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

#prog-builder-from-list {
    white-space: nowrap;
}

#prog-builder-desc-group input {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid #000;
    background: #fff;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.prog-builder-save-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Chord list header */
.chord-list-header {
    display: flex;
    align-items: center;
}

.chord-list-header .toggle-label {
    margin-left: auto;
}

.chord-list-header .toggle-text {
    padding: 0.15rem 0.5rem;
    font-size: 0.5rem;
    line-height: 1;
}

/* Chord list */
.chord-list {
    list-style: none;
    border: 1px solid #000;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

.chord-list:empty::after {
    content: 'Select Scale or Chord mode to add chords';
    display: block;
    padding: 1rem;
    text-align: center;
    font-size: 0.625rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.chord-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    transition: background-color 0.1s;
}

.chord-list-item:last-child {
    border-bottom: none;
}

.chord-list-item:hover {
    background-color: #f5f5f5;
}

.chord-list-item.selected {
    background-color: #000;
    color: #fff;
}

.chord-list-item.selected:hover {
    background-color: #333;
}

.remove-chord-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 0.25rem;
    opacity: 0.5;
    transition: opacity 0.1s;
}

.remove-chord-btn:hover {
    opacity: 1;
}

.chord-list-item.selected .remove-chord-btn {
    color: #fff;
}

/* Chord list actions */
.chord-list-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    flex: 1;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid #000;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

.btn-add {
    background-color: #000;
    color: #fff;
}

.btn-add:hover {
    background-color: #333;
}

.btn-clear {
    background-color: #fff;
    color: #000;
}

.btn-clear:hover {
    background-color: #000;
    color: #fff;
}

/* Info panel - lighter border for output/reference */
#info-panel {
    background-color: #f5f5f5;
    border: 1px solid #999;
    padding: 1rem;
    container-type: inline-size;
    display: flex;
    flex-direction: column;
}

.info-content {
    padding: 0;
}

.info-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ccc;
}

.info-grid {
    display: grid;
    gap: 0;
    width: 100%;
    overflow: hidden;
}

.info-grid-text {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    color: #333;
}

.info-grid-cell {
    text-align: center;
    font-family: 'Monaco', 'Consolas', monospace;
    min-width: 0;
    border: 1px solid #ccc;
    margin-top: -1px;
    margin-left: -1px;
    padding: 0.125rem 0;
}

.info-grid-interval {
    font-size: 0.875rem;
    color: #666;
    padding-bottom: 0.125rem;
}

.info-grid-note {
    font-size: 0.875rem;
    font-weight: 700;
}

.info-grid-description {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
    color: #333;
    margin-top: 0.5rem;
}

@container (max-width: 180px) {
    .info-grid-interval,
    .info-grid-note { font-size: 0.6875rem; }
    .info-grid-description { font-size: 0.625rem; }
}

.chromatic-circle {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.75rem;
    flex: 1;
    min-height: 0;
}

.chromatic-circle svg {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    max-width: 100%;
    max-height: 100%;
}

@media (max-width: 768px) {
    .chromatic-circle svg {
        width: 90%;
        height: auto;
        aspect-ratio: 1;
    }
}

@media (min-width: 769px) {
    .chromatic-circle svg {
        height: 100%;
        width: auto;
    }
}

/* Mode section container - groups mode toggle with dependent controls */
.mode-section {
    border: 2px solid #000;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.mode-section > label {
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #000;
}

.mode-header {
    display: flex;
    align-items: center;
}

.mode-header .toggle-label {
    margin-left: auto;
}

.mode-header .toggle-text {
    padding: 0.15rem 0.5rem;
    font-size: 0.5rem;
    line-height: 1;
}

.mode-controls {
    margin-left: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid #333;
    margin-top: 1rem;
}

.mode-controls .control-group {
    margin-bottom: 1rem;
}

.mode-controls .control-group:last-child {
    margin-bottom: 0;
}

/* Secondary controls - lighter border */
.mode-controls select {
    border: 1px solid #666;
}

.mode-controls select:focus,
.mode-controls select:hover {
    border-color: #000;
}

/* Typography hierarchy - control labels */
.mode-controls .control-group > label {
    font-size: 0.75rem;
    font-weight: 400;
    color: #444;
}


/* Spacing scale consistency */
.control-group {
    margin-bottom: 1rem;
}

/* CAGED shape selector - colored borders for "All" mode visual reference */
input[name="caged-shape"][value="C"] ~ * {
    border-left: 3px solid #FF4444;
}

input[name="caged-shape"][value="A"] ~ * {
    border-left: 3px solid #FF8C00;
}

input[name="caged-shape"][value="G"] ~ * {
    border-left: 3px solid #32CD32;
}

input[name="caged-shape"][value="E"] ~ * {
    border-left: 3px solid #4169E1;
}

input[name="caged-shape"][value="D"] ~ * {
    border-left: 3px solid #9370DB;
}

/* Desktop mode section - compact layout */
@media (min-width: 1025px) {
    .mode-section {
        margin-bottom: 0;
        padding: 0.75rem;
    }

    .mode-section .mode-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 0.75rem;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 2px solid #333;
    }

    /* Root note — always left column */
    #root-group { grid-column: 1; grid-row: 1; margin-bottom: 0; }

    /* Prog sub-mode radios — left column, under key */
    #prog-submode { grid-column: 1; }

    /* Type select — left column */
    #type-group { grid-column: 1; margin-bottom: 0; }

    /* Prog nav — left column */
    .prog-nav { grid-column: 1; }

    /* Scale chords — right column, spanning rows */
    .mode-section .mode-controls #scale-chord-builder {
        grid-column: 2;
        grid-row: 1 / 4;
        margin-bottom: 0;
    }

    /* Prog builder — right column, spanning rows */
    #prog-builder { grid-column: 2; grid-row: 1 / 4; }

    /* Prog edit selector — left column */
    #prog-edit-selector { grid-column: 1; }

    /* Prog description — left column */
    #prog-builder-desc-group { grid-column: 1; }

    /* Chord list takes full height on desktop */
    #controls-panel > .control-group,
    .controls-scroll-area > .control-group {
        display: flex;
        flex-direction: column;
    }

    .chord-list {
        flex: 1 1 auto;
        min-height: 100px;
        max-height: none;
    }

    /* Compact info panel */
    #info-panel {
        padding: 0.75rem;
    }

    .info-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.25rem;
    }
}

/* ========================================
   INTERVAL FILTER
   ======================================== */

.interval-filter-actions {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.btn-sm {
    flex: 0;
    padding: 0.25rem 0.625rem;
    font-family: inherit;
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
    transition: background-color 0.1s, color 0.1s;
}

@media (hover: hover) {
    .btn-sm:hover {
        background: #000;
        color: #fff;
    }
}

.interval-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.interval-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.interval-check input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.interval-check span {
    display: inline-block;
    padding: 0.3rem 0.5rem;
    font-size: 0.625rem;
    font-family: inherit;
    letter-spacing: 0.05em;
    border: 2px solid var(--interval-color, #000);
    background: #fff;
    color: #000;
    transition: background-color 0.1s, color 0.1s;
    min-width: 2rem;
    text-align: center;
}

.interval-check.checked span {
    background-color: var(--interval-color, #000);
    color: #fff;
}


@media (max-width: 768px) {
    .interval-checkboxes {
        gap: 0.2rem;
    }

    .interval-check span {
        padding: 0.25rem 0.375rem;
        font-size: 0.5625rem;
        min-width: 1.75rem;
    }

    .btn-sm {
        padding: 0.2rem 0.5rem;
        font-size: 0.5rem;
    }
}

/* ========================================
   FIND MODE
   ======================================== */

/* Crosshair cursor on fretboard in Find mode */
.find-mode-active #fretboard-panel {
    cursor: crosshair;
}

/* Find results list */
.find-results-list {
    list-style: none;
    border: 1px solid #000;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

.find-result-placeholder {
    display: block;
    padding: 1rem;
    text-align: center;
    font-size: 0.625rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.find-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    transition: background-color 0.1s;
}

.find-result-item:last-child {
    border-bottom: none;
}

.find-result-item:hover {
    background-color: #f5f5f5;
}

.find-result-item.selected {
    background-color: #000;
    color: #fff;
}

.find-result-item.selected:hover {
    background-color: #333;
}

.find-result-symbol {
    font-weight: 400;
}

.find-result-notes {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.625rem;
    color: #666;
    letter-spacing: 0.1em;
}

.find-result-item.selected .find-result-notes {
    color: #ccc;
}

.find-actions {
    display: flex;
    gap: 0.5rem;
}

.find-actions .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Mobile overrides for Find mode */
@media (max-width: 768px) {
    .find-results-list {
        min-height: 60px;
        max-height: 150px;
    }

    .find-result-item {
        padding: 0.35rem 0.5rem;
        font-size: 0.625rem;
    }

    .find-result-notes {
        font-size: 0.5rem;
    }
}

/* ========================================
   GAMES MODE
   ======================================== */

#games-panel {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 100;
    display: none;
    overflow-y: auto;
}

/* Game content area */
.game-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: calc(4rem + env(safe-area-inset-top, 0px)) calc(1rem + env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) calc(1rem + env(safe-area-inset-left, 0px));
}

/* Back button */
.games-back-btn {
    position: fixed;
    z-index: 120;
    background: #fff;
    border: 2px solid #000;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    color: #000;
}

.games-back-btn:hover {
    background: #000;
    color: #fff;
}

/* Controls box */
.games-controls {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    z-index: 120;
    display: flex;
    gap: 0.5rem;
    border: 2px solid #000;
    padding: 0.5rem;
    background: #fff;
    align-items: center;
}

.games-controls select {
    padding: 0.35rem 0.5rem;
    font-size: 0.625rem;
    border: 1px solid #000;
    min-width: 0;
    width: auto;
    background-image: none;
}

.games-controls button {
    padding: 0.35rem 0.75rem;
    font-family: inherit;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
    color: #000;
}

@media (hover: hover) {
    .games-controls button:hover {
        background: #000;
        color: #fff;
    }
}

.games-controls button.games-sound-on {
    background: #000;
    color: #fff;
}

/* Modal */
.game-settings-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
}

.game-settings-box {
    background: #fff;
    border: 2px solid #000;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.game-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #000;
}

.game-settings-header h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.game-settings-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
}

.game-settings-close:hover {
    opacity: 0.6;
}

.game-settings-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

/* Settings form elements */
.game-setting-group {
    margin-bottom: 1rem;
}

.game-setting-label {
    display: block;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.game-setting-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.game-setting-header .game-setting-label {
    margin-bottom: 0;
}

.game-setting-btns {
    display: flex;
    gap: 0.25rem;
}

.game-setting-btn {
    padding: 0.2rem 0.5rem;
    font-family: inherit;
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
}

.game-setting-btn:hover {
    background: #000;
    color: #fff;
}

.game-setting-input {
    width: 100%;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.75rem;
    border: 1px solid #000;
    border-radius: 0;
}

.game-setting-select {
    width: 100%;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.75rem;
    border: 1px solid #000;
    border-radius: 0;
    background-color: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.game-setting-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.game-setting-check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    cursor: pointer;
    letter-spacing: 0.05em;
}

.game-setting-check-label:hover {
    border-color: #000;
}

.game-setting-check-label input[type="checkbox"] {
    margin: 0;
    width: 12px;
    height: 12px;
}

/* Title page */
.game-title-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 1.5rem;
}

.game-title {
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    text-align: center;
}

.game-explanation {
    font-size: 0.75rem;
    color: #444;
    max-width: 500px;
    text-align: center;
    line-height: 1.5;
}

.game-start-btn {
    padding: 1rem 3rem;
    font-family: inherit;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    border: 2px solid #000;
    background: #000;
    color: #fff;
    cursor: pointer;
}

.game-start-btn:hover {
    background: #fff;
    color: #000;
}

.game-btn-secondary {
    background: #fff;
    color: #000;
}

.game-btn-secondary:hover {
    background: #000;
    color: #fff;
}

.game-btn-row {
    display: flex;
    gap: 1rem;
}

/* Game play area */
.game-play-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 1rem;
}

.game-top-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.game-top-row .game-round-counter {
    flex: 1;
    text-align: center;
}

.game-hint-spacer {
    min-width: 3rem;
}

.game-hint-toggle .toggle-text {
    padding: 0.25rem 0.5rem;
    font-size: 0.5rem;
}

.game-round-counter {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #666;
}

.game-circle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.game-next-btn {
    padding: 0.75rem 2rem;
    font-family: inherit;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    border: 2px solid #000;
    background: #000;
    color: #fff;
    cursor: pointer;
}

.game-next-btn:hover {
    background: #fff;
    color: #000;
}

/* Score display */
.game-score {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.game-score-pct {
    font-size: 1rem;
    color: #666;
    letter-spacing: 0.1em;
}

/* Stats grid */
.stats-table {
    width: 100%;
    max-width: 600px;
    overflow-x: auto;
}

.stats-row {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.stats-root-label {
    flex: 0 0 2rem;
    text-align: right;
    font-size: 0.5rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.25rem;
    font-weight: 700;
}

.stats-cell {
    flex: 1;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.5rem;
    border: 1px solid #e0e0e0;
    min-width: 2rem;
}

.stats-cell-header {
    background: none !important;
    border: none;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.05em;
}

#game-stats-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Reaction Time Chart */
.rt-chart-container {
    width: 100%;
    max-width: 500px;
}
.rt-chart-heading {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    color: #666;
    text-align: center;
    margin-bottom: 0.25rem;
}

/* Ear Training Game */
.ear-training-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    justify-content: center;
    max-width: 500px;
    width: 100%;
}
.ear-training-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 700;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
    min-width: 3rem;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}
.ear-training-btn.selected {
    background: #000;
    color: #fff;
}
.ear-training-btn.correct {
    background: #32CD32;
    border-color: #28a428;
    color: #000;
}
.ear-training-btn.wrong {
    background: #FF4444;
    border-color: #cc0000;
    color: #fff;
}
.ear-training-section-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    color: #666;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}
.ear-training-feedback {
    font-size: 0.75rem;
    font-weight: 700;
    min-height: 1.25rem;
    text-align: center;
    margin-top: 0.75rem;
}
.ear-training-replay-btn {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    border: 2px solid #000;
    background: #000;
    color: #fff;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

/* Games responsive: back button position */
@media (max-width: 768px) {
    .games-back-btn {
        top: calc(0.75rem + env(safe-area-inset-top, 0px));
        right: calc(0.75rem + env(safe-area-inset-right, 0px));
    }

    .game-content {
        padding: calc(3rem + env(safe-area-inset-top, 0px)) calc(0.75rem + env(safe-area-inset-right, 0px)) calc(5rem + env(safe-area-inset-bottom, 0px)) calc(0.75rem + env(safe-area-inset-left, 0px));
    }

    .game-title-page {
        gap: 1rem;
        width: 100%;
    }

    #game-stats-container {
        width: 100%;
        margin-top: 0.5rem;
    }

    .game-title {
        font-size: 1.125rem;
        margin-top: 1.5rem;
    }

    .game-start-btn {
        padding: 0.75rem 2rem;
        font-size: 0.75rem;
    }

    .game-score {
        font-size: 1.5rem;
    }

    .game-score-pct {
        font-size: 0.75rem;
    }

    .game-btn-row {
        gap: 0.75rem;
    }

    .game-explanation {
        max-width: 90vw;
    }

    .stats-table {
        max-width: 100%;
    }

    .stats-cell {
        min-width: 0;
        height: 1.25rem;
        font-size: 0.4375rem;
    }

    .rt-chart-container {
        max-width: 100%;
    }

    .games-controls {
        bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
        right: calc(0.5rem + env(safe-area-inset-right, 0px));
    }

    .rt-chart-row { height: 1rem; }
    .rt-chart-label { flex: 0 0 2rem; font-size: 0.4375rem; }
    .rt-chart-time { font-size: 0.4375rem; }
    .game-btn-row { flex-wrap: wrap; justify-content: center; }
}

@media (min-width: 769px) {
    .games-back-btn {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        left: calc(1rem + env(safe-area-inset-left, 0px));
    }
}

@keyframes rainbow-stroke {
    0%   { stroke: black; }
    50%  { stroke: transparent; }
    100% { stroke: black; }
}

.rainbow-border {
    animation: rainbow-stroke 1s linear infinite;
}

@keyframes rainbow-border-color {
    0%   { border-color: black; }
    50%  { border-color: transparent; }
    100% { border-color: black; }
}

select.rainbow-select {
    border-width: 2px;
    animation: rainbow-border-color 1s linear infinite;
}

/* Fretboard Drills game styles */
.game-fretboard-question {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
}

.game-fretboard-hint {
    text-align: center;
    font-size: 0.75rem;
    font-family: monospace;
    color: #666;
    padding: 0 1rem 0.25rem;
    min-height: 1.2em;
}

.game-fretboard-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

.game-fretboard-container svg {
    max-width: 100%;
    max-height: 60vh;
}

/* ---- Fretboard Drills: split-screen layout ---- */

/* Override game-content when split layout is active */
.fretboard-drills-active .game-content {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

.game-split-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 3fr 2fr;
    gap: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

.game-split-fretboard {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
    background-color: #f5f5f5;
    border: 1px solid #000;
}

.game-split-fretboard .game-fretboard-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-split-fretboard .game-fretboard-container svg {
    max-height: 100%;
}

.game-split-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    padding-bottom: 1rem;
    min-height: 0;
    overflow-y: auto;
}

.game-rotate-toggle {
    display: none;
}

/* Mobile: tighter padding */
@media (max-width: 768px) {
    .fretboard-drills-active .game-content {
        padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 0 calc(4rem + env(safe-area-inset-bottom, 0px)) 0;
    }

    .fretboard-drills-active .games-back-btn {
        top: calc(0.25rem + env(safe-area-inset-top, 0px));
        right: calc(0.25rem + env(safe-area-inset-right, 0px));
        padding: 0.3rem 0.6rem;
        font-size: 0.5rem;
    }

    .game-split-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
    }

    .game-split-controls {
        padding: 0.5rem;
        padding-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .game-split-controls .game-fretboard-question {
        font-size: 0.85rem;
        padding: 0.25rem 0.5rem;
    }

    .game-split-controls .game-fretboard-hint {
        font-size: 0.625rem;
        padding: 0 0.5rem 0.25rem;
    }

    .game-rotate-toggle {
        display: flex;
    }

    .game-controls-inner {
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1;
        justify-content: center;
        gap: 0.25rem;
    }

    .game-controls-inner.rotated {
        transform: rotate(90deg);
        white-space: nowrap;
    }

    .game-split-fretboard {
        order: 2;
        border-bottom: none;
        border-left: 1px solid #000;
    }

    .game-split-controls {
        order: 1;
    }
}

/* ========================================
   DEV PANEL
   ======================================== */

#dev-toggle-btn {
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: calc(1rem + env(safe-area-inset-left, 0px));
    z-index: 56;
    padding: 0.35rem 0.75rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
}

#dev-toggle-btn:hover,
#dev-toggle-btn.active {
    background: #000;
    color: #fff;
}

#dev-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100%;
    z-index: 55;
    background: #fff;
    border-left: 2px solid #000;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    transition: right 0.2s ease;
}

#dev-panel.open {
    right: 0;
}

.dev-panel-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #000;
}

.dev-param-group {
    margin-bottom: 0.75rem;
}

.dev-param-label {
    display: block;
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
    color: #000;
}

.dev-param-value {
    font-family: 'Monaco', 'Consolas', monospace;
    color: #666;
}

.dev-select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    font-family: inherit;
    font-size: 0.6875rem;
    border: 1px solid #000;
    border-radius: 0;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.dev-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #ccc;
    outline: none;
    border-radius: 0;
}

.dev-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #000;
    border: none;
    cursor: pointer;
}

.dev-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #000;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

.dev-btn-row {
    display: flex;
    gap: 0.375rem;
    margin: 1rem 0;
}

.dev-btn {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-family: inherit;
    font-size: 0.5625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid #000;
    background: #fff;
    color: #000;
    cursor: pointer;
}

.dev-btn:hover {
    background: #000;
    color: #fff;
}

.dev-textarea {
    width: 100%;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.625rem;
    padding: 0.5rem;
    border: 1px solid #000;
    border-radius: 0;
    resize: none;
    background: #f5f5f5;
    color: #000;
}

@media (max-width: 768px) {
    #dev-panel {
        width: 100%;
        right: -100%;
    }
}
