/* Import Google Fonts for pixel style */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* --- BASE STYLES (Applies to ALL screen sizes, including smallest mobile) --- */
body {
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #34495e;
    color: #ecf0f1;
    margin: 0;
    padding: 5px; /* Very small padding for tight screens */
    box-sizing: border-box;
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

.container {
    background-color: #2c3e50;
    border: 2px solid #1a252f; /* Even thinner border */
    border-radius: 0;
    box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.4); /* Smaller shadow */
    padding: 10px; /* Reduced padding */
    text-align: center;
    width: 100%; /* Take full width available */
    max-width: 320px; /* Constrain max-width for very small phones like iPhone SE/5 */
    box-sizing: content-box;
}

.pixel-text {
    font-family: 'Press Start 2P', cursive;
    text-shadow: 1px 1px 0 #000; /* Smaller text shadow */
    word-wrap: break-word; /* Allow long words to break for narrow screens */
}

.title {
    color: #ffeb3b;
    font-size: 1.1em; /* Even smaller title for very small mobile */
    margin-bottom: 8px;
    line-height: 1.2; /* Adjust line height for better spacing */
}

.subtitle {
    font-size: 0.6em; /* Even smaller subtitle */
    margin-bottom: 15px;
}

/* Pixel Button Style */
.pixel-button {
    background-color: #27ae60;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 0;
    font-size: 0.8em; /* Smaller font size */
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    text-shadow: 1px 1px 0 #1e8449;
    box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.6); /* Smaller shadow */
    transition: all 0.05s ease-out;
    margin-top: 10px; /* Reduced margin */
}

.pixel-button:hover {
    background-color: #229954;
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.6);
    transform: translate(1px, 1px);
}

.pixel-button:active {
    background-color: #1b6c3e;
    box-shadow: none;
    transform: translate(2px, 2px);
}

.pixel-button:disabled {
    background-color: #666;
    color: #aaa;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
}

.small-button {
    padding: 6px 10px;
    font-size: 0.6em;
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.6);
}

.small-button:hover {
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.6);
    transform: translate(1px, 1px);
}

.small-button:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

.icon-button {
    padding: 4px 7px;
    font-size: 0.9em;
}
.icon-button i {
    text-shadow: none;
}

.button-group .pixel-button {
    margin-top: 0;
}

.screen {
    display: none;
    position: relative;
    padding-bottom: 15px;
    padding-top: 25px;
}

.screen.active {
    display: block;
}

.top-left {
    position: absolute;
    top: 5px;
    left: 5px;
    margin-top: 0;
    z-index: 20;
}

/* --- Game Screen Specifics --- */
.score-display {
    font-size: 0.9em;
    margin-bottom: 10px;
    color: #f1c40f;
    text-shadow: 1px 1px 0 #b38a0b;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.score-display #time {
    display: block;
    margin-top: 0px;
    white-space: nowrap;
}

.score-display .time-suffix {
    display: none;
}


.time-display.hidden {
    display: none;
}

#fretboard-container {
    background-color: #8B4513;
    border: 2px solid #5a2e0a;
    border-radius: 0;
    position: relative;
    margin: 0 auto 15px auto;
    height: 150px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 0;
    overflow: hidden;
    box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.5);
}

/* Fret bars */
.fret-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #7f8c8d;
    z-index: 2;
    box-shadow: 0.5px 0px 0px rgba(0,0,0,0.2);
}

/* Position each fret bar (relative positioning remains same) */
.fret-bar-1 { left: calc((100% / 12) * 1); }
.fret-bar-2 { left: calc((100% / 12) * 2); }
.fret-bar-3 { left: calc((100% / 12) * 3); }
.fret-bar-4 { left: calc((100% / 12) * 4); }
.fret-bar-5 { left: calc((100% / 12) * 5); }
.fret-bar-6 { left: calc((100% / 12) * 6); }
.fret-bar-7 { left: calc((100% / 12) * 7); }
.fret-bar-8 { left: calc((100% / 12) * 8); }
.fret-bar-9 { left: calc((100% / 12) * 9); }
.fret-bar-10 { left: calc((100% / 12) * 10); }
.fret-bar-11 { left: calc((100% / 12) * 11); }
.fret-bar-12 { left: calc((100% / 12) * 12); }


