/**
 * ============================================================================
 * BATTLESHIPS - STYLESHEET
 * Game-specific styling for Battleships
 * ============================================================================
 */

/* ============================================================================
   FONT FAMILY - ROCKWELL FOR ALL TEXT
   ============================================================================ */

/* Apply Rockwell to everything on battleships pages - but exclude Font Awesome icons and SVGs */
body:has(#battleships-menu) *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
body:has(#battleships-game) *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
#battleships-game *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu button *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu .game-menu-button *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu .game-menu-hero *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu .stat-card *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-menu-screen.battleships-menu .game-menu-preview *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.modal-overlay *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.modal-content *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.board-container *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-top-bar *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands),
.game-bottom-panel *:not(i[class*="fa-"]):not(svg[class*="fa-"]):not(svg.svg-inline--fa):not(.fa):not(.fas):not(.far):not(.fab):not(.fa-solid):not(.fa-regular):not(.fa-brands) {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif !important;
}

/* Monospace font for timer only */
.game-timer {
    font-family: 'Courier New', monospace !important;
}

/* Exception: Font Awesome icons should use their font - override Rockwell */
/* Font Awesome 6 Pro kit handles this automatically, but we need to ensure Rockwell doesn't override */
/* Ensure ::before pseudo-elements use Font Awesome font */
i[class*="fa-"]:before,
svg[class*="fa-"],
.fa:before,
.fas:before,
.far:before,
.fab:before,
.fa-solid:before,
.fa-regular:before,
.fa-brands:before,
.game-menu-hero__icon i:before,
.game-menu-hero__icon svg,
.game-menu-button-icon i:before,
.game-menu-button-icon svg,
.stat-card i:before,
.stat-card svg,
.game-menu-badge i:before,
.game-menu-badge svg {
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    display: inline-block !important;
    speak: none !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

i[class*="fa-"],
.fa,
.fas,
.far,
.fab,
.fa-solid,
.fa-regular,
.fa-brands,
.game-menu-hero__icon i,
.game-menu-button-icon i,
.stat-card i,
.game-menu-badge i {
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    display: inline-block !important;
}

/* Ensure SVG icons from Font Awesome kit display correctly */
svg.svg-inline--fa,
svg[data-icon],
.game-menu-button-icon svg,
.game-menu-hero__icon svg,
.stat-card svg,
.game-menu-badge svg {
    display: inline-block !important;
    font-size: inherit !important;
    height: 1em !important;
    width: 1em !important;
    overflow: visible !important;
    vertical-align: -0.125em !important;
    fill: currentColor !important;
    color: inherit !important;
}

/* Manual icon content injection as fallback if kit CSS doesn't load */
/* Font Awesome 6 Pro Unicode values - MUST come after font-family rules */
/* Use attribute selectors to match classes more reliably */
i[class*="fa-ship"]:before { 
    content: "\f21a" !important; 
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-fire"]:before { 
    content: "\f06d" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-play"]:before { 
    content: "\f04b" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-check-circle"]:before { 
    content: "\f058" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-robot"]:before { 
    content: "\f544" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-users"]:before { 
    content: "\f0c0" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-chart-line"]:before { 
    content: "\f201" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-cog"]:before { 
    content: "\f013" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-book-open"]:before { 
    content: "\f518" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-home"]:before { 
    content: "\f015" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-plus"]:before { 
    content: "\f067" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-sign-in-alt"]:before { 
    content: "\f2f6" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-copy"]:before { 
    content: "\f0c5" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-check"]:before { 
    content: "\f00c" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-times"]:before { 
    content: "\f00d" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-bars"]:before { 
    content: "\f0c9" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}
i[class*="fa-chevron-down"]:before { 
    content: "\f078" !important;
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}

/* Ensure icon containers don't hide SVG */
.game-menu-button-icon,
.game-menu-hero__icon {
    display: grid !important;
    place-items: center !important;
}

.game-menu-button-icon svg,
.game-menu-hero__icon svg {
    display: block !important;
}

/* Ensure button text alignment matches other buttons exactly */
.game-menu-button {
}

.game-menu-button-text {
    align-self: center !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

.game-menu-button-subtext {
    grid-column: 2 / span 1 !important;
    font-size: 0.95rem !important;
    color: var(--game-text-muted) !important;
    margin-top: -0.35rem !important;
    line-height: 1.5 !important;
}

.game-menu-button-icon {
    display: grid !important;
    place-items: center !important;
    width: 48px !important;
    height: 48px !important;
}

/* ============================================================================
   GAME SCREEN
   ============================================================================ */

#battleships-game {
    height: 100vh;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    color: #F8FAFC;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    #battleships-game {
        overflow-y: hidden;
        overflow-x: hidden;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height for mobile */
        padding: 0.5rem;
    }
}

/* Account for shared game header if present */
body.with-game-header #battleships-game {
    padding-top: 5rem;
}

/* On mobile, use fixed header */
@media (max-width: 768px) {
    body.with-game-header #battleships-game {
        padding-top: 70px !important;
    }
}

