:root {
    --primary-purple: #9370DB;
    --near-black: #0D0D0D;
    --card-black: #1A1A1A;
    --grid-color: rgba(147, 112, 219, 0.05);
    --dot-color: rgba(255, 255, 255, 0.1);
    --ship-color: #4169E1;
    --hit-color-light: #f95d5d; 
    --sunk-color: #6b0505;      
    --miss-color: #457b9d;
    --cell-size: clamp(25px, 8vw, 45px);
}

html, body {
    min-height: 100vh; 
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--near-black);
    color: #EAEAEA;
    font-family: 'Manrope', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; 
    background-image:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: moveGrid 0.8s linear infinite;
    overflow-x: hidden;
}

@keyframes moveGrid {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 0 -120px;
    }
}

#particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.solana-flake {
    position: absolute;
    top: -10%;
    background-image: url('solana_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    animation: fall linear infinite;

    /* NEW STYLES for glow and shape */
    border-radius: 50%;
    opacity: 0.7;
    box-shadow: 0 0 15px 3px rgba(147, 112, 219, 0.4);
}

@keyframes fall {
    from {
        /* Add a starting rotation value */
        transform: translateY(-10vh) rotate(0deg);
    }
    to {
        /* The flake will fall and complete two full rotations */
        transform: translateY(105vh) rotate(720deg);
    }
}

/* REPLACE the entire block of 20 :nth-child rules with this one */

.solana-flake:nth-child(1){width:24px;height:24px;left:10%;animation-duration:12s;animation-delay:-1s;opacity:.3}
.solana-flake:nth-child(2){width:36px;height:36px;left:20%;animation-duration:8s;animation-delay:-5s;opacity:.5}
.solana-flake:nth-child(3){width:16px;height:16px;left:30%;animation-duration:14s;animation-delay:-10s;opacity:.2}
.solana-flake:nth-child(4){width:28px;height:28px;left:40%;animation-duration:9s;animation-delay:-3s;opacity:.4}
.solana-flake:nth-child(5){width:40px;height:40px;left:50%;animation-duration:7s;animation-delay:-7s;opacity:.6}
.solana-flake:nth-child(6){width:20px;height:20px;left:60%;animation-duration:13s;animation-delay:-2s;opacity:.25}
.solana-flake:nth-child(7){width:32px;height:32px;left:70%;animation-duration:10s;animation-delay:-8s;opacity:.45}
.solana-flake:nth-child(8){width:48px;height:48px;left:80%;animation-duration:6s;animation-delay:-4s;opacity:.7}
.solana-flake:nth-child(9){width:24px;height:24px;left:90%;animation-duration:11s;animation-delay:-11s;opacity:.35}
.solana-flake:nth-child(10){width:36px;height:36px;left:5%;animation-duration:15s;animation-delay:-6s;opacity:.55}
main#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1600px;
    min-height: 100vh; 
    padding: 1rem; 
    box-sizing: border-box;
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
    position: relative;
    z-index: 1;
}

#game-core-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start; 
    align-items: center;
    gap: clamp(1rem, 1.5rem, 1.5rem); 
    width: 100%;
    padding-top: 1.5rem;
    box-sizing: border-box;
}

#top-section { 
    width: 100%; 
    max-width: 800px;
    text-align: center; 
}

@keyframes auroraGlow {
    0%   { text-shadow: 0 0 20px rgba(153, 69, 255, 0.8), 0 0 30px rgba(153, 69, 255, 0.6); }
    25%  { text-shadow: 0 0 25px rgba(255, 255, 255, 0.8), 0 0 35px rgba(255, 255, 255, 0.8); }
    50%  { text-shadow: 0 0 20px rgba(152, 63, 253, 0.8), 0 0 30px rgba(152, 63, 253, 0.8); }
    75%  { text-shadow: 0 0 25px rgba(64, 64, 64, 0.8), 0 0 35px rgba(64, 64, 64, 0.8); }
    100% { text-shadow: 0 0 20px rgba(153, 69, 255, 0.8), 0 0 30px rgba(153, 69, 255, 0.6); }
}

h1 { 
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 800;
    margin: 0;
    color: white;
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: auroraGlow 6s ease-in-out infinite;
}

.subtitle {
    color: var(--primary-purple);
    font-weight: 700;
    font-size: clamp(0.8rem, 3vw, 1rem);
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
}

#game-status {
    position: relative;
    background-color: var(--card-black);
    border: 1px solid var(--primary-purple);
    border-radius: 50px;
    margin-top: 1rem;
    text-align: center;
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
    animation: pulseGlowStatus 3s ease-in-out infinite;
    width: clamp(300px, 90%, 450px);
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

