@import url('https://fonts.googleapis.com/css2?family=Lilita+One&display=swap');

/* ============================================================================
   LUMI SNAKE .IO - MASTER STYLESHEET
   ============================================================================
   Description: Main stylesheet for the game UI, menus, and overlays.
   Note: Designed to be fully responsive and easily customizable.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. CSS VARIABLES (Custom Properties)
   ---------------------------------------------------------------------------- */
:root {
    /* Variables used for the 3D "Oreo" text effect on the main title */
    --shadow1: #b5b5b5;
    --shadow2: #333333;
    --shadow3: #222222;
}

/* ----------------------------------------------------------------------------
   2. GLOBAL RESET & BASE STYLES
   ---------------------------------------------------------------------------- */
body, html {
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%;
    overflow: hidden; /* Prevents scrollbars during gameplay */
    background-color: #0c1014; /* Dark fallback background */
    touch-action: none; /* Prevents default browser touch gestures (like zooming) */
    font-family: "Lilita One", 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none; /* Prevents text highlighting while dragging/playing */
    color: white;
}

/* The main HTML5 canvas where the game engine renders the graphics */
canvas { 
    position: absolute; 
    top: 0; 
    left: 0; 
    display: block; 
    width: 100%; 
    height: 100%; 
    z-index: 1; /* Lowest layer, sits behind the UI */
}

/* Cinematic black screen overlay used for smooth transitions */
#fadeOverlay {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: #0c1014; 
    z-index: 500; /* High layer to cover everything */
    pointer-events: none; /* Allows clicks to pass through when transparent */
    opacity: 0; 
    transition: opacity 0.8s ease-in-out;
}

/* ----------------------------------------------------------------------------
   3. GAME OVER & RESULT SCREEN
   ---------------------------------------------------------------------------- */
#resultScreen {
    display: none; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0,0,0,0.85); /* Dark semi-transparent overlay */
    z-index: 400; 
    flex-direction: column;
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(10px); /* Blurs the game arena in the background */
}

#resultTitle { 
    font-family: "Lilita One", sans-serif;
    font-size: 72px; 
    margin-bottom: 10px; 
    letter-spacing: 5px; 
    text-transform: uppercase; 
    text-align: center;
}

#resultScoreDisplay {
    font-family: "Lilita One", sans-serif;
    color: #55FF55; 
    margin-bottom: 30px; 
    font-size: 36px; 
    letter-spacing: 2px; 
    text-shadow: 0 0 15px rgba(85,255,85,0.6); /* Neon green glow */
}

/* ----------------------------------------------------------------------------
   4. IN-GAME HEADS UP DISPLAY (HUD)
   ---------------------------------------------------------------------------- */
/* Wrapper for all in-game UI elements (Score, Leaderboard, Controls) */
#gameUI { 
    display: none; 
    z-index: 100; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; /* Let clicks pass through to the game canvas */
}

/* Player's current score display (Top Left) */
#scoreBoard {
    position: absolute; 
    top: 15px; 
    left: 15px; 
    font-size: 22px;
    background: rgba(0, 0, 0, 0.5); 
    padding: 15px; 
    border-radius: 12px; 
    border: 1px solid rgba(255,255,255,0.1); 
    backdrop-filter: blur(5px);
}
#score { 
    color: #55FF55; 
    text-shadow: 0 0 10px rgba(85,255,85,0.5); 
}
#playersAlive { 
    font-size: 16px; 
    margin-top: 8px; 
    color: #FF5555; 
    text-transform: uppercase;
}

/* Stamina/Boost Meter */
#boostBarContainer {
    margin-top: 10px; 
    width: 150px; 
    height: 8px; 
    background: rgba(0,0,0,0.5); 
    border-radius: 10px; 
    border: 1px solid #333; 
    overflow: hidden;
}
#boostBar { 
    width: 100%; 
    height: 100%; 
    background: #00FFFF; 
    border-radius: 10px; 
    transition: width 0.1s; 
    box-shadow: 0 0 10px #00FFFF;
}

