* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100vw;
    height: 100dvh;
    background: url('images/background.jpg') no-repeat center center fixed;
    background-size: cover;
    overflow: hidden;
    user-select: none;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.top-bar {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 15;
    gap: 10px;
}

.weapon-panel {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.75);
    padding: 8px 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    flex-wrap: wrap;
}

.weapon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #fff;
    color: #fff;
    padding: 6px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.weapon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.weapon-btn.active-weapon {
    border-color: #00ffcc;
    background: rgba(0, 255, 204, 0.2);
    box-shadow: 0 0 10px #00ffcc;
}

.weapon-btn.special {
    border-color: #ffcc00;
    color: #ffcc00;
}

.weapon-btn.auto-mode {
    border-color: #ff00ff;
    background: rgba(255, 0, 255, 0.25);
    box-shadow: 0 0 10px #ff00ff;
    color: #ff99ff;
}

.weapon-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.sound-toggle-btn {
    background: rgba(0, 0, 0, 0.75);
    border: 2px solid #fff;
    color: #fff;
    padding: 8px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    white-space: nowrap;
    transition: all 0.2s ease;
}

.sound-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.info-container {
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.75);
    padding: 6px 15px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.timer {
    font-size: 1.8rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    line-height: 1.1;
}

.timer.bonus-time {
    color: #ff3333;
    animation: blinkTimer 0.3s infinite alternate;
}

@keyframes blinkTimer {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

.panic-text {
    font-size: 0.85rem;
    font-weight: bold;
    color: #ff3333;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    display: none;
    animation: blink 0.3s infinite alternate;
}

@keyframes blink {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.2; transform: scale(1.05); }
}

.game-arena {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 5% 70px 5%;
    z-index: 2;
}

.character {
    max-height: 65vh;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.6));
    transition: filter 0.15s ease;
}

.character.hit-effect {
    filter: drop-shadow(0 0 25px rgba(255, 0, 0, 0.9)) brightness(1.2);
}

.rkn {
    cursor: pointer;
}

#projectilesContainer, #counterProjectilesContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.projectile {
    position: absolute;
    width: 55px;
    height: 55px;
    object-fit: contain;
    transition: transform 0.35s ease-in-out, left 0.35s ease-in-out, top 0.35s ease-in-out;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.95));
    opacity: 1;
}

.health-bar-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    padding: 12px 25px;
    border-radius: 30px;
    border: 2px solid rgba(255,255,255,0.3);
    z-index: 10;
}

.health-text {
    color: #fff;
    font-size: 1.4rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    text-align: center;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 15px;
}

.modal {
    background: #1a1a1a;
    border: 3px solid #333;
    border-radius: 20px;
    padding: 30px;
    width: 600px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    color: #fff;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.modal h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    color: #4CAF50;
}

.rules-box {
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #ddd;
}

.rules-box ul {
    margin-top: 5px;
    padding-left: 20px;
}

.rules-box li {
    margin-bottom: 4px;
}

.author-link {
    margin-top: 15px;
    font-size: 0.95rem;
    color: #aaa;
}

.author-link a {
    color: #00ffcc;
    text-decoration: none;
    font-weight: bold;
}

.author-link a:hover {
    text-decoration: underline;
}

.loader-container {
    width: 100%;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    height: 16px;
    margin-bottom: 10px;
    border: 1px solid #555;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.1s linear;
}

.loader-text {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 15px;
}

.modal-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

.modal-btn:hover {
    background: #45a049;
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) and (orientation: portrait) {
    html, body { position: fixed; }
    .top-bar { top: 8px; padding: 0 10px; }
    .weapon-panel {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
        padding: 6px;
        max-width: 85%;
    }
    .weapon-btn { padding: 4px 5px; font-size: 0.7rem; justify-content: center; }
    .weapon-btn img { width: 14px; height: 14px; }
    .sound-toggle-btn { padding: 8px 10px; font-size: 0.75rem; }
    .info-container { top: 92px; }
    .timer { font-size: 1.6rem; }
    .panic-text { font-size: 1.3rem; }
    .character { max-height: 22vh; }
    .game-arena { padding: 0 3% 45px 3%; }
    .health-bar-container { bottom: 6px; padding: 6px 15px; width: 90%; max-width: 400px; }
    .health-text { font-size: 0.8rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .top-bar { top: 6px; padding: 0 10px; }
    .weapon-panel { display: flex; flex-wrap: wrap; padding: 6px 10px; gap: 6px; max-width: 75%; }
    .weapon-btn { padding: 4px 8px; font-size: 0.7rem; }
    .sound-toggle-btn { padding: 6px 10px; font-size: 0.75rem; }
    .info-container { top: 55px; }
    .timer { font-size: 1.3rem; }
    .panic-text { font-size: 1rem; }
    .character { max-height: 45vh; }
    .health-bar-container { bottom: 4px; padding: 4px 10px; }
    .health-text { font-size: 0.75rem; }
}

/* Стили для выбора сложности в модальном окне */
.difficulty-selector {
    margin: 12px 0;
    text-align: center;
}

.diff-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 6px;
}

.diff-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid #555;
    color: #bbb;
    padding: 8px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.diff-btn:hover {
    border-color: #888;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.diff-btn.active-diff {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.25);
    color: #fff;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}