@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    /* Soft Retro "Paper & Ink" Palette */
    --bg-color: #f4f1ea;
    /* Warm, soft paper white */
    --bg-secondary: #ffffff;
    /* Pure white for "raised" elements */
    --text-primary: #2c2c2c;
    /* Soft Charcoal/Ink (not harsh black) */
    --text-secondary: #6e6e6e;
    /* Medium Grey pen */
    --staff-line: #2c2c2c;
    /* Charcoal staff */

    --accent-color: #3b82f6;
    /* Keeps the blue but it will pop nicely on paper */
    --correct: #4ade80;
    /* Softer, pastel green */
    --wrong-position: #facc15;
    /* Golden yellow */
    --incorrect: #e5e5e5;
    /* Light Grey */

    --border-color: #2c2c2c;
    /* Charcoal borders */
    --shadow: 4px 4px 0px #2c2c2c;
    /* Shadow matches ink color */

    --font-display: 'Press Start 2P', system-ui, cursive;
    --font-main: 'VT323', monospace;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1.5rem 1rem;
    image-rendering: pixelated;
    /* Crisp edges */
}

.app-container {
    width: fit-content;
    min-width: 900px;
    /* Widened to fit longer melodies without squishing */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 4px solid var(--text-primary);
    /* Thick retro border */
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo-area h1 {
    font-family: var(--font-display);
    font-size: 3.5rem;
    /* MUCH BIGGER */
    line-height: 1.1;
    font-weight: 400;
    letter-spacing: 0.1em;
    /* Even out spacing between letters */

    /* TO CHANGE TITLE COLOR: Change the color value below */
    color: #ffffff;
    /* white text */

    /* TO CHANGE OUTLINE COLOR: Change all 4 text-shadow values below to your desired color */
    text-shadow:
        -4px -4px 0 #000000,
        /* black outline */
        4px -4px 0 #000000,
        -4px 4px 0 #000000,
        4px 4px 0 #000000;

    margin: 0;
    transform: rotate(-2deg);
    /* Jaunty angle */
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.6rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border: 2px solid var(--border-color);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
    transform: rotate(1deg);
    /* Slight counter rotation */
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    /* No rounded corners */
    padding: 0.75rem 1.5rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    /* Retro shadow */
    transition: transform 0.1s;
}

.icon-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 5px 5px 0px #000;
}

.icon-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px #000;
}

/* Main */
main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Section Labels */
.section-label {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* History Section */
.history-section {
    background: var(--bg-secondary);
    border: 4px solid var(--border-color);
    /* Blocky border */
    border-radius: 0;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: none;
    /* Hidden by default, shown by JS */
    order: 2;
    /* Position below current guess on desktop too */
}

/* Reorder main sections so Current Guess comes first */
.current-section {
    order: 1;
}

.feedback-message {
    order: 3;
}

.legend {
    order: 4;
}

.score-display {
    order: 5;
}

/* --- COLLAPSIBLE HISTORY SECTION (Desktop) --- */
.history-section .section-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.collapse-toggle {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.collapse-toggle:hover {
    color: var(--text-primary);
}

/* Arrow flips when collapsed */
.history-section.collapsed .collapse-toggle {
    transform: rotate(180deg);
}

/* Smooth transition for collapse */
#guess-history {
    overflow: visible;
    max-height: none;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Collapsed state hides content */
.history-section.collapsed #guess-history {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.guess-history {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-placeholder {
    display: none;
    /* Handled by JS now, but good fallback */
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 2rem;
    border: 2px dashed var(--incorrect);
}

.history-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: transparent;
    border: 2px solid var(--border-color);
}

.history-label {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--text-secondary);
    width: 50px;
    flex-shrink: 0;
}

/* ============================================
   STAFF & NOTE DISPLAY SYSTEM
   Clean, elegant musical notation
   ============================================ */

/* --- History Mini Staff --- */
.history-staff {
    flex-grow: 1;
    height: 100px;
    position: relative;
    display: flex;
    align-items: center;
}

.history-staff-lines {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
}

.history-staff-line {
    height: 4px;
    background: var(--staff-line);
    opacity: 0.3;
}

.history-notes {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    /* Center short melodies */
    align-items: flex-start;
    z-index: 2;
}

