/* css/style.css */
/* Деревянная резня - стили */

@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Roboto:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Roboto', sans-serif;
    user-select: none;
    cursor: crosshair;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* === HUD === */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    pointer-events: none;
    z-index: 10;
}

/* HP */
#hp-container {
    position: relative;
    width: 220px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    backdrop-filter: blur(4px);
}

#hp-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4caf50, #66bb6a);
    border-radius: 12px;
    transition: width 0.3s ease, background 0.3s ease;
}

#hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Имя карты */
#map-name {
    background: rgba(200, 100, 0, 0.6);
    border: 1px solid rgba(255, 165, 0, 0.5);
    color: #ffe0a0;
    font-weight: bold;
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

/* Ресурсы */
#resources {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.resource {
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Оружие */
#weapon-info {
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 200, 0, 0.3);
    backdrop-filter: blur(4px);
}

#weapon-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255, 200, 0, 0.4);
}

#weapon-level {
    font-size: 11px;
    color: #bbb;
    margin-left: 8px;
}

/* Время */
#time-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
}

#time-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffcc00;
    box-shadow: 0 0 10px #ffcc00;
}

#time-bar-container {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

#time-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffe066, #ffb347);
    border-radius: 4px;
    transition: width 0.5s linear;
}

#time-text {
    font-size: 12px;
    color: #ddd;
    min-width: 80px;
}

#night-counter {
    background: rgba(0, 0, 0, 0.55);
    padding: 5px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #aaaaff;
    border: 1px solid rgba(100, 100, 255, 0.2);
    backdrop-filter: blur(4px);
}

/* Подсказка */
#interaction-prompt {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px);
    z-index: 15;
    animation: prompt-pulse 2s infinite;
}

@keyframes prompt-pulse {

    0%,
    100% {
        opacity: 0.9;
    }

    50% {
        opacity: 1;
        border-color: rgba(255, 200, 0, 0.5);
    }
}

/* Пауза */
#pause-btn {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 35;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.6);
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

#pause-btn:hover {
    background: rgba(255, 170, 0, 0.28);
    border-color: rgba(255, 200, 0, 0.55);
}

#pause-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 190;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(6px);
}

#pause-screen h1 {
    font-family: 'Russo One', sans-serif;
    color: #ffd45a;
    font-size: 44px;
    letter-spacing: 2px;
    margin-bottom: 22px;
    text-shadow: 0 0 20px rgba(255, 212, 90, 0.45);
}

#resume-btn {
    background: linear-gradient(135deg, #8B6914, #b38828);
    color: #fff;
    border: 2px solid #e0b95a;
    padding: 12px 34px;
    border-radius: 8px;
    font-family: 'Russo One', sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    cursor: pointer;
}

#resume-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* Магазин */
#shop-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 900px;
    max-height: 92vh;
    background: rgba(20, 15, 10, 0.95);
    border: 2px solid #8B6914;
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    overflow-y: auto;
    color: #e0d5c5;
    backdrop-filter: blur(12px);
    box-shadow: 0 0 40px rgba(139, 105, 20, 0.3);
    pointer-events: auto;
}

.shop-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.shop-section {
    break-inside: avoid;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(139, 105, 20, 0.4);
    padding-bottom: 10px;
}

.shop-header h2 {
    font-family: 'Russo One', sans-serif;
    color: #ffd700;
    font-size: 22px;
    text-shadow: 0 0 15px rgba(255, 200, 0, 0.4);
}

.shop-header .shop-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #f7f7f7;
    font-weight: 700;
    cursor: pointer;
}

.shop-header .shop-close:hover {
    background: rgba(220, 70, 70, 0.5);
    border-color: rgba(255, 140, 140, 0.7);
}

/* .shop-section base margin handled by grid gap above */

.shop-section h3 {
    color: #d2be93;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(139, 105, 20, 0.35);
    color: #efe3cc;
    transition: background 0.2s, border-color 0.2s;
}

.shop-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.shop-item.disabled {
    opacity: 0.85;
}

