/* Musical Accompanist Tool Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* Print Styles for Two-Page Layout */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        background: white !important;
        padding: 0;
        font-size: 12pt;
        line-height: 1.4;
        color: black !important;
    }
    
    .container {
        max-width: none;
        background: white;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }
    
    /* Page layout */
    @page {
        size: 8.5in 11in;
        margin: 0.5in;
    }
    
    /* Hide interactive elements */
    .subscription-status,
    .playback-controls,
    .status-section,
    .piano-action-buttons,
    .progression-controls,
    #play-btn, #pause-btn, #stop-btn,
    .modal, .context-menu,
    script, .vercel-analytics,
    footer {
        display: none !important;
    }
    
    /* Header adjustments for print */
    header {
        background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
        color: white !important;
        padding: 15pt;
        text-align: center;
        page-break-after: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    header h1 {
        font-size: 18pt;
        margin-bottom: 8pt;
        color: white !important;
    }
    
    header p {
        font-size: 12pt;
        color: white !important;
        margin-bottom: 0;
    }
    
    /* Section spacing */
    section {
        margin-bottom: 20pt;
        page-break-inside: avoid;
    }
    
    /* Control panel - condensed for print */
    .control-panel {
        page-break-after: avoid;
    }
    
    .controls-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10pt;
        margin-bottom: 10pt;
    }
    
    .control-group {
        margin-right: 15pt;
        min-width: 120pt;
    }
    
    .control-group label {
        font-weight: bold;
        font-size: 10pt;
    }
    
    /* Roman numeral section - page 1 focus */
    .roman-numeral-section {
        page-break-before: avoid;
        page-break-after: auto;
    }
    
    .roman-numeral-section h2 {
        font-size: 14pt;
        margin-bottom: 10pt;
        border-bottom: 2pt solid #4facfe;
        padding-bottom: 5pt;
    }
    
    .chord-type-tabs {
        display: flex;
        gap: 5pt;
        margin-bottom: 15pt;
        flex-wrap: wrap;
    }
    
    .chord-tab {
        background: #f0f0f0;
        border: 1pt solid #ccc;
        padding: 5pt 10pt;
        font-size: 10pt;
        border-radius: 3pt;
    }
    
    .chord-tab.active {
        background: #4facfe;
        color: white;
    }
    
    .chord-group {
        margin-bottom: 15pt;
    }
    
    .chord-category {
        margin-bottom: 12pt;
    }
    
    .category-label {
        font-weight: bold;
        font-size: 11pt;
        margin-bottom: 5pt;
        display: block;
        color: #333;
    }
    
    .roman-numeral-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 5pt;
    }
    
    .roman-chord-btn {
        background: white;
        border: 1pt solid #333;
        padding: 5pt 8pt;
        font-size: 10pt;
        border-radius: 3pt;
        min-width: 40pt;
        text-align: center;
    }
    
    /* Piano section - start of page 2 */
    .piano-section {
        page-break-before: always;
        page-break-after: avoid;
    }
    
    .piano-section h2 {
        font-size: 14pt;
        margin-bottom: 10pt;
        border-bottom: 2pt solid #4facfe;
        padding-bottom: 5pt;
    }
    
    .piano-keyboard {
        margin-bottom: 15pt;
    }
    
    .piano-keys {
        display: flex;
        position: relative;
        height: 80pt;
        margin-bottom: 10pt;
    }
    
    .key {
        border: 1pt solid #000;
        text-align: center;
        font-size: 8pt;
        display: flex;
        align-items: flex-end;
        justify-content: center;
        padding-bottom: 5pt;
    }
    
    .key.white {
        background: white;
        width: 25pt;
        height: 80pt;
        z-index: 1;
    }
    
    .key.black {
        background: #333;
        color: white;
        width: 15pt;
        height: 50pt;
        position: absolute;
        z-index: 2;
        margin-left: -7.5pt;
    }
    
    /* Position black keys */
    .key.black[data-note="C#4"] { left: 25pt; }
    .key.black[data-note="D#4"] { left: 50pt; }
    .key.black[data-note="F#4"] { left: 100pt; }
    .key.black[data-note="G#4"] { left: 125pt; }
    .key.black[data-note="A#4"] { left: 150pt; }
    .key.black[data-note="C#5"] { left: 200pt; }
    .key.black[data-note="D#5"] { left: 225pt; }
    .key.black[data-note="F#5"] { left: 275pt; }
    .key.black[data-note="G#5"] { left: 300pt; }
    .key.black[data-note="A#5"] { left: 325pt; }
    
    /* Chord display section */
    .chord-display-section {
        page-break-inside: avoid;
    }
    
    .chord-display-section h2 {
        font-size: 14pt;
        margin-bottom: 10pt;
        border-bottom: 2pt solid #4facfe;
        padding-bottom: 5pt;
    }
    
    .chord-display {
        border: 1pt solid #ccc;
        padding: 15pt;
        background: #f9f9f9;
        min-height: 100pt;
        font-family: monospace;
        font-size: 10pt;
    }
    
    /* Hide slider inputs, show only labels and values */
    input[type="range"] {
        display: none;
    }
    
    input[type="checkbox"] {
        width: 10pt;
        height: 10pt;
    }
    
    select {
        font-size: 9pt;
        padding: 2pt;
    }
    
    /* Ensure proper spacing */
    h2 {
        color: #333 !important;
    }
    
    /* Additional spacing for readability */
    .roman-chord-info {
        margin-top: 15pt;
        padding: 10pt;
        background: #f0f0f0;
        border-radius: 5pt;
        font-size: 10pt;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Subscription Status Banners */
.subscription-status {
    margin-top: 20px;
}

.user-status-banner {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.user-status-banner.trial {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.5);
}

.user-status-banner.expired {
    background: rgba(255, 152, 0, 0.15);
    border-color: rgba(255, 152, 0, 0.5);
}

.user-status-banner.premium {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

.subscribe-button, .manage-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.subscribe-button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.subscribe-button.urgent {
    background: #ff6b6b;
}

.subscribe-button.urgent:hover {
    background: #ff5252;
}

.manage-button {
    background: #2196F3;
}

.manage-button:hover {
    background: #1976D2;
}

/* Trial Modal Styles */
.trial-modal .modal-content {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.trial-content h2 {
    color: #4facfe;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.2rem;
}

.trial-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.trial-benefits {
    margin-bottom: 40px;
}

.benefit-section h3 {
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
}

.benefit-section ul {
    list-style: none;
    padding: 0;
}

.benefit-section li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    color: #555;
    position: relative;
    padding-left: 20px;
}

.benefit-section li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #4CAF50;
    font-weight: bold;
}

.pricing-section {
    text-align: center;
    margin-bottom: 20px;
}

.price-card {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    display: inline-block;
    min-width: 250px;
}

.price-card h3 {
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.price {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.price span {
    font-size: 1.2rem;
    opacity: 0.8;
}

.price-card p {
    opacity: 0.9;
    margin-bottom: 20px;
}

.subscribe-btn-modal {
    background: #4CAF50;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
}

.subscribe-btn-modal:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.trial-note {
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    margin-top: 20px;
}

main {
    padding: 30px;
}

section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

section h2 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* Control Panel */
.control-panel {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.control-group {
    flex: 1;
    min-width: 150px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.control-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

.control-group input[type="checkbox"] {
    margin-right: 8px;
}

.control-group span {
    font-weight: bold;
    color: #495057;
}

/* Chord Display */
.chord-display-section {
    background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
}

/* Drag over effects */
.chord-display.drag-over {
    background: #e3f2fd;
    border: 2px dashed #007bff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}

.chord-display {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 60px;
    align-items: flex-start;
    padding: 15px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* Chord Display */
.chord-display-section {
    background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
}

.chord-display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.chord-display-header h2 {
    margin: 0;
    flex: 1;
}

.progression-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.progression-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: #6c757d;
    min-width: 100px;
}

.progression-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.measure-setup {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.measure-setup input[type="number"] {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    background: white;
    color: #495057;
}

.measure-setup input[type="number"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.action-btn {
    padding: 6px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.action-btn.active {
    background: #007bff;
    color: white;
}

.clear-progression-btn {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.clear-progression-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.clear-progression-btn:active {
    transform: translateY(0);
}

.chord-display {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 60px;
    align-items: flex-start;
    padding: 15px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* Measure styling */
.measure {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    margin: 8px;
    min-width: 200px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.measure::before {
    content: "";
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 4px;
    background: #495057;
    border-radius: 2px;
}

.measure::after {
    content: "";
    position: absolute;
    right: 0;
    top: 15%;
    bottom: 15%;
    width: 2px;
    background: #495057;
    border-radius: 1px;
}

.measure.current-measure {
    background: #e7f3ff;
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0,123,255,0.25);
    transform: scale(1.02);
}

.measure.current-measure::before {
    background: #007bff;
    width: 5px;
}

.measure.current-measure::after {
    background: #007bff;
    width: 3px;
}

.measure-number {
    position: absolute;
    top: -10px;
    left: 8px;
    background: #495057;
    color: white;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.measure-time-signature {
    position: absolute;
    top: -10px;
    right: 35px;
    background: #6c757d;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.measure.current-measure .measure-number {
    background: #007bff;
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

/* Delete button for measures */
.measure-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    background: #dc3545;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 20;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    line-height: 1;
    pointer-events: auto;
}

.measure:hover .measure-delete {
    opacity: 1;
    transform: scale(1.05);
}

.measure-delete:hover {
    background: #c82333 !important;
    transform: scale(1.15) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4) !important;
}

/* Edit button for chords */
.chord-edit {
    position: absolute;
    top: -8px;
    right: 12px; /* Position to the left of delete button */
    width: 18px;
    height: 18px;
    background: #28a745;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    line-height: 1;
    pointer-events: auto;
}

.chord-item:hover .chord-edit {
    opacity: 1;
    transform: scale(1.1);
}

.chord-edit:hover {
    background: #218838 !important;
    transform: scale(1.2) !important;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4) !important;
}

/* Delete button for chords */
.chord-delete {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    background: #dc3545;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    line-height: 1;
    pointer-events: auto;
}

.chord-item:hover .chord-delete {
    opacity: 1;
    transform: scale(1.1);
}

.chord-delete:hover {
    background: #c82333 !important;
    transform: scale(1.2) !important;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4) !important;
}

.chord-delete:hover {
    background: #c82333;
    transform: scale(1.1);
}

.chord-item.bar-line {
    background: #495057;
    color: white;
    padding: 8px 4px;
    font-size: 0.8rem;
    font-weight: bold;
    min-width: 20px;
}

.chord-item.custom-chord {
    background: #28a745;
    color: white;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.chord-item.custom-chord:hover {
    background: #1e7e34;
}

.chord-item.single-note {
    background: #17a2b8;
    color: white;
    font-style: italic;
}

.chord-item.single-note:hover {
    background: #138496;
}



/* Piano Keyboard */
.piano-section {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.piano-keyboard {
    position: relative;
    height: 120px;
    max-width: 720px;
    min-width: 320px; /* Changed from 720px to allow mobile flexibility */
    width: 100%; /* Add responsive width */
    margin: 20px auto;
    background: #333;
    border-radius: 5px;
    padding: 10px;
    overflow-x: auto;
    box-sizing: border-box; /* Ensure padding is included in width */
}

.piano-keys {
    position: relative;
    width: 100%;
    height: 100%;
}

.key {
    position: absolute;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.1s ease;
}

.key.white {
    width: 50px;
    height: 100px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 0 0 5px 5px;
    color: #333;
    z-index: 1;
}

.key.white:nth-child(1) { left: 0; }
.key.white:nth-child(2) { left: 50px; }
.key.white:nth-child(3) { left: 100px; }
.key.white:nth-child(4) { left: 150px; }
.key.white:nth-child(5) { left: 200px; }
.key.white:nth-child(6) { left: 250px; }
.key.white:nth-child(7) { left: 300px; }
.key.white:nth-child(8) { left: 350px; }
.key.white:nth-child(9) { left: 400px; }
.key.white:nth-child(10) { left: 450px; }
.key.white:nth-child(11) { left: 500px; }
.key.white:nth-child(12) { left: 550px; }
.key.white:nth-child(13) { left: 600px; }
.key.white:nth-child(14) { left: 650px; }

.key.black {
    width: 30px;
    height: 60px;
    background: #333;
    border: 2px solid #111;
    border-radius: 0 0 3px 3px;
    color: white;
    z-index: 2;
    font-size: 10px;
}

/* Black key positioning for two octaves */
.key.black[data-note="C#4"] { left: 35px; }
.key.black[data-note="D#4"] { left: 85px; }
.key.black[data-note="F#4"] { left: 185px; }
.key.black[data-note="G#4"] { left: 235px; }
.key.black[data-note="A#4"] { left: 285px; }
.key.black[data-note="C#5"] { left: 385px; }
.key.black[data-note="D#5"] { left: 435px; }
.key.black[data-note="F#5"] { left: 535px; }
.key.black[data-note="G#5"] { left: 585px; }
.key.black[data-note="A#5"] { left: 635px; }

.key:hover {
    transform: scale(0.98);
}

.key.active {
    background: #007bff !important;
    color: white !important;
    transform: scale(0.95);
}

.key.white.active {
    background: #007bff !important;
}

.key.in-key {
    /* Clear, visible indicator for keys that belong to the current key signature */
    border-color: #4caf50 !important;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.key.white.in-key {
    background: rgba(255, 255, 255, 0.85) !important;
    background-image: linear-gradient(rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.15)) !important;
}

.key.black.in-key {
    background: rgba(51, 51, 51, 0.85) !important;
    background-image: linear-gradient(rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.3)) !important;
    border-color: #4caf50 !important;
}

.key.active.in-key {
    /* Keep the active state visually dominant while showing it's also in-key */
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4), 0 0 12px rgba(0, 123, 255, 0.3);
}

.piano-controls {
    margin-top: 20px;
}

.chord-builder {
    text-align: center;
}

.chord-builder label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #495057;
}

.selected-notes {
    min-height: 40px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

.selected-note {
    background: #007bff;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 600;
}

.chord-builder button {
    margin: 0 5px;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

#play-selected {
    background: #28a745;
    color: white;
}

#play-selected:hover {
    background: #1e7e34;
}

#clear-selection {
    background: #dc3545;
    color: white;
}

#clear-selection:hover {
    background: #c82333;
}

#add-to-progression {
    background: #007bff;
    color: white;
}

#add-to-progression:hover {
    background: #0056b3;
}

/* Playback Controls */
.playback-controls {
    text-align: center;
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.playback-controls button {
    padding: 15px 30px;
    margin: 0 10px;
    border: none;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.play-btn {
    background: #28a745;
    color: white;
}

.play-btn:hover:not(:disabled) {
    background: #1e7e34;
    transform: translateY(-2px);
}

.pause-btn {
    background: #ffc107;
    color: #212529;
}

.pause-btn:hover:not(:disabled) {
    background: #e0a800;
    transform: translateY(-2px);
}

.stop-btn {
    background: #dc3545;
    color: white;
}

.stop-btn:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
}

.playback-controls button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Status Section */
.status-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

#status-display {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

#current-chord-display {
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* Footer */
footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
}

/* Tablet responsive adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .piano-keyboard {
        min-width: 520px; /* Reduced for better tablet fit */
        max-width: 640px;
        overflow-x: auto;
    }
    
    .key.white {
        width: 45px;
        height: 90px;
    }
    
    .key.white:nth-child(1) { left: 0; }
    .key.white:nth-child(2) { left: 45px; }
    .key.white:nth-child(3) { left: 90px; }
    .key.white:nth-child(4) { left: 135px; }
    .key.white:nth-child(5) { left: 180px; }
    .key.white:nth-child(6) { left: 225px; }
    .key.white:nth-child(7) { left: 270px; }
    .key.white:nth-child(8) { left: 315px; }
    .key.white:nth-child(9) { left: 360px; }
    .key.white:nth-child(10) { left: 405px; }
    .key.white:nth-child(11) { left: 450px; }
    .key.white:nth-child(12) { left: 495px; }
    .key.white:nth-child(13) { left: 540px; }
    .key.white:nth-child(14) { left: 585px; }
    
    .key.black {
        width: 28px;
        height: 55px;
    }
    
    /* Black key positioning for 45px white keys */
    .key.black[data-note="C#4"] { left: 31px; }
    .key.black[data-note="D#4"] { left: 76px; }
    .key.black[data-note="F#4"] { left: 166px; }
    .key.black[data-note="G#4"] { left: 211px; }
    .key.black[data-note="A#4"] { left: 256px; }
    .key.black[data-note="C#5"] { left: 346px; }
    .key.black[data-note="D#5"] { left: 391px; }
    .key.black[data-note="F#5"] { left: 481px; }
    .key.black[data-note="G#5"] { left: 526px; }
    .key.black[data-note="A#5"] { left: 571px; }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .control-group {
        min-width: 100%;
    }
    

    
    .chord-display {
        justify-content: center;
    }
    
    .chord-display-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .chord-display-header h2 {
        align-self: center;
    }
    
    .clear-progression-btn {
        align-self: center;
    }
    
    /* Responsive measures for mobile */
    .measure {
        min-width: 140px;
        padding: 10px 12px;
        margin: 4px;
        gap: 4px;
    }
    
    .chord-item {
        font-size: 0.85rem;
        padding: 6px 8px;
        min-width: 28px;
    }
    
    .measure-number {
        font-size: 0.65rem;
        padding: 2px 5px;
        top: -8px;
        left: 6px;
    }
    
    .playback-controls button {
        padding: 12px 20px;
        margin: 5px;
        font-size: 1rem;
    }
    
    #current-chord-display {
        font-size: 1.5rem;
    }
    
    .piano-keyboard {
        min-width: 100%; /* Use full width available */
        max-width: 100%;
        height: 90px; /* Slightly taller for easier touch */
        margin: 20px auto;
        overflow-x: auto; /* Enable horizontal scrolling when needed */
        overflow-y: hidden;
    }
    
    .piano-section {
        overflow-x: auto;
        padding: 15px 5px; /* Reduced padding for mobile */
    }
    
    .piano-keys {
        min-width: 560px; /* Minimum width to accommodate all keys */
        width: 100%;
        position: relative;
    }
    
    .key.white {
        width: 40px;
        height: 80px;
    }
    
    .key.white:nth-child(1) { left: 0; }
    .key.white:nth-child(2) { left: 40px; }
    .key.white:nth-child(3) { left: 80px; }
    .key.white:nth-child(4) { left: 120px; }
    .key.white:nth-child(5) { left: 160px; }
    .key.white:nth-child(6) { left: 200px; }
    .key.white:nth-child(7) { left: 240px; }
    .key.white:nth-child(8) { left: 280px; }
    .key.white:nth-child(9) { left: 320px; }
    .key.white:nth-child(10) { left: 360px; }
    .key.white:nth-child(11) { left: 400px; }
    .key.white:nth-child(12) { left: 440px; }
    .key.white:nth-child(13) { left: 480px; }
    .key.white:nth-child(14) { left: 520px; }
    
    .key.black {
        width: 25px;
        height: 50px;
    }
    
    /* Black key positioning for 40px white keys */
    .key.black[data-note="C#4"] { left: 28px; }
    .key.black[data-note="D#4"] { left: 68px; }
    .key.black[data-note="F#4"] { left: 148px; }
    .key.black[data-note="G#4"] { left: 188px; }
    .key.black[data-note="A#4"] { left: 228px; }
    .key.black[data-note="C#5"] { left: 308px; }
    .key.black[data-note="D#5"] { left: 348px; }
    .key.black[data-note="F#5"] { left: 428px; }
    .key.black[data-note="G#5"] { left: 468px; }
    .key.black[data-note="A#5"] { left: 508px; }
    
    .chord-builder button {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

@media (max-width: 480px) {
    .roman-numeral-buttons {
        gap: 5px;
    }
    
    .roman-chord-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-width: 40px;
    }
    
    .roman-chord-info {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
    
    main {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .controls-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .control-group {
        min-width: 100%;
    }
    
    .chord-display {
        flex-direction: column;
        align-items: stretch;
    }
    
    .chord-display-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .chord-display-header h2 {
        align-self: flex-start;
        font-size: 1.5rem;
    }
    
    .progression-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .progression-info {
        align-items: flex-start;
        text-align: left;
    }
    
    .measure-setup {
        flex-direction: column;
        align-items: stretch;
    }
    
    .measure-setup input[type="number"] {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .action-btn {
        width: 100%;
        padding: 10px;
        font-size: 1rem;
    }
    
    .clear-progression-btn {
        width: 100%;
        padding: 10px;
        font-size: 1rem;
    }
    
    .chord-item {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
    
    .measure {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }
    
    .measure-number {
        top: -8px;
        left: 8px;
        font-size: 0.7rem;
        padding: 2px 6px;
    }
    
    .measure-time-signature {
        top: -8px;
        right: 8px;
        font-size: 0.7rem;
        padding: 2px 6px;
    }
    
    .playback-controls button {
        padding: 10px 20px;
        margin: 5px 0;
        font-size: 1rem;
    }
    
    #current-chord-display {
        font-size: 1.8rem;
    }
    
    .piano-keyboard {
        height: 90px; /* Better for touch */
        min-width: 490px; /* 14 * 35px for proper spacing */
    }
    
    .key.white {
        width: 35px;
        height: 75px; /* Slightly taller for easier touch */
    }
    
    .key.white:nth-child(1) { left: 0; }
    .key.white:nth-child(2) { left: 35px; }
    .key.white:nth-child(3) { left: 70px; }
    .key.white:nth-child(4) { left: 105px; }
    .key.white:nth-child(5) { left: 140px; }
    .key.white:nth-child(6) { left: 175px; }
    .key.white:nth-child(7) { left: 210px; }
    .key.white:nth-child(8) { left: 245px; }
    .key.white:nth-child(9) { left: 280px; }
    .key.white:nth-child(10) { left: 315px; }
    .key.white:nth-child(11) { left: 350px; }
    .key.white:nth-child(12) { left: 385px; }
    .key.white:nth-child(13) { left: 420px; }
    .key.white:nth-child(14) { left: 455px; }
    
    .key.black {
        width: 22px; /* Slightly wider for better touch */
        height: 45px; /* Slightly taller for better touch */
    }
    
    .key.black[data-note="C#4"] { left: 26px; }
    .key.black[data-note="D#4"] { left: 66px; }
    .key.black[data-note="F#4"] { left: 146px; }
    .key.black[data-note="G#4"] { left: 186px; }
    .key.black[data-note="A#4"] { left: 226px; }
    .key.black[data-note="C#5"] { left: 266px; }
    .key.black[data-note="D#5"] { left: 306px; }
    .key.black[data-note="F#5"] { left: 386px; }
    .key.black[data-note="G#5"] { left: 426px; }
    .key.black[data-note="A#5"] { left: 466px; }
    
    .chord-builder button {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
}

/* Portrait mobile specific adjustments */
@media (max-width: 480px) and (orientation: portrait) {
    .piano-section {
        padding: 10px 2px;
    }
    
    .piano-keyboard {
        height: 85px;
        min-width: 100%;
        max-width: 100%;
        margin: 15px auto;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .piano-keys {
        min-width: 490px; /* Force horizontal scroll for all keys */
        width: 490px;
    }
    
    .key.white {
        width: 35px;
        height: 70px;
        font-size: 10px;
    }
    
    .key.white:nth-child(1) { left: 0; }
    .key.white:nth-child(2) { left: 35px; }
    .key.white:nth-child(3) { left: 70px; }
    .key.white:nth-child(4) { left: 105px; }
    .key.white:nth-child(5) { left: 140px; }
    .key.white:nth-child(6) { left: 175px; }
    .key.white:nth-child(7) { left: 210px; }
    .key.white:nth-child(8) { left: 245px; }
    .key.white:nth-child(9) { left: 280px; }
    .key.white:nth-child(10) { left: 315px; }
    .key.white:nth-child(11) { left: 350px; }
    .key.white:nth-child(12) { left: 385px; }
    .key.white:nth-child(13) { left: 420px; }
    .key.white:nth-child(14) { left: 455px; }
    
    .key.black {
        width: 20px;
        height: 42px;
        font-size: 8px;
    }
    
    .key.black[data-note="C#4"] { left: 26px; }
    .key.black[data-note="D#4"] { left: 61px; }
    .key.black[data-note="F#4"] { left: 131px; }
    .key.black[data-note="G#4"] { left: 166px; }
    .key.black[data-note="A#4"] { left: 201px; }
    .key.black[data-note="C#5"] { left: 271px; }
    .key.black[data-note="D#5"] { left: 306px; }
    .key.black[data-note="F#5"] { left: 376px; }
    .key.black[data-note="G#5"] { left: 411px; }
    .key.black[data-note="A#5"] { left: 446px; }
    
    .chord-builder {
        padding: 15px 10px;
    }
    
    .chord-builder button {
        padding: 12px;
        font-size: 1rem;
        margin: 8px 0;
    }
    
    .selected-notes {
        padding: 8px;
        min-height: 35px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .selected-note {
        font-size: 0.8rem;
        padding: 4px 8px;
        margin: 2px;
    }
}

/* Enhanced Roman Numeral Section with Tabs */
.roman-numeral-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.roman-numeral-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
}

/* Chord Type Tabs */
.chord-type-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 10px;
}

.chord-tab {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
    min-width: 100px;
}

.chord-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.chord-tab.active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Chord Groups */
.chord-group {
    display: none;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.chord-group.active {
    display: flex;
}

/* Chord Categories within groups */
.chord-category {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.category-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Roman numeral button groups */
.roman-numeral-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

/* Enhanced Roman numeral buttons */
.roman-chord-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 50px;
    position: relative;
    backdrop-filter: blur(10px);
}

.roman-chord-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.roman-chord-btn.active,
.roman-chord-btn.selected {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.roman-chord-btn.selected:hover {
    background: rgba(255, 255, 255, 1);
    color: #667eea;
}

/* Tooltip enhancement for chord buttons */
.roman-chord-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.roman-chord-btn:hover::after {
    opacity: 1;
}

/* Roman chord info display */
.roman-chord-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px 24px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    margin-top: 10px;
}

#roman-chord-display {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
}

/* Color coding for different chord types */
.chord-group[data-group="triads"] .roman-chord-btn {
    border-color: rgba(76, 175, 80, 0.6);
}

.chord-group[data-group="triads"] .roman-chord-btn:hover {
    border-color: rgba(76, 175, 80, 0.8);
    background: rgba(76, 175, 80, 0.2);
}

.chord-group[data-group="sevenths"] .roman-chord-btn {
    border-color: rgba(255, 193, 7, 0.6);
}

.chord-group[data-group="sevenths"] .roman-chord-btn:hover {
    border-color: rgba(255, 193, 7, 0.8);
    background: rgba(255, 193, 7, 0.2);
}

.chord-group[data-group="secondary"] .roman-chord-btn {
    border-color: rgba(255, 87, 34, 0.6);
}

.chord-group[data-group="secondary"] .roman-chord-btn:hover {
    border-color: rgba(255, 87, 34, 0.8);
    background: rgba(255, 87, 34, 0.2);
}

.chord-group[data-group="advanced"] .roman-chord-btn {
    border-color: rgba(156, 39, 176, 0.6);
}

.chord-group[data-group="advanced"] .roman-chord-btn:hover {
    border-color: rgba(156, 39, 176, 0.8);
    background: rgba(156, 39, 176, 0.2);
}

/* Responsive design for Roman numeral section */
@media (max-width: 768px) {
    .chord-type-tabs {
        flex-direction: column;
        gap: 4px;
    }
    
    .chord-tab {
        min-width: auto;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .roman-numeral-buttons {
        gap: 6px;
    }
    
    .roman-chord-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        min-width: 45px;
    }
    
    .category-label {
        font-size: 0.8rem;
        padding: 4px 10px;
    }
    
    .roman-chord-info {
        padding: 15px 18px;
        font-size: 1rem;
    }
    
    #roman-chord-display {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .chord-type-tabs {
        padding: 2px;
    }
    
    .chord-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .roman-numeral-buttons {
        gap: 4px;
    }
    
    .roman-chord-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 40px;
    }
    
    .chord-category {
        gap: 8px;
    }
    
    .category-label {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    
    .roman-chord-info {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    #roman-chord-display {
        font-size: 1rem;
    }
}

/* Rest symbol styling for empty slots */
.rest-symbol {
    font-size: 1.5em;
    color: #666;
    opacity: 0.7;
    font-family: 'Times New Roman', serif;
}

.empty-slot:hover .rest-symbol {
    color: #333;
    opacity: 1;
}

.empty-slot.selected-for-piano .rest-symbol {
    color: #007bff;
    opacity: 1;
}

/* Animation for chord transitions */
@keyframes chordPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.chord-item.current {
    animation: chordPulse 0.5s ease-in-out;
}

/* Drag and drop styles */
.chord-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.chord-item.drag-over {
    background: #e7f3ff !important;
    border: 2px dashed #007bff !important;
    transform: scale(1.05);
}

.chord-item.drag-over.empty-slot {
    background: #e7f3ff !important;
    border: 2px dashed #007bff !important;
    opacity: 1;
}

/* Improved cursor for draggable items */
.chord-item:not(.empty-slot) {
    cursor: grab;
}

.chord-item:not(.empty-slot):active {
    cursor: grabbing;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.modal h3 {
    margin-bottom: 15px;
    color: #495057;
}

.modal input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 15px;
}

.modal input:focus {
    outline: none;
    border-color: #007bff;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}

.btn-danger:hover {
    background: #c82333;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 150px;
}

.menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #495057;
    transition: background 0.2s ease;
}

.menu-item:hover {
    background: #f8f9fa;
}

.menu-item:first-child {
    border-radius: 5px 5px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 5px 5px;
}

/* Enhanced Chord Display Header */
.chord-display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.chord-display-header h2 {
    margin: 0;
    flex: 1;
}

.progression-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.progression-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: #6c757d;
    min-width: 100px;
}

.progression-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 6px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.action-btn.active {
    background: #007bff;
    color: white;
}

/* Enhanced chord items with more context */
.chord-item {
    position: relative;
}

.chord-item.has-substitutions::after {
    content: "✨";
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.7rem;
    color: #ffc107;
}

.chord-item.edited::after {
    content: "✏️";
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.7rem;
}

.chord-item .chord-function {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: normal;
    white-space: nowrap;
}

.chord-item .chord-notes {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: normal;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
}

/* Slot selection and navigation */
.selected-slot-display {
    background: #e7f3ff;
    border: 1px solid #007bff;
    border-radius: 6px;
    padding: 15px;
    margin: 8px 0;
    font-size: 1rem;
}

.slot-selection-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.slot-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.slot-navigation button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    min-height: 40px;
    transition: all 0.2s ease;
}

.slot-navigation button:hover {
    background: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
}

.slot-navigation input[type="number"] {
    width: 60px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    min-height: 40px;
    box-sizing: border-box;
}

.slot-navigation input[type="number"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

/* Enhanced visual feedback for selected slot */
.chord-item.selected-for-piano {
    border: 3px solid #28a745 !important;
    background: #d4edda !important;
    animation: pulse-green 2s infinite;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.5);
}

.chord-item.selected-for-piano::before {
    content: "SELECTED";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 10px rgba(40, 167, 69, 0.5); }
    50% { box-shadow: 0 0 20px rgba(40, 167, 69, 0.8); }
    100% { box-shadow: 0 0 10px rgba(40, 167, 69, 0.5); }
}

/* Roman Numeral Section */
.roman-numeral-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.roman-numeral-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
}