.history-note {
    width: auto;
    /* Overridden by specific rhythm classes */
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
    /* Respect width */
    min-width: 0;
    height: 40px;
    /* Taller to fit scaled note */
    background: transparent;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    border: none;
    box-shadow: none;
    min-width: 0;
    /* Allow shrinking below content size */
}

.history-note .note-visual.small {
    width: 40px;
    height: 80px;
    filter: none;
    /* Reset main filter */
}

/* History Notes use colored images directly - no filters needed */
.history-note.correct .note-img,
.history-note.wrong-position .note-img,
.history-note.incorrect .note-img {
    filter: none;
    opacity: 1;
}

/* History note vertical positions - translate based on pitch */
.history-note[data-pitch="C"] {
    transform: translateY(11.5px);
}

.history-note[data-pitch="D"] {
    transform: translateY(3.1px);
}

.history-note[data-pitch="E"] {
    transform: translateY(-6.5px);
}

.history-note[data-pitch="F"] {
    transform: translateY(-14.5px);
}

.history-note[data-pitch="G"] {
    transform: translateY(-23px);
}

.history-note[data-pitch="A"] {
    transform: translateY(-31px);
}

.history-note[data-pitch="B"] {
    transform: translateY(-40px);
}

.history-note[data-pitch="C5"] {
    transform: translateY(-49px);
}

/* --- RHYTHM SPACING CONTROL (Manual Tuning) --- */
/* Adjust WIDTH values to change gap size (Note Image is 90px) */
/* e.g. 130px = 90px image + 40px gap */

.note,
.history-note {
    flex-shrink: 0;
    flex-grow: 0;
    /* Never stretch */
}

.last-note {
    width: 90px !important;
    /* Just the image width */
    padding-right: 0 !important;
    margin-right: 0 !important;
}

.note.quarter,
.history-note.quarter {
    width: 120px;
}

.note.half,
.history-note.half {
    width: 140px;
}

.note.whole,
.history-note.whole {
    width: 170px;
}

.note.eighth,
.history-note.eighth {
    width: 80px;
}

.note.sixteenth,
.history-note.sixteenth {
    width: 60px;
}



/* --- Main Staff Container --- */
.current-section {
    background: var(--bg-secondary);
    border: 4px solid var(--border-color);
    /* Thicker border */
    border-radius: 0;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.staff-container {
    position: relative;
    height: 260px;
    /* Increased height for tall note sprites */
    display: flex;
    /* Allow growing */
    width: max-content;
    min-width: 100%;
    align-items: center;
    margin-bottom: 1rem;
    --step: 18px;
    /* Increased from 14px to fill staff height better */
    /* The golden rule: step size */
}

/* Staff lines - Absolute positioning relative to center */
.staff-lines {
    position: absolute;
    inset: 0;
}

.staff-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    /* Thicker lines for 8-bit */
    background: var(--staff-line);
    opacity: 0.4;
    transform: translateY(-50%);
}

/*
   Centering logic (User Requested: Low C is Bottom Line):
   Center Reference = Line 3 (G) = 0 steps.
   Step Size = 14px.
   Down = Positive Y.
*/

.staff-line:nth-child(5) {
    top: calc(50% + (4 * var(--step)));
}

/* Line 1 (Bottom): C (+4 steps) */
.staff-line:nth-child(4) {
    top: calc(50% + (2 * var(--step)));
}

/* Line 2: E (+2 steps) */
.staff-line:nth-child(3) {
    top: 50%;
}

/* Line 3: G (Center 0) */
.staff-line:nth-child(2) {
    top: calc(50% - (2 * var(--step)));
}

/* Line 4: B (-2 steps) */
.staff-line:nth-child(1) {
    top: calc(50% - (4 * var(--step)));
}

/* Line 5 (Top): D5 (-4 steps) */

#melody-slots {
    position: relative;
    width: 100%;
    /* Will grow with content */
    height: 100%;
    display: flex;
    justify-content: center;
    /* Center the melody */
    align-items: center;
    z-index: 2;
}

/* --- Note Styling --- */
.note {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: ns-resize;
    user-select: none;
    transition: transform 0.05s steps(2);
    /* Snappy movement */
    /* Snappy movement */
    position: relative;
    width: auto;
    flex-basis: auto;
    /* Respect width */
    flex-grow: 0;
    flex-shrink: 0;
    min-width: 0;
    /* Allow shrinking below content width for short notes */
    height: 80px;
    /* Base height for hit area */
    /* Container for touch target */
    justify-content: center;
    outline: none;
}

