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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0a15;
    min-height: 100vh;
    color: #fff;
    overflow: hidden;
}

#gameCanvas { display: block; }

/* Game Cursor */
.game-cursor {
    position: fixed;
    width: 20px;
    height: 20px;
    border: 2px solid #48dbfb;
    border-radius: 50%;
    pointer-events: none;
    z-index: 150;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #48dbfb;
}

.game-cursor::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #48dbfb;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.game-cursor.hidden { display: none; }

/* UI Overlay */
.ui-overlay { position: fixed; pointer-events: none; z-index: 100; }
.top-left { top: 20px; left: 20px; }
.top-right { top: 20px; right: 20px; }
.bottom-right { bottom: 20px; right: 20px; }
.bottom-left { bottom: 20px; left: 20px; }

.panel {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

/* Stats */
.alive-counter { font-size: 1.5rem; font-weight: bold; }
.alive-counter span { color: #ff6b6b; }
.stats { display: flex; gap: 20px; margin-top: 10px; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.3rem; font-weight: bold; color: #48dbfb; }
.stat-label { font-size: 0.75rem; color: #888; }

/* Leaderboard */
.leaderboard { min-width: 200px; }
.leaderboard h3 { font-size: 1rem; margin-bottom: 10px; color: #feca57; }

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    margin-bottom: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    font-size: 0.85rem;
}

.leaderboard-item.player {
    background: rgba(72, 219, 251, 0.2);
    border: 1px solid rgba(72, 219, 251, 0.5);
}

.leaderboard-item .rank { width: 20px; font-weight: bold; color: #feca57; }
.leaderboard-item .snake-dot { width: 10px; height: 10px; border-radius: 50%; margin: 0 8px; }
.leaderboard-item .name { flex: 1; }
.leaderboard-item .score { color: #48dbfb; font-weight: bold; }

/* Minimap */
#minimap {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
}

/* Boost Bar */
.boost-bar-container { width: 200px; text-align: center; }
.boost-bar-bg { width: 100%; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; }
.boost-bar { height: 100%; background: linear-gradient(90deg, #feca57, #ff9f43); border-radius: 4px; transition: width 0.1s; }
.boost-label { font-size: 0.75rem; color: #888; margin-top: 5px; }

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.menu-overlay.hidden { display: none; }

.menu {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #48dbfb;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0 60px rgba(72, 219, 251, 0.3);
    max-height: 90vh;
    overflow-y: auto;
}

.menu h2 {
    font-size: 2.2rem;
    margin-bottom: 25px;
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Player Info */
.player-info { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 20px; }
.player-avatar { width: 60px; height: 60px; border-radius: 50%; border: 3px solid #48dbfb; }
.player-name { font-size: 1.3rem; font-weight: bold; }

/* Rating Display */
.rating-display { margin: 15px 0; padding: 15px; background: rgba(0, 0, 0, 0.4); border-radius: 15px; }
.rating-value { font-size: 2.5rem; font-weight: bold; color: #feca57; }
.rating-label { color: #888; margin-top: 5px; font-size: 0.9rem; }

/* Buttons */
.menu-buttons { display: flex; flex-direction: column; gap: 12px; }

.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary { background: linear-gradient(45deg, #48dbfb, #0abde3); color: #000; }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(72, 219, 251, 0.4); }

.btn-ranked { background: linear-gradient(45deg, #ff6b6b, #ee5a5a); color: #fff; }
.btn-ranked:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4); }

.btn-settings { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2); }
.btn-settings:hover { background: rgba(255, 255, 255, 0.2); }

.btn-danger { background: rgba(255, 107, 107, 0.2); color: #ff6b6b; border: 1px solid rgba(255, 107, 107, 0.3); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.3); }

.btn-leaderboard { background: linear-gradient(45deg, #feca57, #f39c12); color: #000; }
.btn-leaderboard:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(254, 202, 87, 0.4); }

/* Controls Hint */
.controls-hint {
    margin-top: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #888;
}

/* Game Over Stats */
.game-over-stats { margin: 20px 0; padding: 20px; background: rgba(0, 0, 0, 0.4); border-radius: 15px; }
.game-over-stats .place { font-size: 4rem; font-weight: bold; }

.place-gold { color: #ffd700; }
.place-silver { color: #c0c0c0; }
.place-bronze { color: #cd7f32; }
.place-top10 { color: #48dbfb; }
.place-neutral { color: #888; }
.place-negative { color: #ff6b6b; }

.rating-change { font-size: 1.5rem; margin-top: 10px; }
.rating-change.positive { color: #2ecc71; }
.rating-change.negative { color: #ff6b6b; }
.rating-change.neutral { color: #888; }

/* Full Leaderboard */
.full-leaderboard { text-align: left; max-height: 400px; overflow-y: auto; }

.full-leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.full-leaderboard-item.current {
    background: rgba(72, 219, 251, 0.2);
    border: 1px solid rgba(72, 219, 251, 0.5);
}

.full-leaderboard-item .rank-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 15px;
}

.full-leaderboard-item .player-avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.rank-1 { background: linear-gradient(45deg, #ffd700, #ffed4a); color: #000; }
.rank-2 { background: linear-gradient(45deg, #c0c0c0, #e8e8e8); color: #000; }
.rank-3 { background: linear-gradient(45deg, #cd7f32, #daa06d); color: #000; }

/* Player Indicator */
.player-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
    text-align: center;
    animation: fadeOut 2s ease-out forwards;
}

.player-indicator .arrow { font-size: 3rem; color: #48dbfb; animation: bounce 0.5s ease-in-out infinite; }
.player-indicator .text { font-size: 1.2rem; color: #fff; margin-top: 10px; }

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.loading-screen.hidden { display: none; }

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(72, 219, 251, 0.3);
    border-top-color: #48dbfb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text { margin-top: 20px; font-size: 1.2rem; color: #48dbfb; }

/* Animations */
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }
@keyframes fadeOut { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== MOBILE CONTROLS ==================== */

/* Hide mobile controls on desktop, show on touch devices */
.mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 80;
}

.mobile-controls.hidden { display: none; }

/* Boost Zone (Left side of screen) */
.boost-zone {
    position: absolute;
    left: 0;
    top: 0;
    width: 40%;
    height: 100%;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    transition: opacity 0.2s, background 0.2s;
}

.boost-zone.active {
    opacity: 0.7;
    background: rgba(254, 202, 87, 0.15);
}

.boost-zone-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(254, 202, 87, 0.5));
}

.boost-zone-text {
    font-size: 0.9rem;
    color: #feca57;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
}

/* Joystick Container (Right side of screen) */
.joystick-container {
    position: absolute;
    right: 0;
    top: 0;
    width: 60%;
    height: 100%;
    pointer-events: auto;
}

/* Joystick Base - appears where touched (fixed position for correct placement) */
.joystick-base {
    position: fixed;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(72, 219, 251, 0.15);
    border: 3px solid rgba(72, 219, 251, 0.4);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 30px rgba(72, 219, 251, 0.2);
    z-index: 85;
}

.joystick-base.hidden { display: none; }

/* Joystick Thumb */
.joystick-thumb {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #5ce1e6, #48dbfb, #0abde3);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(72, 219, 251, 0.6),
                inset 0 -3px 10px rgba(0, 0, 0, 0.3),
                inset 0 3px 10px rgba(255, 255, 255, 0.3);
    transition: transform 0.05s ease-out;
}

/* Mobile/Desktop visibility controls */
.mobile-hint { display: none; }
.desktop-hint { display: block; }

/* Detect touch device */
@media (hover: none) and (pointer: coarse) {
    .mobile-hint { display: block; }
    .desktop-hint { display: none; }

    /* Hide desktop cursor on mobile */
    .game-cursor { display: none !important; }

    /* Adjust UI panels for mobile */
    .ui-overlay.top-left { top: 10px; left: 10px; }
    .ui-overlay.top-right { top: 10px; right: 10px; }
    .ui-overlay.bottom-right { bottom: 80px; right: 10px; }
    .ui-overlay.bottom-left { bottom: 80px; left: 10px; }

    .panel { padding: 10px; }
    .alive-counter { font-size: 1.2rem; }
    .stats { gap: 12px; }
    .stat-value { font-size: 1.1rem; }
    .stat-label { font-size: 0.65rem; }

    .leaderboard { min-width: 150px; }
    .leaderboard h3 { font-size: 0.85rem; margin-bottom: 6px; }
    .leaderboard-item { font-size: 0.75rem; padding: 3px 5px; }

    #minimap { width: 120px; height: 120px; }

    .boost-bar-container { width: 150px; }
    .boost-label { font-size: 0.65rem; }
}

/* Small phones */
@media (max-width: 480px) {
    .ui-overlay.top-right { display: none; }
    #minimap { width: 100px; height: 100px; }
    .boost-bar-container { width: 120px; }

    .joystick-base { width: 120px; height: 120px; }
    .joystick-thumb { width: 50px; height: 50px; }
}