/* String lines - now separate elements, positioned over the grid and fret bars */
.string-line {
    position: absolute;
    left: 0;
    right: 0; /* Extends across the whole fretboard */
    background-color: #bdc3c7; /* String color */
    z-index: 3; /* On top of fret bars */
    box-shadow: 0 0.25px 0.25px rgba(0,0,0,0.2);
}

/*
   String order is mirrored:
   string-line-0 (Low E) is at gridRow 6 -> GRID_ROW_INDEX_FROM_TOP 5
   string-line-5 (High E) is at gridRow 1 -> GRID_ROW_INDEX_FROM_TOP 0

   Formula: top: calc((100% / 6) * GRID_ROW_INDEX_FROM_TOP + (100% / 6) / 2 - (HEIGHT / 2))
*/
/* High E String (Top-most string in standard tuning) - stringIndex 5 -> GRID_ROW_INDEX_FROM_TOP 0 */
.string-line-5 { top: calc((100% / 6) * 0 + (100% / 6) / 2 - 0.35px); height: 0.7px; } /* Thinnest */
/* B String - stringIndex 4 -> GRID_ROW_INDEX_FROM_TOP 1 */
.string-line-4 { top: calc((100% / 6) * 1 + (100% / 6) / 2 - 0.5px); height: 1.0px; }
/* G String - stringIndex 3 -> GRID_ROW_INDEX_FROM_TOP 2 */
.string-line-3 { top: calc((100% / 6) * 2 + (100% / 6) / 2 - 0.65px); height: 1.3px; }
/* D String - stringIndex 2 -> GRID_ROW_INDEX_FROM_TOP 3 */
.string-line-2 { top: calc((100% / 6) * 3 + (100% / 6) / 2 - 0.8px); height: 1.6px; }
/* A String - stringIndex 1 -> GRID_ROW_INDEX_FROM_TOP 4 */
.string-line-1 { top: calc((100% / 6) * 4 + (100% / 6) / 2 - 0.95px); height: 1.9px; }
/* Low E String (Bottom-most string in standard tuning) - stringIndex 0 -> GRID_ROW_INDEX_FROM_TOP 5 */
.string-line-0 { top: calc((100% / 6) * 5 + (100% / 6) / 2 - 1.15px); height: 2.3px; } /* Thickest */


/* Fret Markers (dots) */
.fretboard-marker {
    position: absolute;
    background-color: #FFD700;
    border: 1px solid #b89300;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    box-shadow: 0.5px 0.5px 0px 0px rgba(0, 0, 0, 0.2);
}

/* Position for markers (using previous corrected values) */
.fretboard-marker-3 { left: calc((100% / 12) * 2 + ((100% / 12) / 2)); }
.fretboard-marker-5 { left: calc((100% / 12) * 4 + ((100% / 12) / 2)); }
.fretboard-marker-7 { left: calc((100% / 12) * 6 + ((100% / 12) / 2)); }
.fretboard-marker-9 { left: calc((100% / 12) * 8 + ((100% / 12) / 2)); }

.fretboard-marker-12-top,
.fretboard-marker-12-bottom {
    position: absolute;
    background-color: #FFD700;
    border: 1px solid #b89300;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    z-index: 4;
    left: calc((100% / 12) * 11 + ((100% / 12) / 2));
    transform: translateX(-50%);
    box-shadow: 0.5px 0.5px 0px 0px rgba(0, 0, 0, 0.2);
}
.fretboard-marker-12-top { top: 30%; }
.fretboard-marker-12-bottom { top: 70%; }


