:root {
    --primary: #4facfe;
    --secondary: #00f2fe;
    --accent: #ff0844;
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 172, 254, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(255, 8, 68, 0.15), transparent 25%);
    color: white;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Typography */
.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 28px;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(79, 172, 254, 0.5);
    line-height: 1.4;
}

.subtitle {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 30px;
    font-size: 14px;
}

/* UI Containers */
.menu-container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: flex-start;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
    color: #e2e8f0;
}

/* Name Input */
.name-input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-family: 'Press Start 2P', cursive;
    text-transform: uppercase;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

.name-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.5);
}

/* Gender Selection */
.gender-selection {
    display: flex;
    gap: 15px;
}

.gender-selection input {
    display: none;
}

.gender-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.gender-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.gender-selection input:checked + .gender-card {
    border-color: var(--primary);
    background: rgba(79, 172, 254, 0.1);
    box-shadow: 0 0 15px rgba(79, 172, 254, 0.3);
}

.avatar-placeholder {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    border-radius: 50%;
}

.boy-avatar {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.girl-avatar {
    background: linear-gradient(135deg, #ff0844, #ffb199);
}

/* Buttons and Upload */
.upload-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px dashed var(--primary);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    background: rgba(79, 172, 254, 0.1);
}

.status-text {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 8px;
    text-align: center;
}

.preview-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

#facePreview {
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 15px rgba(79, 172, 254, 0.5);
    background-color: #222;
}

.glow-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.glow-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 172, 254, 0.4);
}

.glow-btn:disabled {
    background: #475569;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Game Canvas Area */
#gameContainer {
    position: relative;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: none; /* Changed by JS to flex */
    justify-content: center;
    align-items: center;
    background: black;
}

#gameCanvas {
    display: block;
    background-color: #5c94fc; /* Mario sky blue */
    width: 100%;
    height: 100%;
    object-fit: contain; /* Scales up while keeping 800x600 aspect ratio */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: center; /* Center the stats */
    pointer-events: none;
    font-family: 'Press Start 2P', cursive;
    font-size: 16px; /* Slightly larger text */
    text-shadow: 2px 2px 0px #000;
}

.stats {
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 10px;
}

.controls-hint {
    font-family: 'Roboto', sans-serif;
    font-size: 12px;
    background: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 5px;
}

/* Pause Menu */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
}

.pause-panel {
    text-align: center;
    padding: 30px;
    width: 350px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

/* Leaderboard */
.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
}

.leaderboard-item:nth-child(1) {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.3), rgba(218, 165, 32, 0.3));
    border-left: 4px solid #ffd700;
}
.leaderboard-item:nth-child(2) {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.3), rgba(169, 169, 169, 0.3));
    border-left: 4px solid #c0c0c0;
}
.leaderboard-item:nth-child(3) {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.3), rgba(139, 69, 19, 0.3));
    border-left: 4px solid #cd7f32;
}
/* Mobile Controls */
#mobileControls {
    position: absolute;
    bottom: 30px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 40px;
    z-index: 50;
    pointer-events: none;
}

.left-controls, .right-controls {
    pointer-events: auto;
}

.mobile-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: transform 0.1s, background 0.1s;
}

.mobile-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.4);
}

.mobile-btn span {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: white;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
}

.action-btn {
    width: 90px;
    height: 90px;
    background: rgba(255, 8, 68, 0.3);
    border-color: rgba(255, 8, 68, 0.5);
}

.dpad {
    display: grid;
    grid-template-areas: 
        ". up ."
        "left . right"
        ". down .";
    gap: 10px;
}

.dpad-up { grid-area: up; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }
.dpad-down { grid-area: down; }

/* Custom Checkbox / Toggle */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 14px;
    color: #e2e8f0;
    background: rgba(0,0,0,0.2);
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.toggle-container input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid var(--primary);
    border-radius: 6px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-container input:checked + .checkmark {
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.toggle-container input:checked + .checkmark::after {
    content: "L";
    position: absolute;
    transform: rotate(45deg) scaleX(-1);
    top: 2px;
    left: 7px;
    width: 6px;
    height: 12px;
    border-right: 3px solid white;
    border-bottom: 3px solid white;
}

@media (max-width: 800px) {
    .mobile-btn {
        width: 60px;
        height: 60px;
    }
    .action-btn {
        width: 80px;
        height: 80px;
    }
    #mobileControls {
        padding: 0 20px;
        bottom: 20px;
    }
}