/* Leaderboard panel (Top Right) */
#leaderboard {
    position: absolute; 
    top: 15px; 
    right: 15px; 
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1); 
    border-radius: 12px; 
    padding: 20px;
    width: 240px; 
    backdrop-filter: blur(5px); 
    font-size: 16px;
}
#leaderboard h3 { 
    margin: 0 0 15px 0; 
    font-size: 18px; 
    color: #aaa; 
    text-align: center; 
    text-transform: uppercase; 
    letter-spacing: 2px;
}
#leaderList { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
    font-family: "Lilita One", sans-serif; 
}
#leaderList li { 
    display: flex; 
    align-items: center; 
    padding: 6px 0; 
    border-bottom: 1px dashed rgba(255,255,255,0.1); 
    color: #ddd;
}
#leaderList li:last-child { border-bottom: none; }

/* Ranking movement indicators (Arrows) */
.rank-arrow { font-size: 18px; margin-right: 10px; min-width: 20px; text-align: center; }
.up { color: #55FF55; }
.down { color: #FF5555; }
.same { color: #555; }

.leader-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 1px;}
.leader-score { margin-left: 10px; color: #fff; }

/* Highlight the local player in the leaderboard */
#leaderList li.is-player { 
    color: #FFFACD; /* Pale Goldenrod for high contrast */
    text-shadow: 0 0 8px rgba(255,250,205,0.8); 
    font-size: 18px;
}

/* ----------------------------------------------------------------------------
   5. MOBILE TOUCH CONTROLS
   ---------------------------------------------------------------------------- */
#touchControls { display: none; } /* Hidden by default on Desktop */

#joystickZone { 
    position: absolute; 
    bottom: 80px; 
    left: 40px; 
    width: 180px; 
    height: 180px; 
    pointer-events: auto; /* Re-enable clicks inside the UI layer */
}
#joystickBase { 
    width: 160px; 
    height: 160px; 
    background: rgba(255,255,255,0.05); 
    border: 3px solid rgba(255,255,255,0.2); 
    border-radius: 50%;
    position: absolute; 
    top: 10px; 
    left: 10px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    backdrop-filter: blur(2px);
}
#joystickStick { 
    width: 70px; 
    height: 70px; 
    background: rgba(0, 255, 255, 0.5); 
    border-radius: 50%; 
    box-shadow: 0 0 25px #00FFFF; 
    position: relative; 
    transition: 0.1s ease-out;
}

#boostZone { 
    position: absolute; 
    bottom: 80px; 
    right: 50px; 
    pointer-events: auto;
}
#mobileBoostBtn {
    width: 100px; 
    height: 100px; 
    border-radius: 50%; 
    background: rgba(85, 255, 85, 0.15); 
    border: 3px solid #55FF55; 
    color: white; 
    font-size: 38px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    box-shadow: 0 0 25px rgba(85, 255, 85, 0.5); 
    user-select: none; 
    outline: none; 
    -webkit-tap-highlight-color: transparent; 
    backdrop-filter: blur(2px);
}
#mobileBoostBtn:active { 
    background: rgba(85, 255, 85, 0.5); 
    transform: scale(0.9); /* Depress effect */
}

/* ----------------------------------------------------------------------------
   6. MAIN MENU (START SCREEN) WITH OREO 3D EFFECT
   ---------------------------------------------------------------------------- */
#startMenu {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: radial-gradient(circle at center, rgba(12, 16, 20, 0.6) 0%, rgba(0,0,0, 0.9) 100%);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    z-index: 200;
}

.menu-container {
    background: rgba(15, 20, 25, 0.75); 
    padding: 40px; 
    border-radius: 24px; 
    border: 1px solid rgba(85, 255, 85, 0.3);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8), 0 0 25px rgba(85, 255, 85, 0.15); 
    text-align: center; 
    max-width: 400px; 
    width: 90%; 
    backdrop-filter: blur(12px);
}