#battleships-game.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

/* Battleships game's own top bar (scoped to avoid conflict with shared header) */
#battleships-game .game-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    font-size: 0.875rem;
    position: relative;
    z-index: 1;
}

.game-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.game-mode {
    font-weight: 600;
    color: #3B82F6;
}

.game-turn {
    font-weight: 500;
}

.game-timer {
    font-family: 'Courier New', monospace;
    color: #FAB719;
}

.game-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-menu,
.btn-hint {
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid #3B82F6;
    border-radius: 0.25rem;
    color: #3B82F6;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.btn-menu:hover,
.btn-hint:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* ============================================================================
   GAME CONTAINER
   ============================================================================ */

.game-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0.5rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Board tabs - hidden on desktop */
.board-tabs {
    display: none;
}

@media (max-width: 768px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 0.5rem;
        overflow: visible;
    }
    
    /* Show tabs on mobile */
    .board-tabs {
        display: flex;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
        background: rgba(15, 23, 42, 0.6);
        border-radius: 0.5rem;
        padding: 0.25rem;
    }
    
    .board-tab {
        flex: 1;
        padding: 0.75rem 1rem;
        background: transparent;
        border: none;
        border-radius: 0.375rem;
        color: #94A3B8;
        font-weight: 600;
        font-size: 0.875rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .board-tab.active {
        background: rgba(59, 130, 246, 0.3);
        color: #3B82F6;
        border: 1px solid #3B82F6;
    }
    
    .board-tab:not(.active):hover {
        background: rgba(148, 163, 184, 0.1);
        color: #F8FAFC;
    }
    
    /* On mobile, only show one board at a time */
    .board-container {
        flex-direction: column;
    }
}

.board-container {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 0.5rem;
    padding: 0.75rem;
    position: relative;
    z-index: 1; /* Create stacking context, but keep low */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* On desktop, always show both boards */
@media (min-width: 769px) {
    .board-container {
        display: flex !important;
    }
}

.board-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
}

.player-board .board-wrapper {
    flex-direction: row;
}

.opponent-board .board-grid {
    margin: 0 auto;
    flex-shrink: 0;
}

/* Ensure board is clickable even when modal is open */
#battleships-game.active .board-container {
    z-index: 5;
    position: relative;
}

#battleships-game.active .board-cell {
    position: relative;
    z-index: 6;
    pointer-events: auto;
}

.board-container h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    text-align: center;
    color: #F8FAFC;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* ============================================================================
   BOARD GRID
   ============================================================================ */

.board-grid {
    display: inline-grid;
    grid-template-columns: auto repeat(10, 1fr);
    gap: 2px;
    background: rgba(148, 163, 184, 0.2);
    padding: 0.35rem;
    border-radius: 0.25rem;
    margin: 0 auto;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: 1; /* Grid is below ship overlay */
}

.board-col-labels {
    display: contents;
}

.board-col-labels > div {
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: #94A3B8;
    padding: 0.25rem;
}

.board-row {
    display: contents;
}

.board-row-label {
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: #94A3B8;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #475569;
    background: #334155;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    overflow: visible;
    z-index: 1; /* Cells are below ship overlay */
}

