.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 13, 40, 0.65);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.winner-modal {
    background: linear-gradient(160deg, rgba(0, 45, 90, 0.85), rgba(15, 65, 120, 0.95));
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    padding: 28px 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.winner-modal::before {
    content: '';
    position: absolute;
    inset: -60px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    animation: winner-glow 6s infinite alternate;
}

.winner-modal > * {
    position: relative;
    z-index: 1;
}

.winner-title {
    font-size: 2em;
    font-weight: 800;
    color: #FFD700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    margin-bottom: 12px;
}

.winner-body {
    font-size: 1em;
    color: #E6F7FF;
    margin-bottom: 22px;
}

.winner-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.winner-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.winner-btn.primary {
    background: linear-gradient(135deg, #24C6DC 0%, #514A9D 100%);
    color: #fff;
    box-shadow: 0 8px 18px rgba(36, 198, 220, 0.35);
}

.winner-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(36, 198, 220, 0.45);
}

.winner-btn.secondary {
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.winner-btn.secondary:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.4);
}

@keyframes winner-glow {
    from {
        transform: scale(1);
        opacity: 0.7;
    }
    to {
        transform: scale(1.2);
        opacity: 0.95;
    }
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: white;
}

.container {
    max-width: 1200px;
    width: 100%;
    text-align: center;
}

