/* Base styles (Light Mode Default) */
body {
    overscroll-behavior: none;
    background-color: #f8f9fa; /* Standard light background */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #212529; /* Default text color */
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth theme transition */
}

.container {
    padding-left: 1rem;
    padding-right: 1rem;
}

h1.display-5 {
    color: #0d6efd; /* Primary color */
}

/* Score Badges */
.badge { transition: background-color 0.3s ease, color 0.3s ease; }

/* --- Canvas --- */
#canvas-container {
    max-width: 600px;
    margin: 0 auto;
    border-radius: 12px;
    border: 1px solid #dee2e6;
    background-image: linear-gradient(to bottom right, #ffffff, #e9ecef); /* Light gradient */
    transition: background-image 0.3s ease, border-color 0.3s ease;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    background-color: #343a40; /* Darker canvas for contrast */
    image-rendering: pixelated;
    border-radius: 11px;
    transition: background-color 0.3s ease;
}

/* --- Touch Controls --- */
/* Removed empty ruleset as it was unnecessary */

#touch-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    padding: 8px;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    background-color: rgba(108, 117, 125, 0.7); /* Secondary color, semi-transparent */
    border-radius: 15px;
    user-select: none;
     transition: background-color 0.3s ease;
}

.touch-btn {
    background-color: rgba(248, 249, 250, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: clamp(1.8rem, 6vw, 2.2rem);
    color: #343a40;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; padding: 8px; line-height: 1; aspect-ratio: 1 / 1;
    user-select: none; -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    transition: background-color 0.1s ease-in-out, color 0.3s ease;
}
.touch-btn:active { background-color: rgba(220, 220, 220, 0.95); }

/* Grid placement for touch buttons (unchanged) */
#touch-up { grid-column: 2; grid-row: 1; } #touch-left { grid-column: 1; grid-row: 2; }
#touch-right { grid-column: 3; grid-row: 2; } #touch-down { grid-column: 2; grid-row: 2; }

/* --- Main Controls --- */
.btn, .form-select { transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease; }
.btn:active, .form-select:active { transform: scale(0.98); box-shadow: none !important; }

/* --- Dark Mode Styles --- */
[data-bs-theme="dark"] body {
    background-color: #212529; /* Bootstrap dark bg */
    color: #dee2e6; /* Bootstrap dark text */
}

[data-bs-theme="dark"] h1.display-5 {
    color: #0d6efd; /* Keep primary or adjust if needed */
}

/* Override specific Bootstrap dark theme components if needed */
[data-bs-theme="dark"] .badge.bg-secondary { background-color: #495057 !important; }
[data-bs-theme="dark"] .badge.bg-dark { background-color: #adb5bd !important; color: #212529 !important; }

[data-bs-theme="dark"] #canvas-container {
    border: 1px solid #495057;
    background-image: linear-gradient(to bottom right, #343a40, #212529); /* Dark gradient */
}

[data-bs-theme="dark"] #gameCanvas {
    background-color: #495057; /* Slightly lighter dark canvas */
}

[data-bs-theme="dark"] #touch-controls {
    background-color: rgba(33, 37, 41, 0.8); /* Darker transparent */
}

[data-bs-theme="dark"] .touch-btn {
    background-color: rgba(73, 80, 87, 0.9); /* Dark buttons */
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8f9fa; /* Light icons */
}
[data-bs-theme="dark"] .touch-btn:active { background-color: rgba(52, 58, 64, 0.95); }

[data-bs-theme="dark"] #gameOverModal .modal-content { background-color: #343a40; border-color: #dc3545; }
[data-bs-theme="dark"] #gameOverModal .modal-body { color: #dee2e6; }
[data-bs-theme="dark"] #modalHighScore { color: #f8f9fa !important; }
[data-bs-theme="dark"] #finalScore { color: #dc3545 !important; } /* Keep score red */

/* --- Media Queries --- */
@media (max-width: 991.98px) { /* Adjustments for tablet/smaller */
    .btn-lg, .form-select-lg { font-size: 1rem; padding: 0.6rem 1.1rem; }
    h1.display-5 { font-size: 2.2rem; } .fs-5 { font-size: 1rem !important; }
}
@media (max-width: 575.98px) { /* Adjustments for mobile */
    .btn-lg, .form-select-lg { font-size: 0.9rem; padding: 0.6rem 0.5rem; }
    .form-select-lg { padding-right: 2rem; }
    h1.display-5 { font-size: 1.9rem; } .fs-5 { font-size: 0.9rem !important; }
}