/*
 * GemRush - Stylesheet for the canvas-based game
 * This file contains all CSS rules for the game's UI, canvas, and responsive design.
 * Designed to be modular, maintainable, and compatible with modern browsers.
 */

/* ==========================================================================
   Global Styles
   ========================================================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: #222831; /* Dark background for contrast */
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* Prevent scrollbars during gameplay */
    color: #EEEEEE; /* Light text for readability */
    position: relative;
}

/* ==========================================================================
   Main Container
   ========================================================================== */
#container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 900px;
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
}

/* ==========================================================================
   Settings Button
   ========================================================================== */
#settingsButton {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    font-size: 16px;
    background: #393E46; /* Neutral background */
    color: #EEEEEE;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    z-index: 10; /* Ensure visibility over other elements */
}

#settingsButton:hover {
    background: #00ADB5; /* Accent color on hover */
    color: #222831;
}

/* ==========================================================================
   Settings Panel
   ========================================================================== */
#settingsPanel {
    display: none; /* Hidden by default */
    position: absolute;
    top: 70px;
    right: 20px;
    background: #393E46;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 11;
    width: 220px;
}

.settings-item {
    margin-bottom: 15px;
}

.settings-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #A9B2B9; /* Muted text for labels */
}

/* Buttons within settings panel */
#fullscreenButton, #soundToggleButton {
    width: calc(100% - 10px);
    padding: 10px;
    font-size: 16px;
    background: #00ADB5;
    color: #222831;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-top: 5px;
}

#fullscreenButton:hover, #soundToggleButton:hover {
    background: #EEEEEE;
    color: #00ADB5;
}

/* Volume slider styling */
#volumeSlider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #4A535E;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ADB5;
    cursor: pointer;
}

#volumeSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00ADB5;
    cursor: pointer;
    border: none;
}

/* ==========================================================================
   Game Canvas
   ========================================================================== */
#gameCanvas {
    border: 4px solid #00ADB5; /* Accent border */
    background: #393E46;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    width: 100%;
    max-width: 800px;
    height: 500px;
    touch-action: manipulation; /* Optimize for touch controls */
}

/* ==========================================================================
   UI Elements
   ========================================================================== */
#ui {
    margin-top: 30px;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 800px;
    color: #A9B2B9;
}

/* ==========================================================================
   Start and Game Over Screens
   ========================================================================== */
#startScreen, #gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2A323A;
    padding: 50px;
    border-radius: 18px;
    color: #EEEEEE;
    text-align: center;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
    max-width: 600px;
    width: 95%;
}

#startScreen h1, #gameOver h2 {
    margin: 0 0 30px;
    font-size: 42px;
    color: #00ADB5;
}

#startScreen p, #gameOver p {
    margin: 0 0 30px;
    font-size: 18px;
    line-height: 1.6;
    opacity: 0.9;
}

/* Start, play again, and next level buttons */
#startButton, #playAgain, #nextLevel {
    padding: 15px 40px;
    font-size: 20px;
    background: #00ADB5;
    color: #222831;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#startButton:hover, #playAgain:hover, #nextLevel:hover {
    background: #EEEEEE;
    color: #00ADB5;
}

/* ==========================================================================
   Pause Message
   ========================================================================== */
#pauseMessage {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(42, 50, 58, 0.9);
    color: #EEEEEE;
    padding: 30px 60px;
    border-radius: 12px;
    font-size: 32px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   High Score Display
   ========================================================================== */
#highScore {
    font-size: 16px;
    opacity: 0.8;
    margin-bottom: 25px;
    color: #A9B2B9;
}

/* ==========================================================================
   Control Information
   ========================================================================== */
#controlInfo {
    margin-top: 30px;
    font-size: 14px;
    opacity: 0.7;
    text-align: center;
    width: 100%;
    max-width: 800px;
    color: #A9B2B9;
}

#controlInfo p {
    margin: 6px 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 600px) {
    #gameCanvas {
        height: 400px;
        border-width: 3px;
    }

    #ui {
        font-size: 16px;
        flex-direction: column;
        align-items: center;
        margin-top: 20px;
    }

    #ui > div {
        margin-bottom: 5px;
    }

    #startScreen, #gameOver {
        padding: 30px;
    }

    #startScreen h1, #gameOver h2 {
        font-size: 32px;
        margin-bottom: 20px;
    }

    #startScreen p, #gameOver p {
        font-size: 16px;
        margin-bottom: 20px;
    }

    #startButton, #playAgain, #nextLevel {
        padding: 12px 30px;
        font-size: 18px;
    }

    #pauseMessage {
        padding: 20px 40px;
        font-size: 24px;
    }

    #settingsButton {
        top: 15px;
        right: 15px;
        padding: 8px 15px;
        font-size: 14px;
    }

    #settingsPanel {
        top: 55px;
        right: 15px;
        width: 190px;
        padding: 15px;
        font-size: 14px;
    }
}