:root {
    /* Acoustic guitar body colors */
    --wood-light: #d4a373;
    --wood-mid: #a97546;
    --wood-dark: #6e4624;
    --soundhole-bg: #1a110a;
    --rosette-1: #3b2512;
    --rosette-2: #cca67c;
    --string-color: #f1f5f9;
    --string-thick: #94a3b8;
    --string-glow: rgba(255, 255, 255, 0.4);
    
    --bg-color: #2c2118;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
    background-color: var(--bg-color);
}

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#guitar-container {
    position: relative;
    background: radial-gradient(circle at center, var(--wood-mid) 0%, var(--wood-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s ease, width 0.3s ease, height 0.3s ease;
}

/* Portrait orientation -> Rotate interface to landscape */
@media (orientation: portrait) {
    #guitar-container {
        width: 100vh;
        width: 100dvh;
        height: 100vw;
        height: 100dvw;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(90deg);
        transform-origin: center;
    }
}

/* Landscape orientation -> Display normally */
@media (orientation: landscape) {
    #guitar-container {
        width: 100vw;
        width: 100dvw;
        height: 100vh;
        height: 100dvh;
        position: relative;
        top: auto;
        left: auto;
        transform: none;
    }
}

/* Optimize size for large desktop screens */
@media (orientation: landscape) and (min-width: 1024px) {
    #guitar-container {
        width: 100vw;
        width: 100dvw;
        max-width: 1024px;
        height: 100vh;
        height: 100dvh;
        margin: 0 auto;
    }
}

