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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

.container {
    max-width: 800px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5em;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.level-info {
    display: flex;
    gap: 20px;
    font-weight: bold;
    color: #2c3e50;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    background: #3498db;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

button:hover {
    background: #2980b9;
}

#game-board {
    display: grid;
    gap: 2px;
    background: #2c3e50;
    padding: 10px;
    border-radius: 10px;
    margin: 20px auto;
    justify-content: center;
    max-width: fit-content;
}

.cell {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    border-radius: 3px;
    position: relative;
}

.floor {
    background: #ecf0f1;
}

.wall {
    background: #34495e;
}

.target {
    background: #f39c12;
    border: 3px dashed #e67e22;
}

.target.completed {
    background: #27ae60;
    border: 3px solid #2ecc71;
}

.player {
    background-image: url('./assets/p360_logo.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 2px solid #2c3e50;
    position: relative;
    z-index: 2;
}

.box {
    background-size: 80%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border: 2px solid #2980b9;
    border-radius: 8px;
    position: relative;
    z-index: 1;
}

.box.aws-ec2 { background-image: url('./assets/ec2.png'); }
.box.aws-s3 { background-image: url('./assets/s3.png'); }
.box.aws-rds { background-image: url('./assets/rds.png'); }
.box.aws-lambda { background-image: url('./assets/lambda.png'); }
.box.aws-cloudfront { background-image: url('./assets/cloudfront.png'); }
.box.aws-ecs { background-image: url('./assets/ecs.png'); }
.box.aws-elb { background-image: url('./assets/elb.png'); }
.box.aws-vpc { background-image: url('./assets/vpc.png'); }
.box.aws-iam { background-image: url('./assets/iam.png'); }
.box.aws-route53 { background-image: url('./assets/route53.png'); }

.box.on-target {
    border: 3px solid #2ecc71;
    animation: pulse 2s infinite;
    box-shadow: 0 0 15px rgba(39, 174, 96, 0.7);
}

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

.controls {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.controls h3 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.controls p {
    color: #7f8c8d;
    margin: 5px 0;
}

.victory-message, .game-complete {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 1000;
}

.victory-message h2, .game-complete h2 {
    color: #27ae60;
    margin-bottom: 15px;
}

.victory-message p, .game-complete p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.victory-message button, .game-complete button {
    background: #27ae60;
    font-size: 16px;
    padding: 12px 25px;
}

.victory-message button:hover, .game-complete button:hover {
    background: #219a52;
}

/* Ranking styles */
.ranking-link, .ranking-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #f39c12;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 14px;
    transition: background 0.3s;
}

.ranking-link:hover, .ranking-btn:hover {
    background: #e67e22;
}

.game-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.ranking-form {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.ranking-form h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

.ranking-form input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
}

.ranking-form input:focus {
    border-color: #3498db;
    outline: none;
}

.ranking-form button {
    width: 100%;
    padding: 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.3s;
}

.ranking-form button:hover {
    background: #229954;
}

.ranking-form button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.save-status {
    margin-top: 10px;
    padding: 8px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

.save-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.save-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.save-status.loading {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.game-complete-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    padding: 10px;
    z-index: 1000;
}

.mobile-joystick {
    display: grid;
    grid-template-columns: 28px 28px 28px;
    grid-template-rows: 28px 28px 28px;
    gap: 3px;
    width: 90px;
    height: 90px;
    justify-content: center;
    align-content: center;
}

.mobile-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
}

.mobile-btn:active {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.9);
}

.mobile-btn.up { grid-column: 2; grid-row: 1; }
.mobile-btn.left { grid-column: 1; grid-row: 2; }
.mobile-btn.right { grid-column: 3; grid-row: 2; }
.mobile-btn.down { grid-column: 2; grid-row: 3; }

/* Mobile responsive improvements */
@media (max-width: 768px) {
    body {
        padding: 5px;
        min-height: 100vh;
        align-items: flex-start;
        overflow-x: hidden;
    }
    
    .container {
        margin: 0;
        padding: 10px;
        width: 100vw;
        max-width: 100vw;
        border-radius: 8px;
        box-sizing: border-box;
    }
    
    #game-board {
        margin: 15px auto;
        padding: 8px;
        max-width: 95vw;
        overflow-x: auto;
        justify-content: center;
    }
    
    .cell {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .level-info {
        justify-content: center;
        gap: 15px;
        font-size: 14px;
    }
    
    button {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    header {
        margin-bottom: 15px;
    }
    
    header h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    
    header p {
        font-size: 0.9em;
    }
    
    .controls {
        margin-top: 10px;
        padding: 8px;
        margin-bottom: 120px; /* Space for mobile controls */
    }
    
    .controls h3 {
        font-size: 1em;
    }
    
    .controls p {
        font-size: 0.8em;
        margin: 2px 0;
    }
    
    .mobile-controls {
        display: block;
    }
    
    /* Hide keyboard instructions on mobile */
    .controls p:first-of-type {
        display: none;
    }
    
    /* Adjust victory messages for mobile */
    .victory-message, .game-complete {
        width: 90%;
        max-width: 350px;
        padding: 20px 15px;
        font-size: 14px;
    }
    
    .victory-message h2, .game-complete h2 {
        font-size: 1.3em;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    #game-board {
        margin: 10px auto;
        padding: 6px;
        max-width: 98vw;
    }
    
    .cell {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    header h1 {
        font-size: 1.6em;
    }
    
    .mobile-controls {
        bottom: 8px;
        padding: 8px;
    }
    
    .mobile-joystick {
        grid-template-columns: 24px 24px 24px;
        grid-template-rows: 24px 24px 24px;
        width: 80px;
        height: 80px;
        gap: 2px;
    }
    
    .mobile-btn {
        font-size: 14px;
        border-radius: 6px;
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }
    
    .controls {
        margin-bottom: 100px; /* Less space on smaller screens */
    }
    
    .game-info {
        gap: 8px;
        margin-bottom: 10px;
    }
    
    button {
        padding: 8px 12px;
        font-size: 12px;
    }
}