/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background-color: #1a1a1a;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

/* Main game container */
.game-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    height: 100vh;
    gap: 10px;
    padding: 10px;
}

/* Header */
.game-header {
    grid-column: 1 / -1;
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-header h1 {
    color: #00ff00;
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-status {
    background-color: #333;
    padding: 8px 15px;
    border-radius: 4px;
    border: 1px solid #555;
}

/* Game board container */
.game-board-container {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

/* Grid styling */
.game-grid {
    display: grid;
    grid-template-columns: repeat(10, 30px);
    grid-template-rows: repeat(10, 30px);
    gap: 1px;
    background-color: #555;
    border: 2px solid #777;
    padding: 2px;
}

.grid-cell {
    background-color: #333;
    border: 1px solid #444;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    position: relative;
    transition: background-color 0.2s ease;
}

.grid-cell:hover {
    background-color: #444;
}

/* Player styling */
.grid-cell.player-1 {
    background-color: #0066ff;
    color: white;
    font-weight: bold;
}

.grid-cell.player-2 {
    background-color: #ff6600;
    color: white;
    font-weight: bold;
}

/* Ghost preview styling */
.grid-cell.ghost-move {
    background-color: rgba(0, 255, 0, 0.3);
    border: 2px dashed #00ff00;
    animation: pulse 1.5s ease-in-out infinite;
}

.grid-cell.ghost-bullet {
    background-color: rgba(255, 255, 0, 0.4);
    border: 1px dashed #ffff00;
    position: relative;
}

.grid-cell.ghost-bullet::after {
    content: '•';
    color: #ffff00;
    font-size: 18px;
    font-weight: bold;
    opacity: 0.7;
}

.grid-cell.bullet {
    background-color: #ffff00;
}

.grid-cell.explosion {
    background-color: #ff0000;
    animation: explosion 0.5s ease-out;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.3; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.6;
        transform: scale(1.05);
    }
}

@keyframes error-flash {
    0%, 100% { 
        background-color: #444;
        border-color: #666;
    }
    50% { 
        background-color: #cc0000;
        border-color: #ff0000;
    }
}

@keyframes ghost-error-flash {
    0%, 100% { 
        background-color: rgba(0, 255, 0, 0.3);
        border-color: #00ff00;
    }
    50% { 
        background-color: rgba(255, 0, 0, 0.8);
        border-color: #ff0000;
    }
}

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

/* Bullet trail visualization */
.grid-cell.bullet-trail {
    background-color: rgba(255, 255, 0, 0.8);
    border: 1px solid #ffff00;
    animation: bullet-fade 5s ease-out forwards;
    position: relative;
}

.grid-cell.bullet-trail::after {
    content: '•';
    color: #ffff00;
    font-weight: bold;
    font-size: 16px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.grid-cell.bullet-hit {
    background-color: rgba(255, 0, 0, 0.9);
    border: 2px solid #ff0000;
    animation: hit-flash 1s ease-out forwards;
}

.grid-cell.bullet-hit::after {
    content: '💥';
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes bullet-fade {
    0% { 
        opacity: 1;
        background-color: rgba(255, 255, 0, 0.8);
    }
    100% { 
        opacity: 0;
        background-color: rgba(255, 255, 0, 0);
    }
}

@keyframes hit-flash {
    0% { 
        opacity: 1;
        background-color: rgba(255, 0, 0, 0.9);
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% { 
        opacity: 0;
        background-color: rgba(255, 0, 0, 0);
        transform: scale(1);
    }
}

/* Player movement effect */
.grid-cell.player-moving {
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid #ffffff;
    animation: move-highlight 0.2s ease-out;
}

/* Player death effect */
.grid-cell.player-dead {
    background-color: rgba(139, 0, 0, 0.8) !important;
    border: 2px solid #8b0000 !important;
    animation: death-effect 2s ease-out forwards;
    position: relative;
}

.grid-cell.player-dead::after {
    content: '💀';
    color: #ffffff;
    font-size: 18px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

@keyframes move-highlight {
    0% { 
        background-color: rgba(255, 255, 255, 0.2);
        transform: scale(1);
    }
    50% {
        background-color: rgba(255, 255, 255, 0.8);
        transform: scale(1.1);
    }
    100% { 
        background-color: rgba(255, 255, 255, 0.5);
        transform: scale(1);
    }
}

@keyframes death-effect {
    0% { 
        transform: scale(1);
        opacity: 1;
    }
    25% {
        transform: scale(1.3);
    }
    50% {
        transform: scale(0.8);
    }
    100% { 
        transform: scale(1);
        opacity: 0.6;
    }
}

/* Game end overlay */
.game-end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: overlay-appear 0.5s ease-out;
}

.game-end-modal {
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    border: 3px solid;
    border-radius: 15px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    min-width: 400px;
    animation: modal-appear 0.5s ease-out 0.2s both;
}

.game-end-modal.winner {
    border-color: #00ff00;
    background: linear-gradient(135deg, #004d00, #002200);
    color: #00ff00;
}

.game-end-modal.loser {
    border-color: #ff0000;
    background: linear-gradient(135deg, #4d0000, #220000);
    color: #ff0000;
}

.game-end-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 0 0 10px currentColor;
}

.game-end-message {
    font-size: 20px;
    margin-bottom: 30px;
    opacity: 0.9;
}

.game-end-button {
    background: #444;
    color: white;
    border: 2px solid #666;
    padding: 12px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    margin: 0 10px;
    transition: all 0.3s ease;
}

.game-end-button:hover {
    background: #555;
    border-color: #888;
}

.game-end-button.primary {
    background: #006600;
    border-color: #00aa00;
}

.game-end-button.primary:hover {
    background: #008800;
    border-color: #00cc00;
}

.game-end-modal.winner .game-end-button {
    border-color: #00ff00;
}

.game-end-modal.loser .game-end-button {
    border-color: #ff0000;
}

@keyframes overlay-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-appear {
    from { 
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }
    to { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Controls sidebar */
.game-controls {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.game-controls h3 {
    color: #00ff00;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 1px;
}

/* Player info */
.player-info {
    background-color: #333;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #555;
}

/* Compass layout for action buttons */
.compass-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #333;
    border-radius: 8px;
    border: 1px solid #555;
}

.compass-center {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #444;
    border: 1px solid #666;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    color: #888;
    text-align: center;
    padding: 5px;
    position: relative;
}

.move-compass .compass-center {
    border-color: #0066ff;
}

.shoot-compass .compass-center {
    border-color: #ff6600;
}

.compass-empty {
    /* Empty grid cells for spacing */
}

.compass-north, .compass-south, .compass-east, .compass-west {
    padding: 12px 8px;
    font-size: 16px;
    font-weight: bold;
}

.move-btn, .shoot-btn, .submit-btn, .undo-btn {
    background-color: #444;
    color: #ffffff;
    border: 1px solid #666;
    padding: 10px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    transition: all 0.2s ease;
}

.move-btn:hover {
    background-color: #0066ff;
    border-color: #0088ff;
}

.shoot-btn:hover {
    background-color: #ff6600;
    border-color: #ff8800;
}

.turn-controls h3 {
    margin-bottom: 8px;
    margin-top: 15px;
}

.turn-controls h3:first-child {
    margin-top: 0;
}

.turn-management {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 20px;
}

.undo-btn {
    background-color: #cc6600;
    font-size: 12px;
    font-weight: bold;
}

.undo-btn:hover:not(:disabled) {
    background-color: #ff8800;
}

.undo-btn:disabled {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
}

.submit-btn {
    background-color: #006600;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

.submit-btn:hover:not(:disabled) {
    background-color: #008800;
}

.submit-btn:disabled {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
}

/* Game info */
.game-info {
    background-color: #333;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #555;
}

.game-info div {
    margin-bottom: 8px;
    font-size: 14px;
}

#shot-available {
    color: #00ff00;
}

#shot-available.used {
    color: #ff6600;
}

/* Responsive design */
@media (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .game-controls {
        order: 2;
        max-height: 200px;
    }
    
    .game-board-container {
        order: 3;
    }
}

@media (max-width: 768px) {
    .game-grid {
        grid-template-columns: repeat(10, 20px);
        grid-template-rows: repeat(10, 20px);
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
}