body {
    margin: 0; background: #05000a; 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;
}

#game-wrapper {
    position: relative; 
    width: 100vw; 
    max-width: 800px; 
    height: 100vh; 
    max-height: 850px; /* 🛑 АНТИЧІТ: блокує розтягування екрану по висоті при зумі */
    background: #0a0014; 
    border: 4px solid #ff4500; overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 69, 0, 0.3);
    box-sizing: border-box;
}

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: #ffaa00; text-shadow: 0 0 15px #ffaa00; 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: #ff4500; text-shadow: 0 0 25px #ff4500; transform: scale(1.1); animation: pulse 0.5s infinite alternate;}

@keyframes pulse {
    from { transform: scale(1.1); text-shadow: 0 0 20px #ff4500; }
    to { transform: scale(1.2); text-shadow: 0 0 40px #ffaa00; color: #ffaa00; }
}

.overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(10px);
    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(255, 170, 0, 0.1); border: 2px solid #ffaa00;
    border-radius: 15px; padding: 10px 20px; width: 80%; max-width: 300px;
    margin-bottom: 20px; flex-shrink: 0; box-shadow: 0 0 15px rgba(255,170,0,0.2);
}
.leaderboard-box h3 { color: #ffaa00; margin: 0 0 10px 0; font-size: 16px; text-transform: lowercase; }

#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(255,170,0,0.2); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { color: #ffaa00; width: 25px; text-align: left; font-size: 12px; }
.lb-name { flex-grow: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { color: #00ffff; font-weight: bold; }
.lb-wait { font-size: 10px; color: #555; text-align: center; width: 100%; }

.logo-container {
    background: #fff; padding: 15px 25px; border-radius: 20px;
    margin-bottom: 20px; box-shadow: 0 0 20px #ffffff, 0 0 40px #ff4500;
    display: flex; justify-content: center; align-items: center; flex-shrink: 0;
}
.logo { width: 200px; height: auto; display: block; }

h1.red { font-size: 32px; color: #ff0000; text-shadow: 0 0 25px #ff0000; margin-bottom: 15px; margin-top: 0; flex-shrink: 0;}
p { color: #aaa; margin-bottom: 20px; font-size: 16px; }

.input-group { position: relative; margin-bottom: 20px; flex-shrink: 0;}
#player-name {
    padding: 15px; border: 3px solid #00ffff; border-radius: 40px;
    background: rgba(0,0,0,0.6); 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(0, 255, 255, 0.4); transition: 0.3s;
}
#player-name::placeholder { color: #555; }
#player-name:focus { box-shadow: 0 0 35px rgba(0, 255, 255, 0.7); border-color: #fff; }
#player-name.input-error {
    border-color: #ff0000; box-shadow: 0 0 35px rgba(255, 0, 0, 0.8);
    animation: shake 0.4s ease-in-out;
}
.error-msg {
    position: absolute; bottom: -25px; left: 0; width: 100%;
    color: #ff0000; font-size: 14px; margin: 0; opacity: 0; transition: 0.3s;
}
.input-group.has-error .error-msg { opacity: 1; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.rules-box {
    text-align: left; background: rgba(0, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 255, 0.2); 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; }

.lang-switch { font-size: 14px; color: #555; font-weight: bold; }
.lang-btn { cursor: pointer; opacity: 0.4; 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: #ccc; 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: 18px; font-weight: bold; cursor: pointer; text-transform: lowercase; transition: 0.2s;
}
button:active { transform: scale(0.95); }
#btn-start, #btn-restart { background: #ff4500; color: #fff; box-shadow: 0 0 25px rgba(255,69,0,0.6); width: 220px;}
.alt { background: transparent; border: 2px solid #00ffff; color: #00ffff; box-shadow: 0 0 15px rgba(0,255,255,0.4); }
.x-btn { background: #000; border: 2px solid #fff; color: #fff; box-shadow: 0 0 15px rgba(255,255,255,0.4); }

.credits-footer {
    margin-top: 10px; padding-bottom: 20px; font-size: 11px; color: #aaa;
    text-transform: lowercase; letter-spacing: 1px; flex-shrink: 0;
}
.credits-footer a { color: #00ffff; text-decoration: none; transition: 0.2s; font-weight: bold; }
.credits-footer a:hover { color: #ff4500; text-shadow: 0 0 10px #ff4500; }

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