.note:focus-visible {
    /* Use browser default or custom focus ring */
    outline: 4px solid var(--accent-color);
    outline-offset: 4px;
    z-index: 100;
}

.note:hover {
    filter: brightness(1.1);
}

.note:active {
    cursor: grabbing;
}

.note.playing {
    /* No smooth pulse, maybe a flash? */
    animation: flash 0.1s steps(2);
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Note Visual Container for merged shape */
.note-visual {
    position: relative;
    width: 90px;
    /* EVEN BIGGER (was 60px) */
    height: 160px;
    /* EVEN BIGGER (was 120px) */
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Align bottom */
    /* REMOVED SHADOWS as requested */
    filter: none;
}

/* The Image Itself */
.note-img {
    width: 100%;
    height: auto;
    display: block;
    image-rendering: pixelated;
    pointer-events: none;
}

/* The Overlay Removed */
.note-overlay {
    display: none;
}


.note:hover .note-visual {
    transform: translate(-2px, -2px);
    /* No shadow on hover either */
    filter: none;
}

/* --- Feedback States --- */
/* We use filters to colorize the black note images */

/* Correct: Green Tint - REMOVED, using images */
.note.correct .note-img {
    filter: none;
}

.note.correct .note-overlay {
    color: #000;
    /* Text visible on green */
    text-shadow: none;
}

/* Wrong Position: Yellow Tint - REMOVED, using images */
.note.wrong-position .note-img {
    filter: none;
}

.note.wrong-position .note-overlay {
    color: #000;
    text-shadow: none;
}

/* Incorrect: Grey/Faded */
.note.incorrect .note-img {
    opacity: 0.3;
}

.note.incorrect .note-overlay {
    color: var(--text-primary);
    text-shadow: none;
}

/* Reveal: Blue Tint */
.note.reveal .note-img {
    filter: sepia(100%) saturate(500%) hue-rotate(180deg);
}

/* Clean up old CSS elements if they exist in DOM (they don't anymore, but good to be safe) */
.note-stem,
.note-head {
    display: none;
}

/* Drag hint */
.drag-hint {
    position: absolute;
    top: -24px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s;
    font-family: var(--font-display);
}

.note:hover .drag-hint {
    opacity: 1;
}

/* ============================================
   DIRECTIONAL ARROWS - CUSTOMIZATION GUIDE
   ============================================ */

/* --- CURRENT GUESS ARROWS (Main Staff) --- */
.arrow-hint {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    animation: bounce 0.5s steps(2) infinite;
}

/* CURRENT GUESS ARROW SIZE: Change width/height to resize arrows */
.arrow-hint img {
    width: 32px;
    /* Arrow width */
    height: 32px;
    /* Arrow height */
    image-rendering: pixelated;
    display: block;
}

/* CURRENT GUESS UP ARROW POSITION: Change 'top' value to move up/down */
.arrow-hint.up {
    top: -40px;
    left: 32px;
    /* Negative = above note, increase to move down */
}

/* CURRENT GUESS DOWN ARROW POSITION: Change 'top' value to move up/down */
.arrow-hint.down {
    top: 94px;
    left: 28px;
    /* Positive = below note, decrease to move up */
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

/* --- HISTORY (PREVIOUS GUESSES) ARROWS --- */
.history-note .arrow-hint {
    animation: none;
    /* No bounce animation for history */
    /* Center arrows horizontally relative to the note */
    left: 50%;
    transform: translateX(-50%);
}

/* HISTORY ARROW SIZE: Change width/height to resize arrows */
.history-note .arrow-hint img {
    width: 20px;
    /* Arrow width */
    height: 20px;
    /* Arrow height */
}

/* HISTORY UP ARROW POSITION: Change 'top' value to move up/down */
.history-note .arrow-hint.up {
    top: 15px;
    /* Negative = above note, increase to move down */
}

/* HISTORY DOWN ARROW POSITION: Change 'top' value to move up/down */
.history-note .arrow-hint.down {
    top: 84px;
    /* Positive = below note, decrease to move up */
}

/* Note vertical positions using CSS custom property */
/* Relies on flex container centering items at middle line (G).
   Positive Y is DOWN. 
*/
/* --- Note Placement Logic Overhaul --- */
/* 
   We use a strict integer grid system centered on "G" (middle line).
   Positive Offset = Down
   Negative Offset = Up
   
   Formula: (Offset * Step) - Anchor
*/

.note {
    --pitch-offset: 0;
    /* USER: ADJUST THIS VALUE to slide all notes up/down together */
    --sprite-anchor: 28.5px;

    transform: translateY(calc((var(--pitch-offset) * var(--step)) - var(--sprite-anchor)));
}

/* Strict Integer Grid Offsets */

/* Line 1 (Bottom) area */
.note[data-pitch="C"] {
    --pitch-offset: 4;
}

/* 4 steps down from G */
.note[data-pitch="D"] {
    --pitch-offset: 3;
}

/* Line 1 */
.note[data-pitch="E"] {
    --pitch-offset: 2;
}

/* Space 1 */
.note[data-pitch="F"] {
    --pitch-offset: 1;
}

/* Line 2 (Center) */
.note[data-pitch="G"] {
    --pitch-offset: 0;
}

/* Space 2 */
.note[data-pitch="A"] {
    --pitch-offset: -1;
}

/* Line 3 */
.note[data-pitch="B"] {
    --pitch-offset: -2;
}

/* Space 3 */
.note[data-pitch="C5"] {
    --pitch-offset: -3;
}

/* Removed Ledger Line for C since it's now on the staff */

@keyframes pulse {

    0%,
    100% {
        transform: translateY(var(--ty)) scale(1);
    }

    50% {
        transform: translateY(var(--ty)) scale(1.2);
    }
}

/* Controls Row */
.controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Melody Contour Widget */
.contour-widget {
    margin: 0 auto 1.5rem;
    width: 60%;
    max-width: 800px;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    /* 8-bit container */
    background: var(--bg-color);
    border: 4px solid var(--border-color);
    box-shadow: 4px 4px 0 #000;
}

.contour-label {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    background: var(--bg-color);
    padding: 4px 8px;
    position: absolute;
    top: -12px;
    border: 2px solid #000;
    /* Or a specific color like #000 */
    padding: 2px 6px;
    /* Add some breathing room */
    display: inline-block;
    /* Ensures the border wraps the text tightly */
    border-radius: 4px;
    /* Optional: Rounded corners */
}

.contour-widget svg {
    width: 100%;
    height: 100%;
    color: var(--accent-color);
    overflow: visible;
}

.contour-widget path {
    stroke-width: 4px;
    /* Chunky line */
    stroke: var(--accent-color);
    opacity: 1;
    shape-rendering: crispEdges;
    /* Try to make it look pixelated */
    filter: drop-shadow(4px 4px 0 var(--shadow));
}

.contour-widget circle {
    fill: var(--text-primary);
    r: 4;
    /* Bigger dots */
    shape-rendering: crispEdges;
}

.action-btn {
    border: 3px solid var(--border-color);
    /* Black internal border */
    border-radius: 0;
    padding: 1.25rem 2rem;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 4px 4px 0 var(--shadow);
    text-transform: uppercase;
    position: relative;
}

.action-btn::after {
    /* Inner highlight for plastic look */
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 50%;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.listen-btn {
    background: var(--text-primary);
    /* Charcoal */
    color: var(--bg-secondary);
    /* Paper White */
}

.listen-btn:hover {
    background: #404040;
    /* Slightly lighter charcoal */
    color: var(--bg-secondary);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--shadow);
}

.listen-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.guess-btn {
    background: var(--correct);
    color: #000;
    /* Black text on Green */
}

.guess-btn:hover {
    background: #16a34a;
    /* Darker Green */
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--shadow);
}

.guess-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--shadow);
}

