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

[hidden] {
    display: none !important;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: white;
    padding: 1rem;
}

.container {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem 1.6rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 1400px;
    width: 100%;
}

h1 {
    font-size: 2.15rem;
    margin-bottom: 0.35rem;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    justify-content: center;
    align-items: flex-end;
    margin: 0 auto 0.9rem;
    max-width: 860px;
    padding: 0.7rem 0.85rem;
    background: rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
}

.controls > * {
    background: none;
    border: none;
    padding: 0;
    min-height: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
    justify-content: center;
}

.control-group > label,
.control-label {
    font-size: 0.62rem;
    font-weight: bold;
    opacity: 0.58;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    padding-left: 0.15rem;
}

.action-btn {
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s ease;
    padding: 0.72rem 1.12rem;
    min-width: 112px;
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    font-size: 0.95rem;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.action-btn.secondary {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: none;
}

.action-btn:disabled {
    cursor: default;
    opacity: 0.42;
    transform: none;
    box-shadow: none;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.mode-toggle {
    display: inline-flex;
    padding: 0.18rem;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    gap: 0.18rem;
}

.mode-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.54rem 0.92rem;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.mode-btn:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

.mode-btn.active {
    background: linear-gradient(180deg, rgba(123, 187, 239, 0.95) 0%, rgba(66, 140, 201, 0.95) 100%);
    color: #f8fbff;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
}

.settings-panel {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: max-height 0.3s ease, opacity 0.25s ease, transform 0.25s ease, margin-bottom 0.25s ease;
    margin-bottom: 0;
}

.settings-panel.open {
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 0.65rem;
}

.settings-panel-header {
    display: flex;
    justify-content: center;
    margin-bottom: 0.45rem;
}

.range-inputs {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(18, 25, 33, 0.36);
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(135, 206, 235, 0.22);
    font-size: 1.12rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.status-banner.info {
    border-color: rgba(135, 206, 235, 0.35);
}

.status-banner.success {
    border-color: rgba(46, 204, 113, 0.45);
    background: rgba(39, 174, 96, 0.18);
}

.status-banner.error {
    border-color: rgba(231, 76, 60, 0.45);
    background: rgba(192, 57, 43, 0.18);
}

.fretboard-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 1.25rem;
    margin: 0.75rem 0 1rem;
    overflow-x: auto;
}

.fretboard {
    position: relative;
    width: 100%;
    height: 280px;
    background: linear-gradient(to bottom, #f5deb3 0%, #deb887 50%, #f5deb3 100%);
    border-radius: 10px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
    margin: 0 auto;
    min-width: 1000px;
    border: 2px solid #4682b4;
    overflow: visible;
}

.strings,
.frets,
.fret-markers,
.notes {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

.notes {
    pointer-events: none;
    z-index: 2;
}

.stats-heatmap-layer {
    pointer-events: auto;
    z-index: 3;
}

.string {
    position: absolute;
    left: 0.5%;
    right: 0.5%;
    width: 99%;
    background: linear-gradient(to right, rgba(118, 126, 138, 0.9) 0%, rgba(76, 84, 94, 0.82) 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 1px 2px rgba(0, 0, 0, 0.3);
    opacity: 0.72;
    transition: opacity 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.string.active {
    opacity: 1;
    background: linear-gradient(to right, rgba(167, 176, 188, 1) 0%, rgba(112, 121, 132, 0.95) 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24), 0 0 10px rgba(255, 255, 255, 0.2);
}

.string.target-string {
    opacity: 1;
    background: linear-gradient(to right, rgba(255, 247, 188, 0.98) 0%, rgba(252, 220, 103, 0.98) 55%, rgba(214, 173, 49, 0.95) 100%);
    box-shadow: 0 0 0 1px rgba(255, 246, 191, 0.5), 0 0 16px rgba(241, 196, 15, 0.48);
}

.string:nth-child(1) { top: 15%; height: 2px; }
.string:nth-child(2) { top: 30%; height: 2px; }
.string:nth-child(3) { top: 45%; height: 3px; }
.string:nth-child(4) { top: 60%; height: 3px; }
.string:nth-child(5) { top: 75%; height: 4px; }
.string:nth-child(6) { top: 90%; height: 4px; }

.fret {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #c0c0c0 0%, #808080 50%, #c0c0c0 100%);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.3);
}

.fret-markers {
    top: 50%;
    transform: translateY(-50%);
    height: 0;
}

.fret-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    top: -9px;
    border: 2px solid #4682b4;
    box-shadow: 0 0 8px 2px rgba(70, 130, 180, 0.25);
}

.fret-marker.double {
    width: 14px;
    height: 14px;
    top: -22px;
}

.fret-numbers {
    position: relative;
    height: 30px;
    margin-top: 10px;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    width: 100%;
    min-width: 1000px;
}

.fret-number {
    position: absolute;
    transform: translateX(-50%);
    font-weight: bold;
}

.answers-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 1rem 1.1rem;
}

.answer-surface {
    display: grid;
    gap: 0.75rem;
}

.stats-view-panel {
    display: grid;
    gap: 0.8rem;
}

.info-popover-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.info-trigger {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.72);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 900;
    line-height: 1;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.info-trigger:hover,
.info-trigger:focus-visible {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transform: translateY(-1px);
    outline: none;
}

.info-trigger[aria-expanded="true"] {
    background: rgba(123, 187, 239, 0.22);
    border-color: rgba(123, 187, 239, 0.44);
    color: #ffffff;
}

.info-popover-overlay {
    position: fixed;
    z-index: 1000;
    max-width: min(320px, calc(100vw - 1rem));
    padding: 0.5rem 0.58rem;
    border-radius: 8px;
    background: rgba(24, 33, 44, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    color: rgba(255, 255, 255, 0.84);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.35;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    text-transform: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
    transform: translateY(4px);
}

.info-popover-overlay[data-state="measuring"] {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: none;
}

.info-popover-overlay[data-state="open"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

@media (max-width: 1024px) {
    .controls > * {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0.55rem;
    }

    .container {
        padding: 1rem;
        border-radius: 16px;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 0.55rem;
    }

    .controls {
        gap: 0.8rem;
        margin-bottom: 0.85rem;
        padding: 0.6rem 0.7rem;
    }

    .controls > * {
        width: 100%;
        min-height: auto;
    }

    .settings-panel.open {
        margin-bottom: 0.75rem;
    }

    .fretboard-container,
    .answers-panel {
        padding: 0.85rem;
    }

    .status-banner {
        padding: 0.58rem 0.75rem;
        margin-bottom: 0.55rem;
        font-size: 0.98rem;
        border-radius: 12px;
    }

    .fretboard-container {
        margin: 0.55rem 0 0.7rem;
    }

    .fretboard {
        height: 220px;
        min-width: 900px;
    }

    .fret-numbers {
        height: 24px;
        margin-top: 8px;
        font-size: 15px;
        min-width: 900px;
    }
}

@media (max-width: 520px) {
    body {
        padding: 0.4rem;
    }

    .container {
        padding: 0.8rem;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.55rem;
    }

    .controls {
        margin-bottom: 0.7rem;
    }

    .status-banner {
        font-size: 0.9rem;
        padding: 0.5rem 0.65rem;
    }

    .fretboard-container,
    .answers-panel {
        padding: 0.62rem;
    }

    .fretboard-container {
        margin: 0.5rem 0 0.6rem;
    }

    .fretboard {
        height: 190px;
        min-width: 820px;
    }

    .fret-numbers {
        min-width: 820px;
        font-size: 13px;
        height: 22px;
        margin-top: 6px;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    body {
        padding: 0.25rem;
    }

    .container {
        padding: 0.6rem;
        border-radius: 12px;
    }

    .controls {
        margin-bottom: 0.6rem;
        padding: 0.45rem 0.5rem;
    }

    .settings-panel.open {
        margin-bottom: 0.75rem;
    }

    .status-banner {
        margin-bottom: 0.45rem;
    }

    .mode-btn {
        padding: 0.48rem 0.55rem;
        font-size: 0.78rem;
    }

    .fretboard-container,
    .answers-panel {
        padding: 0.5rem;
    }

    .fretboard-container {
        margin: 0.4rem 0 0.5rem;
    }

    .answers-panel {
        border-radius: 12px;
    }

    .stats-view-panel {
        gap: 0.55rem;
    }
}

@media (max-height: 540px) and (orientation: landscape) {
    body {
        padding: 0.25rem;
    }

    .container {
        padding: 0.4rem 0.5rem;
        border-radius: 10px;
    }

    h1 {
        font-size: 1.25rem;
        margin-bottom: 0.35rem;
    }

    .controls {
        display: flex;
        align-items: stretch;
        justify-content: center;
        gap: 0.45rem;
        padding: 0.4rem;
        margin-bottom: 0.4rem;
    }

    .control-group {
        gap: 0.28rem;
    }

    .control-label {
        font-size: 0.55rem;
        margin-bottom: 0;
    }

    .range-inputs {
        gap: 0.35rem;
    }

    .action-btn,
    .mode-btn {
        min-width: 88px;
        min-height: 34px;
        padding: 0.38rem 0.58rem;
        font-size: 0.74rem;
        border-radius: 8px;
    }

    .mode-toggle {
        min-width: 230px;
    }

    .status-banner {
        padding: 0.34rem 0.55rem;
        margin-bottom: 0.35rem;
        font-size: 0.78rem;
        border-radius: 9px;
    }

    .fretboard-container {
        padding: 0.38rem 0.42rem 0.28rem;
        margin: 0.25rem 0 0.35rem;
        border-radius: 10px;
    }

    .fretboard {
        height: 148px;
        min-width: 780px;
    }

    .fret-numbers {
        height: 18px;
        margin-top: 4px;
        font-size: 12px;
        min-width: 780px;
    }

    .fret-marker {
        width: 11px;
        height: 11px;
    }

    .answers-panel {
        padding: 0.34rem 0.42rem;
        border-radius: 10px;
    }
}
