* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    padding: 1rem;
}

.game-container {
    width: 100%;
    max-width: 900px;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    padding: 2rem;
    border-radius: 1rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
}

.overlay-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.difficulty-select {
    margin: 2rem 0;
}

.difficulty-select h3 {
    text-align: center;
    margin-bottom: 1rem;
}

.difficulty-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.5rem;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.instructions {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-top: 2rem;
}

.instructions h3, .instructions h4 {
    margin-bottom: 1rem;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.instructions li {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.port-legend {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.legend-grid div {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.stats {
    margin: 2rem 0;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-label {
    font-weight: bold;
}

.stat-value {
    font-size: 1.2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: #48bb78;
    color: #fff;
}

.btn-primary:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    margin-left: 1rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

#gameUI {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#gameUI.hidden {
    display: none;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.stat-box .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.stat-box span:last-child {
    font-size: 1.5rem;
    font-weight: bold;
}

.port-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    min-height: 80px;
}

.port-info h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.port-details {
    font-size: 0.95rem;
    line-height: 1.5;
}

.grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

#grid {
    display: grid;
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px;
    border-radius: 0.5rem;
}

.cell {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    user-select: none;
}

.cell:hover:not(.revealed):not(.flagged) {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.cell.revealed {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    cursor: default;
}

.cell.flagged {
    background: rgba(246, 173, 85, 0.6);
    color: #fff;
}

.cell.port {
    background: #e53e3e;
    color: #fff;
    animation: explode 0.5s ease;
}

.cell.number-1 { color: #2b6cb0; }
.cell.number-2 { color: #38a169; }
.cell.number-3 { color: #dd6b20; }
.cell.number-4 { color: #9f7aea; }
.cell.number-5 { color: #d53f8c; }
.cell.number-6 { color: #00b5d8; }
.cell.number-7 { color: #000; }
.cell.number-8 { color: #000; }

.controls {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

@keyframes explode {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

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

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .overlay-content {
        padding: 1.5rem;
    }

    #gameUI {
        padding: 1rem;
    }

    .cell {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .game-stats {
        flex-direction: column;
    }

    .btn-secondary {
        margin-left: 0;
        margin-top: 0.5rem;
        display: block;
    }

    .legend-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .cell {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    #grid {
        gap: 1px;
    }
}
