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

:root {
    --sky-blue: #50B8FF;
    --cloud-light: #FFFFFF;
    --cloud-shadow: #D8E8F0;
    --grass-light: #00E000;
    --grass-dark: #00A000;
    --wood-light: #E89818;
    --wood-dark: #984800;
    --ui-black: #000000;
    --ui-white: #FFFFFF;
    --bomb-blue: #00A8FF;
    --bomb-dark: #0058F8;
    --pink: #F800D8;
    --red: #F80000;
    
    --font-main: 'Press Start 2P', monospace;
    --pixel-size: 4px;
}

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

body {
    background-color: var(--sky-blue);
    font-family: var(--font-main);
    color: var(--ui-white);
    text-transform: uppercase;
    line-height: 1.4;
    -webkit-font-smoothing: none;
    image-rendering: pixelated;
    overflow-x: hidden;
}


body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
    background-size: 100% 4px;
    z-index: 999;
    pointer-events: none;
}


.bg-clouds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: -2;
    background-image: 
        radial-gradient(circle at 20px 20px, var(--cloud-light) 20px, transparent 21px),
        radial-gradient(circle at 40px 20px, var(--cloud-light) 20px, transparent 21px),
        radial-gradient(circle at 30px 40px, var(--cloud-light) 20px, transparent 21px);
    background-size: 120px 80px;
    background-position: 0 50px;
    opacity: 0.8;
    animation: panClouds 60s linear infinite;
}

@keyframes panClouds {
    from { background-position: 0 50px; }
    to { background-position: 1000px 50px; }
}


.game-viewport {
    max-width: 1024px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 80px 0 40px 0;
}


.tree-pillar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 64px;
    background: repeating-linear-gradient(
        to bottom,
        var(--wood-light),
        var(--wood-light) 8px,
        var(--wood-dark) 8px,
        var(--wood-dark) 16px
    );
    z-index: -1;
    border-left: 4px solid var(--ui-black);
    border-right: 4px solid var(--ui-black);
    box-shadow: inset 8px 0 0 rgba(0,0,0,0.2), inset -4px 0 0 rgba(255,255,255,0.3);
}
.tree-pillar.left { left: calc(50% - 512px); }
.tree-pillar.right { right: calc(50% - 512px); }


.branch {
    position: absolute;
    width: 120px;
    height: 48px;
    background: repeating-linear-gradient(
        to right,
        var(--wood-light),
        var(--wood-light) 8px,
        var(--wood-dark) 8px,
        var(--wood-dark) 16px
    );
    border: 4px solid var(--ui-black);
    z-index: -1;
    box-shadow: 0 8px 0 rgba(0,0,0,0.3);
}
.branch.left { top: 300px; left: calc(50% - 512px); border-left: none; border-radius: 0 24px 24px 0; }
.branch.right { top: 600px; right: calc(50% - 512px); border-right: none; border-radius: 24px 0 0 24px; }


.level-container {
    width: 760px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    z-index: 10;
    padding: 0 20px;
}


.retro-box {
    background-color: var(--ui-black);
    border: 4px solid var(--ui-black);
    box-shadow: 
        inset 0 0 0 4px var(--ui-white),
        8px 8px 0 rgba(0,0,0,0.5); 
    padding: 24px;
    position: relative;
}

.retro-box::before {
    content: '';
    position: absolute;
    top: 8px; left: 8px; right: 8px; bottom: 8px;
    background: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.03),
        rgba(255,255,255,0.03) 2px,
        transparent 2px,
        transparent 4px
    );
    pointer-events: none;
}

.retro-box h2 {
    font-size: 16px;
    margin-bottom: 24px;
    color: var(--bomb-blue);
    text-shadow: 2px 2px 0 var(--ui-black), -2px -2px 0 var(--ui-black), 2px -2px 0 var(--ui-black), -2px 2px 0 var(--ui-black);
    letter-spacing: 2px;
    display: inline-block;
    border-bottom: 4px solid var(--ui-white);
    padding-bottom: 8px;
}


.hud-top {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 880px;
    display: flex;
    justify-content: space-between;
    z-index: 100;
    pointer-events: none;
}

.hud-element {
    background-color: var(--ui-black);
    border: 4px solid var(--ui-black);
    box-shadow: inset 0 0 0 4px var(--ui-white);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
}

.hud-label {
    font-size: 10px;
    color: var(--sky-blue);
}

.hud-value {
    font-size: 16px;
    color: var(--ui-white);
}

.hud-value .blink {
    animation: blink 1s step-end infinite;
}


.hero {
    text-align: center;
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    background: rgba(0,0,0,0.6);
    border-radius: 16px;
    border: 4px solid var(--ui-black);
}

.hero-title {
    font-size: 48px;
    color: var(--ui-white);
    text-shadow: 
        4px 4px 0 var(--ui-black),
        -4px -4px 0 var(--ui-black),
        4px -4px 0 var(--ui-black),
        -4px 4px 0 var(--ui-black),
        0 8px 0 var(--ui-black);
    line-height: 1.2;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 12px;
    color: var(--grass-light);
    margin-bottom: 32px;
}


