/* Стили ретро-автомата "Морской бой" */
:root {
    --neon-green: #00ff66;
    --neon-red: #ff3344;
    --neon-orange: #ff9900;
    --bg-dark: #05050a;
    --cabin-gray: #1b1e22;
    --font-retro: 'Courier Prime', monospace;
    --font-ui: 'Outfit', sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #0b0c10;
    color: #fff;
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
}

/* Корпус игрового автомата */
.game-container {
    width: 100%;
    max-width: 860px;
    background: linear-gradient(135deg, #242830, #14161b);
    border: 8px solid #323846;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 
                inset 0 2px 10px rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Кнопка назад к порталу */
.back-link {
    position: absolute;
    top: 24px;
    left: 24px;
    color: #a0aec0;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.back-link:hover {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Вывеска автомата */
.cabinet-brand {
    font-family: var(--font-retro);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--neon-orange);
    text-shadow: 0 0 10px rgba(255, 153, 0, 0.5), 
                 0 0 20px rgba(255, 153, 0, 0.2);
    margin-bottom: 24px;
    margin-top: 10px;
    text-align: center;
}

/* Экран перископа */
.periscope-viewport {
    width: 100%;
    aspect-ratio: 5/3;
    max-width: 800px;
    background: var(--bg-dark);
    position: relative;
    border: 10px solid #0f1015;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 255, 102, 0.05),
                0 0 20px rgba(0, 0, 0, 0.9);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Круговой маскирующий оверлей перископа */
.periscope-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Создает круглое смотровое окно */
    background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.92) 55%);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

/* Перекрестие прицела */
.aim-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 1.5px solid var(--neon-green);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.85;
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.3);
}

.aim-crosshair::before,
.aim-crosshair::after {
    content: '';
    position: absolute;
    background: var(--neon-green);
}

/* Вертикальная линия прицела */
.aim-crosshair::before {
    top: -15px;
    left: 50%;
    width: 1.5px;
    height: 90px;
    transform: translateX(-50%);
}

/* Горизонтальная линия прицела */
.aim-crosshair::after {
    top: 50%;
    left: -15px;
    width: 90px;
    height: 1.5px;
    transform: translateY(-50%);
}

/* Сетка угломера на перископе */
.ticks-horizontal {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 480px;
    height: 20px;
    transform: translate(-50%, -50%);
    border-top: 1px dashed rgba(0, 255, 102, 0.25);
    opacity: 0.5;
}

.ticks-vertical {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 280px;
    transform: translate(-50%, -50%);
    border-left: 1px dashed rgba(0, 255, 102, 0.25);
    opacity: 0.5;
}

/* Индикаторы состояния сверху */
.indicators {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    z-index: 10;
}

.indicator {
    background: rgba(0, 255, 102, 0.03);
    border: 1px solid rgba(0, 255, 102, 0.3);
    padding: 6px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.05);
}

#ind-torpedo {
    border-color: rgba(255, 51, 68, 0.4);
    background: rgba(255, 51, 68, 0.02);
}

.ind-label {
    font-family: var(--font-retro);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.7);
}

#ind-torpedo .ind-label {
    color: var(--neon-red);
    text-shadow: 0 0 5px rgba(255, 51, 68, 0.5);
}

#ind-hits .ind-label {
    color: var(--neon-green);
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.5);
}

.ind-count {
    font-family: var(--font-retro);
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

/* Информация сонара внизу */
.bottom-sonar-info {
    width: fit-content;
    margin: 0 auto;
    font-family: var(--font-retro);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: var(--neon-green);
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.6);
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 14px;
    border-radius: 6px;
    border: 1px solid rgba(0, 255, 102, 0.15);
    z-index: 10;
}

/* Экраны-оверлеи (Старт / Конец игры) */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    z-index: 20;
    text-align: center;
}

.overlay-screen.hidden {
    display: none !important;
}

.retro-title {
    font-family: var(--font-retro);
    font-size: 2.2rem;
    color: var(--neon-orange);
    text-shadow: 0 0 10px rgba(255, 153, 0, 0.8);
    margin-bottom: 16px;
    letter-spacing: 0.05em;
}

.retro-desc {
    color: #a0aec0;
    font-size: 1rem;
    max-width: 460px;
    line-height: 1.5;
    margin-bottom: 30px;
}

.retro-btn {
    font-family: var(--font-retro);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bg-dark);
    background: var(--neon-green);
    border: none;
    padding: 12px 36px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px var(--neon-green);
    transition: all 0.15s ease;
}

.retro-btn:hover {
    transform: scale(1.05);
    background: #24ff80;
    box-shadow: 0 0 30px #24ff80;
}

.retro-btn:active {
    transform: scale(0.95);
}

/* Статистика конца игры */
.game-stats {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px 40px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-family: var(--font-retro);
    font-size: 1.1rem;
    color: #e2e8f0;
    line-height: 1.8;
}

.game-stats span {
    font-weight: 700;
    color: #fff;
}

.retro-rating {
    font-size: 1.25rem;
    color: var(--neon-orange) !important;
    text-shadow: 0 0 8px rgba(255, 153, 0, 0.5);
    margin-top: 10px;
}

/* Панель управления снизу */
.controls-panel {
    width: 100%;
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.joystick-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.95rem;
    color: #e2e8f0;
    background: #2d3748;
    border: 1px solid #4a5568;
    padding: 14px 22px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: #4a5568;
    color: #fff;
}

.control-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

/* Кнопка запуска торпеды (Большая Красная кнопка «ПЛИ!») */
.fire-btn {
    font-family: var(--font-retro);
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff3344, #cc1122);
    border: 3px solid #ff6677;
    padding: 12px 64px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 8px 0 #990011, 
                0 15px 30px rgba(255, 51, 68, 0.4);
    transition: all 0.1s ease;
}

.fire-btn:hover {
    background: linear-gradient(135deg, #ff4455, #dd2233);
}

.fire-btn:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 #990011, 
                0 5px 15px rgba(255, 51, 68, 0.4);
}

/* Кнопка звука */
.mute-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e0;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.mute-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Подсказки */
.pc-tips {
    margin-top: 18px;
    font-size: 0.8rem;
    color: #718096;
    text-align: center;
}

.pc-tips span {
    color: #cbd5e0;
    font-family: var(--font-retro);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 2px;
}

/* Адаптивность для мобильных */
@media (max-width: 680px) {
    .cabinet-brand {
        font-size: 1.6rem;
        margin-bottom: 16px;
    }
    
    .game-container {
        padding: 16px;
        border-width: 5px;
    }

    .periscope-overlay {
        background: radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.95) 60%);
        padding: 10px;
    }

    .aim-crosshair {
        width: 46px;
        height: 46px;
    }
    
    .aim-crosshair::before { height: 70px; }
    .aim-crosshair::after { width: 70px; }

    .indicator {
        padding: 4px 10px;
        gap: 6px;
    }
    
    .ind-count {
        font-size: 1.1rem;
    }

    .controls-panel {
        flex-direction: column;
        gap: 16px;
        margin-top: 16px;
    }

    .joystick-controls {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .control-btn {
        width: 100%;
        padding: 16px;
    }

    .fire-btn {
        width: 100%;
        padding: 16px;
    }

    .pc-tips {
        display: none;
    }
    
    .back-link {
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 12px;
    }
}
