/* css/styles.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #0a1628;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Loading Screen */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a1628 0%, #1a3a5c 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #4fc3f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-screen p {
    margin-top: 20px;
    font-size: 18px;
    color: #4fc3f7;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.player-info, .enemy-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-name {
    font-size: 16px;
    font-weight: bold;
    color: #4fc3f7;
}

.enemy-info .player-name {
    color: #ff7043;
}

.ships-count {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
}

.turn-indicator {
    padding: 10px 25px;
    background: rgba(79, 195, 247, 0.2);
    border: 2px solid #4fc3f7;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    color: #4fc3f7;
    text-transform: uppercase;
    animation: pulse 2s ease-in-out infinite;
}

.turn-indicator.enemy-turn {
    background: rgba(255, 112, 67, 0.2);
    border-color: #ff7043;
    color: #ff7043;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
    display: flex;
    justify-content: center;
}

#score-display {
    font-size: 20px;
    font-weight: bold;
    color: #ffd54f;
}

/* Notifications */
#notifications {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.notification {
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 10px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    animation: notificationIn 0.3s ease-out;
}

.notification.hit {
    border: 3px solid #ff5722;
    color: #ff5722;
    text-shadow: 0 0 20px rgba(255, 87, 34, 0.5);
}

.notification.miss {
    border: 3px solid #4fc3f7;
    color: #4fc3f7;
}

.notification.sunk {
    border: 3px solid #ffd54f;
    color: #ffd54f;
    font-size: 32px;
    animation: sunkNotification 0.5s ease-out;
}

.notification.victory {
    border: 3px solid #4caf50;
    color: #4caf50;
    font-size: 40px;
    animation: victoryNotification 0.5s ease-out;
}

@keyframes notificationIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes sunkNotification {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes victoryNotification {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.3) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .hud-top {
        padding: 10px 15px;
    }

    .player-name {
        font-size: 14px;
    }

    .ships-count {
        font-size: 12px;
    }

    .turn-indicator {
        padding: 8px 15px;
        font-size: 14px;
    }

    .notification {
        padding: 15px 25px;
        font-size: 18px;
    }

    .notification.sunk {
        font-size: 24px;
    }

    .notification.victory {
        font-size: 28px;
    }
}


/* Добавляем в css/styles.css */

/* ═══════════════════════════════════════════
   SHIP PANEL
   ═══════════════════════════════════════════ */

   .ship-panel {
    position: absolute;
    right: -300px;
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
    max-height: 80vh;
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #4fc3f7;
    border-right: none;
    border-radius: 15px 0 0 15px;
    padding: 20px;
    transition: right 0.3s ease;
    overflow-y: auto;
    z-index: 100;
}

.ship-panel.visible {
    right: 0;
}

.ship-panel h3 {
    margin: 0 0 10px 0;
    color: #4fc3f7;
    font-size: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ship-panel .hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    margin-bottom: 15px;
    line-height: 1.4;
}

.ship-group {
    margin-bottom: 15px;
}

.group-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(79, 195, 247, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
}

.ship-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}

.ship-size {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.ship-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ship-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ship-item:hover:not(.placed) {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4fc3f7;
}

.ship-item.active {
    background: rgba(79, 195, 247, 0.3);
    border-color: #4fc3f7;
    box-shadow: 0 0 15px rgba(79, 195, 247, 0.3);
}

.ship-item.placed {
    opacity: 0.4;
    cursor: not-allowed;
}

.ship-item.placed .ship-preview {
    filter: grayscale(1);
}

.ship-preview {
    display: flex;
    gap: 3px;
}

.ship-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* ═══════════════════════════════════════════
   READY BUTTON
   ═══════════════════════════════════════════ */

.ready-button {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 50px;
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #fff;
    background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
    transition: all 0.3s ease;
    z-index: 100;
}

.ready-button:hover:not(.disabled) {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.6);
}

.ready-button:active:not(.disabled) {
    transform: translateX(-50%) scale(0.98);
}