#enemy-ships-tracker {
    margin-top: 1rem;
}
#enemy-ships-tracker h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--primary-purple);
    letter-spacing: 1px;
    opacity: 0.7;
}
#enemy-ship-list {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.enemy-ship-indicator {
    display: flex;
    gap: 2px;
    transition: opacity 0.5s ease;
}
.enemy-ship-indicator.sunk {
    opacity: 0.2;
    text-decoration: line-through;
}
.enemy-ship-segment {
    width: 15px;
    height: 15px;
    background-color: #191970;
    border: 1px solid var(--primary-purple);
    border-radius: 2px;
}

@keyframes pulseGlowStatus {
    0%, 100% {
        box-shadow: 0 0 10px -2px var(--primary-purple);
    }
    50% {
        box-shadow: 0 0 15px 0px var(--primary-purple);
    }
}

#game-status::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress-width, 0%);
    background-color: rgba(147, 112, 219, 0.3);
    transition: width 0.5s ease-in-out;
}

#game-status span {
    position: relative;
    z-index: 1;
    color: var(--primary-purple);
    font-family: 'Roboto Mono', sans-serif;
    font-size: clamp(0.8rem, 3vw, 1rem);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 0 0 8px rgba(147, 112, 219, 0.5);
}


#mobile-toggle {
    margin-top: 1rem;
    max-width: 280px;
    align-self: center;
}

.boards-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.board {
    display: none; 
    flex-direction: column;
    align-items: center;
}

#computer-board-container {
    position: relative;
}

.board h2 { display: none; }

.grid {
    display: grid;
    grid-template-columns: repeat(9, var(--cell-size));
    grid-template-rows: repeat(9, var(--cell-size));
    gap: 2px;
    padding: 8px;
    border-radius: 12px;
    background-color: var(--card-black);

    /* --- REVERTED TO ORIGINAL NON-GLOWING STYLE --- */
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    
    transition: border-color 0.3s, box-shadow 0.3s;
}

#computer-grid { 
    border: 1px solid var(--primary-purple); 
}

.cell { border-radius: 4px; position: relative; overflow: hidden; }
.cell::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 15%; height: 15%;
    background-color: var(--dot-color); border-radius: 50%;
    transition: all 0.3s ease;
}
#computer-grid .cell { cursor: pointer; }
#computer-grid .cell:hover:not(.hover-invalid):not(.hover-cluster) { background-color: var(--primary-purple); }
.cell.hit::before, .cell.miss::before, .cell.sunk::before, .cell.ship-placed::before { background-color: transparent; }

#player-grid .cell.ship-placed {
    background-image: url('ship1.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;

    /* ADD THIS LINE to apply the glow */
    filter: drop-shadow(0 0 6px rgba(147, 112, 219, 0.7));
}

#computer-grid .cell.hit, #opponent-grid .cell.hit {
    background: url('ship2.png') center/contain no-repeat, var(--hit-color-light);
}
#computer-grid .cell.miss, #opponent-grid .cell.miss { background-color: var(--miss-color); }

#player-grid .cell.hit {
    background: url('ship1.png') center/contain no-repeat, var(--hit-color-light);
}
#player-grid .cell.miss { background-color: rgba(255, 255, 255, 0.5); }

#player-grid .cell.sunk {
    background: url('ship1.png') center/contain no-repeat, var(--sunk-color) !important;
}
#computer-grid .cell.sunk, #opponent-grid .cell.sunk {
    background: url('ship2.png') center/contain no-repeat, var(--sunk-color) !important;
}

#player-grid .cell.ship-reveal {
    background: url('ship1.png') center/contain no-repeat;
    opacity: 0.5;
}
#computer-grid .cell.ship-reveal {
    background: url('ship2.png') center/contain no-repeat;
    opacity: 0.5;
}

#computer-grid .cell.hit,
#computer-grid .cell.sunk,
#computer-grid .cell.ship-reveal,
#opponent-grid .cell.hit,
#opponent-grid .cell.sunk {
    filter: hue-rotate(180deg);
}

.cell.sunk::after {
    content: '✖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: calc(var(--cell-size) * 0.8);
    font-weight: bold;
    line-height: 1;
    z-index: 2;
}

.cell.hover-valid { background-color: rgba(255, 255, 255, 0.5); }
.cell.hover-invalid { background-color: rgba(231, 76, 60, 0.5); cursor: not-allowed; }
.cell.hover-cluster { background-color: rgba(255, 69, 0, 0.4); }

.cell.explode::before {
    top: 0; left: 0;
    width: 100%; height: 100%;
    transform: scale(0);
    background-color: orangered;
    border-radius: 50%;
    animation: explosion 0.5s ease-out forwards;
    z-index: 3;
}