@media (max-width: 1024px) {
    .board-cell {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 768px) {
    .board-cell {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}

.board-cell.empty {
    background: #334155;
}

.board-cell.hover:not(.hit):not(.miss):not(.ship) {
    background: #475569;
    transform: scale(1.05);
    border-color: #3B82F6;
}

.board-cell.selected {
    border: 2px solid #FAB719;
    background: #FEF3C7;
    box-shadow: 0 0 8px rgba(250, 183, 25, 0.5);
}

/* Ship pieces */
.board-cell.ship {
    background: #334155;
    border-color: #475569;
    overflow: visible;
    z-index: 2;
}

/* Ship wrapper div (contains image and effects) */
.ship-piece-wrapper {
    position: absolute;
    pointer-events: none;
    z-index: 101;
    overflow: visible;
}

.ship-piece-overlay {
    display: block;
    image-rendering: -webkit-optimize-contrast; /* Smooth rendering for high-res images */
    image-rendering: crisp-edges;
    image-rendering: auto; /* Let browser choose best algorithm */
    pointer-events: none;
    user-select: none;
    object-fit: fill; /* Fill exact dimensions */
    object-position: center center;
    position: relative; /* Ensure z-index works */
    width: 100%;
    height: 100%;
}

/* Ship overlay container */
.ship-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100; /* Well above grid cells */
}

/* Horizontal ships span multiple cells */
.board-row {
    position: relative;
}

.board-cell.ship-horizontal.ship-start {
    overflow: visible;
}

.board-cell.ship-horizontal.ship-middle,
.board-cell.ship-horizontal.ship-end {
    overflow: visible;
}

/* Vertical ships span multiple cells */
.board-cell.ship-vertical.ship-start {
    overflow: visible;
}

.board-cell.ship-vertical.ship-middle,
.board-cell.ship-vertical.ship-end {
    overflow: visible;
}

/* Ship hit overlay */
.ship-hit-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #EF4444;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.board-cell.ship-hit {
    background: rgba(239, 68, 68, 0.3);
}

.board-cell.hit {
    background: rgba(239, 68, 68, 0.4);
    border-color: #DC2626;
    cursor: not-allowed;
}

/* Hit markers on opponent board */
.board-cell.hit .hit-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
}

.board-cell.hit .hit-icon i {
    font-size: 1.25rem;
    animation: explode 0.3s ease;
}

/* Flame icons on opponent board */
.board-cell.hit .hit-icon i.ship-flame-icon {
    color: #FFD700 !important;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.8), 0 0 8px rgba(255, 165, 0, 0.6) !important;
    position: relative;
    animation: explode 0.3s ease, flameFlickerIconOpponent 1.2s ease-in-out infinite 0.3s !important;
}

/* Flame animation for opponent board - preserves centering */
@keyframes flameFlickerIconOpponent {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }
    25% {
        transform: scale(1.1) rotate(-2deg);
        opacity: 0.85;
    }
    50% {
        transform: scale(0.95) rotate(2deg);
        opacity: 0.75;
    }
    75% {
        transform: scale(1.05) rotate(-1deg);
        opacity: 0.8;
    }
}

.board-cell.hit .hit-icon.sunk i {
    color: #991B1B;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(153, 27, 27, 0.5);
}

/* Ship hit markers on overlay */
.ship-hit-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ship-hit-marker i {
    font-size: 1.5rem;
}

/* Flame icons in hit markers */
.ship-hit-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ship-hit-marker i.ship-flame-icon {
    color: #FFD700 !important;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.8), 0 0 8px rgba(255, 165, 0, 0.6) !important;
    transform: translate(-50%, -50%);
}

.ship-hit-marker.sunk i {
    color: #991B1B;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(153, 27, 27, 0.5);
}

/* ============================================================================
   FLAME AND SMOKE EFFECTS FOR HIT SHIPS
   ============================================================================ */

/* Apply effects to ship wrapper divs that have been hit */
.ship-piece-wrapper.ship-hit {
    position: relative;
}

/* Fade out sunk ships over 60 seconds, leaving gravestones as memorial */
/* Default: start animation from opacity 1 */
.ship-piece-wrapper.ship-hit.ship-sunk:not([style*="opacity"]) {
    animation: shipFadeOut 60s ease-out forwards;
    animation-fill-mode: forwards; /* Keep final state after animation */
    opacity: 1;
}

/* If opacity is set inline, use that value and don't animate (prevents flash on re-render) */
.ship-piece-wrapper.ship-hit.ship-sunk[style*="opacity"] {
    animation: none !important; /* If opacity is set inline, don't animate */
    /* Opacity will be set via inline style from JavaScript */
}

/* Fade out animation - ship disappears but gravestones remain */
@keyframes shipFadeOut {
    0% {
        opacity: 1;
    }
    95% {
        opacity: 0.1;
    }
    100% {
        opacity: 0;
    }
}

/* Hide ship image but keep gravestones visible */
/* Default: start animation from opacity 1 */
.ship-piece-wrapper.ship-hit.ship-sunk .ship-piece-overlay:not([style*="opacity"]) {
    animation: shipImageFadeOut 60s ease-out forwards;
    animation-fill-mode: forwards; /* Keep final state after animation */
}

/* Prevent animation restart if opacity is set inline */
.ship-piece-wrapper.ship-hit.ship-sunk .ship-piece-overlay[style*="opacity"] {
    animation: none !important;
    /* Opacity will be set via inline style from JavaScript */
}

@keyframes shipImageFadeOut {
    0% {
        opacity: 1;
    }
    95% {
        opacity: 0.05;
    }
    100% {
        opacity: 0;
    }
}