/* Chord Type Tabs */
.chord-type-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 10px;
}

.chord-tab {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
    min-width: 100px;
}

.chord-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.chord-tab.active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Chord Groups */
.chord-group {
    display: none;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.chord-group.active {
    display: flex;
}

/* Chord Categories within groups */
.chord-category {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.category-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Roman numeral button groups */
.roman-numeral-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

/* Enhanced Roman numeral buttons */
.roman-chord-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 50px;
    position: relative;
    backdrop-filter: blur(10px);
}

.roman-chord-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.roman-chord-btn.active,
.roman-chord-btn.selected {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border-color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.roman-chord-btn.selected:hover {
    background: rgba(255, 255, 255, 1);
    color: #667eea;
}

/* Tooltip enhancement for chord buttons */
.roman-chord-btn::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: normal;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.roman-chord-btn:hover::after {
    opacity: 1;
}

/* Roman chord info display */
.roman-chord-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px 24px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    margin-top: 10px;
}

#roman-chord-display {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
}

/* Color coding for different chord types */
.chord-group[data-group="triads"] .roman-chord-btn {
    border-color: rgba(76, 175, 80, 0.6);
}

.chord-group[data-group="triads"] .roman-chord-btn:hover {
    border-color: rgba(76, 175, 80, 0.8);
    background: rgba(76, 175, 80, 0.2);
}

