body {
    margin: 0; background: #030008; color: #fff;
    font-family: 'orbitron', sans-serif;
    display: flex; justify-content: center; align-items: center;
    height: 100vh; overflow: hidden; touch-action: none;
    user-select: none; -webkit-user-select: none;
}

/* Красивий анімований фон на весь екран */
.ambient-background {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1;
    background: linear-gradient(45deg, #05000a, #1a0033, #0a0022, #2d004d);
    background-size: 400% 400%;
    animation: ambientShift 15s ease infinite;
}
@keyframes ambientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#game-wrapper {
    position: relative; width: 100vw; max-width: 800px; height: 100vh; max-height: 850px; 
    background: radial-gradient(circle at center, #1a0033 0%, #05000a 100%); 
    border: 4px solid #b026ff; overflow: hidden;
    box-shadow: 0 0 40px rgba(176, 38, 255, 0.4); box-sizing: border-box; transition: box-shadow 0.3s;
}
#game-wrapper.blink-active {
    box-shadow: inset 0 0 100px rgba(255, 0, 255, 0.6), 0 0 80px rgba(255, 0, 255, 0.8);
    border-color: #ff00ff;
}

canvas { position: absolute; inset: 0; z-index: 1; display: block; }

#ui { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; z-index: 100; pointer-events: none; }

.score-text { font-size: 28px; color: #ff00ff; text-shadow: 0 0 15px #ff00ff; font-weight: 900; }
.energy-text { font-size: 24px; color: #00ffff; text-shadow: 0 0 15px #00ffff; font-weight: 700; transition: 0.2s; }
.energy-text.fever { color: #fff; text-shadow: 0 0 25px #ff00ff, 0 0 40px #b026ff; transform: scale(1.1); animation: pulse 0.3s infinite alternate;}

@keyframes pulse {
    from { transform: scale(1.1); text-shadow: 0 0 20px #b026ff; }
    to { transform: scale(1.2); text-shadow: 0 0 50px #ff00ff; color: #ff00ff; }
}

.overlay {
    position: absolute; inset: 0; background: rgba(5, 0, 15, 0.85); backdrop-filter: blur(8px);
    display: none; flex-direction: column; align-items: center; justify-content: flex-start; 
    z-index: 200; text-align: center; padding: 30px 15px; box-sizing: border-box; overflow-y: auto; 
}
.overlay.active { display: flex; }

.leaderboard-box {
    background: rgba(176, 38, 255, 0.15); border: 2px solid #b026ff;
    border-radius: 15px; padding: 10px 20px; width: 80%; max-width: 300px;
    margin-bottom: 20px; flex-shrink: 0; box-shadow: 0 0 25px rgba(176, 38, 255, 0.4);
}
.leaderboard-box h3 { color: #e0b0ff; margin: 0 0 10px 0; font-size: 16px; text-transform: lowercase; text-shadow: 0 0 10px #b026ff; }

#lb-list { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.lb-row { display: flex; justify-content: space-between; align-items: center; color: #fff; font-size: 14px; padding: 3px 0; border-bottom: 1px solid rgba(176, 38, 255, 0.3); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { color: #ff00ff; width: 25px; text-align: left; font-size: 12px; }
.lb-name { flex-grow: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; }
.lb-score { color: #00ffff; font-weight: 900; text-shadow: 0 0 5px #00ffff; }
.lb-wait { font-size: 12px; color: #aaa; text-align: center; width: 100%; }

.logo-container { margin-bottom: 20px; flex-shrink: 0; }
.main-logo { width: 220px; height: auto; display: block; filter: drop-shadow(0 0 20px rgba(176, 38, 255, 0.8)); }

h1.red { font-size: 36px; color: #ff00ff; text-shadow: 0 0 25px #b026ff; margin-bottom: 15px; margin-top: 0; flex-shrink: 0;}
p { color: #ccaaff; margin-bottom: 20px; font-size: 16px; }

.input-group { position: relative; margin-bottom: 20px; flex-shrink: 0;}
#player-name {
    padding: 15px; border: 3px solid #b026ff; border-radius: 40px; background: rgba(20, 0, 40, 0.8); 
    color: #fff; font-family: 'orbitron'; font-size: 20px; text-align: center; outline: none;
    width: 260px; text-transform: lowercase; letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(176, 38, 255, 0.6); transition: 0.3s;
}
#player-name::placeholder { color: #7744aa; }
#player-name:focus { box-shadow: 0 0 40px rgba(255, 0, 255, 0.9); border-color: #ff00ff; }

.rules-box {
    text-align: left; background: rgba(176, 38, 255, 0.1); border: 1px solid rgba(176, 38, 255, 0.4); 
    border-radius: 15px; padding: 15px 20px; margin: 20px 0; width: 85%; max-width: 380px; flex-shrink: 0;
}
.rules-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rules-header h3 { color: #00ffff; margin: 0; font-size: 16px; text-transform: lowercase; text-shadow: 0 0 10px #00ffff; }

.lang-switch { font-size: 14px; color: #9955cc; font-weight: bold; }
.lang-btn { cursor: pointer; opacity: 0.5; transition: 0.3s; padding: 2px; }
.lang-btn.active { opacity: 1; color: #fff; text-shadow: 0 0 15px #ffffff; }

.rules-box ul { margin: 0; padding-left: 20px; color: #e0b0ff; font-size: 13px; text-transform: lowercase; }
.rules-box li { margin-bottom: 6px; }

.buttons { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 15px; width: 90%; flex-shrink: 0;}
button {
    padding: 15px 30px; border: none; border-radius: 40px; font-family: 'orbitron';
    font-size: 16px; font-weight: bold; cursor: pointer; text-transform: lowercase; transition: 0.2s;
}
button:active { transform: scale(0.95); }
#btn-start, #btn-restart { background: linear-gradient(90deg, #b026ff, #ff00ff); color: #fff; box-shadow: 0 0 25px rgba(176, 38, 255, 0.8); width: 220px;}
.alt { background: rgba(0,0,0,0.6); border: 2px solid #00ffff; color: #00ffff; box-shadow: 0 0 15px rgba(0,255,255,0.6); }
.x-btn { background: #000; border: 2px solid #fff; color: #fff; box-shadow: 0 0 15px rgba(255,255,255,0.5); }

.credits-footer { margin-top: 10px; padding-bottom: 20px; font-size: 12px; color: #9955cc; text-transform: lowercase; flex-shrink: 0; }
.credits-footer a { color: #ff00ff; text-decoration: none; transition: 0.2s; font-weight: bold; text-shadow: 0 0 5px #ff00ff; }

.ss-export { position: absolute; top: -9999px; left: -9999px; width: 600px; height: 600px; background: #0a0014; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 10px solid #b026ff; box-sizing: border-box; text-align: center; }
.ss-stone { width: 100px; margin-bottom: 25px; filter: drop-shadow(0 0 20px #00ffff); }
.ss-export h2 { color: #fff; font-size: 28px; text-shadow: 0 0 20px #ff00ff; margin-bottom: 20px; }
.ss-box { border: 4px solid #b026ff; padding: 15px 60px; background: rgba(176,38,255,0.1); border-radius: 15px; }
.ss-box p { color: #00ffff; font-size: 20px; margin: 0; }
#ss-score-val { color: #ff00ff; font-size: 70px; margin: 0; text-shadow: 0 0 30px #ff00ff; font-weight: 900; }
.ss-rocky { width: 140px; margin: 30px 0; filter: drop-shadow(0 0 25px #b026ff); }
.ss-foot { color: #ff00ff; font-size: 20px; font-weight: bold; }