/* Fade out flames on sunk ships */
.ship-piece-wrapper.ship-hit.ship-sunk .ship-flame-icon {
    animation: fadeOutSlowly 60s ease-out forwards;
}

/* Fade out smoke circles on sunk ships */
.ship-piece-wrapper.ship-hit.ship-sunk .smoke-circle {
    animation: fadeOutSlowly 60s ease-out forwards, smokeRiseCircle 2s ease-out infinite;
}

@keyframes fadeOutSlowly {
    0% {
        opacity: 1;
    }
    95% {
        opacity: 0.1;
    }
    100% {
        opacity: 0;
    }
}

/* Keep gravestones visible - they are the memorial */
.ship-overlay .ship-hit-marker.sunk {
    animation: none !important;
    opacity: 1 !important;
    z-index: 200 !important; /* Ensure gravestones stay visible above faded ship */
    pointer-events: none;
}

/* Also ensure gravestones in cells remain visible */
.board-cell.hit .hit-icon.sunk,
.board-cell.hit .hit-icon.sunk i {
    animation: none !important;
    opacity: 1 !important;
    z-index: 200 !important;
}

/* Keep gravestones visible - they are the memorial */
.ship-piece-wrapper.ship-hit.ship-sunk ~ .ship-hit-marker.sunk,
.ship-overlay .ship-hit-marker.sunk {
    animation: none !important;
    opacity: 1 !important;
    z-index: 200 !important; /* Ensure gravestones stay visible above faded ship */
}

/* Also ensure gravestones in cells remain visible */
.board-cell.hit .hit-icon.sunk,
.board-cell.hit .hit-icon.sunk i {
    animation: none !important;
    opacity: 1 !important;
    z-index: 200 !important;
}

/* Flame icons are now rendered via JavaScript using Font Awesome icons */
/* Removed ::before pseudo-element flame effect - using icons instead */

/* Smoke circles created dynamically via JavaScript - perfectly circular */
.smoke-circle {
    position: absolute;
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.7) 0%,
        rgba(240, 240, 240, 0.5) 30%,
        rgba(220, 220, 220, 0.4) 50%,
        rgba(200, 200, 200, 0.2) 70%,
        transparent 90%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 101;
    transform: translateX(-50%);
    animation: smokeRiseCircle 2s ease-out infinite;
    filter: blur(2px);
    /* Ensure perfect circles - width and height must be equal */
    aspect-ratio: 1 / 1;
}

/* Light smoke - few hits - perfectly circular */
.smoke-circle.light {
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(240, 240, 240, 0.4) 40%,
        rgba(220, 220, 220, 0.3) 60%,
        transparent 85%);
    filter: blur(2px);
    opacity: 0.7;
    aspect-ratio: 1 / 1;
}

/* Medium smoke - moderate hits - perfectly circular */
.smoke-circle.medium {
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.75) 0%,
        rgba(240, 240, 240, 0.55) 30%,
        rgba(220, 220, 220, 0.45) 50%,
        rgba(200, 200, 200, 0.3) 70%,
        transparent 90%);
    filter: blur(2.5px);
    opacity: 0.85;
    /* Scale up but maintain circle */
    transform: translateX(-50%) scale(1.1);
    aspect-ratio: 1 / 1;
}

/* Intense smoke - many hits or sunk - perfectly circular */
.smoke-circle.intense {
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.85) 0%,
        rgba(240, 240, 240, 0.65) 25%,
        rgba(220, 220, 220, 0.55) 45%,
        rgba(200, 200, 200, 0.4) 65%,
        rgba(180, 180, 180, 0.25) 80%,
        transparent 95%);
    filter: blur(3px);
    opacity: 1;
    /* Scale up but maintain circle */
    transform: translateX(-50%) scale(1.2);
    aspect-ratio: 1 / 1;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* Smoke rise animation for individual circles - more visible */
@keyframes smokeRiseCircle {
    0% {
        transform: translateX(-50%) translateY(0) scale(0.6);
        opacity: 0.8;
    }
    15% {
        transform: translateX(-50%) translateY(-8px) scale(0.9);
        opacity: 0.7;
    }
    35% {
        transform: translateX(-50%) translateY(-20px) scale(1.3);
        opacity: 0.6;
    }
    60% {
        transform: translateX(-50%) translateY(-35px) scale(1.7);
        opacity: 0.4;
    }
    85% {
        transform: translateX(-50%) translateY(-55px) scale(2.2);
        opacity: 0.2;
    }
    100% {
        transform: translateX(-50%) translateY(-80px) scale(2.5);
        opacity: 0;
    }
}

