:root {
    --bg-color: #87CEEB; /* Sky blue for light mode */
    --ui-bg: rgba(255, 255, 255, 0.8);
    --text-color: #333;
    --btn-bg: #FF5722;
    --btn-text: #fff;
}

body.dark-mode {
    --bg-color: #1a1a2e; /* Midnight blue for dark mode */
    --ui-bg: rgba(0, 0, 0, 0.8);
    --text-color: #fff;
    --btn-bg: #4a4e69;
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden; /* Prevent scrolling */
    transition: background-color 0.5s;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 600px;
    background: var(--bg-color);
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    border-radius: 10px;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to game if not on buttons */
}

#score, #high-score {
    font-size: 1.5rem;
    font-weight: bold;
    background: var(--ui-bg);
    padding: 5px 15px;
    border-radius: 5px;
}

button {
    pointer-events: auto;
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: var(--btn-bg);
    color: var(--btn-text);
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.95);
}

#theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
}

.main-buttons {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--container-bg, #fff);
    color: var(--text-color, #333);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
}

body.dark-mode .modal-content {
    background-color: #1e1e1e;
    color: #fff;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
}

.form-group textarea {
    height: 100px;
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.submit-btn:hover {
    background-color: #45a049;
}

#joystick-container {
    position: absolute;
    bottom: 50px;
    left: 50px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    z-index: 20;
    pointer-events: auto;
    touch-action: none;
}

#joystick-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(0,0,0,0.4);
}

body.dark-mode #joystick-container {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode #joystick-handle {
    background: rgba(200, 200, 255, 0.8);
}