.cell.radar-reveal {
    animation: radar-pulse 2s ease-out;
}
@keyframes radar-pulse {
    0% { box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7); }
    50% { box-shadow: inset 0 0 25px 5px rgba(0, 191, 255, 0.7); }
    100% { box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7); }
}

/* ============================================== */
/* === UPGRADED RADAR SWEEP ANIMATION STYLES === */
/* ============================================== */

/* ============================================== */
/* === ORIGINAL RADAR SWEEP ANIMATION STYLES === */
/* ============================================== */

.radar-sweep {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: calc(9 * var(--cell-size) + 16px + 4px);
    height: calc(9 * var(--cell-size) + 16px + 4px);
    border-radius: 50%;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    z-index: 5;
    transition: opacity 0.3s ease-out;
}
.radar-sweep.active {
    opacity: 1;
}
.radar-sweep::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        linear-gradient(to right, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        linear-gradient(to bottom, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 25%, rgba(147, 112, 219, 0.3) 25% 25.5%, transparent 25.5%),
        radial-gradient(circle, transparent 50%, rgba(147, 112, 219, 0.3) 50% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 75%, rgba(147, 112, 219, 0.3) 75% 75.5%, transparent 75.5%);
}
.radar-sweep::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: conic-gradient(from 0deg, transparent 0deg 270deg, rgba(147, 112, 219, 0.4) 350deg, transparent 360deg);
    animation: radar-sweep-animation 2s linear;
}
@keyframes radar-sweep-animation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes explosion {
    50% { transform: scale(1.5); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

#bottom-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    align-items: center;
}

#bottom-section:has(#ship-selection:empty) {
    gap: 0;
}

.setup-box {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

#action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.secondary-actions {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    width: 100%;
}

.secondary-actions .btn {
    flex-grow: 1;
    text-decoration: none;
    text-align: center;
    line-height: 1.5;
    box-sizing: border-box;
}

.ship-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
#ship-selection:empty {
    display: none;
}


.ship:hover, .ship.selected { border-color: var(--primary-purple); }

.ship.placed {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.ship.vertical {
    flex-direction: column;
}

.ship-segment { 
    width: clamp(16px, 4vw, 22px);
    height: clamp(16px, 4vw, 22px); 
    background-color: var(--primary-purple); 
    border-radius: 3px; 
}

.btn {
    padding: 0.75em 1.5em;
    font-family: 'Roboto Mono', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
}

.btn--primary { background-color: var(--primary-purple); color: white; border-color: var(--primary-purple); }
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 0 15px -2px var(--primary-purple);
    }
    50% {
        box-shadow: 0 0 25px 2px var(--primary-purple);
    }
}
.btn--primary.glowing-button {
    animation: buttonGlow 2.5s ease-in-out infinite;
}

.btn--secondary { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn--secondary:hover { transform: translateY(-3px); }

#power-ups-container { 
    display: flex; 
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem; 
}

.power-up {
    color: #EAEAEA;
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: 12px;
    padding: 0.5rem 1rem; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 0.75rem; 
    font-family: 'Manrope', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.0) 100%), #1A1A1A;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.1), 0 2px 3px rgba(0,0,0,0.3);
}
.power-up:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.4);
}

.power-up.selected { 
    border-color: var(--primary-purple);
    box-shadow: 0 0 10px -2px var(--primary-purple), inset 0 1px 1px rgba(255,255,255,0.1), 0 2px 3px rgba(0,0,0,0.3);
    animation: pulseGlowPowerup 2.5s ease-in-out infinite;
}

@keyframes pulseGlowPowerup {
    0%, 100% {
        box-shadow: 0 0 10px -2px var(--primary-purple), inset 0 1px 1px rgba(255,255,255,0.1), 0 2px 3px rgba(0,0,0,0.3);
    }
    50% {
        box-shadow: 0 0 18px 0px var(--primary-purple), inset 0 1px 1px rgba(255,255,255,0.1), 0 2px 3px rgba(0,0,0,0.3);
    }
}

.power-up:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    filter: grayscale(50%);
}
.power-up .count { 
    background-color: var(--primary-purple); 
    color: white; 
    font-size: 0.8rem; 
    font-weight: bold;
    border-radius: 50%; 
    width: 22px; 
    height: 22px; 
    line-height: 22px; 
    text-align: center; 
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(147, 112, 219, 0.5);
}

.hidden { display: none !important; }

.gamestate-setup #player-board-container { display: flex; }
.gamestate-player_turn #computer-board-container { display: flex; }
.gamestate-computer_turn #player-board-container,
.gamestate-transition #player-board-container { display: flex; }

.gamestate-gameover #player-board-container,
.gamestate-gameover #computer-board-container { display: flex; }

