:root {
    --cell-size: 40px; 
    --border-color: #444;
    --sea-gradient: linear-gradient(180deg, #e1f5fe 0%, #b3e5fc 100%);
    --accent-teal: #00acc1;
}

* { 
    box-sizing: border-box; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex; 
    flex-direction: column; 
    align-items: center;
    background: var(--sea-gradient); 
    min-height: 100vh; 
    margin: 0; 
    padding: 20px;
}

h1 { 
    color: #1a237e; 
    margin-bottom: 5px; 
    text-transform: uppercase;
    letter-spacing: 2px;
}

#main-game-area {
    width: 100%; 
    display: none; 
    flex-direction: column; 
    align-items: center;
}

.top-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-group {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-weight: bold;
    color: #37474f;
}

#difficulty-select {
    padding: 8px 15px; 
    border-radius: 50px; 
    border: 2px solid var(--accent-teal); 
    outline: none;
    background: white;
    font-weight: 600;
}

#status-text {
    font-weight: bold; 
    text-transform: uppercase; 
    color: #455a64;
    margin: 5px 0;
    font-size: 0.9rem;
    letter-spacing: 1px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.setup-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 25px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
}

.dock-container {
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 25px;
    min-height: 220px; 
    margin-bottom: 10px;
}

.orientation-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.button-group {
    display: flex; 
    background: #fff; 
    padding: 5px; 
    border-radius: 50px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

.button-group button {
    padding: 10px 30px; 
    border: none; 
    border-radius: 50px; 
    background: transparent;
    color: #666; 
    font-weight: bold; 
    cursor: pointer; 
    transition: all 0.3s ease;
}

.button-group button.active {
    background: var(--accent-teal); 
    color: white; 
    box-shadow: 0 4px 15px rgba(0, 172, 193, 0.3);
}

.dock-ship {
    height: var(--cell-size);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    cursor: grab;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: transform 0.2s ease;
}

.dock-ship.vertical { 
    transform: rotate(90deg); 
}

.dock-ship:active { 
    cursor: grabbing; 
}

.carrier { width: calc(var(--cell-size) * 5); background-image: url('./assets/carrier.png'); }
.battleship { width: calc(var(--cell-size) * 4); background-image: url('./assets/battleship.png'); }
.cruiser { width: calc(var(--cell-size) * 3); background-image: url('./assets/cruiser.png'); }
.submarine { width: calc(var(--cell-size) * 3); background-image: url('./assets/submarine.png'); }
.destroyer { width: calc(var(--cell-size) * 2); background-image: url('./assets/destroyer.png'); }

.game-container { 
    display: flex; 
    gap: 40px; 
    justify-content: center; 
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: calc(var(--cell-size) * 10);
    height: 40px;
    margin-bottom: 10px;
}

.board-header h3 {
    margin: 0;
    color: #1a237e;
    font-weight: 800;
    font-size: 1.1rem;
}

.board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    background-color: #81d4fa;
    border: 2px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    padding: 0;
    overflow: hidden;
}

.ship-display {
    position: absolute;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 5;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background-color 0.2s;
}

.cell.hit { 
    background-color: rgba(255, 0, 0, 0.5);
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 6;
}

.cell.hit::after { 
    content: '💥'; 
    font-size: 20px; 
}

.cell.miss { 
    background-color: #1a237e; 
    opacity: 1;
    z-index: 6;
}

.cell.p2-shot.hit { 
    background-color: rgba(255, 200, 0, 0.7) !important; 
}

.cell.p2-shot.hit::after { 
    content: '⭐'; 
    font-size: 20px; 
}

.cell.p2-shot.miss { 
    background-color: rgba(46, 160, 67, 0.8) !important; 
    opacity: 1 !important;
}

#cpu-board {
    background-color: rgba(255, 160, 80, 0.4) !important;
}

#cpu-board .cell {
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.cell:hover { 
    background-color: rgba(0, 150, 136, 0.4); 
    cursor: cell; 
}

.cell.preview-valid { 
    background-color: rgba(46, 204, 113, 0.7) !important; 
}

.cell.preview-invalid { 
    background-color: rgba(231, 76, 60, 0.7) !important; 
}
.modal-overlay {
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.85);
    display: none; 
    justify-content: center; 
    align-items: center; 
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal-content { 
    background: white; 
    padding: 50px; 
    border-radius: 30px; 
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h2 {
    font-weight: 900;
    color: #212121;
    margin-bottom: 10px;
    font-size: 2rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 30px;
}

.start-game-btn, #modal-btn {
    padding: 18px 70px; 
    font-size: 1.3rem; 
    background: var(--accent-teal);
    color: white; 
    border: none; 
    border-radius: 50px; 
    cursor: pointer;
    font-weight: bold; 
    text-transform: uppercase;
    box-shadow: 0 8px 0px #006064;
    transition: all 0.2s;
}

.start-game-btn:hover, #modal-btn:hover { 
    background: #00bcd4; 
    transform: translateY(-2px); 
}

.start-game-btn:active, #modal-btn:active { 
    transform: translateY(4px); 
    box-shadow: 0 2px 0px #006064; 
}

.fleet-hidden .ship-display {
    opacity: 0 !important;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.toggle-btn {
    padding: 8px 16px;
    border-radius: 50px;
    border: 2px solid var(--accent-teal);
    background: white;
    color: var(--accent-teal);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.toggle-btn:hover {
    background: var(--accent-teal);
    color: white;
    transform: translateY(-2px);
}

.toggle-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#fog-of-war-modal {
    background: radial-gradient(circle, rgba(44, 62, 80, 0.9) 0%, rgba(0, 0, 0, 0.95) 100%);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content h2#fog-title {
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    100% { transform: translate(1px, 1px) rotate(0deg); }
}