* { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; 
    background: radial-gradient(circle at center, #1e3c72 0%, #2a5298 50%, #111 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-user-select: none; user-select: none;
    /* Блокуємо скрол на мобільних: */
    touch-action: none; overscroll-behavior: none;
}

#online-counter {
    position: fixed; top: 15px; right: 20px;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
    color: #fff; font-weight: 600; font-size: 15px;
    padding: 8px 18px; border-radius: 20px; z-index: 1000; pointer-events: none;
    display: flex; align-items: center; gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3); border: 1px solid rgba(255, 255, 255, 0.1);
}

#btn-gonya { background: #fff9e6; color: #cc9900; border: 2px solid #ffcc00; }
#btn-gonya:hover { background: #ffcc00; color: white; }

        #training-modal {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.75);
            z-index: 4000;
            align-items: center;
            justify-content: center;
        }
        #training-modal.open { display: flex; }
        .training-box {
            background: #1a1a2e;
            border: 2px solid #4da6ff;
            border-radius: 16px;
            padding: 36px 44px;
            text-align: center;
            min-width: 320px;
        }
        .training-box h2 {
            color: #fff;
            font-size: 24px;
            margin-bottom: 8px;
        }
        .training-box p {
            color: #aaa;
            font-size: 14px;
            margin-bottom: 24px;
        }
        .diff-btns { display: flex; gap: 12px; justify-content: center; margin-bottom: 28px; }
        .diff-btn {
            padding: 12px 22px;
            border-radius: 10px;
            border: 2px solid #555;
            background: transparent;
            color: #ccc;
            font-size: 15px;
            cursor: pointer;
            transition: all .2s;
        }
        .diff-btn:hover  { transform: scale(1.06); }
        .diff-btn.active { color: #fff; }
        .diff-btn[data-d="easy"]   { border-color: #4dff88; }
        .diff-btn[data-d="easy"].active   { background: #4dff8822; color: #4dff88; }
        .diff-btn[data-d="medium"]{ border-color: #ffd633; }
        .diff-btn[data-d="medium"].active { background: #ffd63322; color: #ffd633; }
        .diff-btn[data-d="hard"]  { border-color: #ff4d4d; }
        .diff-btn[data-d="hard"].active   { background: #ff4d4d22; color: #ff4d4d; }
        .training-start-btn {
            padding: 13px 40px;
            font-size: 17px;
            border-radius: 10px;
            border: 2px solid #4da6ff;
            background: #4da6ff22;
            color: #4da6ff;
            cursor: pointer;
            transition: all .2s;
            margin-right: 10px;
        }
        .training-start-btn:hover { background: #4da6ff44; transform: scale(1.04); }
        .training-cancel-btn {
            padding: 13px 20px;
            font-size: 15px;
            border-radius: 10px;
            border: 2px solid #555;
            background: transparent;
            color: #888;
            cursor: pointer;
            transition: all .2s;
        }
        .training-cancel-btn:hover { color: #ccc; border-color: #888; }

#online-counter::before {
    content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    background-color: #00ffcc; box-shadow: 0 0 10px #00ffcc;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 204, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 204, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 204, 0); }
}

#auth, #menu {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    padding: 40px 50px; border-radius: 24px; text-align: center; 
    box-shadow: 0 15px 35px rgba(0,0,0,0.5), 0 0 20px rgba(77, 166, 255, 0.2); 
    border: 1px solid rgba(255, 255, 255, 0.5); z-index: 10; width: 90%; max-width: 450px;
}

h1 { color: #222; margin-top: 0; font-size: 28px; text-shadow: 1px 1px 2px rgba(255,255,255,0.8); }
h3 { color: #444; margin-bottom: 10px; }
.selection { margin-bottom: 20px; }

input { 
    width: 100%; padding: 14px 15px; margin-bottom: 15px; font-size: 16px; 
    border-radius: 12px; border: 2px solid #ddd; background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease; outline: none;
}
input:focus { border-color: #4da6ff; box-shadow: 0 0 8px rgba(77, 166, 255, 0.4); }

button { 
    padding: 12px 20px; margin: 6px; font-size: 16px; font-weight: bold; cursor: pointer; 
    border: none; border-radius: 12px; background-color: #f0f0f0; color: #333;
    transition: all 0.2s ease; -webkit-appearance: none; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
button:hover { transform: translateY(-3px); box-shadow: 0 7px 12px rgba(0,0,0,0.15); }
button:active { transform: translateY(0); box-shadow: 0 3px 5px rgba(0,0,0,0.1); }

#btn-korzhik { background: #e6f2ff; color: #0066cc; border: 2px solid #4da6ff; }
#btn-korzhik:hover { background: #4da6ff; color: white; }
#btn-karamelka { background: #ffe6f2; color: #cc0066; border: 2px solid #ff99cc; }
#btn-karamelka:hover { background: #ff99cc; color: white; }
#btn-kompot { background: #e6ffe6; color: #009900; border: 2px solid #33cc33; }
#btn-kompot:hover { background: #33cc33; color: white; }

.char-btn.active-btn, .mode-btn.active-btn {
    background: #4da6ff !important; color: white !important;
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.6); transform: scale(1.05);
}

.action-buttons { display: flex; flex-direction: column; align-items: center; margin-top: 30px; gap: 15px; }

#btn-start {
    width: 80%; padding: 20px; font-size: 24px; font-weight: 900; text-transform: uppercase; letter-spacing: 2px;
    background: linear-gradient(45deg, #00c6ff, #0072ff); color: white; border: none; border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 114, 255, 0.4); animation: pulseStart 2s infinite;
}
#btn-start:hover { transform: scale(1.05); background: linear-gradient(45deg, #0072ff, #00c6ff); }

@keyframes pulseStart {
    0% { box-shadow: 0 0 0 0 rgba(0, 114, 255, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(0, 114, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 114, 255, 0); }
}

#btn-spectate { background: rgba(0,0,0,0.05); border: 1px solid #ccc; color: #555; font-size: 14px; padding: 10px 20px; }

#gameCanvas { display: none; width: 100vw; height: 100vh; object-fit: cover; touch-action: none; outline: none; -webkit-tap-highlight-color: transparent; }
#status, #auth-status { font-size: 15px; font-weight: 600; color: #666; margin-top: 15px; }

#matchmaking-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(10, 15, 30, 0.9); backdrop-filter: blur(10px);
    z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#mm-text { color: white; margin-top: 40px; font-size: 22px; font-weight: 300; letter-spacing: 1px; animation: blinkText 1.5s infinite; }
@keyframes blinkText { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.radar {
    width: 120px; height: 120px; background: rgba(0, 255, 204, 0.2); border-radius: 50%;
    position: relative; border: 2px solid rgba(0, 255, 204, 0.5); box-shadow: 0 0 30px rgba(0, 255, 204, 0.3);
}
.radar::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 60px; height: 60px;
    background: conic-gradient(from 0deg, rgba(0,255,204,0) 70%, rgba(0,255,204,0.8) 100%);
    border-radius: 100% 0 0 0; transform-origin: bottom right; animation: scan 1.5s linear infinite; transform: translate(-100%, -100%);
}
@keyframes scan { 100% { transform: translate(-100%, -100%) rotate(360deg); } }

#chat-container {
    position: absolute; bottom: 20px; left: 20px; width: 320px;
    background: rgba(15, 20, 30, 0.75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.15); display: flex; flex-direction: column;
    z-index: 100; pointer-events: auto; transition: opacity 0.4s ease, transform 0.4s ease; opacity: 0.3; 
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#chat-container:hover, #chat-container:focus-within { opacity: 1 !important; transform: translateY(-5px); }
#chat-messages { height: 160px; overflow-y: auto; color: #eee; padding: 12px; font-size: 14px; text-align: left; text-shadow: 1px 1px 2px rgba(0,0,0,0.8); display: flex; flex-direction: column; gap: 6px; }
#chat-messages div { word-wrap: break-word; line-height: 1.3; }
#chat-messages div b { color: #4da6ff; font-weight: bold; }
#chat-messages::-webkit-scrollbar { width: 6px; }
#chat-messages::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 10px; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.4); border-radius: 10px; }
#chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.7); }
#chat-input-wrapper { display: flex; border-top: 1px solid rgba(255,255,255,0.15); padding: 6px; background: rgba(0,0,0,0.3); border-radius: 0 0 16px 16px; }
#chat-input { flex-grow: 1; border: none; padding: 10px 15px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); color: white; width: auto; outline: none; font-size: 14px; margin-bottom: 0; }
#chat-input::placeholder { color: rgba(255,255,255,0.6); }
#chat-input:focus { background: rgba(255, 255, 255, 0.2); box-shadow: none; }
#chat-btn { padding: 10px 15px; margin: 0 0 0 6px; border: none; background: #4da6ff; color: white; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: none; }
#chat-btn:hover { background: #66b3ff; transform: scale(1.05); }

#chat-toggle-btn {
    position: absolute; bottom: 240px; left: 20px; background: rgba(0, 0, 0, 0.6); color: white;
    border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; width: 40px; height: 40px;
    font-size: 20px; cursor: pointer; z-index: 101; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(5px); transition: all 0.3s ease; padding: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
#chat-toggle-btn:hover { transform: scale(1.15); background: rgba(77, 166, 255, 0.6); }
#chat-toggle-btn.chat-hidden { bottom: 20px; opacity: 0.5; }
#chat-toggle-btn.chat-hidden:hover { opacity: 1; }

@media (max-width: 600px) {
    #auth, #menu { width: 92%; padding: 25px 20px; }
    button { width: 100%; margin: 6px 0; padding: 15px; }
    #chat-container { width: 260px; bottom: 10px; left: 10px; }
    #chat-messages { height: 120px; font-size: 13px; }
    #online-counter { top: 10px; right: 10px; font-size: 13px; padding: 6px 12px; }
    #chat-toggle-btn { bottom: 180px; left: 10px; width: 35px; height: 35px; font-size: 16px; }
    #chat-toggle-btn.chat-hidden { bottom: 10px; }
}

/* =========================================
   ГОЛОСОВИЙ ЧАТ (VOICE CHAT UI)
   ========================================= */
#voice-settings {
    margin-top: 25px;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    text-align: left;
}

#voice-settings h3 {
    margin-top: 0;
    color: #4da6ff;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.voice-control-group {
    margin-bottom: 15px;
}

.voice-control-group label {
    color: #fff;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-control-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #4da6ff;
}

.voice-select {
    width: 100%;
    padding: 10px 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.voice-select:focus {
    border-color: #4da6ff;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(77, 166, 255, 0.3);
}

.voice-select option {
    background: #1e3c72; /* Темно-синій фон для опцій */
    color: white;
}
/* =========================================
   МОБІЛЬНА АДАПТАЦІЯ (ТЕЛЕФОНИ ТА ПЛАНШЕТИ)
   ========================================= */

/* 1. Робимо меню скролимим зсередини, щоб воно ніколи не вилазило за екран */
#auth, #menu {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Плавний скрол для iOS */
    scrollbar-width: none; /* Прибираємо візуальний скролбар (Firefox) */
}
#auth::-webkit-scrollbar, #menu::-webkit-scrollbar {
    display: none; /* Прибираємо скролбар (Chrome/Safari/Opera) */
}

/* 2. Компактний вигляд спеціально для телефонів */
@media (max-width: 768px) {
    #menu, #auth { padding: 15px; width: 95%; max-width: 400px; }
    
    #voice-settings { padding: 10px; margin-top: 10px; }
    #voice-settings h3 { font-size: 15px; margin-bottom: 5px; }
    .voice-control-group { margin-bottom: 8px; }
    .voice-control-group label { font-size: 13px; }
    .voice-select { padding: 6px; font-size: 13px; }
    
    .selection h3 { font-size: 14px; margin-bottom: 5px; }
    .char-btn, .mode-btn { padding: 8px 10px; font-size: 12px; margin: 3px; }
    
    .action-buttons button { padding: 12px; font-size: 16px; margin-top: 5px; }
    
    /* Зменшуємо заголовки щоб звільнити ще більше місця */
    #auth h1, #welcome-text { font-size: 22px; margin-bottom: 10px; }
    #my-elo-display { font-size: 16px; margin-bottom: 10px; }
}

/* ДОДАЙ ЦЕ В КІНЕЦЬ СВОГО style.css */
#auth, #menu {
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; 
    scrollbar-width: none; 
}
#auth::-webkit-scrollbar, #menu::-webkit-scrollbar {
    display: none; 
}

@media (max-width: 768px) {
    #menu, #auth { padding: 15px; width: 95%; max-width: 400px; }
    
    #voice-settings { padding: 10px; margin-top: 10px; }
    #voice-settings h3 { font-size: 15px; margin-bottom: 5px; }
    .voice-control-group { margin-bottom: 8px; }
    .voice-control-group label { font-size: 13px; }
    .voice-select { padding: 6px; font-size: 13px; }
    
    .selection h3 { font-size: 14px; margin-bottom: 5px; }
    .char-btn, .mode-btn { padding: 8px 10px; font-size: 12px; margin: 3px; }
    
    .action-buttons button { padding: 12px; font-size: 16px; margin-top: 5px; }
    #auth h1, #welcome-text { font-size: 22px; margin-bottom: 10px; }
    #my-elo-display { font-size: 16px; margin-bottom: 10px; }
}