.sprite-container {
    position: relative;
    width: 128px;
    height: 128px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.btn-start {
    background-color: var(--red);
    color: var(--ui-white);
    border: 4px solid var(--ui-black);
    box-shadow: inset -4px -4px 0 rgba(0,0,0,0.3), inset 4px 4px 0 rgba(255,255,255,0.4), 4px 4px 0 var(--ui-black);
    padding: 16px 32px;
    font-family: var(--font-main);
    font-size: 16px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    text-decoration: none;
    display: inline-block;
}

.btn-start:active {
    transform: translate(4px, 4px);
    box-shadow: inset -4px -4px 0 rgba(0,0,0,0.3), inset 4px 4px 0 rgba(255,255,255,0.4), 0 0 0 var(--ui-black);
}

.btn-start:hover {
    background-color: #FF3030;
}


.dialogue-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.portrait-box {
    width: 120px;
    height: 120px;
    background-color: #181818;
    border: 4px solid var(--ui-black);
    box-shadow: inset 0 0 0 4px var(--ui-white);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    background-image: repeating-linear-gradient(45deg, #202020 25%, transparent 25%, transparent 75%, #202020 75%, #202020), repeating-linear-gradient(45deg, #202020 25%, #181818 25%, #181818 75%, #202020 75%, #202020);
    background-position: 0 0, 8px 8px;
    background-size: 16px 16px;
}

.dialogue-text {
    font-size: 12px;
    line-height: 1.8;
    flex-grow: 1;
}

.dialogue-text p {
    margin-bottom: 16px;
}

.continue-arrow {
    float: right;
    color: var(--pink);
    animation: bounceX 0.5s infinite alternate;
}

@keyframes bounceX {
    from { transform: translateX(0); }
    to { transform: translateX(8px); }
}


.stat-row {
    margin-bottom: 24px;
}

.stat-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
}

.stat-bar-container {
    height: 24px;
    border: 4px solid var(--ui-black);
    background-color: #380000;
    padding: 2px;
    box-shadow: inset 0 0 0 2px var(--ui-black);
}

.stat-bar-fill {
    height: 100%;
    background: repeating-linear-gradient(
        to right,
        var(--grass-light),
        var(--grass-light) 8px,
        var(--ui-black) 8px,
        var(--ui-black) 10px
    );
}

.fill-blue { background: repeating-linear-gradient(to right, var(--bomb-blue), var(--bomb-blue) 8px, var(--ui-black) 8px, var(--ui-black) 10px); }
.fill-pink { background: repeating-linear-gradient(to right, var(--pink), var(--pink) 8px, var(--ui-black) 8px, var(--ui-black) 10px); }


.quest-list {
    list-style: none;
}

.quest-item {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: flex-start;
}

.quest-icon {
    width: 32px;
    height: 32px;
    background-color: var(--ui-black);
    border: 2px solid var(--ui-white);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    flex-shrink: 0;
    box-shadow: 2px 2px 0 var(--bomb-blue);
}

.quest-text {
    font-size: 10px;
    line-height: 1.6;
    padding-top: 8px;
}


.ground-layer {
    height: 128px;
    background: repeating-conic-gradient(
        var(--grass-light) 0% 25%, 
        var(--grass-dark) 0% 50%
    );
    background-size: 32px 32px;
    border-top: 8px solid var(--ui-black);
    position: relative;
    margin-top: 48px;
    box-shadow: inset 0 8px 0 rgba(255,255,255,0.4);
}


.deco-sprite {
    position: absolute;
    image-rendering: pixelated;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}


.text-pink { color: var(--pink); }
.text-blue { color: var(--bomb-blue); }
.text-yellow { color: #F8D800; }

/* Music Fixed Controls */
.music-controls-fixed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.music-control-box {
    background: var(--ui-black);
    border: 2px solid var(--ui-white);
    padding: 10px;
    box-shadow: 4px 4px 0 var(--ui-black);
}

.volume-container input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bomb-blue);
    outline: none;
}

.volume-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    background: var(--ui-white);
    cursor: pointer;
    border: 1px solid var(--ui-black);
}


/* Game Styles */
.game-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative; /* Added for absolute children */
}

#game-canvas {
    background-color: #1a1a1a;
    border: 4px solid var(--ui-black);
    box-shadow: inset 0 0 0 4px var(--ui-white);
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    outline: none;
}

#game-canvas:focus {
    box-shadow: inset 0 0 0 4px var(--bomb-blue), 0 0 10px var(--bomb-blue);
}

.game-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none; /* Controlled by JS */
}

.gif-overlay {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    image-rendering: pixelated;
    z-index: 100;
}

.game-controls-hint {
    font-size: 10px;
    color: var(--grass-light);
    text-align: center;
    line-height: 1.6;
}

.game-status {
    font-size: 12px;
    color: var(--pink);
    min-height: 18px;
}