h1 {
    color: white;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.players {
    
    margin: 10px 0;
}

.player {
    
    text-wrap-mode: wrap;

    border-radius: 10px;
    font-size: 1.2em;
    font-weight: bold;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    border: 2px solid transparent;
    padding: 0px 5px 10px;
    margin: 0 10px 10px 10px;
}

.player.active {
    background: rgba(76, 175, 80, 0.3);
    border: 5px solid #4CAF50;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.8);
}

.player.me { border-left: 4px solid #4CAF50; }
.player.opponent { border-left: 4px solid #FF5252; }

.score {
    display: inline-block;
    margin-top: 5px;
    color: #fff;
}

.score-number {
    font-size: 1.6em;
    font-weight: bold;
    line-height: 1;
    padding: 20px;
}

.score-label {
    font-size: 0.85em;
    opacity: 0.85;
    margin-top: 4px;
}

.controls {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.zoom-controls {
    margin: 10px 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.zoom-controls button {
    padding: 8px 12px;
    min-width: 44px;
    font-size: 1em;
}

.zoom-reset-btn {
    min-width: 60px;
}

.zoom-display {
    min-width: 68px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: bold;
    font-size: 0.95em;
}

button {
    padding: 12px 5px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

button:disabled:hover {
    background: #4CAF50;
    transform: none;
}
.rotation-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.rotation-btn {
    background: #2196F3;
    padding: 8px 15px;
    font-size: 0.9em;
}

.rotation-info {
    font-size: 0.9em;
    color: #FFD700;
    font-weight: bold;
}

.direction-hint {
    display: none;
    color: #FFD700;
    font-size: 0.8em;
    margin-top: 5px;
    background: rgba(255, 215, 0, 0.1);
    padding: 5px;
    border-radius: 5px;
}

.game-boards {
    display: flex;
    justify-content: center;

}

.board-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    position: relative;
}

.board-title {
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: bold;
}

.canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

canvas {
    display: block;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 50, 0.7);
    border-radius: 10px;
    width: 100%;
    height: 100%;
    transition: box-shadow 0.3s ease;
}

.board-highlight-target {
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.95);
}

.board-highlight-danger {
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.95);
}

.ship-palette {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ship {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.ship.selected {
    background: rgba(76, 175, 80, 0.5);
    border: 2px solid #4CAF50;
}

.ship.placed {
    background: rgba(100, 100, 100, 0.5);
    cursor: not-allowed;
}

.online-buttons {
    text-align: center;
    margin: 15px 0;
}

.online-buttons input {
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 0.9em;
    margin: 5px;
    background: rgba(255, 255, 255, 0.9);
}

#connectionStatus {
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 5px;
    margin-top: 8px;
    display: none;
    font-size: 0.9em;
}

.peerjs-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 0.9em;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-indicator.checking {
    background: #FFD700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    animation: pulse 1.5s ease-in-out infinite;
}

.status-indicator.success {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.status-indicator.error {
    background: #FF5252;
    box-shadow: 0 0 8px rgba(255, 82, 82, 0.6);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#roomInfo {
    background: rgba(233, 236, 239, 0.2);
    padding: 8px;
    border-radius: 5px;
    border-left: 4px solid #4CAF50;
    margin-top: 8px;
    display: none;
    font-size: 0.9em;
}

.room-id-container {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.copy-btn {
    padding: 4px 8px;
    font-size: 0.85em;
    min-width: 32px;
    height: 28px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

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

.sync-controls {
    margin-top: 12px;
    text-align: center;
    display: none;
}

.sync-controls button {
    min-width: 180px;
}

.sync-status {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.85em;
    border-radius: 6px;
    display: none;
    background: rgba(209, 236, 241, 0.15);
    color: #d1ecf1;
    border: 1px solid rgba(209, 236, 241, 0.3);
}

.sync-status.info {
    background: rgba(209, 236, 241, 0.15);
    color: #d1ecf1;
    border-color: rgba(209, 236, 241, 0.3);
}

.sync-status.success {
    background: rgba(212, 237, 218, 0.15);
    color: #d4edda;
    border-color: rgba(212, 237, 218, 0.3);
}

.sync-status.error {
    background: rgba(248, 215, 218, 0.15);
    color: #f8d7da;
    border-color: rgba(248, 215, 218, 0.3);
}

.sync-controls button.disabled,
.sync-controls button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.game-phase {
    font-size: 1.1em;
    margin: 12px 0;
    font-weight: bold;
    color: #FFD700;
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 10px;
    margin-top: 15px;
    font-size: 0.85em;
    color: #ccc;
    backdrop-filter: blur(10px);
}

.delete-hint {
    color: #FF5252;
    font-size: 0.8em;
    margin-top: 5px;
}

.debug-info {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 0.9em;
    color: #fff;
    border-left: 3px solid #4CAF50;
    display: none;
}

.mouse-coords {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 3px;
    font-size: 0.7em;
    color: white;
}

.last-click-info {
    background: rgba(255, 215, 0, 0.2);
    padding: 8px;
    border-radius: 5px;
    margin-top: 8px;
    font-size: 0.9em;
    color: #FFD700;
    border-left: 3px solid #FFD700;
}

.touch-zones-toggle {
    background: #9C27B0;
    padding: 8px 15px;
    font-size: 0.9em;
    margin-top: 10px;
}

.coords-debug {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 0.8em;
    color: #ccc;
    font-family: monospace;
}

.test-controls {
    display: none;
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.test-mode-btn {
    background: #FF9800 !important;
    padding: 10px 20px;
    font-size: 0.9em;
}

.test-mode-btn:hover {
    background: #F57C00 !important;
}
.mode-btn {width: 45%;}
.test-info {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 4px solid #FF9800;
}

.test-results {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.test-line {
    margin: 5px 0;
    padding: 5px;
    border-radius: 3px;
}

.line-0 { background: rgba(255, 0, 0, 0.2); border-left: 3px solid #f00; }
.line-1 { background: rgba(0, 255, 0, 0.2); border-left: 3px solid #0f0; }
.line-2 { background: rgba(0, 0, 255, 0.2); border-left: 3px solid #00f; }
/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    .game-boards {
        flex-direction: column;
        align-items: center;
    }
    
    .board-container {
        margin-bottom: 15px;
    }
    
    .canvas-container {
        max-width: 350px;
    }
    
    .players {
        flex-direction: column;
        gap: 10px;
    }
}