/* ui.css - UI overlays and components - Updated for connection quality system */
.ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.ui-overlay > * {
    pointer-events: auto;
}

.status {
    position: fixed;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    font-size: 0.875rem;
    color: #ffffff;
    z-index: 100;
    white-space: nowrap;
    pointer-events: auto;
}

.info-panel {
    position: fixed;
    top: 5%;
    left: 5rem; /* Adjusted to account for connection quality icon */
    display: flex;
    flex-direction: column;
    /* Standardize the gap between all elements */
    gap: 1.25rem;
    z-index: 100;
    pointer-events: auto;
}

/* Game notifications (non-network) */
.game-notification {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.game-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.game-notification.attack-success {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.game-notification.attack-fail {
    background: linear-gradient(135deg, #f44336, #da190b);
}

.game-notification.attack-cooldown {
    background: linear-gradient(135deg, #ff9800, #e68900);
}

.lives-count {
   padding: 0.5rem 1rem;
   border-radius: 20px;
   font-size: 0.875rem;
   color: #ffffff;
}

.theme-light .lives-count {
   color: rgba(0, 0, 0, 0.8);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #ffffff;
}

#return-button-container {
    position: fixed;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-align: center;
    pointer-events: auto;
}

#return-to-lobby {
    padding: 0.5rem 1.5rem;
    font-size: 0.875rem;
    min-width: 150px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

#return-to-lobby:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Update modal button styles */
.modal .dialog-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.modal .button {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: #ffffff;
    transition: all 0.2s ease;
}

.modal .button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal .button.cancel {
    background: rgba(255, 255, 255, 0.05);
}

.modal .button.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.flag-count,
.power-ups-inventory,
.lives-count,
.attack-inventory {
    /* Remove any inconsistent padding */
    padding: 0;
    /* Ensure left alignment */
    text-align: left;
    /* Remove any border radius if not needed */
    border-radius: 0;
}

.game-timer,
.game-score {
    /* Remove center alignment and existing padding */
    text-align: left;
    padding: 0;
    /* Remove min-width that forces centering */
    min-width: 0;
    /* Remove border radius for consistency */
    border-radius: 0;
}

/* Constant Return to Lobby Button */
.constant-return-lobby {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    transition: all 0.2s ease;
    opacity: 0;
    pointer-events: none;
    color: white;
}

.constant-return-lobby svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

.constant-return-lobby:hover {
    background: rgba(220, 38, 38, 0.8); /* Reddish background on hover */
}

.game-active .constant-return-lobby {
    opacity: 1;
    pointer-events: auto;
}

/* Single Player Game Over Modal */
.single-player-game-over {
    text-align: center;
}

.single-player-game-over .stats {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.single-player-game-over .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.single-player-game-over .stat-row:last-child {
    border-bottom: none;
}

.single-player-game-over .stat-label {
    color: #9ca3af;
}

.single-player-game-over .stat-value {
    font-weight: 600;
    font-family: monospace;
}

/* Remove all legacy network notification styles */
.network-notification,
.connection-banner,
.server-message,
.server-notification,
.network-status,
.connection-status-banner {
    display: none !important;
}

/* Theme transitions */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Light theme overrides */
body.theme-light {
    background-color: #e5e7eb;  /* Light grey background */
    color: #2d2d2d;
}

/* Game interface light theme */
.theme-light .game-interface {
    background-color: #d1d5db;  /* Slightly darker grey for the game canvas */
}

/* Game board light theme */
.theme-light .game-board {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.theme-light .cell {
    background: #d1d5db;  /* Slightly darker than background */
    color: #2d2d2d;
}

.theme-light .cell.mine {
    background: #dc2626;
    color: white;
}

.theme-light .cell.hidden {
    background: #f3f4f6;  /* Lighter grey for hidden cells */
}

.theme-light .cell.hidden:hover {
    background: #e5e7eb;  /* Slightly darker on hover */
}

/* UI elements light theme */
.theme-light .modal-content {
    background: #f3f4f6;  /* Slightly lighter than base */
    border-color: rgba(0, 0, 0, 0.1);
}

.theme-light .modal {
    background: rgba(229, 231, 235, 0.5);
}

.theme-light .header {
    background: rgba(243, 244, 246, 0.9);
    color: #2d2d2d;
}

/* Power-ups light theme */
.theme-light .power-up {
    background: rgba(243, 244, 246, 0.9);
    color: #2d2d2d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.theme-light .power-up:hover:not(.disabled) {
    background: #f3f4f6;
}

/* Lobby light theme */
.theme-light .lobby-container {
    background: rgba(243, 244, 246, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.theme-light .lobby-container h3 {
    color: #111827;  /* Very dark grey for headings */
}

.theme-light .single-player-section {
    background: rgba(243, 244, 246, 0.5);
}

.theme-light .single-player-section h3 {
    color: #111827;  /* Very dark grey for section title */
}

/* Difficulty buttons */
.theme-light .difficulty-btn {
    background: rgba(0, 0, 0, 0.1);
    color: #1f2937;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-light .difficulty-btn:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.theme-light .difficulty-btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* Separator */
.theme-light .separator {
    color: #4b5563;  /* Medium grey for separator text */
}

.theme-light .separator::before,
.theme-light .separator::after {
    background: rgba(0, 0, 0, 0.1);
}

.theme-light .separator span {
    background: #f3f4f6;
    color: #4b5563;
}

/* Player input and lobby form */
.theme-light .player-input {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1f2937;
}

.theme-light .player-input:focus {
    border-color: rgba(37, 99, 235, 0.5);
    background: rgba(255, 255, 255, 0.8);
}

.theme-light .lobby-form .button {
    color: #ffffff;
    background: #2563eb;
}

.theme-light .lobby-form .button:hover {
    background: #1d4ed8;
}

/* Player list */
.theme-light .player-item {
    color: #1f2937;
    background: rgba(0, 0, 0, 0.03);
}

/* Multiplayer elements light theme */
/* Player cards and info */
.theme-light .players-grid {
    background: transparent;
}

.theme-light .player-card {
    background: rgba(243, 244, 246, 0.9);
    color: #1f2937;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.theme-light .player-card .player-name {
    color: #111827;
}

.theme-light .player-card .progress-text {
    color: #4b5563;
}

.theme-light .player-card .progress-bar {
    background: rgba(0, 0, 0, 0.1);
}

.theme-light .player-card.attackable:hover {
    background: rgba(243, 244, 246, 0.95);
}

.theme-light .player-card.dead {
    opacity: 0.6;
}

/* Attack inventory and slots */
.theme-light .attack-inventory {
    background: transparent !important;
    box-shadow: none !important;
}

.theme-light .attack-inventory-title {
    color: #4b5563;
}

.theme-light .attack-item {
    background: rgba(0, 0, 0, 0.1);
}

.theme-light .attack-item:hover {
    background: rgba(0, 0, 0, 0.15);
}

.theme-light .attack-item.empty {
    background: rgba(0, 0, 0, 0.05);
}

.theme-light .attack-tooltip {
    background: rgba(0, 0, 0, 0.9);
    color: #ffffff;
}

/* Attack dialog */
.theme-light .attack-option {
    background: rgba(0, 0, 0, 0.05);
}

.theme-light .attack-option:hover {
    background: rgba(0, 0, 0, 0.08);
}

.theme-light .attack-name {
    color: #111827;
}

.theme-light .attack-description {
    color: #4b5563;
}

/* Attack slots display */
.theme-light .attack-slots .slot {
    background: rgba(0, 0, 0, 0.1);
}

.theme-light .attack-slots .slot.filled {
    background: rgba(37, 99, 235, 0.5);
}

/* Attack Selection Dialog */
.theme-light .attack-dialog .modal-content {
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theme-light .attack-dialog .modal-title {
    color: #111827;
}

.theme-light .attack-dialog .attack-option {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.theme-light .attack-dialog .attack-option:hover {
    background: rgba(0, 0, 0, 0.08);
}

.theme-light .attack-dialog .attack-name {
    color: #111827;
    font-weight: 600;
}

.theme-light .attack-dialog .attack-description {
    color: #4b5563;
}

/* Attack dialog buttons */
.theme-light .attack-dialog .button {
    color: #ffffff;
}

.theme-light .attack-dialog .button.danger {
    background: #dc2626;
}

.theme-light .attack-dialog .button.danger:hover {
    background: #b91c1c;
}

/* Attack notifications */
.theme-light .attack-notification {
    background: rgba(37, 99, 235, 0.95);
    color: #ffffff;
}

.theme-light .attack-notification.discovery {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(67, 56, 202, 0.95));
}

/* Cell number colors for light theme - Adjusted for better contrast on grey background */
.theme-light .cell.n1 { color: #1e40af; }  /* Blue */
.theme-light .cell.n2 { color: #166534; }  /* Green */
.theme-light .cell.n3 { color: #991b1b; }  /* Red */
.theme-light .cell.n4 { color: #5b21b6; }  /* Purple */
.theme-light .cell.n5 { color: #92400e; }  /* Orange */
.theme-light .cell.n6 { color: #0e7490; }  /* Teal */
.theme-light .cell.n7 { color: #9d174d; }  /* Pink */
.theme-light .cell.n8 { color: #1f2937; }  /* Dark grey */

/* Improved shadows and depth */
.theme-light .cell {
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.theme-light .cell.hidden {
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.03);
}

/* Custom Game Dialog light theme */
.theme-light .modal-title {
    color: #111827;  /* Very dark grey for modal title */
}

.theme-light .modal-form label {
    color: #1f2937;  /* Dark grey for labels */
}

.theme-light .modal-form .hint {
    color: #4b5563;  /* Medium grey for hint text */
}

.theme-light .settings-section h4 {
    color: #111827;  /* Very dark grey for section headers */
}

.theme-light .modal-form .button {
    color: #ffffff;  /* White text for buttons */
    background: #2563eb;  /* Blue background for primary button */
}

.theme-light .modal-form .button:hover {
    background: #1d4ed8;  /* Darker blue on hover */
}

.theme-light .modal-form .button.secondary {
    background: #4b5563;  /* Grey for secondary button */
}

.theme-light .modal-form .button.secondary:hover {
    background: #374151;  /* Darker grey on hover */
}

.theme-light .input-group input,
.theme-light .input-group select {
    color: #1f2937;  /* Dark grey for input text */
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.5);
}

.theme-light .input-group input:focus,
.theme-light .input-group select:focus {
    border-color: rgba(37, 99, 235, 0.5);  /* Blue focus ring */
    background: rgba(255, 255, 255, 0.8);
}

/* Button and interactive element shadows */
.theme-light .button {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Attack and special effects adjustments */
.theme-light .attack-effect-overlay.flashBomb {
    background-color: rgba(243, 244, 246, 0.95);
}

/* Light theme text colors */
.theme-light .game-timer,
.theme-light .game-score,
.theme-light .flag-count {
   color: rgba(0, 0, 0, 0.8);
}

/* Remove opaque backgrounds */
.theme-light .game-timer,
.theme-light .game-score,
.theme-light .flag-count {
   background: transparent;
   box-shadow: none;
   backdrop-filter: none;
}

/* Theme toggle button - ensure it doesn't conflict with connection icon */
.theme-toggle {
    position: fixed;
    top: calc(1rem + 44px); /* Position below return button */
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    transition: all 0.2s ease;
    color: white;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.8);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Light theme styles for theme toggle */
.theme-light .theme-toggle {
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-light .theme-toggle:hover {
    background: #ffffff;
}

/* Responsive styles */
@media (max-width: 768px) {
    .info-panel {
        top: 3.5rem;
        left: 3.5rem; /* Adjusted for mobile with connection icon */
        gap: 0.5rem;
    }
    
    .status {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .game-timer,
    .game-score {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        min-width: 80px;
    }
    
    /* Adjust constant return button for mobile */
    .constant-return-lobby {
        top: 0.5rem;
        right: 0.5rem;
        width: 32px;
        height: 32px;
    }
    
    .constant-return-lobby svg {
        width: 16px;
        height: 16px;
    }
    
    /* Adjust theme toggle for mobile */
    .theme-toggle {
        top: calc(0.5rem + 38px);
        right: 0.5rem;
        width: 32px;
        height: 32px;
    }
    
    .theme-toggle svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 640px) {
    .game-notification {
        width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}