/* Feedback */
.feedback-message {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-secondary);
    min-height: 2.5rem;
    padding: 1rem;
    text-transform: uppercase;
}

.feedback-message.success {
    color: var(--correct);
    text-shadow: 2px 2px 0 #000;
}

.feedback-message.game-over {
    color: #e74c3c;
    /* Red */
    text-shadow: 2px 2px 0 #000;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    font-family: var(--font-main);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 0;
    /* Square */
    border: 2px solid var(--border-color);
}

.legend-color.green {
    background: var(--correct);
}

.legend-color.yellow {
    background: var(--wrong-position);
}

.legend-color.gray {
    background: var(--incorrect);
}

/* Score Display */
.score-display {
    text-align: center;
    font-size: 1.6rem;
    color: var(--text-secondary);
    font-family: var(--font-main);
}

.score-display strong {
    color: var(--accent-color);
    font-family: var(--font-display);
    font-size: 1.3rem;
}

/* Footer */
footer {
    /* Removed container positioning to allow individual button placement */
    pointer-events: none;
    /* Let clicks pass through container if it overlays anything */
}

#btn-new {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 500;
    /* Ensure clickable */
    pointer-events: auto;
}

#btn-dev {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 500;
    pointer-events: auto;
}

.new-melody-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--text-primary);
    border-radius: 0;
    /* Square */
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--shadow);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    pointer-events: auto;
}