/* Note dots (clickable areas) */
.fret-cell {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background-color: rgba(0,0,0,0);
    z-index: 5;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

/* Style for disabled (greyed-out) fret cells */
.fret-cell.disabled-fret {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
    background-color: rgba(0, 0, 0, 0.1);
}


.note-dot {
    width: 20px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.6em;
    font-weight: bold;
    color: transparent;
    transition: background-color 0.05s ease, color 0.05s ease, border-color 0.05s ease;
    z-index: 10;
    box-shadow: 0.5px 0.5px 0px 0px rgba(0, 0, 0, 0.3);
}

.note-dot:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(0,0,0,0.8);
}

.note-dot.active {
    background-color: #3498db;
    color: #ecf0f1;
    border-color: #2980b9;
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.4);
    transform: translate(-1px, -1px);
}

.note-dot.correct-guess {
    background-color: #2ecc71;
    color: #fff;
    border-color: #27ae60;
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.4);
    transform: translate(-1px, -1px);
}

.note-dot.incorrect-guess {
    background-color: #e74c3c;
    color: #fff;
    border-color: #c0392b;
    box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.4);
    transform: translate(-1px, -1px);
}

.challenge-area {
    margin: 10px 0;
    font-size: 0.9em;
    color: #ffeb3b;
    text-shadow: 1px 1px 0 #b38a0b;
}

#target-note {
    color: #ffeb3b;
}

.feedback-message {
    margin-top: 5px;
    font-size: 0.7em;
    font-weight: bold;
    min-height: 15px;
    text-shadow: 1px 1px 0 #000;
}

/* --- Settings Screen Styles --- */
.settings-options {
    margin-top: 20px;
    margin-bottom: 20px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-label {
    font-size: 0.9em;
    color: #ecf0f1;
    margin-bottom: 8px;
    display: block;
}

.radio-label, .checkbox-label {
    display: block;
    margin: 8px 0;
    cursor: pointer;
    font-size: 0.8em;
    text-align: left;
    padding-left: 10px;
}

/* Style for the actual radio/checkbox input (hide default, make custom) */
.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #bdc3c7;
    border-radius: 0;
    background-color: #2c3e50;
    vertical-align: middle;
    margin-right: 5px;
    box-shadow: 0.5px 0.5px 0px 0px rgba(0,0,0,0.5);
    transition: background-color 0.1s ease, border-color 0.1s ease;
    flex-shrink: 0;
}

.radio-label input[type="radio"]:checked,
.checkbox-label input[type="checkbox"]:checked {
    background-color: #27ae60;
    border-color: #1b6c3e;
}

.radio-label input[type="radio"]:hover,
.checkbox-label input[type="checkbox"]:hover {
    border-color: #fff;
}