.chord-group[data-group="sevenths"] .roman-chord-btn {
    border-color: rgba(255, 193, 7, 0.6);
}

.chord-group[data-group="sevenths"] .roman-chord-btn:hover {
    border-color: rgba(255, 193, 7, 0.8);
    background: rgba(255, 193, 7, 0.2);
}

.chord-group[data-group="secondary"] .roman-chord-btn {
    border-color: rgba(255, 87, 34, 0.6);
}

.chord-group[data-group="secondary"] .roman-chord-btn:hover {
    border-color: rgba(255, 87, 34, 0.8);
    background: rgba(255, 87, 34, 0.2);
}

.chord-group[data-group="advanced"] .roman-chord-btn {
    border-color: rgba(156, 39, 176, 0.6);
}

.chord-group[data-group="advanced"] .roman-chord-btn:hover {
    border-color: rgba(156, 39, 176, 0.8);
    background: rgba(156, 39, 176, 0.2);
}

/* Responsive design for Roman numeral section */
@media (max-width: 768px) {
    .chord-type-tabs {
        flex-direction: column;
        gap: 4px;
    }
    
    .chord-tab {
        min-width: auto;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .roman-numeral-buttons {
        gap: 6px;
    }
    
    .roman-chord-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        min-width: 45px;
    }
    
    .category-label {
        font-size: 0.8rem;
        padding: 4px 10px;
    }
    
    .roman-chord-info {
        padding: 15px 18px;
        font-size: 1rem;
    }
    
    #roman-chord-display {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .chord-type-tabs {
        padding: 2px;
    }
    
    .chord-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .roman-numeral-buttons {
        gap: 4px;
    }
    
    .roman-chord-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 40px;
    }
    
    .chord-category {
        gap: 8px;
    }
    
    .category-label {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    
    .roman-chord-info {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    #roman-chord-display {
        font-size: 1rem;
    }
}



