:root {
    --bg-color: #050505;
    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: #888899;
    --glow-red: #ff3366;
    --glow-blue: #33ccff;
    --glow-green: #33ff99;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to Three.js canvas */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    pointer-events: auto; /* Re-enable pointer events for UI elements */
}

.top-bar {
    margin-top: 1rem;
    padding: 1rem 2rem;
    border-radius: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 90%;
    max-width: 600px;
    transition: transform 0.3s ease;
}

.controls-bar {
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.glass-select {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

.glass-select option {
    background: var(--bg-color);
    color: var(--text-main);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.label {
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.value {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.text-glow-red {
    color: var(--glow-red);
    text-shadow: 0 0 10px rgba(255, 51, 102, 0.5);
}

.text-glow-blue {
    color: var(--glow-blue);
    text-shadow: 0 0 10px rgba(51, 204, 255, 0.5);
}

.text-glow-green {
    color: var(--glow-green);
    text-shadow: 0 0 10px rgba(51, 255, 153, 0.5);
}

.glow-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.glow-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.glow-btn:active {
    transform: scale(0.95);
}

.glow-btn.small {
    width: 36px;
    height: 36px;
}

.glow-btn.inactive {
    opacity: 0.25;
    border-color: rgba(255, 255, 255, 0.05);
    filter: grayscale(100%);
}

.glow-btn.inactive:hover {
    opacity: 0.6;
    transform: scale(1.05);
    filter: grayscale(50%);
}

.glow-btn.active {
    opacity: 1.0;
    border-color: #00ffff;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.8), inset 0 0 15px rgba(0, 255, 255, 0.4);
    color: #00ffff;
    background: rgba(0, 255, 255, 0.15);
    transform: scale(1.1);
}

.glow-btn.active:hover {
    box-shadow: 0 0 35px rgba(0, 255, 255, 1.0), inset 0 0 20px rgba(0, 255, 255, 0.6);
    transform: scale(1.15);
}

.glow-btn.large {
    border-radius: 12px;
    width: auto;
    height: auto;
    padding: 1rem 2rem;
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
}

.glow-btn.large:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.1));
}

#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 3rem 4rem;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#message-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -40%) scale(0.9);
}

#message-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 4px;
    margin: 0;
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#message-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.controls-hint {
    position: absolute;
    bottom: 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    background: var(--glass-bg);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    pointer-events: none;
}

#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    touch-action: none; /* Crucial for custom touch/drag handlers on mobile */
}

/* Leaderboard Overlay */
#leaderboard-overlay {
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid rgba(51, 204, 255, 0.4);
    box-shadow: 0 0 30px rgba(51, 204, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    border-radius: 15px;
    z-index: 100;
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: opacity 0.4s ease;
}

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

#leaderboard-title {
    margin: 0 0 1rem 0;
    color: #33ccff;
    text-shadow: 0 0 10px #33ccff;
    font-size: 1.8rem;
    letter-spacing: 2px;
    text-transform: capitalize;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

#leaderboard-table th {
    color: #777;
    text-align: left;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard-table th:last-child,
#leaderboard-table td:last-child {
    text-align: right;
}

#leaderboard-table td {
    padding: 0.5rem 0;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#leaderboard-table tr:nth-child(1) td {
    color: #ffd700;
    text-shadow: 0 0 5px #ffd700;
    font-weight: bold;
}
#leaderboard-table tr:nth-child(2) td {
    color: #c0c0c0;
    text-shadow: 0 0 5px #c0c0c0;
}
#leaderboard-table tr:nth-child(3) td {
    color: #cd7f32;
    text-shadow: 0 0 5px #cd7f32;
}

/* Name Input Form */
#name-input-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#name-input-container.hidden {
    display: none;
}

#name-input-container input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #33ccff;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1.1rem;
    width: 80%;
    text-align: center;
    outline: none;
    box-shadow: inset 0 0 10px rgba(51, 204, 255, 0.1);
    transition: all 0.3s;
}

#name-input-container input:focus {
    box-shadow: 0 0 15px rgba(51, 204, 255, 0.4), inset 0 0 10px rgba(51, 204, 255, 0.2);
}

#name-input-container button {
    margin-top: 5px;
}
