:root {
    --bg-color: #0f172a;
    --game-bg: #1e293b;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --text-color: #1f2937;
    /* Dark Gray for light background */
    --success-color: #4ade80;
    --danger-color: #f87171;
}

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

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0fdf4;
    /* Green-50 */
    font-family: 'Outfit', sans-serif;
    color: #1f2937;
    /* Gray-800 */
    overflow: hidden;
    /* Prevent scrolling on mobile */
}

.game-container {
    position: relative;
    width: 384px;
    height: 640px;
    background-color: #ffffff;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    /* Responsive scaling */
    max-width: 100%;
    max-height: 100vh;
    aspect-ratio: 384 / 640;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    /* Overlay for visibility */
    backdrop-filter: blur(2px);
    /* Optional: slight blur for better contrast */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed, though we use keys */
}

.hud {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.score-box {
    color: var(--accent-color);
}

.timer-box {
    color: var(--text-color);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    /* Brighter overlay */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

h1 {
    font-size: 2.0rem;
    margin-bottom: 20px;
    color: var(--accent-color);
    /* Removed strong text-shadow for cleaner look on light bg */
    text-align: center;
    line-height: 1.1;
}

p {
    font-size: 1.2rem;
    margin-bottom: 30px;
}

.controls-hint {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    opacity: 0.7;
}

button {
    background: var(--accent-color);
    color: #ffffff;
    /* Explicit white text */
    border: none;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.game-over-buttons {
    display: flex;
    gap: 20px;
}

.mode-select {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.stats-container {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-great {
    color: var(--success-color);
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

.stat-miss {
    color: var(--danger-color);
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.4);
}

button:active {
    transform: translateY(0);
}

.difficulty-select {
    display: flex;
    gap: 40px;
    /* Increased gap between Normal and Hard */
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--text-color);
}

.difficulty-select label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Gap between checkbox and text */
}

.difficulty-select input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-color);
}

/* #flash-overlay removed */

.flash-success {
    animation: flashGreenBorder 0.4s ease-out;
}

.flash-danger {
    animation: flashRedBorder 0.4s ease-out;
}

@keyframes flashGreenBorder {
    0% {
        border-color: #4ade80;
        box-shadow: 0 0 30px #4ade80;
    }

    100% {
        border-color: var(--accent-glow);
        box-shadow: none;
    }
}

@keyframes flashRedBorder {
    0% {
        border-color: #f87171;
        box-shadow: 0 0 30px #f87171;
    }

    100% {
        border-color: var(--accent-glow);
        box-shadow: none;
    }
}

/* Modal Styles */
.modal-content {
    background: white;
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 90%;
    width: 400px;
    margin: 0 20px;
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 25px;
    /* Spacing below title */
    font-size: 1.8rem;
}

.modal-content ul {
    text-align: left;
    list-style: none;
    padding: 0;
    margin-bottom: 30px;
    /* Spacing below list */
    font-size: 1.1rem;
    color: #374151;
}

.modal-content li {
    margin-bottom: 15px;
    /* Spacing between list items */
    line-height: 1.6;
}

.modal-content button {
    margin-top: 10px;
}