body.view-override.gamestate-player_turn #player-board-container { display: flex; }
body.view-override.gamestate-player_turn #computer-board-container { display: none; }
body.view-override.gamestate-computer_turn #player-board-container { display: none; }
body.view-override.gamestate-computer_turn #computer-board-container { display: flex; }

@media (min-width: 901px) {
    :root {
        --cell-size: clamp(35px, 4.5vmin, 55px);
    }
    
    body {
        align-items: center; 
    }

    #game-core-container {
        padding-top: 0; 
        justify-content: center; 
        gap: clamp(1rem, 2vmin, 2rem);
    }

    .boards-container {
        flex-direction: row;
        justify-content: center;
        gap: clamp(1rem, 3vmin, 3rem);
    }
    
    .board {
        display: flex !important;
    }

    .board h2 { display: block; font-size: clamp(0.9rem, 2vmin, 1.1rem); }
    
    #bottom-section {
        flex-direction: row;
        width: auto;
        border: 0px solid;
        border-radius: 12px;
        padding: 0.6rem 0.8rem;
        gap: 1rem;
    }

    .setup-box {
        width: auto;
        max-width: none;
    }
    
    #action-buttons-container {
        order: 1;
        flex-direction: row;
        align-items: center;
        gap: 0.75rem;
    }
    
    .secondary-actions {
        order: -1;
    }

    .ship-selection {
        display: flex; 
        gap: 0.5rem;
    }
    
    .ship-segment {
        width: 22px;
        height: 22px;
    }

    .btn { 
        width: auto;
        padding: 0.6em 1.2em;
        font-size: 0.9rem;
    }
    .power-up {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    .power-up .count {
        width: 20px;
        height: 20px;
        line-height: 20px;
        font-size: 0.7rem;
    }
}

@media (max-height: 700px) and (max-width: 400px) {
    #game-core-container {
        gap: 0.5rem; 
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    .grid {
        transform: scale(0.85);
    }
    h1 {
        font-size: 1.6rem;
        letter-spacing: 2px;
    }
     .subtitle {
        font-size: 0.7rem;
    }

    #game-status {
        padding: 0 1rem;
    }
    #game-status span {
        font-size: 0.7rem;
    }

    .ship-segment {
        --ship-seg-size: 16px;
        width: var(--ship-seg-size);
        height: var(--ship-seg-size);
    }
    .btn {
        padding: 0.6em 1.2em;
        font-size: 0.8rem;
    }
}

@media (min-width: 901px) and (max-height: 850px) {
    :root {
        --cell-size: clamp(28px, 4vh, 35px);
    }
    
    body {
        align-items: flex-start;
    }

    #game-core-container {
        justify-content: flex-start;
        gap: clamp(0.5rem, 1.5vh, 1rem);
        padding-top: 1vh;
        padding-bottom: 2vh;
    }

    .boards-container {
        gap: clamp(1rem, 2vmin, 2rem);
    }
}

/* --- MODIFIED SECTION FOR MOBILE BUTTON ORDERING --- */
@media (max-width: 900px) {
    #action-buttons-container #start-button {
        order: -1; /* Move Start Game button to the top */
        animation: buttonGlow 2.5s ease-in-out infinite;
    }
    .secondary-actions {
        flex-direction: column; /* Stack Rotate and Multiplayer buttons */
    }
}

@media (max-width: 525px) {
    #game-status {
        transform: scale(1, 1);
    }
}
/* --- END MODIFIED SECTION --- */

@media (min-height: 1000px) and (max-width: 1400px) {
    #player-board-container {
        transform: scale(0.9);
    }

    #computer-board-container {
        transform: scale(0.9);
    }
}

.popup{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.5);font-size:clamp(4rem,15vw,8rem);font-weight:800;color:#fff;text-shadow:0 0 20px rgba(0,0,0,.5);pointer-events:none;opacity:0;z-index:1000}.popup.show{animation:popup-effect 1.2s ease-out forwards}@keyframes fadeIn{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes popup-effect{0%,100%{opacity:0;transform:translate(-50%,-50%) scale(.5)}20%,80%{opacity:1;transform:translate(-50%,-50%) scale(1)}}


/* --- Multiplayer Page Styles --- */
.multiplayer-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 100vh;
    width: 100%;
    padding: 1rem;
    box-sizing: border-box;
    gap: 2rem;
    opacity: 0;
    animation: fadeIn 0.8s ease-out forwards;
    z-index: 1;
}

.development-text {
    font-size: clamp(2rem, 8vw, 4.5rem);
    font-weight: 800;
    color: white;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: auroraGlow 6s ease-in-out infinite;
}