/* Top trim (similar to Kalimba) */
.top-trim {
    width: 100%;
    height: 10%;
    background: linear-gradient(to bottom, #111827, #1f2937);
    border-bottom: 2px solid #374151;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 25;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    box-sizing: border-box;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

@media (orientation: portrait) {
    .top-trim {
        padding-left: max(24px, env(safe-area-inset-top));
        padding-right: max(24px, env(safe-area-inset-bottom));
    }
}

.brand-logo {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    white-space: nowrap;
}

@media (min-width: 640px) {
    .brand-logo {
        font-size: 1.15rem;
        letter-spacing: 0.15em;
    }
}

/* Guitar Body Area */
.guitar-body {
    width: 100%;
    height: 90%;
    margin-top: 5%; /* Push down for top trim */
    display: flex;
    flex-direction: row; /* Chord panel on left, strings on right */
    position: relative;
    z-index: 10;
}

/* Chord Panel */
.chord-panel {
    width: 30%;
    max-width: 300px;
    height: 100%;
    background: rgba(15, 10, 5, 0.6);
    border-right: 2px solid rgba(0,0,0,0.3);
    box-shadow: 10px 0 20px rgba(0,0,0,0.3);
    padding: 15px;
    padding-left: max(15px, env(safe-area-inset-left));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    backdrop-filter: blur(5px);
}

@media (orientation: portrait) {
    .chord-panel {
        padding-left: max(15px, env(safe-area-inset-top));
    }
}

.chord-panel-title {
    color: #cbd5e1;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    margin-bottom: 12px;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chord-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    align-content: start;
}

.chord-btn {
    background: linear-gradient(to bottom, #374151, #1f2937);
    border: 1px solid rgba(255,255,255,0.1);
    color: #e2e8f0;
    border-radius: 8px;
    padding: 12px 0;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.chord-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.chord-btn.active {
    background: linear-gradient(to bottom, #d97706, #b45309);
    color: white;
    border-color: #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4), inset 0 2px 2px rgba(255,255,255,0.3);
}

/* Strum Area (Strings + Soundhole) */
.strum-area {
    width: 70%;
    flex-grow: 1;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.soundhole {
    position: absolute;
    width: min(50vh, 50vw);
    height: min(50vh, 50vw);
    border-radius: 50%;
    background: var(--soundhole-bg);
    box-shadow: inset 10px 10px 20px rgba(0,0,0,0.8), inset -5px -5px 15px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.rosette {
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    border-radius: 50%;
    border: 3px solid var(--rosette-1);
    box-shadow: 0 0 0 2px var(--wood-mid), 0 0 0 5px var(--rosette-2), 0 0 0 8px var(--rosette-1);
    position: absolute;
}

.strings-container {
    width: 100%;
    height: 60%;
    position: absolute;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 10%;
    box-sizing: border-box;
    /* This ensures touches within the string area register for glissando */
}

.string-wrapper {
    width: 100%;
    height: 15%; /* Touch target height */
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.guitar-string {
    width: 100%;
    /* Default thickness, overridden by JS */
    height: 3px; 
    background: linear-gradient(to bottom, #fff, var(--string-thick) 50%, #333);
    box-shadow: 0 4px 6px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.8);
    position: absolute;
    transform-origin: center;
}

/* String vibration animation */
.guitar-string.vibrate {
    animation: string-vibrate 0.4s ease-out;
}

@keyframes string-vibrate {
    0% { transform: scaleY(1) translateY(0); filter: drop-shadow(0 0 0 var(--string-glow)); }
    10% { transform: scaleY(2.5) translateY(-4px); filter: drop-shadow(0 0 8px var(--string-glow)); }
    20% { transform: scaleY(2.5) translateY(4px); }
    30% { transform: scaleY(2) translateY(-3px); }
    40% { transform: scaleY(2) translateY(3px); }
    50% { transform: scaleY(1.5) translateY(-2px); }
    60% { transform: scaleY(1.5) translateY(2px); }
    80% { transform: scaleY(1.2) translateY(-1px); }
    100% { transform: scaleY(1) translateY(0); filter: drop-shadow(0 0 0 var(--string-glow)); }
}

/* Floating pill instructions */
#instructions {
    position: absolute;
    bottom: max(25px, calc(10px + env(safe-area-inset-bottom)));
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: #cbd5e1;
    font-size: 0.85rem;
    background: rgba(15, 10, 5, 0.7);
    padding: 8px 22px;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
    backdrop-filter: blur(8px);
    z-index: 30;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* Flying notes (Amber/Gold for Acoustic feel) */
.flying-note {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 50;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.8) rotate(-10deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(1.5) rotate(15deg);
        opacity: 0;
    }
}

/* Start Overlay Styling */
#start-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(20, 15, 10, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    color: white;
    cursor: default;
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease, visibility 0.5s;
}

.start-card {
    background: rgba(30, 20, 12, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    padding: 36px 30px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.start-icon-container {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.15) 0%, rgba(180, 83, 9, 0.05) 100%);
    border: 1px solid rgba(217, 119, 6, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    box-shadow: 0 0 20px rgba(217, 119, 6, 0.1);
}

.start-icon {
    width: 32px;
    height: 32px;
    color: #f59e0b;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.4));
}

.start-title {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.start-subtitle {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-bottom: 30px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}

.start-btn {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: white;
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 8px 25px rgba(217, 119, 6, 0.4);
    transition: all 0.25s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: 0.06em;
    cursor: pointer;
    width: 100%;
    text-transform: uppercase;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(217, 119, 6, 0.5);
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-left-color: #f59e0b;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    #instructions {
        font-size: 0.75rem;
        padding: 6px 16px;
        width: 80%;
    }
}

/* Custom Modal Styling */
.custom-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}
.custom-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.custom-modal-overlay.hidden {
    display: none !important;
}

.custom-modal-content {
    background: linear-gradient(to bottom, #1e293b, #0f172a);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 2rem;
    padding: 2rem;
    max-width: 28rem;
    width: calc(100% - 2rem);
    margin: 0 1rem;
    box-shadow: 0 0 50px -12px rgba(0,0,0,0.7);
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    color: #e2e8f0;
    font-family: inherit;
    box-sizing: border-box;
}
.custom-modal-overlay.show .custom-modal-content {
    transform: scale(1);
}

.custom-modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    color: #94a3b8;
    background: #1e293b;
    border: 1px solid transparent;
    border-radius: 50%;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.custom-modal-close:hover {
    color: #fff;
    background: #334155;
    border-color: #475569;
}

.custom-modal-icon {
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(to bottom right, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.1));
    color: #f59e0b;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.custom-modal-title {
    font-size: 1.875rem;
    font-weight: 800;
    color: #fff;
    margin: 0 0 0.375rem 0;
    letter-spacing: -0.025em;
}

.custom-modal-subtitle {
    color: #f59e0b;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 1.5rem 0;
}

.custom-modal-body {
    font-size: 0.875rem;
    line-height: 1.625;
    color: #cbd5e1;
    margin-bottom: 2rem;
}
.custom-modal-body p {
    margin-top: 0;
    margin-bottom: 1rem;
}

.custom-modal-highlight {
    padding: 1rem;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 0.75rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.custom-modal-highlight p {
    margin: 0;
    font-size: 0.875rem;
}
.custom-modal-highlight strong {
    color: #fff;
}
.custom-modal-highlight-img {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.375rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.custom-modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: linear-gradient(to right, #d97706, #f59e0b);
    color: #fff;
    font-weight: 700;
    text-align: center;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
    box-sizing: border-box;
}
.custom-modal-btn:hover {
    background: linear-gradient(to right, #f59e0b, #fbbf24);
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.5);
    transform: translateY(-2px);
}