/* Epic 3D "Oreo" Text Effect for the Game Title */
.menu-container h1 { 
    color: #ffffff;
    font-size: 70px;
    font-family: "Lilita One", sans-serif;
    margin-top: -10px;
    margin-bottom: 20px;
    letter-spacing: 2px;
    transform: scaleY(0.85); /* Slightly squash the text for a cartoonish look */
    text-shadow:
        0px 2px 0px var(--shadow1), 
        0px 4px 0px var(--shadow1), 
        0px 6px 0px var(--shadow1),
        0px 8px 0px var(--shadow1),
        0px 10px 0px var(--shadow1),
        3px -3px 0 var(--shadow2), 
        -3px -3px 0 var(--shadow2), 
        3px -2px 0 var(--shadow2), 
        -3px -2px 0 var(--shadow2), 
        3px 0px 0 var(--shadow2), 
        -3px 0px 0 var(--shadow2), 
        3px 2px 0 var(--shadow2), 
        -3px 2px 0 var(--shadow2), 
        3px 4px 0 var(--shadow2), 
        -3px 4px 0 var(--shadow2), 
        3px 6px 0 var(--shadow2), 
        -3px 6px 0 var(--shadow2), 
        3px 8px 0 var(--shadow2), 
        -3px 8px 0 var(--shadow2), 
        3px 10px 0 var(--shadow2), 
        -3px 10px 0 var(--shadow2), 
        3px 12px 0 var(--shadow2), 
        -3px 12px 0 var(--shadow2), 
        3px 14px 0 var(--shadow2), 
        -3px 14px 0 var(--shadow2), 
        3px 16px 0 var(--shadow2), 
        -3px 16px 0 var(--shadow2), 
        -3px 20px 0 var(--shadow3), 
        3px 20px 0 var(--shadow3),
        -3px 24px 0 var(--shadow3), 
        3px 24px 0 var(--shadow3), 
        3px 18px 0 var(--shadow3), 
        3px 20px 0 var(--shadow3), 
        3px 22px 0 var(--shadow3), 
        3px 24px 0 var(--shadow3), 
        3px 26px 0 var(--shadow3), 
        3px 28px 0 var(--shadow3),
        0px 5px 30px rgba(85,255,85,0.4); /* Underlying neon glow */
}

.best-score { 
    font-size: 16px; 
    color: #aaa; 
    margin-bottom: 25px; 
    text-transform: uppercase; 
    letter-spacing: 1px;
}
.best-score span { 
    color: #FFD700; 
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); /* Gold glow for score */
}

/* ----------------------------------------------------------------------------
   7. ANIMATED NICKNAME INPUT (GEMINI AI STYLE)
   ---------------------------------------------------------------------------- */