.multiplayer-container .btn {
    max-width: 250px;
}

/* 
===============================================
=== STYLES ADDED FOR MULTIPLAYER LOBBY/GAME ===
===============================================
*/

/* --- LOBBY STYLES --- */
#lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 500px;
}

.lobby-list-container {
    width: 100%;
    background-color: var(--card-black);
    border: 1px solid var(--primary-purple);
    border-radius: 12px;
    padding: 1rem;
    box-sizing: border-box;
}

.lobby-list-container h2 {
    text-align: center;
    margin: 0 0 1rem 0;
    color: var(--primary-purple);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#lobby-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 40vh;
    overflow-y: auto;
}

.lobby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.lobby-item span {
    font-family: 'Roboto Mono', sans-serif;
}

.lobby-item .btn--secondary {
    width: auto;
    padding: 0.5em 1em;
    font-size: 0.9rem;
}

/* --- GAMEPLAY VISUAL FIXES --- */

/* Fix cursor for opponent grid */
#opponent-grid .cell {
    cursor: not-allowed;
}
#opponent-grid.active-turn .cell {
    cursor: pointer;
}

/* Add hover effect for active turn */
#opponent-grid.active-turn .cell:hover:not(.hit):not(.miss) {
    background-color: var(--primary-purple);
}

/* Add visual glow for active turn board */
.grid.active-turn {
    border-color: var(--hit-color-light);
    box-shadow: 0 0 20px 0px var(--hit-color-light);
}

/* --- BUTTON NORMALIZATION FIX --- */
/* Ensures <a> tags with the .btn class look identical to <button> tags */
.btn {
    text-decoration: none; /* Removes underline from <a> tags */
    display: inline-flex;  /* Helps with vertical alignment and sizing */
    justify-content: center;
    align-items: center;
    box-sizing: border-box; /* Ensures padding doesn't break width */
}

/* --- MODAL POP-UP STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-black);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--primary-purple);
    box-shadow: 0 0 30px rgba(147, 112, 219, 0.4);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-purple);
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* --- HOSTING VIEW STYLES --- */
#hosting-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    color: #EAEAEA;
}
.hosting-text {
    font-size: 1.2rem;
    text-align: center;
    line-height: 1.5;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- MODAL POP-UP STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-black);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--primary-purple);
    box-shadow: 0 0 30px rgba(147, 112, 219, 0.4);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-purple);
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* --- HOSTING VIEW STYLES --- */
#hosting-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    color: #EAEAEA;
}
.hosting-text {
    font-size: 1.2rem;
    text-align: center;
    line-height: 1.5;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

#lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 500px;
}

/* --- HOSTING VIEW STYLES --- */
#hosting-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    color: #EAEAEA;
}
.hosting-text {
    font-size: 1.2rem;
    text-align: center;
    line-height: 1.5;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- MODAL POP-UP STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}
.modal-content {
    background-color: var(--card-black);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--primary-purple);
    box-shadow: 0 0 30px rgba(147, 112, 219, 0.4);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}
.modal-content h2 {
    margin-top: 0;
    color: var(--primary-purple);
}
.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

/* --- GAMEPLAY VISUAL FIXES --- */
.grid.active-turn {
    border-color: var(--hit-color-light);
    box-shadow: 0 0 20px 0px var(--hit-color-light);
}
#opponent-grid .cell { cursor: not-allowed; }
#opponent-grid.active-turn .cell:hover:not(.hit):not(.miss) { background-color: var(--primary-purple); }

/* --- BUTTON NORMALIZATION FIX --- */
.btn {
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

/* 
============================================================
=== ADD THIS TO THE END of your existing style.css file ===
============================================================
*/

/* --- LOGIN SCREEN STYLES --- */
#login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.5s ease-out;
}
.login-title {
    color: var(--primary-purple);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.username-input {
    /* Copied from #game-status for a perfect match */
    background-color: var(--card-black);
    border: 1px solid var(--primary-purple);
    border-radius: 50px; /* Fully rounded corners */
    animation: pulseGlowStatus 3s ease-in-out infinite;
    
    /* Sizing and Text Styling */
    color: #EAEAEA;
    height: 50px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    font-family: 'Roboto Mono', sans-serif;
    font-size: 1rem;
    padding: 0 1.5rem;
    transition: all 0.3s ease;
}

/* Remove default browser outline on focus */
.username-input:focus {
    outline: none;
    /* Make the glow more intense when the user is typing */
    animation: pulseGlowStatus 1.5s ease-in-out infinite;
    box-shadow: 0 0 18px 0px var(--primary-purple);
}

/* Style for the placeholder text */
.username-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Roboto Mono', sans-serif;
}
/* --- SEA WAVE AND FLOATING LOGO STYLES --- */
/* ============================================================== */
/* === 3. CORRECTED style for the animation container background === */
/* ============================================================== */

