/* Base styles for dark/arcade aesthetic */
body {
    margin: 0;
    padding: 0;
    background-color: #2c3e50;
    /* A dark theme color for modern aesthetic */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    user-select: none;
    /* Prevent text selection */
}

/* Outer wrapper for positioning context of game + ui */
#main-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    z-index: 10;
}

/* Container for canvas only - handles clipping */
#game-container {
    position: relative;
    width: 100%;
    aspect-ratio: 800 / 250;
    background-color: #ecf0f1;
    /* Bright background for the canvas like Chrome Dino */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

/* Canvas styling */
canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    /* Essential for pixel art rendering */
}

canvas.blurred {
    filter: blur(6px) grayscale(20%);
    transition: filter 0.3s ease;
}

/* UI overlay covers the main-wrapper area but doesn't clip children */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Height equals game-container height, but start-screen can overflow */
    pointer-events: none;
    /* Allow clicks/touches to pass through to document/canvas */
}

/* Score display top right */
#score-board {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 14px;
    color: #555;
    letter-spacing: 2px;
}

#hi-score {
    color: #888;
    margin-right: 15px;
}

#start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    pointer-events: auto;
    background: rgba(44, 62, 80, 0.95);
    padding: 30px;
    border-radius: 12px;
    border: 4px solid #f39c12;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    width: 80%;
    max-width: 400px;
}

#start-screen h1 {
    font-size: 24px;
    color: #f39c12;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.6);
}

.welcome-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #f39c12;
}

#start-screen .desc {
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 20px;
}

#start-btn {
    background-color: #27ae60;
    color: white;
    font-family: 'Press Start 2P', monospace;
    border: none;
    padding: 15px 20px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 0px #2ecc71;
    transition: all 0.1s;
    margin-bottom: 15px;
}

#start-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Style for the donation buttons */
.pixel-btn {
    display: inline-block;
    background-color: #e67e22;
    color: white;
    font-family: 'Press Start 2P', monospace;
    text-decoration: none;
    padding: 10px 15px;
    font-size: 10px;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 0px #d35400;
    transition: all 0.1s;
    margin-bottom: 15px;
    border: none;
    line-height: 1.5;
}

.pixel-btn:hover {
    background-color: #f39c12;
}

.pixel-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0px #d35400;
}

.green-btn {
    background-color: #27ae60;
    box-shadow: 0 4px 0px #2ecc71;
}

.green-btn:active {
    box-shadow: 0 2px 0px #2ecc71;
}

#game-over-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
    flex-wrap: wrap;
}

#donate-btn-start {
    display: block;
    width: fit-content;
    margin: 10px auto 25px auto;
}

#coffee-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    pointer-events: auto;
    background: rgba(44, 62, 80, 0.8);
    backdrop-filter: blur(5px);
    padding: 10px;
    border-radius: 50px;
    border: 2px solid #e67e22;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 8px;
    font-family: 'Press Start 2P', monospace;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#coffee-float:hover {
    transform: scale(1.1);
    background: rgba(52, 152, 219, 0.9);
    border-color: #f39c12;
}

#coffee-float span {
    font-size: 20px;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    pointer-events: auto;
    background: rgba(52, 152, 219, 0.92);
    /* calm blue */
    padding: 20px 35px;
    border-radius: 12px;
    border: 4px solid #e67e22;
    /* calm orange */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

#start-screen p,
#game-over p {
    margin: 10px 0;
}

#game-over p:first-child {
    font-size: 28px;
    color: #f39c12;
    /* bright orange */
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.6);
    margin-bottom: 20px;
}

#start-screen .subtitle {
    font-size: 10px;
    color: #bdc3c7;
    line-height: 1.5;
    margin-top: 15px !important;
}

#game-over .subtitle {
    font-size: 12px;
    color: #ecf0f1;
    margin-top: 25px !important;
}

/* Utility to hide elements easily */
.hidden {
    display: none !important;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    body {
        align-items: center;
        background-color: #000;
    }

    #main-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 50;
    }

    #game-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-width: none;
        transform: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 33.33vh;
        /* Place top of canvas exactly 1/3 from top */
        background-color: #2c3e50;
        /* Match body for mobile feel */
        overflow: visible;
        /* On mobile, let it be flexible */
    }

    #ui-layer {
        height: auto;
        aspect-ratio: 800 / 250;
        width: 100%;
        position: absolute;
        top: 33.33vh;
        /* Sync with canvas top */
    }

    /* Adjust canvas to fit width while staying at its top position */
    canvas {
        width: 100%;
        height: auto;
        aspect-ratio: 800 / 250;
        object-fit: contain;
    }
}