.shop-item.equipped {
    border-color: rgba(255, 215, 0, 0.75);
    background: rgba(125, 95, 25, 0.28);
}

.shop-item strong {
    color: #ffda57;
}

.shop-item small {
    color: #d6c7a7;
}

.shop-item .item-info {
    color: #e8dbc1;
}

.shop-item .item-cost {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shop-item .item-cost span {
    color: #e0c79b;
    font-weight: 700;
}

.shop-cost {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
}

.cost-bark {
    color: #c89045;
}

.cost-hide {
    color: #a08060;
}

.shop-btn {
    background: linear-gradient(135deg, #8B6914, #a07a1e);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    pointer-events: auto;
}

.shop-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #a07a1e, #c09030);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 105, 20, 0.4);
}

.shop-btn:disabled {
    background: #5b5b5b;
    color: #d3d3d3;
    border: 1px solid #777;
    cursor: not-allowed;
}

.shop-btn.gamepad-focus {
    outline: 2px solid #8fd3ff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(143, 211, 255, 0.25);
}

.close-btn {
    background: rgba(200, 50, 50, 0.6);
    padding: 5px 10px;
    font-size: 16px;
}

.close-btn:hover {
    background: rgba(200, 50, 50, 0.9);
}

/* Экран смерти */
#death-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(80, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(8px);
}

#death-screen h1 {
    font-family: 'Russo One', sans-serif;
    color: #ff3333;
    font-size: 48px;
    text-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
    margin-bottom: 15px;
}

#death-screen p {
    color: #ffaaaa;
    font-size: 18px;
    margin-bottom: 30px;
}

#respawn-btn {
    background: linear-gradient(135deg, #cc3333, #992222);
    color: #fff;
    border: 2px solid #ff4444;
    padding: 14px 40px;
    font-size: 18px;
    font-family: 'Russo One', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

#respawn-btn:hover {
    background: linear-gradient(135deg, #ee4444, #cc3333);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.5);
}

/* Экран победы */
#victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 50, 20, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(8px);
}

#victory-screen h1 {
    font-family: 'Russo One', sans-serif;
    color: #44ff44;
    font-size: 48px;
    text-shadow: 0 0 30px rgba(0, 255, 0, 0.6);
    margin-bottom: 15px;
}

#victory-screen p {
    color: #aaffaa;
    font-size: 18px;
    margin-bottom: 30px;
}

#continue-btn {
    background: linear-gradient(135deg, #33cc33, #229922);
    color: #fff;
    border: 2px solid #44ff44;
    padding: 14px 40px;
    font-size: 18px;
    font-family: 'Russo One', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

#continue-btn:hover {
    background: linear-gradient(135deg, #44ee44, #33cc33);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(50, 255, 50, 0.5);
}

/* Стартовый экран */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(1200px 700px at 50% -120px, rgba(133, 29, 57, 0.35), rgba(0, 0, 0, 0) 55%),
        radial-gradient(900px 520px at 50% 100%, rgba(36, 60, 92, 0.28), rgba(0, 0, 0, 0) 60%),
        linear-gradient(180deg, #04050c 0%, #090812 48%, #050505 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    overflow: hidden;
}

#start-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            125deg,
            rgba(210, 240, 255, 0.02) 0px,
            rgba(210, 240, 255, 0.02) 2px,
            rgba(0, 0, 0, 0) 2px,
            rgba(0, 0, 0, 0) 11px
        );
    opacity: 0.5;
    pointer-events: none;
}

#start-screen::after {
    content: '';
    position: absolute;
    inset: -20%;
    background: radial-gradient(circle at center, rgba(150, 25, 55, 0.12), rgba(0, 0, 0, 0.75) 64%);
    animation: start-vignette 7s ease-in-out infinite;
    pointer-events: none;
}