#sea-animation-container {
    width: 100%;
    max-width: 500px;
    height: 150px;
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
    border-radius: 12px;
    
    /* REVERTED: The simple, static square grid background you wanted */
    background-color: var(--near-black);
    background-image: 
        linear-gradient(to right, rgba(147, 112, 219, 0.1) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(147, 112, 219, 0.1) 1px, transparent 1px);
    background-size: 30px 30px; /* This defines the size of the squares */

    will-change: transform;
}





/* --- HOSTING VIEW STYLES (From previous version) --- */
#hosting-container {
    display: flex; flex-direction: column; align-items: center; gap: 1.5rem; margin-top: 2rem; color: #EAEAEA;
}
.hosting-text { font-size: 1.2rem; text-align: center; line-height: 1.5; }
.spinner { width: 50px; height: 50px; border: 5px solid rgba(255, 255, 255, 0.2); border-top-color: var(--primary-purple); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- MODAL POP-UP STYLES (From previous version) --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 2000; backdrop-filter: blur(5px); }
.modal-content { background-color: var(--card-black); padding: 2rem; border-radius: 16px; border: 1px solid var(--primary-purple); box-shadow: 0 0 30px rgba(147, 112, 219, 0.4); text-align: center; animation: fadeIn 0.3s ease-out; }
.modal-content h2 { margin-top: 0; color: var(--primary-purple); }
.modal-actions { margin-top: 1.5rem; display: flex; gap: 1rem; }

/* 
============================================================
=== ADD THIS TO THE END of your existing style.css file ===
============================================================
*/

/* --- LOGIN SCREEN STYLES --- */
#login-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 1rem; width: 100%; max-width: 400px; animation: fadeIn 0.5s ease-out; }
.login-title { color: var(--primary-purple); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.username-input { background-color: var(--card-black); border: 1px solid rgba(255, 255, 255, 0.3); color: #EAEAEA; padding: 0.75em 1.5em; border-radius: 12px; font-family: 'Roboto Mono', sans-serif; font-size: 1rem; text-align: center; width: 100%; box-sizing: border-box; transition: border-color 0.3s, box-shadow 0.3s; }
.username-input:focus { outline: none; border-color: var(--primary-purple); box-shadow: 0 0 15px -2px var(--primary-purple); }

/* --- SEA WAVE AND FLOATING LOGO STYLES --- */
#sea-animation-container {
    /* This is important for performance */
    will-change: transform;
}
@keyframes wave { 0% { transform: translateX(0); } 50% { transform: translateX(-25%); } 100% { transform: translateX(0); } }


/* --- NEW LOBBY LIST STYLES --- */
#lobby-container { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; margin-top: 1rem; width: 100%; max-width: 500px; }
#lobby-list-container { width: 100%; background-color: var(--card-black); border: 1px solid var(--primary-purple); border-radius: 12px; padding: 1rem; box-sizing: border-box; min-height: 200px; }
#lobby-list-container h2 { text-align: center; margin: 0 0 1rem 0; color: var(--primary-purple); text-transform: uppercase; letter-spacing: 1px; }
#lobby-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 40vh; overflow-y: auto; }
.lobby-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; background-color: rgba(255, 255, 255, 0.05); border-radius: 8px; animation: fadeIn 0.3s ease-out; }
.lobby-item span { font-family: 'Roboto Mono', sans-serif; }
.lobby-item .btn--secondary { width: auto; padding: 0.5em 1em; font-size: 0.9rem; }
.lobby-item.my-lobby .btn--secondary { background-color: #444; border-color: #555; cursor: not-allowed; }
.lobby-item.my-lobby .btn--secondary:hover { transform: none; }



/* 
============================================================
=== ADD THIS TO THE END of your existing style.css file ===
============================================================
*/

/* --- NEW: Waving Dots Loading Animation --- */
.loading-dots-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
}
.loading-dot {
    width: 12px;
    height: 12px;
    margin: 0 4px;
    background-color: var(--primary-purple);
    border-radius: 50%;
    animation: wave-animation 1.4s linear infinite;
}
/* The magic is in the animation delay, creating the wave effect */
.loading-dot:nth-child(2) { animation-delay: -1.2s; }
.loading-dot:nth-child(3) { animation-delay: -1.0s; }
.loading-dot:nth-child(4) { animation-delay: -0.8s; }
.loading-dot:nth-child(5) { animation-delay: -0.6s; }

@keyframes wave-animation {
    0%, 60%, 100% {
        transform: initial;
    }
    30% {
        transform: translateY(-15px);
    }
}


