/* ==========================================
   Neon Snake - CSS Stylesheet
   ========================================== */

/* Theme Definitions */
:root {
    /* Cyberpunk Theme (Default) */
    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.4);
    --secondary: #ff007f;
    --secondary-glow: rgba(255, 0, 127, 0.4);
    --bg-color: #070716;
    --card-bg: rgba(20, 20, 45, 0.5);
    --border-color: rgba(0, 240, 255, 0.2);
    --text-color: #ffffff;
    --text-muted: #8a8ab0;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

[data-theme="matrix"] {
    --primary: #00ff41;
    --primary-glow: rgba(0, 255, 65, 0.4);
    --secondary: #008f11;
    --secondary-glow: rgba(0, 143, 17, 0.4);
    --bg-color: #050a05;
    --card-bg: rgba(10, 25, 10, 0.5);
    --border-color: rgba(0, 255, 65, 0.2);
    --text-color: #d1ffd6;
    --text-muted: #6e9a72;
}

[data-theme="crimson"] {
    --primary: #ff3b00;
    --primary-glow: rgba(255, 59, 0, 0.4);
    --secondary: #ffcc00;
    --secondary-glow: rgba(255, 204, 0, 0.4);
    --bg-color: #120303;
    --card-bg: rgba(30, 10, 10, 0.5);
    --border-color: rgba(255, 59, 0, 0.2);
    --text-color: #ffe6e6;
    --text-muted: #b08a8a;
}

[data-theme="aurora"] {
    --primary: #9d4edd;
    --primary-glow: rgba(157, 78, 221, 0.4);
    --secondary: #00f5d4;
    --secondary-glow: rgba(0, 245, 212, 0.4);
    --bg-color: #080315;
    --card-bg: rgba(25, 10, 45, 0.5);
    --border-color: rgba(157, 78, 221, 0.2);
    --text-color: #f3e8ff;
    --text-muted: #9f8fa5;
}

/* Base resets & Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.5s ease;
}

/* Ambient Background Glow */
.bg-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(0,0,0,0) 70%);
    z-index: -1;
    pointer-events: none;
    transition: background 0.5s ease;
    filter: blur(40px);
    opacity: 0.6;
}

/* Layout Container */
.container {
    display: flex;
    flex-direction: row;
    gap: 30px;
    max-width: 1100px;
    width: 95%;
    margin: 20px auto;
    z-index: 10;
}

/* Sidebar Styling */
.sidebar-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 280px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
    animation: snake-wiggle 3s ease-in-out infinite;
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.8rem;
    letter-spacing: 2px;
    color: var(--text-color);
}

.logo-area h1 span {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45), 0 0 15px var(--primary-glow);
}

/* Score Panel Stats */
.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.stat-box:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary-glow);
    letter-spacing: 1px;
}

.text-gold { color: #ffd700; text-shadow: 0 0 8px rgba(255, 215, 0, 0.4); }
.text-cyan { color: #00f0ff; text-shadow: 0 0 8px rgba(0, 240, 255, 0.4); }
.text-pink { color: #ff007f; text-shadow: 0 0 8px rgba(255, 0, 127, 0.4); }

/* Settings Panel */
.settings h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    color: var(--primary);
    text-shadow: 0 0 5px var(--primary-glow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.setting-item.toggle-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.setting-item label, .setting-item.toggle-item span {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Custom Select Dropdowns */
.setting-item select {
    background: rgba(10, 10, 25, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.setting-item select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Custom Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-glow);
    border-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Game Board Area */
.game-area {
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.canvas-container {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 25px var(--primary-glow);
    border: 2px solid var(--primary);
    background: #000;
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 600px;
    transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Game Overlay Screen */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: opacity 0.4s ease;
}

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

.overlay-content {
    text-align: center;
    padding: 30px;
}

.overlay-content h2 {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary-glow);
    animation: title-pulse 2s infinite alternate;
}

.overlay-content p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 30px;
}

.overlay-content p span {
    background: rgba(255, 255, 255, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
}

/* Glow Action Button */
.glow-button {
    background: transparent;
    color: var(--text-color);
    border: 2px solid var(--primary);
    padding: 12px 30px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    outline: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px var(--primary-glow);
}

.glow-button:hover {
    background: var(--primary);
    color: var(--bg-color);
    box-shadow: 0 0 30px var(--primary), 0 0 10px var(--primary);
    transform: scale(1.05);
}

.glow-button:active {
    transform: scale(0.98);
}

/* Control Row Under Canvas */
.controls-row {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 600px;
}

.control-btn {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 12px;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.control-btn:hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Mobile D-Pad (hidden by default) */
.mobile-controller {
    display: none;
    margin-top: 10px;
}

.dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    position: relative;
}

.dpad-middle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.dbtn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: active 0.1s ease, border-color 0.3s ease;
    touch-action: manipulation;
}

.dbtn:active {
    background: var(--primary);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--primary);
    border-color: var(--primary);
}

.dpad-center {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
}

/* Footer / Instructions styling */
footer {
    width: 100%;
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 40px;
}

footer span {
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

/* Animations */
@keyframes snake-wiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(5deg) scale(1.05); }
    75% { transform: rotate(-5deg) scale(0.95); }
}

@keyframes title-pulse {
    0% {
        text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-glow);
    }
    100% {
        text-shadow: 0 0 20px var(--primary-glow), 0 0 35px var(--primary), 0 0 10px var(--secondary);
    }
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .sidebar-panel {
        width: 100%;
        max-width: 600px;
    }
    .logo-area {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .overlay-content h2 {
        font-size: 2.2rem;
    }
    footer {
        display: none; /* Hide desktop instructions on small screens */
    }
    .mobile-controller {
        display: block; /* Show D-Pad on small screens */
    }
}