.ready-button.disabled {
    background: linear-gradient(135deg, #666 0%, #444 100%);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ═══════════════════════════════════════════
   MOBILE ADJUSTMENTS
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .ship-panel {
        width: 220px;
        padding: 15px;
        max-height: 70vh;
    }

    .ship-panel h3 {
        font-size: 16px;
    }

    .ship-cell {
        width: 20px;
        height: 20px;
    }

    .ready-button {
        padding: 12px 35px;
        font-size: 16px;
        bottom: 20px;
    }

    .ship-panel .hint {
        font-size: 11px;
    }
}

/* Кнопка поворота для мобильных */
.rotate-button {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(79, 195, 247, 0.9);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 100;
}

.rotate-button.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Добавляем в styles.css */

/* ═══════════════════════════════════════════
   BATTLE UI
   ═══════════════════════════════════════════ */

   .battle-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
}

.turn-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 40px;
    border-radius: 30px;
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    transition: all 0.3s ease;
}

.turn-indicator.my-turn {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.9), rgba(46, 125, 50, 0.9));
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.5);
    color: #fff;
}

.turn-indicator.enemy-turn {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.9), rgba(183, 28, 28, 0.9));
    box-shadow: 0 0 30px rgba(244, 67, 54, 0.5);
    color: #fff;
    animation: pulse-danger 1s infinite;
}

@keyframes pulse-danger {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
}

.battle-stats {
    position: absolute;
    top: 80px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.battle-stats .stat {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
}

.battle-stats .stat.player {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid rgba(76, 175, 80, 0.5);
}

.battle-stats .stat.enemy {
    background: rgba(244, 67, 54, 0.3);
    border: 1px solid rgba(244, 67, 54, 0.5);
}

.battle-stats .label {
    color: rgba(255, 255, 255, 0.7);
}

.battle-stats .value {
    font-weight: bold;
    color: #fff;
}

.message-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.battle-message {
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: message-appear 0.3s ease-out;
    white-space: nowrap;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.battle-message.hit {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #fff;
    box-shadow: 0 0 40px rgba(255, 152, 0, 0.6);
}

.battle-message.miss {
    background: rgba(100, 100, 100, 0.8);
    color: #ccc;
}

.battle-message.sunk {
    background: linear-gradient(135deg, #f44336, #c62828);
    color: #fff;
    box-shadow: 0 0 50px rgba(244, 67, 54, 0.7);
    font-size: 32px;
}

.battle-message.danger {
    background: linear-gradient(135deg, #f44336, #b71c1c);
    color: #fff;
    box-shadow: 0 0 40px rgba(244, 67, 54, 0.6);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

.battle-message.info {
    background: rgba(33, 150, 243, 0.9);
    color: #fff;
}

.battle-message.fade-out {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.5s ease;
}

/* ═══════════════════════════════════════════
   GAME OVER
   ═══════════════════════════════════════════ */

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fade-in 0.5s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over-content {
    text-align: center;
    padding: 50px 80px;
    border-radius: 20px;
    animation: scale-in 0.5s ease;
}

@keyframes scale-in {
    from { 
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-over-content.victory {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95), rgba(27, 94, 32, 0.95));
    border: 3px solid #4caf50;
    box-shadow: 0 0 60px rgba(76, 175, 80, 0.5);
}

.game-over-content.defeat {
    background: linear-gradient(135deg, rgba(183, 28, 28, 0.95), rgba(100, 20, 20, 0.95));
    border: 3px solid #c62828;
    box-shadow: 0 0 60px rgba(244, 67, 54, 0.5);
}

.game-over-content h1 {
    font-size: 60px;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.game-over-content p {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 30px 0;
}

.final-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
}

.play-again-btn {
    padding: 15px 50px;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #fff;
    background: linear-gradient(135deg, #2196f3, #1565c0);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(33, 150, 243, 0.4);
    pointer-events: auto;
}

.play-again-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(33, 150, 243, 0.6);
}

/* ═══════════════════════════════════════════
   MOBILE BATTLE UI
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .turn-indicator {
        padding: 10px 25px;
        font-size: 14px;
        letter-spacing: 2px;
    }

    .battle-stats {
        top: 65px;
        left: 10px;
    }

    .battle-stats .stat {
        padding: 8px 15px;
        font-size: 12px;
    }

    .battle-message {
        padding: 15px 25px;
        font-size: 20px;
    }

    .battle-message.sunk {
        font-size: 24px;
    }

    .game-over-content {
        padding: 30px 40px;
        margin: 20px;
    }

    .game-over-content h1 {
        font-size: 36px;
    }

    .game-over-content p {
        font-size: 16px;
    }

    .play-again-btn {
        padding: 12px 35px;
        font-size: 14px;
    }
}