/* --- FIX: Opponent Ship Visibility on Hit --- */
/* This ensures the ship2.png background is applied to the opponent's grid */

#computer-grid .cell.hit, 
#opponent-grid .cell.hit {
    background: url('ship2.png') center/contain no-repeat, var(--hit-color-light);
}

#computer-grid .cell.sunk,
#opponent-grid .cell.sunk {
    background: url('ship2.png') center/contain no-repeat, var(--sunk-color) !important;
}

/* Ensure the hue-rotate filter also applies to the opponent's grid */
#computer-grid .cell.hit,
#computer-grid .cell.sunk,
#computer-grid .cell.ship-reveal,
#opponent-grid .cell.hit,
#opponent-grid .cell.sunk {
    filter: hue-rotate(180deg);
}

/* NEW ADDITIONS - 10.09, 16:45 */

/* 
===============================================
=== NEW STYLES FOR AUTHENTICATION FORM ===
===============================================
*/

/* Style the form container itself */
/* 
===============================================
=== STYLES FOR AUTHENTICATION FORM ===
===============================================
*/

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    align-items: center;
}

#password-input {
    margin-top: -0.5rem; /* Reduce space between inputs */
}

/* --- MODIFIED FOR CENTERING --- */
.auth-actions {
    width: 100%;
    margin-top: 0.5rem;
    display: flex; /* Use flexbox to center content */
    justify-content: center; /* Center the button horizontally */
}

/* New rule to control the button's width */
.auth-actions .btn {
    width: auto; /* Allow the button to size to its content */
    min-width: 150px; /* Give it a nice minimum width */
}
/* --- END MODIFICATION --- */


.toggle-text {
    margin: 0.5rem 0 0 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

.toggle-text span {
    color: var(--primary-purple);
    font-weight: bold;
    cursor: pointer;
    text-decoration: underline;
}

.toggle-text span:hover {
    filter: brightness(1.2);
}

/* 
===============================================


/* 
===============================================
=== CORRECT STYLES FOR JS-POWERED ANIMATION ===
===============================================
*/

#sea-animation-container {
    /* Helps browser optimize animation performance */
    will-change: transform;
}

/* This is the class the JavaScript will look for */
.floaty {
    position: absolute;
    background-size: contain;
    background-repeat: no-repeat;
    will-change: transform; /* Another performance hint for the browser */

    /* Provides a default size so items are never invisible */
    width: 40px;
    height: 40px;
}

/* This rule applies the correct image to solana elements */
.solana {
    background-image: url('solana_logo.png');
    opacity: 0.8; 
    border-radius: 50%;
    box-shadow: 0 0 15px 3px rgba(147, 112, 219, 0.5);
}
/* This rule applies the correct image to ship elements */
.ship {
    padding: 6px; 
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px; 
    cursor: pointer; 
    display: flex;
    gap: 1.8px; 
    background-color: #1A1A1A;
    transition: border-color 0.3s ease, opacity 0.3s ease;
}

.floaty-ship {
    background-image: url('ship1.png');
    opacity: 0.9;
    filter: drop-shadow(0 0 8px rgba(147, 112, 219, 0.6));
}
#start-button {
    animation: buttonGlow 2.5s ease-in-out infinite;
}

/* ======================================================== */
/* === STYLE FOR UNAVAILABLE (DISABLED) START BUTTON === */
/* ======================================================== */

.btn--primary:disabled {
    /* --- The "Darked Out" Look --- */
    background-color: #493f64; /* A much darker, less saturated purple */
    border-color: #352d49;
    color: rgba(255, 255, 255, 0.4); /* Make the text faded */
    cursor: not-allowed; /* Show the 'not allowed' cursor on hover */

    /* --- Removing Active Effects --- */
    transform: none; /* Prevent the hover 'lift' effect */
    box-shadow: none; /* Remove any shadow */

    /* --- IMPORTANT: This stops the glowing --- */
    animation: none;
}

/* --- 2. Glow effect for ships on the player's grid --- */
#player-grid .cell.ship-placed {
    /* The drop-shadow filter is perfect for adding a glow to PNGs */
    filter: drop-shadow(0 0 6px rgba(147, 112, 219, 0.7));
}

/* --- 3. Glow effect for unplaced ships in the selection tray --- */
.ship {
    padding: 6px; 
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px; 
    cursor: pointer; 
    display: flex;
    gap: 1.8px; 
    background-color: #1A1A1A;
    /* Add box-shadow to the transition for a smooth effect */
    transition: border-color 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    
    /* A subtle, default glow for all selectable ships */
    box-shadow: 0 0 8px -2px rgba(147, 112, 219, 0.5);
}