/* --- MEDIA QUERIES FOR SLIGHTLY LARGER MOBILE SCREENS (e.g., iPhone 6/7/8 Plus, landscape phones) --- */
@media (min-width: 375px) {
    .container {
        max-width: 360px;
        padding: 15px;
        border: 3px solid #1a252f;
        box-shadow: 6px 6px 0px 0px rgba(0, 0, 0, 0.4);
    }
    body {
        padding: 10px;
    }
    .title {
        font-size: 1.3em;
    }
    .subtitle {
        font-size: 0.8em;
    }
    .pixel-button {
        padding: 10px 20px;
        font-size: 0.9em;
        box-shadow: 3px 3px 0px 0px rgba(0, 0, 0, 0.6);
    }
    .small-button {
        padding: 8px 12px;
        font-size: 0.7em;
        box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.6);
    }
    .icon-button {
        padding: 5px 8px;
        font-size: 1em;
    }
    .button-group {
        gap: 10px;
    }
    .screen {
        padding-bottom: 20px;
        padding-top: 30px;
    }
    .score-display {
        font-size: 1.1em;
        flex-direction: row;
        gap: 20px;
    }
    .score-display #time {
        display: inline;
        margin-top: 0;
    }
    .score-display .time-suffix {
        display: inline;
    }
    #fretboard-container {
        height: 165px;
        border: 3px solid #5a2e0a;
        box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.5);
    }
    .fret-bar {
        width: 2px;
    }
    /* Adjusted string thicknesses for this breakpoint (tighter spacing) */
    /* High E String (Top-most) - stringIndex 5 -> GRID_ROW_INDEX_FROM_TOP 0 */
    .string-line-5 { top: calc((100% / 6) * 0 + (100% / 6) / 2 - 0.45px); height: 1.0px; }
    /* B String - stringIndex 4 -> GRID_ROW_INDEX_FROM_TOP 1 */
    .string-line-4 { top: calc((100% / 6) * 1 + (100% / 6) / 2 - 0.6px); height: 1.3px; }
    /* G String - stringIndex 3 -> GRID_ROW_INDEX_FROM_TOP 2 */
    .string-line-3 { top: calc((100% / 6) * 2 + (100% / 6) / 2 - 0.75px); height: 1.6px; }
    /* D String - stringIndex 2 -> GRID_ROW_INDEX_FROM_TOP 3 */
    .string-line-2 { top: calc((100% / 6) * 3 + (100% / 6) / 2 - 0.9px); height: 1.9px; }
    /* A String - stringIndex 1 -> GRID_ROW_INDEX_FROM_TOP 4 */
    .string-line-1 { top: calc((100% / 6) * 4 + (100% / 6) / 2 - 1.05px); height: 2.2px; }
    /* Low E String (Bottom-most) - stringIndex 0 -> GRID_ROW_INDEX_FROM_TOP 5 */
    .string-line-0 { top: calc((100% / 6) * 5 + (100% / 6) / 2 - 1.25px); height: 2.6px; }


    .fretboard-marker {
        width: 15px;
        height: 15px;
        border: 1px solid #b89300;
        box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.2);
    }
    .fretboard-marker-12-top, .fretboard-marker-12-bottom {
        width: 15px;
        height: 15px;
        border: 1px solid #b89300;
        box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.2);
    }
    .note-dot {
        width: 25px;
        height: 25px;
        border: 1px solid rgba(0,0,0,0.5);
        font-size: 0.7em;
        box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.3);
    }
    .challenge-area {
        font-size: 1.1em;
        margin: 15px 0;
    }
    .feedback-message {
        font-size: 0.9em;
        margin-top: 10px;
    }
    .settings-options {
        margin-top: 30px;
        margin-bottom: 30px;
    }
    .setting-group {
        margin-bottom: 20px;
    }
    .setting-label {
        font-size: 1.1em;
    }
    .radio-label, .checkbox-label {
        display: inline-block;
        margin: 0 15px;
        font-size: 0.9em;
        text-align: center;
        padding-left: 0;
    }
    .radio-label input[type="radio"],
    .checkbox-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        border: 2px solid #bdc3c7;
    }
}