/* Additional Print Optimizations */
@media print {
    /* Ensure consistent typography */
    .roman-numeral-section {
        background: none !important;
        color: black !important;
    }
    
    .roman-numeral-section h2 {
        color: #333 !important;
    }
    
    /* Better button styling for print */
    button, .roman-chord-btn, .chord-tab {
        border: 1pt solid #333 !important;
        background: white !important;
        color: black !important;
        font-size: 9pt !important;
        padding: 3pt 6pt !important;
    }
    
    .chord-tab.active {
        background: #e0e0e0 !important;
        font-weight: bold !important;
    }
    
    /* Optimize space usage */
    .roman-numeral-controls {
        gap: 10pt;
    }
    
    .chord-group {
        display: block !important;
        margin-bottom: 12pt;
    }
    
    .chord-group[data-group]:not(.active) {
        display: block !important;
    }
    
    /* Print layout adjustments */
    .piano-controls {
        display: none !important;
    }
    
    .selected-notes, .slot-selection-info {
        display: none !important;
    }
    
    /* Improve text contrast */
    .print-instruction {
        color: #666 !important;
        font-style: italic;
    }
    
    /* Page numbering */
    .print-page-number {
        position: fixed;
        bottom: 10pt;
        right: 10pt;
        font-size: 9pt;
    }
}

/* Screen-only styles to hide print instructions */
@media screen {
    .print-instruction {
        display: none;
    }
}