/* CSS Variables & Reset */
:root {
    --font-main: 'Fredoka', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-sec: 'Varela Round', sans-serif;

    --color-primary: #FF6B6B;
    --color-secondary: #4ECDC4;
    --color-accent: #FFE66D;
    
    /* Default Light Mode */
    --color-dark: #2D3436;
    --color-light: #F7F9FC;
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: white;
    --text-color: #2D3436;
    --text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --color-dark: #F7F9FC;
    --color-light: #2D3436;
    --bg-gradient: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    --card-bg: #2c3e50;
    --text-color: #ecf0f1;
    --text-shadow: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: none; /* Prevent default touch actions like scrolling */
    user-select: none; /* Prevent text selection */
}

body {
    font-family: var(--font-main);
    overflow: hidden;
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    width: 100vw;
    transition: background 0.5s;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas by default */
}

.pointer-events-auto {
    pointer-events: auto;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 10;
    transition: opacity 0.3s;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none; /* Helper for JS toggling */
}

/* Main Menu */
.card {
    background: var(--card-bg);
    padding: 2rem 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 90%;
    width: 400px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

h1 {
    font-size: 3rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    text-shadow: var(--text-shadow);
}

.input-group {
    margin: 1.5rem 0;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
    background: white; /* Always white for input */
    color: #2D3436;
}

input[type="text"]:focus {
    border-color: var(--color-secondary);
}

.btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
    box-shadow: 0 6px 0px #e05e5e;
    transition: transform 0.1s, box-shadow 0.1s;
    margin: 10px;
    display: inline-block;
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0px #e05e5e;
}

.btn-secondary {
    background: var(--color-secondary);
    box-shadow: 0 6px 0px #3dbdb4;
    font-size: 1.2rem;
    padding: 10px 20px;
    color: white; /* Ensure text matches contrast */
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: bold;
}

.btn-secondary:active {
    box-shadow: 0 2px 0px #3dbdb4;
    transform: translateY(4px);
}

/* HUD */
#hud {
    display: none;
    width: 100%;
    height: 100%;
}

.hud-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: auto;
}

.hud-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    pointer-events: auto;
    display: flex;
    gap: 10px;
    align-items: center;
}

.stat-box {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 12px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    color: #2D3436; /* Always dark text for readability on light bg */
}

#leaderboard {
    position: absolute;
    top: 80px;
    right: 20px;
    background: rgba(0,0,0,0.3);
    color: white;
    padding: 10px;
    border-radius: 10px;
    width: 150px;
    pointer-events: none;
}

#leaderboard h3 {
    font-size: 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 5px;
    margin-bottom: 5px;
}

#leaderboard ol {
    padding-left: 20px;
    font-size: 0.9rem;
}

#mobile-controls {
    position: absolute;
    bottom: 20px;
    width: 100%;
    padding: 0 20px;
    display: none; /* Shown via JS on mobile */
    justify-content: space-between;
    pointer-events: none;
}

.touch-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    border: 2px solid white;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: var(--color-dark);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-weight: bold;
}

.touch-btn:active {
    background: rgba(255,255,255,0.8);
    transform: scale(0.95);
}

/* Color Selection */
.color-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.color-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s;
}

.color-dot:hover { transform: scale(1.2); }
.color-dot.selected { border-color: var(--color-dark); transform: scale(1.1); }
