/* ========================================================================
   Fretboard Game — Styles
   ======================================================================== */

/* --- Layout Shell --- */

.fretboard-game-page {
    padding-top: 5rem;
    min-height: 100vh;
}

.fretboard-game-wrapper {
    width: min(100%, 1440px);
    margin-inline: auto;
    padding: 2rem 1.5rem 4rem;
}

.fretboard-game-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.fretboard-game-header h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.1;
    margin: 0 0 0.5rem;
}

.fretboard-game-header p {
    color: var(--text-muted);
    margin: 0;
    max-width: 36rem;
    margin-inline: auto;
}

/* --- Controls Bar --- */

.game-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.control-group select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.04);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.control-group select:hover,
.control-group select:focus-visible {
    border-color: var(--accent-gold);
    outline: none;
}

.control-group select option {
    background: #12131a;
    color: var(--text-main);
}

/* --- Score Panel --- */

.game-score-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 7rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    transition: border-color 0.3s ease, background 0.3s ease;
}

.score-card.highlight-correct {
    border-color: rgba(76, 175, 80, 0.5);
    background: rgba(76, 175, 80, 0.06);
}

.score-card.highlight-wrong {
    border-color: rgba(244, 67, 54, 0.5);
    background: rgba(244, 67, 54, 0.06);
}

.score-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    line-height: 1;
    color: #fff;
}

.score-value.accent {
    color: var(--accent-gold);
}

.score-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* --- Game Prompt --- */

.game-prompt {
    text-align: center;
    margin-bottom: 2rem;
    min-height: 4rem;
}

.prompt-instruction {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.4rem;
}

.prompt-note {
    font-family: var(--font-heading);
    font-size: clamp(2.5rem, 5vw, 4rem);
    line-height: 1;
    color: var(--accent-gold);
    margin: 0;
    animation: noteAppear 0.3s ease-out;
}

.prompt-note.card-game-title {
    font-size: clamp(1.45rem, 3vw, 2.5rem);
    line-height: 1.12;
    max-width: 46rem;
    margin-inline: auto;
}

@keyframes noteAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.prompt-detail {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.3rem 0 0;
}

/* --- Fretboard --- */

.fretboard-container {
    overflow-x: auto;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    -webkit-overflow-scrolling: touch;
}

.fretboard {
    display: grid;
    gap: 0;
    min-width: 900px;
    user-select: none;
    position: relative;
}

/* Fret number header row */
.fret-numbers {
    display: contents;
}

.fret-number {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.fret-number.open-label {
    color: var(--accent-gold);
    font-weight: 800;
}

/* String label column */
.string-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding-right: 0.5rem;
}

/* Individual fret cells */
.fret-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.8rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

/* String line through each fret */
.fret-cell::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-50%);
    pointer-events: none;
}

/* Bass strings are thicker */
.fret-cell[data-string="0"]::before,
.fret-cell[data-string="1"]::before {
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
}

/* Fret wire (right border except on open string) */
.fret-cell:not(.open-string)::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.10);
    pointer-events: none;
}

/* Open string gets a nut (left border) */
.fret-cell.open-string::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: rgba(255, 255, 255, 0.28);
    pointer-events: none;
}

/* Fretboard surface */
.fret-cell:not(.open-string) {
    background:
        linear-gradient(180deg, rgba(60, 40, 18, 0.20), rgba(40, 26, 10, 0.25));
}

.fret-cell.open-string {
    background: rgba(255, 255, 255, 0.015);
}

/* Hover */
.fret-cell:hover {
    background: rgba(201, 168, 76, 0.10);
}

/* Fret dot indicators */
.fret-cell .fret-dot {
    position: absolute;
    bottom: -0.7rem;
    left: 50%;
    transform: translateX(-50%);
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.30);
    pointer-events: none;
    z-index: 1;
}

/* Note bubble inside a fret cell */
.note-bubble {
    position: relative;
    z-index: 2;
    min-width: 2rem;
    max-width: calc(100% - 0.3rem);
    height: 2rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 2px solid transparent;
    color: transparent;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

/* Highlight state — the note the user should find */
.fret-cell.highlighted .note-bubble {
    background: var(--accent-gold);
    color: #070709;
    border-color: var(--accent-gold);
    transform: scale(1.15);
    animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(201, 168, 76, 0); }
}

/* Correct feedback */
.fret-cell.correct .note-bubble {
    background: #4caf50;
    color: #fff;
    border-color: #4caf50;
    transform: scale(1.15);
    animation: popCorrect 0.35s ease-out;
}

@keyframes popCorrect {
    0%   { transform: scale(0.6); opacity: 0.6; }
    60%  { transform: scale(1.25); }
    100% { transform: scale(1.15); opacity: 1; }
}

/* Wrong feedback */
.fret-cell.wrong .note-bubble {
    background: #f44336;
    color: #fff;
    border-color: #f44336;
    animation: shake 0.4s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(3px); }
}

/* Revealed answer */
.fret-cell.revealed .note-bubble {
    background: rgba(201, 168, 76, 0.15);
    color: var(--accent-gold);
    border-color: rgba(201, 168, 76, 0.5);
    border-style: dashed;
}

/* Show note labels */
.fretboard.show-notes .fret-cell:not(.highlighted):not(.correct):not(.wrong):not(.revealed) .note-bubble {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.10);
}

.fretboard:not(.show-notes) .fret-cell.highlighted:not(.correct):not(.revealed) .note-bubble {
    color: transparent;
}

/* --- Note Answer Buttons (Identify mode) --- */