/* More visible animation for medium intensity - maintains circular shape */
.smoke-circle.medium {
    animation: smokeRiseCircleMedium 2.2s ease-out infinite;
}

@keyframes smokeRiseCircleMedium {
    0% {
        transform: translateX(-50%) translateY(0) scale(0.7);
        opacity: 0.9;
        border-radius: 50%;
    }
    15% {
        transform: translateX(-50%) translateY(-10px) scale(1.0);
        opacity: 0.8;
        border-radius: 50%;
    }
    35% {
        transform: translateX(-50%) translateY(-25px) scale(1.4);
        opacity: 0.7;
        border-radius: 50%;
    }
    60% {
        transform: translateX(-50%) translateY(-40px) scale(1.9);
        opacity: 0.5;
        border-radius: 50%;
    }
    85% {
        transform: translateX(-50%) translateY(-60px) scale(2.4);
        opacity: 0.3;
        border-radius: 50%;
    }
    100% {
        transform: translateX(-50%) translateY(-85px) scale(2.8);
        opacity: 0;
        border-radius: 50%;
    }
}

/* Most visible animation for intense smoke - maintains circular shape */
.smoke-circle.intense {
    animation: smokeRiseCircleIntense 2.5s ease-out infinite;
}

@keyframes smokeRiseCircleIntense {
    0% {
        transform: translateX(-50%) translateY(0) scale(0.8);
        opacity: 1;
        border-radius: 50%;
    }
    15% {
        transform: translateX(-50%) translateY(-12px) scale(1.1);
        opacity: 0.95;
        border-radius: 50%;
    }
    35% {
        transform: translateX(-50%) translateY(-30px) scale(1.5);
        opacity: 0.85;
        border-radius: 50%;
    }
    60% {
        transform: translateX(-50%) translateY(-50px) scale(2.0);
        opacity: 0.7;
        border-radius: 50%;
    }
    85% {
        transform: translateX(-50%) translateY(-75px) scale(2.6);
        opacity: 0.4;
        border-radius: 50%;
    }
    100% {
        transform: translateX(-50%) translateY(-100px) scale(3.0);
        opacity: 0;
        border-radius: 50%;
    }
}

/* Keep ::after for additional smoke effect if needed */
.ship-piece-wrapper.ship-hit::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    width: 12%;
    height: 12%;
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(240, 240, 240, 0.3) 50%,
        transparent 80%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    opacity: 0.6;
    animation: smokeRise1 2.5s ease-out infinite;
    filter: blur(4px);
    transform: translateX(-50%);
}

/* Flame icon flicker animation - preserves centering */
@keyframes flameFlickerIcon {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 0.7;
    }
    25% {
        transform: translate(-50%, -50%) scale(1.1) rotate(-2deg);
        opacity: 0.85;
    }
    50% {
        transform: translate(-50%, -50%) scale(0.95) rotate(2deg);
        opacity: 0.75;
    }
    75% {
        transform: translate(-50%, -50%) scale(1.05) rotate(-1deg);
        opacity: 0.8;
    }
}

/* Intense flame animation for sunk ships */
@keyframes intenseFlameIcon {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 165, 0, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 4px rgba(255, 140, 0, 1)) drop-shadow(0 0 8px rgba(255, 100, 0, 0.6));
    }
}

/* Smoke rise animations - multiple circles rising at different rates - maintains circular shape */
@keyframes smokeRise1 {
    0% {
        transform: translateX(-50%) translateY(0) scale(0.6);
        opacity: 0.5;
        border-radius: 50%;
    }
    33% {
        transform: translateX(-50%) translateY(-20px) scale(1.0);
        opacity: 0.4;
        border-radius: 50%;
    }
    66% {
        transform: translateX(-50%) translateY(-40px) scale(1.4);
        opacity: 0.2;
        border-radius: 50%;
    }
    100% {
        transform: translateX(-50%) translateY(-60px) scale(1.8);
        opacity: 0;
        border-radius: 50%;
    }
}

/* Additional smoke animations for staggered effect */
@keyframes smokeRise2 {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-25px) scale(1.1);
        opacity: 0.3;
    }
    80% {
        transform: translateY(-50px) scale(1.6);
        opacity: 0.15;
    }
    100% {
        transform: translateY(-70px) scale(2.0);
        opacity: 0;
    }
}

@keyframes smokeRise3 {
    0% {
        transform: translateY(0) scale(0.7);
        opacity: 0.35;
    }
    50% {
        transform: translateY(-30px) scale(1.3);
        opacity: 0.25;
    }
    100% {
        transform: translateY(-65px) scale(1.9);
        opacity: 0;
    }
}