/* --- DESKTOP/LARGER TABLET STYLES (Overrides for screens wider than 769px) --- */
@media (min-width: 769px) {
    .container {
        max-width: 900px;
        padding: 30px;
        border: 4px solid #1a252f;
        box-shadow: 8px 8px 0px 0px rgba(0, 0, 0, 0.4);
    }
    body {
        padding: 20px;
    }
    .pixel-text {
        text-shadow: 2px 2px 0 #000;
    }
    .title {
        font-size: 2.5em;
        margin-bottom: 20px;
    }
    .subtitle {
        font-size: 1.2em;
        margin-bottom: 40px;
    }
    .pixel-button {
        padding: 15px 30px;
        font-size: 1.3em;
        text-shadow: 2px 2px 0 #1e8449;
        box-shadow: 4px 4px 0px 0px rgba(0, 0, 0, 0.6);
        margin-top: 20px;
    }
    .small-button {
        padding: 12px 18px;
        font-size: 0.9em;
        box-shadow: 3px 3px 0px 0px rgba(0, 0, 0, 0.6);
    }
    .icon-button {
        padding: 6px 9px;
        font-size: 1.1em;
    }
    .button-group {
        gap: 15px;
        margin-top: 40px;
    }
    .screen {
        padding-bottom: 30px;
        padding-top: 40px;
    }
    .top-left {
        top: 10px;
        left: 10px;
    }
    .score-display {
        font-size: 1.4em;
        margin-bottom: 25px;
        text-shadow: 2px 2px 0 #b38a0b;
        display: flex;
        flex-direction: row;
        gap: 30px;
    }
    .score-display #time {
        display: inline;
        margin-top: 0;
    }
    .score-display .time-suffix {
        display: inline;
    }
    #fretboard-container {
        border: 4px solid #5a2e0a;
        margin: 0 auto 30px auto;
        height: 250px;
        box-shadow: 6px 6px 0px 0px rgba(0, 0, 0, 0.5);
    }
    .fret-bar {
        width: 3px;
    }
    /* Adjusted string thicknesses for desktop */
    /* High E String (Top-most) - stringIndex 5 -> GRID_ROW_INDEX_FROM_TOP 0 */
    .string-line-5 { top: calc((100% / 6) * 0 + (100% / 6) / 2 - 0.5px); height: 1.0px; }
    /* B String - stringIndex 4 -> GRID_ROW_INDEX_FROM_TOP 1 */
    .string-line-4 { top: calc((100% / 6) * 1 + (100% / 6) / 2 - 0.7px); height: 1.4px; }
    /* G String - stringIndex 3 -> GRID_ROW_INDEX_FROM_TOP 2 */
    .string-line-3 { top: calc((100% / 6) * 2 + (100% / 6) / 2 - 0.85px); height: 1.7px; }
    /* D String - stringIndex 2 -> GRID_ROW_INDEX_FROM_TOP 3 */
    .string-line-2 { top: calc((100% / 6) * 3 + (100% / 6) / 2 - 1.05px); height: 2.1px; }
    /* A String - stringIndex 1 -> GRID_ROW_INDEX_FROM_TOP 4 */
    .string-line-1 { top: calc((100% / 6) * 4 + (100% / 6) / 2 - 1.25px); height: 2.5px; }
    /* Low E String (Bottom-most) - stringIndex 0 -> GRID_ROW_INDEX_FROM_TOP 5 */
    .string-line-0 { top: calc((100% / 6) * 5 + (100% / 6) / 2 - 1.5px); height: 3.0px; }


    .fretboard-marker {
        border: 2px solid #b89300;
        width: 18px;
        height: 18px;
        box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.3);
    }
    .fretboard-marker-12-top, .fretboard-marker-12-bottom {
        border: 2px solid #b89300;
        width: 18px;
        height: 18px;
        box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.3);
    }
    .note-dot {
        width: 28px;
        height: 28px;
        border: 2px solid rgba(0,0,0,0.5);
        font-size: 0.8em;
        box-shadow: 1px 1px 0px 0px rgba(0, 0, 0, 0.4);
    }
    .challenge-area {
        margin: 30px 0;
        font-size: 1.6em;
        text-shadow: 2px 2px 0 #b38a0b;
    }
    .feedback-message {
        margin-top: 15px;
        font-size: 1.2em;
        min-height: 25px;
        text-shadow: 2px 2px 0 #000;
    }
    .settings-options {
        margin-top: 40px;
        margin-bottom: 40px;
    }
    .setting-group {
        margin-bottom: 30px;
    }
    .setting-label {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    .radio-label, .checkbox-label {
        display: inline-block;
        margin: 0 15px;
        font-size: 1em;
        text-align: center;
        padding-left: 0;
    }
    .radio-label input[type="radio"],
    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
        border: 2px solid #bdc3c7;
    }
}