#start-screen h1 {
    font-family: 'Russo One', sans-serif;
    position: relative;
    z-index: 1;
    color: #d8deee;
    font-size: clamp(44px, 8vw, 86px);
    text-transform: uppercase;
    letter-spacing: clamp(3px, 0.8vw, 10px);
    margin-bottom: 14px;
    text-shadow:
        0 0 18px rgba(208, 226, 255, 0.25),
        0 0 34px rgba(156, 31, 58, 0.35),
        0 10px 28px rgba(0, 0, 0, 0.85);
}

#start-screen p {
    position: relative;
    z-index: 1;
    color: #95a2bf;
    font-size: clamp(15px, 2.2vw, 21px);
    margin-bottom: 25px; /* Уменьшен отступ для места под управление */
    letter-spacing: 1.4px;
    text-shadow: 0 3px 14px rgba(0, 0, 0, 0.9);
}

.controls-info {
    position: relative;
    z-index: 1;
    margin: 0 0 35px 0;
    text-align: center;
    color: #b0c4de;
    font-size: 14px;
    line-height: 1.8;
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 25px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.controls-info p {
    margin-bottom: 0 !important;
    font-size: 14px !important;
    text-shadow: none !important;
    color: #c9d6ea !important;
    letter-spacing: 0.5px !important;
}

.controls-info b {
    color: #ffd700;
    margin: 0 3px;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

#start-btn {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, #1e2f49 0%, #172238 45%, #5d1630 100%);
    color: #ecf0ff;
    border: 1px solid rgba(168, 200, 255, 0.42);
    padding: 16px 62px;
    font-size: 21px;
    font-family: 'Russo One', sans-serif;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease, border-color 0.25s ease;
    letter-spacing: 4px;
    box-shadow:
        0 10px 28px rgba(8, 12, 22, 0.7),
        0 0 24px rgba(109, 35, 60, 0.34);
}

#start-btn:hover {
    border-color: rgba(235, 137, 165, 0.75);
    filter: brightness(1.12);
    transform: translateY(-2px) scale(1.035);
    box-shadow:
        0 14px 34px rgba(8, 12, 22, 0.78),
        0 0 28px rgba(176, 53, 88, 0.5);
}

@keyframes start-vignette {
    0% {
        transform: scale(1);
        opacity: 0.94;
    }

    50% {
        transform: scale(1.02);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.94;
    }
}

/* Скрытие */
.hidden {
    display: none !important;
}

/* Сообщения */
.game-message {
    position: fixed;
    top: 86px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #ffd700;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 700;
    z-index: 50;
    border: 1px solid rgba(255, 200, 0, 0.3);
    animation: msg-appear 0.3s ease;
    pointer-events: none;
}

.game-message.fade-out {
    animation: msg-fade 0.5s ease forwards;
}

@keyframes msg-appear {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes msg-fade {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Числа урона */
.damage-number {
    position: fixed;
    font-size: 20px;
    font-weight: 700;
    pointer-events: none;
    z-index: 40;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    animation: dmg-float 1s ease-out forwards;
}

@keyframes dmg-float {
    from {
        opacity: 1;
        transform: translateY(0) scale(1.2);
    }

    to {
        opacity: 0;
        transform: translateY(-40px) scale(0.8);
    }
}

/* Прицел */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 15;
}

#crosshair.crosshair-ranged {
    /* Для огнестрела прицел поднимаем чуть выше головы персонажа */
    top: calc(50% - 148px);
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
}

#crosshair::before {
    width: 2px;
    height: 20px;
    left: 9px;
    top: 0;
}

#crosshair::after {
    width: 20px;
    height: 2px;
    left: 0;
    top: 9px;
}

/* Полоса босса (волки) */
#wolves-info {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 20px;
    border-radius: 8px;
    color: #ff6666;
    font-size: 14px;
    font-weight: 700;
    z-index: 10;
    border: 1px solid rgba(255, 50, 50, 0.3);
    pointer-events: none;
}

/* Скроллбар магазина */
#shop-panel::-webkit-scrollbar {
    width: 6px;
}

#shop-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

#shop-panel::-webkit-scrollbar-thumb {
    background: #8B6914;
    border-radius: 3px;
}