/* Sunk ships have more intense flame icons (handled in .ship-flame-icon.sunk above) */

/* More smoke circles for sunk ships (created via JavaScript) */
.ship-piece-wrapper.ship-hit.ship-sunk .smoke-circle {
    animation-duration: 1.8s;
    filter: blur(3px);
    opacity: 1;
}

/* Ensure sunk ships get intense smoke */
.ship-piece-wrapper.ship-hit.ship-sunk .smoke-circle:not(.intense) {
    background: radial-gradient(circle,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(240, 240, 240, 0.7) 25%,
        rgba(220, 220, 220, 0.6) 45%,
        rgba(200, 200, 200, 0.45) 65%,
        rgba(180, 180, 180, 0.3) 80%,
        transparent 95%);
    filter: blur(3.5px);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.ship-piece-wrapper.ship-hit.ship-sunk::after {
    width: 15%;
    height: 15%;
    opacity: 0.8;
    animation: smokeRise1 1.2s ease-out infinite, intenseSmoke 2.5s ease-out infinite;
}

/* Intense flame animation for sunk ships */
@keyframes intenseFlame {
    0%, 100% {
        filter: blur(2px) brightness(1);
    }
    50% {
        filter: blur(3px) brightness(1.3);
    }
}

/* Intense smoke animation for sunk ships */
@keyframes intenseSmoke {
    0% {
        filter: blur(3px);
    }
    100% {
        filter: blur(5px);
    }
}

/* Bomb coordinate message */
.bomb-coordinate-message {
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif !important;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.board-cell.miss {
    background: #F3F4F6;
    border-color: #D1D5DB;
    cursor: not-allowed;
}

.board-cell.miss .miss-icon {
    font-size: 1rem;
    color: #6B7280;
}

.board-cell.sunk {
    background: #DC2626;
    border-color: #991B1B;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.hit-animation {
    animation: explode 0.5s ease;
}

.miss-animation {
    animation: ripple 0.5s ease;
}

.miss-animation::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #6B7280;
    animation: ripple 0.5s ease;
}

/* ============================================================================
   SHIP STATUS
   ============================================================================ */

.ship-status {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
    min-width: 140px;
    max-width: 160px;
}

.ship-status-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: rgba(30, 64, 175, 0.2);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.ship-status-item.placed {
    background: rgba(34, 197, 94, 0.2);
}

.ship-status-item.sunk {
    background: rgba(239, 68, 68, 0.2);
    opacity: 0.6;
}

.ship-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.75rem;
}

.ship-size {
    color: #94A3B8;
    font-size: 0.65rem;
}

.ship-status-badge {
    color: #22C55E;
    font-weight: bold;
    font-size: 0.875rem;
}

/* ============================================================================
   SHOT HISTORY
   ============================================================================ */

.shot-history {
    margin-top: 1rem;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    max-height: 100px;
    overflow-y: auto;
}

/* ============================================================================
   BOTTOM PANEL
   ============================================================================ */

.game-bottom-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 0.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    flex-shrink: 0;
}

.game-stats-mini {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
}

.game-stats-mini strong {
    color: #3B82F6;
    font-weight: 600;
}

.game-actions-bottom {
    display: flex;
    gap: 0.5rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-primary {
    background: #C90C0F;
    color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
    background: #A00A0C;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(201, 12, 15, 0.3);
}

.btn-primary:disabled {
    background: #6B7280;
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

#battleships-game .game-bottom-panel {
    position: relative;
    z-index: 10;
}

#battleships-game #fireBtn {
    position: relative;
    z-index: 11;
    pointer-events: auto !important;
    cursor: pointer;
}

#battleships-game #fireBtn:not(:disabled) {
    cursor: pointer !important;
}

.btn-secondary {
    background: rgba(59, 130, 246, 0.2);
    color: #3B82F6;
    border: 1px solid #3B82F6;
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 2rem;
    overflow-y: auto;
}

.modal-overlay#shipPlacementModal {
    /* Position modal to side, allow clicks to pass through overlay to board */
    align-items: flex-start;
    justify-content: flex-end;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: none; /* Allow clicks to pass through overlay */
}

.modal-overlay#shipPlacementModal .modal-content {
    pointer-events: auto; /* Modal content itself is clickable */
    margin: 0;
    max-width: 380px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