/* Make the glow more intense when a ship is hovered over or selected */
.ship:hover, .ship.selected { 
    border-color: var(--primary-purple); 
    box-shadow: 0 0 15px 0px rgba(147, 112, 219, 0.8);
}

/* ======================================================== */
/* === GLOWING OUTLINE FOR SEA ANIMATION CONTAINER      === */
/* ======================================================== */

/* 1. The "breathing" animation for the glow */
@keyframes pulseContainerGlow {
    0%, 100% {
        /* The glow at its smallest/dimmest state */
        box-shadow: 0 0 15px 2px rgba(147, 112, 219, 0.5);
    }
    50% {
        /* The glow at its largest/brightest state */
        box-shadow: 0 0 25px 5px rgba(147, 112, 219, 0.7);
    }
}

/* 2. Apply the animation to the container */
#sea-animation-container {
    /* This adds a default border that will also pulse with the glow */
    border: 1px solid rgba(147, 112, 219, 0.6);
    
    /* This command runs the animation we defined above */
    animation: pulseContainerGlow 3s ease-in-out infinite;
}

/* ======================================================== */
/* === LIGHTER GLOW FOR PRE-GAME (SETUP) GRIDS ONLY === */
/* ======================================================== */

.gamestate-setup .grid {
    /* A lighter, semi-transparent purple for the border */
    border-color: rgba(147, 112, 219, 0.5);

    /* A smaller, more subtle glow with reduced opacity */
    box-shadow: 0 0 15px 0px rgba(147, 112, 219, 0.4);
}



/* 10/12 - 5PM ADDITONS */

/* Enhanced Radar Sweep Styles */
.radar-sweep {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(9 * var(--cell-size) + 16px + 4px);
    height: calc(9 * var(--cell-size) + 16px + 4px);
    border-radius: 50%;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    z-index: 5;
    transition: opacity 0.3s ease-out;
}

.radar-sweep.active {
    opacity: 1;
}

.radar-sweep::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to right, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        linear-gradient(to bottom, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 25%, rgba(147, 112, 219, 0.3) 25% 25.5%, transparent 25.5%),
        radial-gradient(circle, transparent 50%, rgba(147, 112, 219, 0.3) 50% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 75%, rgba(147, 112, 219, 0.3) 75% 75.5%, transparent 75.5%);
}

.radar-sweep::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: conic-gradient(from 0deg, transparent 0deg 270deg, rgba(147, 112, 219, 0.4) 350deg, transparent 360deg);
    animation: radar-sweep-animation 2s linear;
}

@keyframes radar-sweep-animation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cell.radar-reveal {
    animation: radar-pulse 2s ease-out;
    z-index: 10;
}

@keyframes radar-pulse {
    0% { 
        box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7);
        background-color: rgba(0, 191, 255, 0.3);
    }
    50% { 
        box-shadow: inset 0 0 25px 5px rgba(0, 191, 255, 0.7);
        background-color: rgba(0, 191, 255, 0.6);
    }
    100% { 
        box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7);
        background-color: rgba(0, 191, 255, 0.3);
    }
}



/* Enhanced Radar Sweep Styles - Matches Multiplayer */
.radar-sweep {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(9 * var(--cell-size) + 16px + 4px);
    height: calc(9 * var(--cell-size) + 16px + 4px);
    border-radius: 50%;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    z-index: 5;
    transition: opacity 0.3s ease-out;
}

.radar-sweep.active {
    opacity: 1;
}

.radar-sweep::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to right, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        linear-gradient(to bottom, transparent 49.5%, rgba(147, 112, 219, 0.3) 49.5% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 25%, rgba(147, 112, 219, 0.3) 25% 25.5%, transparent 25.5%),
        radial-gradient(circle, transparent 50%, rgba(147, 112, 219, 0.3) 50% 50.5%, transparent 50.5%),
        radial-gradient(circle, transparent 75%, rgba(147, 112, 219, 0.3) 75% 75.5%, transparent 75.5%);
}

.radar-sweep::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: conic-gradient(from 0deg, transparent 0deg 270deg, rgba(147, 112, 219, 0.4) 350deg, transparent 360deg);
    animation: radar-sweep-animation 2s linear;
}

@keyframes radar-sweep-animation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cell.radar-reveal {
    animation: radar-pulse 2s ease-out;
    z-index: 10;
    background-color: rgba(0, 191, 255, 0.3) !important;
}

@keyframes radar-pulse {
    0% { 
        box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7);
    }
    50% { 
        box-shadow: inset 0 0 25px 5px rgba(0, 191, 255, 0.7);
    }
    100% { 
        box-shadow: inset 0 0 0 0 rgba(0, 191, 255, 0.7);
    }
}