* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }

body {
    background: #0a0a0a; color: #fff; font-family: system-ui, sans-serif;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; overflow: hidden; touch-action: none;
}

#game-wrapper {
    position: relative; width: 100%; max-width: 900px;
    aspect-ratio: 900/700; background: #111; border-radius: 12px;
    overflow: hidden; box-shadow: 0 0 40px rgba(0,0,0,0.7);
}

/* ВИДЕО ФОН */
#bg-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
    pointer-events: none; /* Клики проходят сквозь видео */
}

canvas { 
    position: relative;
    z-index: 2;
    display: none; 
    width: 100%; 
    height: 100%; 
    cursor: crosshair;
    background: transparent; /* Прозрачный фон для видимости видео */
}

/* Экраны */
#start-screen, #loading, #error-box {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    justify-content: center; align-items: center; background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    z-index: 10; text-align: center; padding: 20px;
}

#loading, #error-box { background: #111; display: none; }

#start-screen h1 { font-size: 3em; color: #FFD700; margin-bottom: 10px; text-shadow: 2px 2px 0 #000; }
#start-screen p { color: #ccc; margin-bottom: 20px; }

#start-btn, #error-box button {
    padding: 15px 40px; font-size: 1.3em; font-weight: bold;
    background: #FFD700; color: #000; border: none; border-radius: 50px;
    cursor: pointer; transition: transform 0.2s;
}

#start-btn:hover, #error-box button:hover { transform: scale(1.05); }

/* Загрузка */
.spinner {
    width: 50px; height: 50px; border: 5px solid #333;
    border-top: 5px solid #FFD700; border-radius: 50%;
    animation: spin 1s linear infinite; margin-bottom: 15px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Верхняя панель */
#top-bar {
    position: absolute; top: 0; left: 0; right: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 100%);
    padding: 10px 20px; display: flex; justify-content: space-around; align-items: center;
    z-index: 5; backdrop-filter: blur(4px);
    transition: opacity 0.3s;
}

#top-bar.hidden { display: none; opacity: 0; }

.stat {
    display: flex; flex-direction: column; align-items: center;
    padding: 5px 15px; background: rgba(255,255,255,0.1);
    border-radius: 8px; min-width: 100px;
}

.stat-label { font-size: 0.75em; color: #aaa; margin-bottom: 3px; }
.stat-value { font-size: 1.3em; font-weight: bold; color: #FFD700; }

/* Сообщение о разблокировке */
.unlock-msg {
    position: absolute; top: 65px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000; padding: 10px 25px; border-radius: 25px;
    font-weight: bold; font-size: 1.1em;
    box-shadow: 0 4px 15px rgba(255,215,0,0.4);
    animation: slideDown 0.4s ease-out;
    z-index: 6; white-space: nowrap;
}

.unlock-msg.hidden { display: none; }

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Всплывающие сообщения */
#notifications {
    position: absolute; inset: 0; pointer-events: none; z-index: 4;
}

.floating-msg {
    position: absolute; font-size: 1.4em; font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
    animation: floatUp 1.2s ease-out forwards;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}

/* Адаптив */
@media (max-width: 600px) {
    #start-screen h1 { font-size: 2em; }
    #top-bar { padding: 8px 10px; }
    .stat { min-width: 70px; padding: 5px 8px; }
    .stat-label { font-size: 0.65em; }
    .stat-value { font-size: 1.1em; }
}