@property --rotation { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.gemini {
    --border-size: 3px;
    --gradient: conic-gradient(from var(--rotation) at 52% 49% in oklab, oklch(0.63 0.2 251.22) 27%, oklch(0.67 0.21 25.81) 33%, oklch(0.9 0.19 93.93) 41%, oklch(0.79 0.25 150.49) 49%, oklch(0.63 0.2 251.22) 65%, oklch(0.72 0.21 150.89) 93%, oklch(0.63 0.2 251.22));
    animation: rotate 5s infinite linear; 
    border-radius: 50px; 
    background: none; 
    position: relative; 
    padding: 0; 
    border: var(--border-size) solid rgba(255,255,255,0.08); 
    margin: 0 auto 25px auto; 
    width: 85%; 
    box-sizing: border-box; 
    transition: 0.3s;
}
.gemini::after { 
    content: ''; position: absolute; display: block; width: 100%; height: 100%; 
    background: var(--gradient); top: 50%; left: 50%; translate: -50% -50%; 
    z-index: -1; animation: rotate 5s infinite linear; filter: blur(15px); 
    border-radius: inherit; opacity: 0; transition: opacity 0.5s; 
}
/* Ignite the border gradient when user types */
.gemini.has-text::after { opacity: 0.8; }

.gemini .inner { 
    background: #11151a; color: #fff; padding: 12px 20px; position: relative; 
    z-index: 2; border-radius: inherit; display: grid; grid-template-columns: auto 1fr; 
    align-items: center; gap: 15px; transition: 0.3s; 
}
.gemini .inner .material-symbols-outlined { color: #888; font-size: 24px; transition: 0.3s; }
.gemini.has-text .inner .material-symbols-outlined { color: #55FF55; text-shadow: 0 0 10px rgba(85,255,85,0.6); }

.gemini .border { 
    position: absolute; inset: calc(var(--border-size) * -1); border-radius: inherit; 
    overflow: hidden; z-index: 1; pointer-events: none; 
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); 
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); 
    -webkit-mask-composite: xor; mask-composite: exclude; padding: var(--border-size); 
}
.gemini .border::after { 
    content: ''; position: absolute; width: 100%; height: 100%; background: var(--gradient); 
    top: 50%; left: 50%; translate: -50% -50%; filter: blur(3px); animation: rotate 5s infinite linear; 
    opacity: 0; transition: 0.5s; 
}
.gemini.has-text .border::after { opacity: 1; border: none; }
.gemini.has-text { border-color: transparent; }

.gemini input { 
    color: #fff; background: none; border: none; font-size: 20px; width: 100%; 
    outline: none; font-family: "Lilita One", sans-serif; text-align: left; letter-spacing: 1px;
}
.gemini input::placeholder { 
    color: #777; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 16px; 
}

@keyframes rotate { to { --rotation: 360deg; } }

/* Error Shake Animation (Triggered if user tries to play without a name) */
.error-shake { animation: shake 0.3s ease-in-out; }
.error-shake .inner { border: 1px solid #FF3333; background: rgba(255,0,0,0.05); }
.error-shake .inner .material-symbols-outlined { color: #FF3333; }
@keyframes shake { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-10px); } 
    50% { transform: translateX(10px); } 
    75% { transform: translateX(-10px); } 
}

/* ----------------------------------------------------------------------------
   8. SKIN SELECTOR CAROUSEL
   ---------------------------------------------------------------------------- */
.skin-selector { 
    display: flex; align-items: center; justify-content: space-between; 
    background: rgba(0, 0, 0, 0.5); padding: 12px; border: 1px solid rgba(255,255,255,0.1); 
    border-bottom: none; border-radius: 16px 16px 0 0; 
}
.skin-btn { 
    background: none; border: none; color: white; font-size: 24px; cursor: pointer; transition: 0.2s;
}
.skin-btn:hover { color: #55FF55; transform: scale(1.3); }

#skinNameDisplay { 
    font-size: 20px; text-align: center; letter-spacing: 1px; 
}

/* Container holding the skin preview HTML5 Canvas */
.skin-preview-container { 
    width: 100%; height: 120px; background: #000; margin-bottom: 25px; 
    border: 1px solid rgba(255,255,255,0.1); overflow: hidden; position: relative; 
    border-radius: 0 0 16px 16px; box-shadow: inset 0 0 40px rgba(0,0,0,1); 
}
#skinPreviewCanvas { 
    width: 100%; height: 100%; display: block; position: absolute; z-index: 2;
}

/* ----------------------------------------------------------------------------
   9. SETTINGS PANELS & PLAY BUTTON
   ---------------------------------------------------------------------------- */
.settings-grid { 
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 25px; 
}
.setting-box { 
    background: rgba(30, 35, 40, 0.6); padding: 12px 5px; border-radius: 12px; 
    font-size: 14px; border: 2px solid transparent; color: #ccc; text-align: center; 
    cursor: pointer; transition: 0.3s ease; letter-spacing: 0.5px; 
}
.setting-box:hover { 
    background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.3); 
    color: #fff; transform: translateY(-2px);
}

