/* style.css */

/* ОСНОВНІ КОЛЬОРИ ТА ЗМІННІ */
:root {
    --bg-color: #1a1a1a;
    --ui-color: #333;
    --accent-color: #ffcc00;
    --text-color: #fff;
    --container-max-width: 500px;
    --generalissimo-color: #ff00ff;
    --superboss-color: #bf00ff;
    --hardcore-border: #ff3300;
}

/* ГЛОБАЛЬНІ НАЛАШТУВАННЯ ТА СКИДАННЯ СТИЛІВ */
* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000;
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    height: 100dvh; 
}

/* ІНТЕРФЕЙС ВЕРХНЬОЇ ПАНЕЛІ (HUD) */
#top-ui {
    width: 100%;
    max-width: var(--container-max-width);
    background: var(--ui-color);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #555;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

/* Стиль для індикації рівня 250+ */
.hardcore-mode #top-ui {
    border-bottom: 2px solid var(--hardcore-border);
    box-shadow: 0 0 10px var(--hardcore-border);
}

.ui-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    font-weight: bold;
}

#rank-label {
    color: var(--accent-color);
    font-size: 9px;
    margin-top: 2px;
    text-transform: uppercase;
}

/* Анімація для Генералісимуса */
.rank-generalissimo {
    color: var(--generalissimo-color) !important;
    text-shadow: 0 0 5px var(--generalissimo-color);
    animation: pulseRank 1.5s infinite;
}

@keyframes pulseRank {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

#mute-btn {
    background: rgba(0,0,0,0.3);
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
}

/* ІГРОВИЙ КОНТЕЙНЕР ТА ПОЛОТНО */
#main-area {
    flex-grow: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    overflow: hidden;
    min-height: 0;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: var(--container-max-width);
    aspect-ratio: 1/1;
    background: #000;
    border: 2px solid var(--ui-color);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    max-height: 100%; 
}

/* Ефект трясіння екрану */
@keyframes shakeEffect {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    20% { transform: translate(-2px, 0px) rotate(-1deg); }
    40% { transform: translate(2px, 1px) rotate(1deg); }
    60% { transform: translate(-1px, -1px) rotate(0deg); }
    80% { transform: translate(2px, -1px) rotate(1deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
.shake { animation: shakeEffect 0.3s ease-in-out; }

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

/* ТАЙМЕРИ БОНУСІВ */
#mg-timer-ui, #net-timer-ui {
    position: absolute;
    right: 10px;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid white;
    display: none;
    pointer-events: none;
    z-index: 20;
}

#mg-timer-ui { top: 10px; background: rgba(255, 0, 0, 0.8); }
#net-timer-ui { top: 45px; background: rgba(0, 150, 0, 0.8); }

/* ПАНЕЛЬ КЕРУВАННЯ */
#controls-wrapper {
    width: 100%;
    max-width: var(--container-max-width);
    background: var(--bg-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 15px 10px;
    border-top: 2px solid #444;
    flex-shrink: 0;
    min-height: 160px;
}

/* Стилі джойстика */
#joystick-container {
    width: min(160px, 42vw);
    height: min(160px, 42vw);
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    border: 2px dashed rgba(255,255,255,0.1);
}

#joystick-stick {
    width: 50%;
    height: 50%;
    background: #444;
    border: 3px solid var(--accent-color);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 15px rgba(0,0,0,0.6);
    pointer-events: none;
    transition: transform 0.05s ease-out;
}

/* Кнопки D-PAD */
.d-pad {
    display: grid;
    grid-template-columns: repeat(3, min(70px, 18vw));
    grid-template-rows: repeat(3, min(70px, 18vw));
    gap: 5px;
}

.btn {
    background: #333;
    border: 1px solid #555;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* Кнопка вогню */
.btn-fire {
    width: min(100px, 26vw);
    height: min(100px, 26vw);
    border-radius: 50%;
    background: #d32f2f;
    border: 4px solid #b71c1c;
    color: white;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 4px 0 #801414;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-fire:active {
    transform: translateY(4px);
    box-shadow: none;
    background: #f44336;
}

/* ЕКРАНИ ПЕРЕКРИТТЯ (ОБЕРЛЕЇ) */
.overlay-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    padding: 20px;
    overflow: hidden; 
}

.hidden { display: none !important; }

h1 { color: var(--accent-color); margin-bottom: 5px; font-size: min(28px, 8vw); text-shadow: 2px 2px #000; flex-shrink: 0; }

.menu-btn {
    background: var(--ui-color);
    color: #fff;
    border: 1px solid #555;
    padding: 12px 25px;
    font-size: 0.9rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    margin: 5px;
    width: 260px;
    max-width: 95%;
    transition: transform 0.1s;
    flex-shrink: 0;
}

.menu-btn:active { transform: scale(0.95); background: var(--accent-color); color: #000; }

.btn-progress { background: #4CAF50; border-color: #388E3C; color: white; border-bottom: 3px solid #2e7d32; }

/* ВКЛАДКИ ЧАСТИН РІВНІВ */
.parts-tab {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.tab-btn {
    padding: 8px 15px;
    background: #444;
    border: 1px solid #666;
    color: #fff;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
}
.tab-btn.active {
    background: var(--accent-color);
    color: #000;
    font-weight: bold;
}

/* СІТКА РІВНІВ */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 12px;
    margin: 10px 0;
    width: 100%;
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.level-item {
    aspect-ratio: 1;
    background: #222;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    color: #666;
    cursor: not-allowed;
    position: relative;
    padding: 5px;
    transition: all 0.1s;
}

.level-item.unlocked { background: #333; border-color: var(--accent-color); color: white; cursor: pointer; }
.level-item.unlocked:active { transform: scale(0.9); background: var(--accent-color); color: #000; }

.level-item .num { font-size: 18px; margin-bottom: 2px; }
.level-item .stars-mini { font-size: 9px; color: #ffcc00; height: 12px; letter-spacing: 1px; }

.total-info { font-size: 11px; color: #aaa; margin-top: 10px; flex-shrink: 0; }

/* КАРТКА ІНФОРМАЦІЇ */
.info-card { 
    background: rgba(255,255,255,0.07); 
    padding: 15px; 
    border-radius: 12px; 
    text-align: left; 
    width: 100%; 
    max-width: 340px; 
    margin-bottom: 15px; 
    font-size: 11px; 
    line-height: 1.6; 
    border: 1px solid #444; 
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
}
.info-card span { color: var(--accent-color); font-weight: bold; }

.bonus-list { list-style: none; padding: 0; margin: 10px 0; }
.bonus-list li { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.bonus-icon-mini { width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: bold; border-radius: 4px; }

/* АДАПТИВНІСТЬ */
@media (max-width: 400px) {
    .level-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

@media (max-height: 600px) {
    #controls-wrapper { min-height: 130px; padding: 5px; }
    .menu-btn { padding: 8px 15px; font-size: 0.8rem; }
    h1 { font-size: 20px; }
}