.note-answer-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.note-answer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.8rem;
    padding: 0.65rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.note-answer-btn:hover {
    border-color: var(--accent-gold);
    background: rgba(201, 168, 76, 0.08);
    color: var(--accent-gold);
}

.note-answer-btn.correct {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    animation: popCorrect 0.35s ease-out;
}

.note-answer-btn.wrong {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    animation: shake 0.4s ease-out;
}

.note-answer-btn:disabled {
    cursor: default;
    opacity: 0.5;
}

/* --- Game Action Buttons --- */

.game-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.game-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-btn:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
}

.game-btn.primary {
    border-color: var(--accent-gold);
    background: rgba(201, 168, 76, 0.10);
    color: var(--accent-gold);
}

.game-btn.primary:hover {
    background: rgba(201, 168, 76, 0.18);
}

/* --- Timer Bar --- */

.timer-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.timer-bar-container.active {
    opacity: 1;
}

.timer-bar {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 2px;
    transition: width 0.1s linear, background 0.3s ease;
    width: 100%;
}

.timer-bar.warning {
    background: #ff9800;
}

.timer-bar.danger {
    background: #f44336;
}

/* --- Feedback Toast --- */

.feedback-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(2rem);
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.feedback-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.feedback-toast.correct {
    background: rgba(76, 175, 80, 0.9);
    color: #fff;
}

.feedback-toast.wrong {
    background: rgba(244, 67, 54, 0.9);
    color: #fff;
}

.feedback-toast.info {
    background: rgba(201, 168, 76, 0.9);
    color: #070709;
}

/* --- Start Screen Overlay --- */

.game-start-screen {
    text-align: center;
    padding: 4rem 1.5rem;
}

.game-start-screen h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    margin: 0 0 1rem;
}

.game-start-screen p {
    color: var(--text-muted);
    margin: 0 0 2rem;
    max-width: 30rem;
    margin-inline: auto;
}

.start-mode-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.2rem;
    max-width: 44rem;
    margin: 0 auto 2.5rem;
}

.mode-card {
    flex: 1 1 18rem;
    max-width: 20rem;
    padding: 1.75rem 1.5rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)),
        rgba(10, 12, 16, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s ease;
}

.mode-card:hover {
    transform: translateY(-3px);
    border-color: rgba(201, 168, 76, 0.36);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.mode-card.selected {
    border-color: var(--accent-gold);
    background: rgba(201, 168, 76, 0.06);
    box-shadow: 0 0 0 1px var(--accent-gold);
}

.mode-card-icon {
    font-size: 2.4rem;
    margin-bottom: 0.75rem;
    line-height: 1;
}

.mode-card h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin: 0 0 0.4rem;
}

.mode-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

/* --- Fretboard Game Library --- */

.fretboard-game-library {
    margin: 3rem auto 0;
    max-width: 72rem;
    text-align: left;
}

.fretboard-game-library-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.fretboard-game-library-header h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    margin: 0.5rem 0 0;
}

.fretboard-game-library-group {
    margin-top: 2rem;
}

.library-group-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.library-group-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.library-group-heading span {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.fretboard-game-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 1rem;
}

.fretboard-game-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.25rem;
    min-height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.012)),
        rgba(10, 12, 16, 0.74);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

.fretboard-game-card-top {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.game-level {
    width: max-content;
    padding: 0.22rem 0.5rem;
    border: 1px solid rgba(201, 168, 76, 0.28);
    border-radius: 999px;
    color: var(--accent-gold);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.fretboard-game-card h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    line-height: 1.25;
    margin: 0;
}

.game-card-subtitle {
    margin: -0.2rem 0 0;
    color: var(--accent-gold);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.game-goal,
.game-reinforces {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.5;
}

.game-goal strong,
.game-reinforces strong {
    color: var(--text-main);
}

.game-how-to span {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-main);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.game-how-to ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.game-how-to li + li {
    margin-top: 0.25rem;
}

.game-card-play {
    justify-content: center;
    width: 100%;
    margin-top: auto;
}

/* --- Results Screen --- */

.game-results {
    text-align: center;
    padding: 3rem 1.5rem;
}

.game-results h2 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 3rem);
    margin: 0 0 0.5rem;
}

.results-subtitle {
    color: var(--text-muted);
    margin: 0 0 2rem;
    font-size: 1.1rem;
}

.results-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.result-stat {
    min-width: 8rem;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 4px;
}

.result-stat .score-value {
    font-size: 2.4rem;
}

/* --- Toggle Notes Checkbox --- */

.toggle-notes-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.toggle-notes-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.toggle-notes-label input[type="checkbox"]:checked {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
}

.toggle-notes-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #070709;
    font-size: 0.65rem;
    font-weight: 900;
}

/* --- Fret dot positions (shown only on bottom string row) --- */

.fret-dots-row {
    display: contents;
}

.fret-dot-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 1.4rem;
}

.fret-dot-marker {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.28);
}

.fret-dot-marker.double {
    width: 0.9rem;
    display: flex;
    gap: 0.35rem;
    background: none;
}

.fret-dot-marker.double::before,
.fret-dot-marker.double::after {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: rgba(201, 168, 76, 0.28);
}

/* --- Responsive --- */

@media (max-width: 760px) {
    .fretboard-game-wrapper {
        padding: 1.5rem 1rem 3rem;
    }

    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        justify-content: space-between;
    }

    .control-group select {
        flex: 1;
    }

    .game-score-panel {
        gap: 0.6rem;
    }

    .score-card {
        min-width: 5.5rem;
        padding: 0.75rem 1rem;
    }

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

    .note-answer-btn {
        min-width: 3rem;
        padding: 0.55rem 0.75rem;
        font-size: 0.9rem;
    }
}