/* Big Green Play Button */
.play-btn { 
    font-family: "Lilita One", sans-serif; 
    background: linear-gradient(135deg, #00FF66, #00CC44); 
    color: #08100a; font-size: 26px; padding: 16px 40px; border: none; 
    cursor: pointer; width: 100%; text-transform: uppercase; letter-spacing: 2px; 
    border-radius: 50px; transition: 0.3s; 
    box-shadow: 0 8px 25px -6px rgba(0, 255, 102, 0.7); 
}
.play-btn:hover { 
    transform: translateY(-4px) scale(1.02); 
    box-shadow: 0 15px 30px -5px rgba(0, 255, 102, 0.8); 
}
.play-btn:active { 
    transform: translateY(1px); 
    box-shadow: 0 5px 15px -5px rgba(0, 255, 102, 0.5); 
}

/* ----------------------------------------------------------------------------
   10. SOCIAL BUTTONS & SHARE MODAL
   ---------------------------------------------------------------------------- */
.social-row { 
    display: flex; justify-content: space-around; margin-top: 20px; width: 100%;
}
.social-btn { 
    font-family: "Lilita One", sans-serif; background: none; border: none; 
    color: #888; font-size: 16px; cursor: pointer; transition: 0.2s; letter-spacing: 1px;
}
.social-btn:hover { color: #fff; transform: translateY(-2px); }

/* The Share Modal Wrapper */
#shareModal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); z-index: 300; justify-content: center; 
    align-items: center; backdrop-filter: blur(8px);
}
.modal-content { 
    background: #161b22; padding: 30px; text-align: center; 
    border: 1px solid rgba(255,255,255,0.1); width: 300px; 
    border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}

.close-modal { 
    position: absolute; top: 15px; right: 20px; color: #aaa; font-size: 24px; 
    cursor: pointer; background: none; border: none; transition: 0.2s;
}
.close-modal:hover { color: #ff5555; transform: scale(1.2); }

#qrcode { 
    margin: 20px auto; background: white; padding: 15px; width: 128px; border-radius: 12px; 
}

.share-action-btn { 
    font-family: "Lilita One", sans-serif; letter-spacing: 1px; display: block; 
    width: 100%; padding: 14px; margin-top: 12px; cursor: pointer; border: none; 
    text-transform: uppercase; border-radius: 12px; transition: 0.3s; font-size: 18px;
}
.btn-copy { background: #2a323d; color: white; }
.btn-copy:hover { background: #3b4654; transform: translateY(-2px);}

.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5d; box-shadow: 0 8px 15px rgba(37, 211, 102, 0.4); transform: translateY(-2px);}

/* ----------------------------------------------------------------------------
   11. RESPONSIVE MEDIA QUERIES (Mobile Devices)
   ---------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Shrink Leaderboard so it doesn't block the gameplay on small screens */
    #leaderboard { 
        width: 130px; padding: 10px; font-size: 11px; top: 10px; right: 10px; 
    }
    #leaderboard h3 { font-size: 13px; margin-bottom: 8px; letter-spacing: 1px;}
    #leaderList li { padding: 4px 0; }
    .rank-arrow { font-size: 12px; margin-right: 5px; min-width: 12px; }
    #leaderList li.is-player { font-size: 14px; }
    
    /* Shrink Scoreboard */
    #scoreBoard { font-size: 18px; padding: 10px; top: 10px; left: 10px; }
    #boostBarContainer { width: 100px; height: 6px; }
    #playersAlive { font-size: 14px; margin-top: 5px; }

    /* Adjust Main Menu size constraints */
    .gemini { width: 95%; }
    .menu-container h1 { font-size: 48px; }
    .menu-container { padding: 25px 20px; }
}