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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow: hidden;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 1240px;
    width: 100%;
    position: relative;
}

.header {
    text-align: center;
    margin-bottom: 15px;
    position: relative;
}

.back-btn {
    position: absolute;
    top: 0;
    left: 0;
    padding: 8px 16px;
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.back-btn:hover {
    background: linear-gradient(135deg, #0984e3 0%, #0652b8 100%);
    transform: scale(1.05);
}

.back-btn:active {
    transform: scale(0.95);
}

.header h1 {
    color: #d63031;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    display: inline-block;
}

.title-text {
    display: inline-block;
}

.byline {
    font-size: 0.45em;
    font-weight: normal;
    color: #636e72;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.4em;
    white-space: nowrap;
}

.stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    font-size: 1.3em;
    font-weight: bold;
    color: #2d3436;
    flex-wrap: wrap;
}

.add-life-btn {
    padding: 8px 16px;
    font-size: 0.8em;
    background: linear-gradient(135deg, #e17055 0%, #d63031 100%);
    color: white;
    border: 2px solid #2d3436;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.add-life-btn:hover {
    background: linear-gradient(135deg, #d63031 0%, #c0392b 100%);
    transform: scale(1.05);
}

.add-life-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.game-info {
    text-align: center;
    margin-bottom: 10px;
    color: #636e72;
    font-size: 1.1em;
}

#gameCanvas {
    display: block;
    background: #ecf0f1;
    border: 4px solid #2d3436;
    border-radius: 10px;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    touch-action: none;
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 10;
    max-width: 90%;
}

.game-over h2 {
    color: #d63031;
    font-size: 2.5em;
    margin-bottom: 15px;
}

.game-over p {
    font-size: 1.3em;
    margin: 10px 0;
    color: #2d3436;
}

#restartBtn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.2em;
    background: #00b894;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

#restartBtn:hover {
    background: #00a383;
    transform: scale(1.05);
}

#restartBtn:active {
    transform: scale(0.95);
}

.hidden {
    display: none;
}

/* Mobile Controls */
.mobile-controls {
    position: relative;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.dpad {
    position: relative;
    width: 180px;
    height: 180px;
}

.dpad-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00b894 0%, #00a383 100%);
    border: 3px solid #2d3436;
    border-radius: 12px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
}

.dpad-btn:active {
    background: linear-gradient(135deg, #00a383 0%, #009874 100%);
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dpad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dpad-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: #ecf0f1;
    border: 3px solid #2d3436;
    border-radius: 50%;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        align-items: flex-start;
        padding-top: 10px;
        min-height: auto;
        overflow: auto;
    }
    
    .game-container {
        padding: 15px;
        border-radius: 15px;
    }
    
    .header h1 {
        font-size: 1.8em;
        margin-bottom: 8px;
    }
    
    .stats {
        gap: 20px;
        font-size: 1.1em;
    }
    
    .add-life-btn {
        font-size: 0.75em;
        padding: 6px 12px;
    }
    
    .game-info {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    #gameCanvas {
        border: 3px solid #2d3436;
    }
    
    .mobile-controls {
        margin-top: 15px;
        padding: 10px;
    }
    
    .game-over {
        padding: 30px 20px;
    }
    
    .game-over h2 {
        font-size: 2em;
    }
    
    .game-over p {
        font-size: 1.1em;
    }
    
    #restartBtn {
        padding: 12px 30px;
        font-size: 1.1em;
    }
}

@media screen and (max-width: 480px) {
    .header h1 {
        font-size: 1.5em;
    }
    
    .stats {
        gap: 15px;
        font-size: 1em;
    }
    
    .add-life-btn {
        font-size: 0.7em;
        padding: 5px 10px;
    }
    
    .game-info {
        font-size: 0.85em;
    }
    
    .dpad {
        width: 160px;
        height: 160px;
    }
    
    .dpad-btn {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
    
    .dpad-center {
        width: 45px;
        height: 45px;
    }
    
    .game-over h2 {
        font-size: 1.6em;
    }
    
    .game-over p {
        font-size: 1em;
    }
}
