:root {
    --bg-color: #0e0e0e;
    /* Deepest black/grey */
    --panel-bg: #1a1a1a;
    /* Dark concrete */
    --text-main: #d0d0d0;
    /* Faded chalk/white */
    --text-dim: #707070;
    /* Old iron */
    --accent: #8c8c8c;
    /* Steel bars */
    --highlight: #8a3324;
    /* Dried blood / Rust */
    --font-stack: 'Courier New', Courier, monospace;
    /* Typewriter style */
    --border-style: 4px double var(--accent);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-stack);
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#main-container {
    width: 100%;
    max-width: 600px;
    height: 95vh;
    border: var(--border-style);
    background-color: var(--panel-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    position: relative;
}

/* Master Visual Section */
#master-visual {
    flex: 2;
    border-bottom: 2px solid var(--accent);
    background: radial-gradient(circle at center, #252525 0%, #000 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.master-silhouette {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 0px #444;
    letter-spacing: 0.2em;
}

.visual-scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.2) 50%, rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.3;
}

/* Dialogue Section */
#dialogue-box {
    flex: 1.2;
    /* Slightly larger for text readability */
    padding: 24px;
    border-bottom: 1px solid var(--accent);
    background-color: #111;
    font-size: 1.05rem;
    line-height: 1.8;
    overflow-y: auto;
    position: relative;
}

#dialogue-text {
    margin: 0;
    white-space: pre-wrap;
    /* Preserve line breaks */
}

.blinking-cursor {
    animation: blink 1s step-end infinite;
    font-weight: bold;
    color: var(--highlight);
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Action Area Section */
#action-area {
    flex: 1;
    padding: 24px;
    background-color: #141414;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--accent);
    border-left: 4px solid var(--accent);
    color: var(--text-main);
    padding: 16px 20px;
    font-family: var(--font-stack);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease-out;
    text-transform: uppercase;
    position: relative;
    /* Ensure relative for progress bar */
    overflow: hidden;
    /* Clip the progress bar */
    z-index: 1;
}

.action-btn:hover {
    background-color: var(--text-dim);
    color: #000;
    border-left-color: var(--highlight);
    padding-left: 28px;
}

.action-btn:active {
    background-color: var(--highlight);
    border-color: var(--highlight);
    color: #fff;
}

.btn-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background-color: var(--highlight);
    z-index: 0;
    opacity: 0.7;
    transition: width 0.3s ease;
}

/* Scrollbar styling for Webkit */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #000;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Rhythm Guide Styles - Appended to existing CSS */

#rhythm-guide {
    position: absolute;
    bottom: 20px;
    width: 80%;
    margin: 0 auto;
    text-align: center;
}

.cadence-bar {
    width: 100%;
    height: 10px;
    background-color: #333;
    border: 1px solid var(--accent);
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}

.cadence-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background-color: var(--text-main);
    /* Animation will be applied by JS class */
}

/* 2-1-2 Rhythm Animation  
       Total Cycle: 5s  
       0-2s: Down (Eccentric) - Bar fills (or empties, depending on metaphor. Let's say Fill = Exertion/Up? No, usually Down is Eccentric. Let's make it simple: Fill = Movement)  
       Let's visualize "Phases":  
       0% -> 40% (2s): Down (Bar fills Red?)  
       40% -> 60% (1s): Hold (Bar pulses)  
       60% -> 100% (2s): Up (Bar un-fills or fills Green?)  
        
       Actually, 'Master' says: "2s Down, 1s Hold, 2s Up".  
       Let's use a moving indicator or a bar that grows/shrinks.  
       Simple approach: Bar grows to 100% in 2s (Down), stays 1s, shrinks to 0% in 2s (Up).  
 */

.cadence-anim::after {
    animation: cadence-cycle 5s linear infinite;
}

@keyframes cadence-cycle {
    0% {
        width: 0%;
        background-color: var(--accent);
    }

    40% {
        width: 100%;
        background-color: var(--highlight);
    }

    /* Down complete */
    60% {
        width: 100%;
        background-color: var(--highlight);
    }

    /* Hold complete */
    100% {
        width: 0%;
        background-color: var(--accent);
    }

    /* Up complete */
}

.cadence-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

/* Helper functions in JS will toggle standard classes for text if needed,    
       but CSS animation is smoother for the bar. */

/* Effects */

@keyframes flash-screen {
    0% {
        background: #fff;
        filter: invert(1);
    }

    50% {
        background: #fff;
        filter: invert(1);
    }

    100% {
        background: var(--bg-color);
        filter: invert(0);
    }
}

.screen-flash {
    animation: flash-screen 0.5s ease-out;
}

.item-unlock-highlight {
    animation: highlight-pulse 2s infinite;
    border: 1px solid var(--highlight) !important;
}

@keyframes highlight-pulse {
    0% {
        box-shadow: 0 0 0px var(--highlight);
    }

    50% {
        box-shadow: 0 0 20px var(--highlight);
    }

    100% {
        box-shadow: 0 0 0px var(--highlight);
    }
}

.level-up-text {
    color: var(--highlight);
    text-shadow: 0 0 10px var(--highlight);
    font-size: 1.1rem;
}