/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #34495e 100%);
    min-height: 100vh;
    position: relative;
}

/* Navy pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(255,255,255,0.1) 1px, transparent 0);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 3.5rem;
    color: #ecf0f1;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    font-weight: bold;
    letter-spacing: 3px;
}

.subtitle {
    color: #bdc3c7;
    font-size: 1.2rem;
    font-style: italic;
    margin-bottom: 20px;
}

.back-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Phase Indicator */
.phase-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    gap: 20px;
}

.phase {
    padding: 10px 20px;
    background: rgba(52, 73, 94, 0.7);
    color: #bdc3c7;
    border-radius: 25px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.phase.active {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

/* Setup Area */
.setup-area {
    background: rgba(236, 240, 241, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.setup-instructions {
    text-align: center;
    margin-bottom: 30px;
}

.setup-instructions h3 {
    color: #2c3e50;
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.setup-content {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
}

/* Fleet Dock */
.fleet-dock {
    background: rgba(52, 73, 94, 0.1);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #34495e;
}

.fleet-dock h4 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.3rem;
}

.ship-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ship {
    background: linear-gradient(45deg, #7f8c8d, #95a5a6);
    border: 2px solid #34495e;
    border-radius: 8px;
    padding: 10px;
    cursor: grab;
    transition: all 0.3s ease;
    user-select: none;
    position: relative;
}

.ship:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.ship.dragging {
    cursor: grabbing;
    opacity: 0.7;
    transform: rotate(5deg);
}

.ship.placed {
    opacity: 0.7;
    cursor: default;
}

.ship.vertical .ship-visual {
    flex-direction: column !important;
    align-items: center !important;
}

.ship-name {
    text-align: center;
    font-weight: bold;
    margin-bottom: 5px;
    color: #2c3e50;
    font-size: 0.9rem;
}

.ship-visual {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2px;
    transition: all 0.3s ease;
}

.rotate-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(52, 73, 94, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rotate-btn:hover {
    background: rgba(52, 73, 94, 1);
    transform: scale(1.1);
}

.ship.placed .rotate-btn {
    display: none;
}

.ship-cell {
    width: 20px;
    height: 20px;
    background: linear-gradient(45deg, #2c3e50, #34495e);
    border: 1px solid #1a252f;
    border-radius: 3px;
}

/* Grid Styles */
.grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    background: #34495e;
    padding: 5px;
    border-radius: 8px;
    width: 320px;
    height: 320px;
}

.grid-cell {
    background: #3498db;
    border: 1px solid #2980b9;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.grid-cell:hover {
    background: #5dade2;
    transform: scale(1.1);
}

/* Grid cell states */
.grid-cell.ship {
    background: linear-gradient(45deg, #7f8c8d, #95a5a6);
    border-color: #34495e;
}

.grid-cell.hit {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

.grid-cell.miss {
    background: linear-gradient(45deg, #ecf0f1, #bdc3c7);
    color: #34495e;
}

.grid-cell.sunk {
    background: linear-gradient(45deg, #8e44ad, #6c3483);
    color: white;
}

.grid-cell.drag-over {
    background: rgba(46, 204, 113, 0.5);
    border-color: #27ae60;
    transform: scale(1.05);
}

.grid-cell.invalid-drop {
    background: rgba(231, 76, 60, 0.5);
    border-color: #c0392b;
    animation: shake 0.5s ease-in-out;
}

/* Battle Area */
.battle-area {
    background: rgba(236, 240, 241, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.battle-grids {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 40px;
    margin-bottom: 30px;
}

.player-area, .enemy-area {
    text-align: center;
}

.player-area h3, .enemy-area h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

/* Fleet Status */
.fleet-status {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.ship-status {
    background: rgba(52, 73, 94, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: bold;
}

.ship-status.sunk {
    background: rgba(231, 76, 60, 0.8);
    text-decoration: line-through;
}

/* Battle Info */
.battle-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(52, 73, 94, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
}

.turn-info {
    text-align: center;
}

.current-turn {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.shots-remaining {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1.1rem;
}

.game-stats {
    display: flex;
    gap: 30px;
}

.stat {
    text-align: center;
}

.stat span:first-child {
    color: #7f8c8d;
    display: block;
    font-size: 0.9rem;
}

.stat span:last-child {
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: bold;
}

/* Button Styles */
.game-controls {
    text-align: center;
    margin-bottom: 20px;
}

.setup-controls {
    text-align: center;
    margin-top: 30px;
}

.btn {
    padding: 12px 24px;
    margin: 0 10px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

.btn-primary:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(45deg, #2980b9, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn-warning {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(45deg, #e67e22, #f39c12);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.3);
}

.btn:active {
    transform: translateY(0);
}

/* Statistics Panel */
.statistics-panel {
    background: rgba(52, 73, 94, 0.9);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.statistics-panel h4 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: #ecf0f1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: rgba(236, 240, 241, 0.1);
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.stat-label {
    color: #bdc3c7;
}

.stat-value {
    color: #ecf0f1;
    font-weight: bold;
}

/* Animations */
@keyframes hit {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); background: #e74c3c; }
    100% { transform: scale(1); }
}

@keyframes miss {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: #ecf0f1; }
    100% { transform: scale(1); }
}

@keyframes sink {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.hit-animation {
    animation: hit 0.6s ease-in-out;
}

.miss-animation {
    animation: miss 0.4s ease-in-out;
}

.sink-animation {
    animation: sink 1s ease-in-out;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .setup-content {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }
    
    .battle-grids {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }
    
    .battle-info {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
    
    .game-stats {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    .grid {
        width: 280px;
        height: 280px;
    }
    
    .phase-indicator {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .ship-visual {
        flex-wrap: wrap;
        max-width: 100px;
    }
    
    .setup-area, .battle-area {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