.new-melody-btn:hover {
    background: var(--text-primary);
    color: var(--bg-secondary);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--shadow);
}

.new-melody-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--shadow);
}

/* Modal */
.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(44, 44, 44, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-color);
    border: 4px solid var(--border-color);
    outline: 2px solid var(--bg-color);
    outline-offset: -8px;
    border-radius: 0;
    padding: 3rem;
    max-width: 95%;
    max-height: 90vh;
    width: 650px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    color: var(--text-primary);
    font-family: var(--font-main);
    animation: modalPop 0.2s ease-out;
    overflow-y: auto;
}

@keyframes modalPop {
    0% {
        transform: scale(0.95);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    text-align: center;
    text-transform: uppercase;
    border-bottom: 3px solid var(--border-color);
    padding-bottom: 1rem;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.modal-content ul {
    padding-left: 0;
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 1.6rem;
    list-style-type: none;
    margin-bottom: 1.5rem;
}

.modal-content li {
    margin-bottom: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.08);
}

.modal-content li strong {
    color: var(--accent-color);
}

.color-hint {
    font-size: 1.4rem;
    font-weight: bold;
    padding: 4px 10px;
    border: 2px solid currentColor;
    display: inline-block;
}

.color-hint.green {
    color: var(--correct);
    background: rgba(74, 222, 128, 0.1);
}

.color-hint.yellow {
    color: var(--wrong-position);
    background: rgba(250, 204, 21, 0.1);
}

.color-hint.gray {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    width: 40px;
    height: 40px;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.1s;
}

.close-btn:hover {
    background: var(--text-primary);
    color: var(--bg-secondary);
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
}

/* =========================================
   RESPONSIVE DESIGN (Legacy Support)
   ========================================= */

@media (max-width: 600px) {
    .app-container {
        min-width: 100%;
        padding: 0.5rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .controls {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }

    /* Scale down the staff to fit */
    .staff-container {
        transform-origin: left center;
        transform: scale(0.65);
        margin-bottom: -40px;
        /* Compensate for scale gap */
        width: 150%;
        /* Fake width so scale doesn't cut it off */
    }

    .history-staff {
        transform-origin: left center;
        transform: scale(0.7);
        width: 140%;
    }

    .history-row {
        overflow: hidden;
        /* Hide overflow from scaling */
    }

    /* Compact History */
    .history-section {
        max-height: 200px;
        overflow-y: auto;
        padding: 0.5rem;
    }

    /* Widget */
    .contour-widget {
        width: 100%;
        height: 100px;
    }

    .action-btn {
        padding: 0.8rem 1rem;
        font-size: 0.6rem;
    }
}

/* Dev Modal Styles */
.dev-content {
    width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.dev-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.5rem;
}

.song-item-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    padding: 1rem;
    text-align: left;
    font-family: var(--font-display);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 2px 2px 0 var(--border-color);
}

.song-item-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--border-color);
    background: var(--accent-color);
    color: #fff;
}

/* Stats Modal Styles */
.stats-content {
    width: 600px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: center;
}

.stat-item {
    padding: 1.25rem 0.75rem;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-family: var(--font-main);
    font-size: 1.3rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.histogram-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 3px solid var(--border-color);
}

.histogram-label {
    font-family: var(--font-display);
    font-size: 1.2rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    text-align: center;
    letter-spacing: 1px;
}

.histogram {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.histogram-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.histogram-bar-label {
    font-family: var(--font-display);
    font-size: 1.4rem;
    width: 28px;
    text-align: right;
    color: var(--text-primary);
}

.histogram-bar-container {
    flex: 1;
    height: 36px;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

.histogram-bar {
    height: 100%;
    background: var(--correct);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    min-width: 40px;
    transition: width 0.3s ease;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.histogram-count {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: #000;
    font-weight: 400;
}