/* Ship Placement Panel (part of game screen, not a modal) */
.ship-placement-panel {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.ship-placement-panel h3 {
    margin: 0 0 1rem 0;
    color: #F8FAFC;
    text-align: center;
    font-size: 1.125rem;
}

.ship-placement-panel .ship-selection {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ship-placement-panel .placement-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ship-placement-panel .placement-hint {
    font-size: 0.875rem;
    color: #94A3B8;
    text-align: center;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .ship-placement-panel {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .ship-placement-panel .ship-selection {
        gap: 0.4rem;
    }
    
    .ship-placement-panel .ship-select-btn {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    .ship-placement-panel .placement-controls {
        gap: 0.4rem;
    }
    
    .ship-placement-panel .btn-secondary,
    .ship-placement-panel .btn-primary {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

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

.modal-content {
    background: #0F172A;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    margin: 0 0 1.5rem 0;
    color: #F8FAFC;
    text-align: center;
}

.ship-selection {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ship-select-btn {
    padding: 1rem;
    background: rgba(30, 64, 175, 0.2);
    border: 1px solid #1E40AF;
    border-radius: 0.25rem;
    color: #F8FAFC;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ship-select-btn:hover {
    background: rgba(30, 64, 175, 0.3);
}

.ship-select-btn.active {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3B82F6;
    font-weight: 600;
}

.ship-select-btn.placed {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22C55E;
    opacity: 0.7;
    cursor: not-allowed;
}

.ship-select-btn.placed:hover {
    background: rgba(34, 197, 94, 0.2);
}

.ship-select-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.placement-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.placement-hint {
    font-size: 0.875rem;
    color: #94A3B8;
    text-align: center;
    margin-top: 1rem;
}

.game-over-modal {
    text-align: center;
}

.game-stats-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 0.25rem;
}

.stat-label {
    color: #94A3B8;
}

.stat-value {
    color: #FAB719;
    font-weight: 600;
    font-size: 1.125rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* ============================================================================
   NOTIFICATIONS
   ============================================================================ */

.notification,
.error-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #0F172A;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    color: #F8FAFC;
    z-index: 2000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.notification.show,
.error-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    border-color: #22C55E;
    background: rgba(34, 197, 94, 0.2);
}

.notification.warning {
    border-color: #F59E0B;
    background: rgba(245, 158, 11, 0.2);
}

.error-notification {
    border-color: #EF4444;
    background: rgba(239, 68, 68, 0.2);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    /* Use shared game header styling */
    #battleships-game .game-top-bar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 1rem 1rem !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: rgba(0, 0, 0, 0.95) !important;
        backdrop-filter: blur(10px);
        z-index: 10000 !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    #battleships-game .game-top-bar .game-title-header {
        font-size: 1.5rem;
        color: #FAB719;
        margin: 0;
    }
    
    #battleships-game .game-top-bar .button-group {
        display: flex;
        gap: 0.5rem;
    }
    
    #battleships-game .game-top-bar .top-bar-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    #battleships-game .game-top-bar .game-header-burger {
        display: block;
    }
    
    /* Add padding to account for fixed header */
    #battleships-game {
        padding-top: 70px !important;
    }
    
    .game-bottom-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
        flex-shrink: 0;
    }
    
    .game-stats-mini {
        justify-content: space-around;
        font-size: 0.8rem;
        gap: 1rem;
    }
    
    /* Make fire button more prominent on mobile */
    #battleships-game #fireBtn {
        width: 100%;
        padding: 1rem 1.5rem;
        font-size: 1.25rem;
        font-weight: 700;
        background: #C90C0F;
        color: #FFFFFF;
        border: 2px solid #FFFFFF;
        box-shadow: 0 4px 12px rgba(201, 12, 15, 0.5);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        position: relative;
        z-index: 10001;
    }

    /* Ensure all buttons in battleships have high z-index on mobile */
    .btn-primary,
    .btn-secondary {
        position: relative;
        z-index: 10001;
    }
    
    #battleships-game #fireBtn:not(:disabled):active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(201, 12, 15, 0.4);
    }
    
    #battleships-game #fireBtn:not(:disabled):hover {
        background: #A00A0C;
        box-shadow: 0 6px 16px rgba(201, 12, 15, 0.6);
    }
    
    /* Fleet stats mobile display - hidden by default, shown by JavaScript */
    .fleet-stats-mobile {
        display: none;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
        background: rgba(15, 23, 42, 0.6);
        border-radius: 0.5rem;
        margin-top: 0.5rem;
        width: 100%;
    }
    
    /* When JavaScript sets display: flex, show it */
    .fleet-stats-mobile[style*="display: flex"],
    .fleet-stats-mobile[style*="display:flex"],
    .fleet-stats-mobile.fleet-stats-visible {
        display: flex !important;
    }
    
    /* Ensure hidden state */
    .fleet-stats-mobile.fleet-stats-hidden {
        display: none !important;
    }
    
    .fleet-stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 0.25rem;
        font-size: 0.875rem;
    }
    
    .fleet-stat-item.damaged {
        background: rgba(239, 68, 68, 0.2);
        border-left: 3px solid #EF4444;
    }
    
    .fleet-stat-item.sunk {
        background: rgba(153, 27, 27, 0.3);
        border-left: 3px solid #991B1B;
        opacity: 0.7;
    }
    
    .fleet-stat-name {
        font-weight: 600;
        color: #F8FAFC;
        text-transform: capitalize;
    }
    
    .fleet-stat-hits {
        color: #94A3B8;
        font-weight: 500;
    }
    
    .fleet-stat-item.damaged .fleet-stat-hits {
        color: #EF4444;
        font-weight: 600;
    }
    
    .fleet-stat-sunk {
        color: #991B1B;
        font-weight: 700;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    .game-actions-bottom {
        width: 100%;
    }
    
    /* Ensure game container fits within viewport */
    .game-container {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .board-container {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding: 0.5rem;
    }
    
    .board-wrapper {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    .board-grid {
        flex-shrink: 0;
        margin: 0 auto;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    .notification,
    .error-notification {
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.board-cell:focus {
    outline: 2px solid #FAB719;
    outline-offset: 2px;
}

.btn-primary:focus,
.btn-secondary:focus {
    outline: 2px solid #FAB719;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}



/* ============================================================================
   FRIENDS SYSTEM STYLES
   ============================================================================ */

.friends-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    overflow-y: auto;
}

.friends-container {
    max-width: 800px;
    margin: 2rem auto;
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.friends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #dee2e6;
}

.friends-header h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 2rem;
}

.close-friends-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-friends-btn:hover {
    background: #f8f9fa;
    color: #2c3e50;
}

.friends-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.add-friend-section h2,
.friends-list-section h2 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.add-friend-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.friend-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
}

.friend-input:focus {
    outline: none;
    border-color: #00FF00;
}

.friend-message {
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    display: none;
}

.friend-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.friend-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.friends-list-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#friends-count {
    background: #00FF00;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 1rem;
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.no-friends-message {
    text-align: center;
    color: #6c757d;
    padding: 2rem;
    font-style: italic;
}

.friend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    transition: all 0.3s;
}

.friend-item:hover {
    border-color: #00FF00;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 0, 0.2);
}

.friend-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.friend-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00FF00 0%, #3B82F6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
}

.friend-details {
    display: flex;
    flex-direction: column;
}

.friend-name {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1rem;
}

.friend-status {
    font-size: 0.85rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.friend-status.online {
    color: #28a745;
    font-weight: bold;
}

.friend-status.online::before {
    content: '●';
    color: #28a745;
    font-size: 1.2rem;
}

.friend-status.offline::before {
    content: '●';
    color: #6c757d;
    font-size: 1.2rem;
}

.status-indicator {
    display: inline-block;
    font-size: 1rem;
    margin-right: 0.25rem;
}

.status-indicator.online-dot {
    color: #28a745;
}

.status-indicator.offline-dot {
    color: #6c757d;
}

/* Connection Quality Indicator */
.connection-quality {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.05);
}

.connection-quality.excellent {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.connection-quality.good {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.connection-quality.fair {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
}

.connection-quality.poor {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.connection-quality-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.connection-quality.excellent .connection-quality-indicator {
    background: #22c55e;
    box-shadow: 0 0 4px #22c55e;
}

.connection-quality.good .connection-quality-indicator {
    background: #3b82f6;
    box-shadow: 0 0 4px #3b82f6;
}

.connection-quality.fair .connection-quality-indicator {
    background: #fbbf24;
    box-shadow: 0 0 4px #fbbf24;
}

.connection-quality.poor .connection-quality-indicator {
    background: #ef4444;
    box-shadow: 0 0 4px #ef4444;
}

.friend-actions {
    display: flex;
    gap: 0.5rem;
}

.friend-action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    transition: all 0.3s;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    min-width: 44px;
    min-height: 44px;
}

.friend-action-btn.challenge {
    background: #28a745;
    color: white;
}

.friend-action-btn.challenge:hover {
    background: #218838;
    transform: scale(1.05);
}

.friend-action-btn.remove {
    background: #dc3545;
    color: white;
}

.friend-action-btn.remove:hover {
    background: #c82333;
    transform: scale(1.05);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .friends-container {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        padding: 1rem;
    }
    
    .friend-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .friend-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .add-friend-form {
        flex-direction: column;
    }
}
