* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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;
    overflow: hidden;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

h1 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 2.5rem;
    font-weight: 700;
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #4a5568;
}

.score, .high-score {
    background: #edf2f7;
    padding: 10px 20px;
    border-radius: 10px;
}

#score, #high-score {
    color: #3182ce;
    font-size: 1.4rem;
}

canvas {
    border: 3px solid #e2e8f0;
    border-radius: 10px;
    background: #f7fafc;
    display: block;
    margin: 0 auto 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    touch-action: none;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #3182ce;
    color: white;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    opacity: 0.85;
    filter: brightness(0.95);
}

#start-btn {
    background: #38a169;
}
#start-btn:hover {
    background: #2f855a;
}
#pause-btn {
    background: #ed8936;
}
#pause-btn:hover {
    background: #dd6b20;
}
#reset-btn {
    background: #e53e3e;
}
#reset-btn:hover {
    background: #c53030;
}
.instructions-toggle {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.instructions-toggle:hover {
    background-color: #45a049;
}

.instructions {
    background: #f7fafc;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
}
.instructions h3 {
    color: #4a5568;
    margin-bottom: 10px;
    text-align: center;
}
.instructions p {
    color: #718096;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.mobile-controls {
    display: none;
    margin-top: 20px;
    margin-bottom: 10px;
}

.d-pad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.d-pad-middle {
    display: flex;
    gap: 70px;
}

.d-pad-btn {
    width: 70px;
    height: 70px;
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.d-pad-btn.active {
    background: linear-gradient(135deg, #4c51bf 0%, #434190 100%) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
}

.d-pad-btn.up {
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.d-pad-btn.down {
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}
.d-pad-btn.left {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}
.d-pad-btn.right {
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.instructions-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.instructions-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 80%;
    max-width: 400px;
    position: relative;
    animation: modalFadeIn 0.3s;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-btn:hover, .close-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

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

.instructions-content h3 {
    margin-top: 10px;
    margin-bottom: 15px;
    color: #4a5568;
}

@media (max-width: 500px) {
    body {
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden;
        height: 100vh;
    }
    .game-container {
        padding: 8px !important;
        margin: 0 !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        border-radius: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.95);
    }
    h1 {
        font-size: 1.4rem;
        margin: 8px 0 !important;
        line-height: 1.3;
        padding: 0;
    }
    canvas {
        width: 100%;
        max-width: 98vw;
        height: auto;
        margin: 8px auto !important;
        padding: 0;
        max-height: 50vh;
        object-fit: contain;
    }
    .game-info {
        margin: 6px 0 !important;
        font-size: 0.9rem;
        flex-direction: row;
        width: 100%;
        padding: 0;
    }
    .score, .high-score {
        padding: 6px 10px !important;
        margin: 0 5px !important;
        flex: 1;
    }
    #score, #high-score {
        font-size: 1rem;
    }
    .controls {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin: 8px 0 !important;
        justify-content: center;
        width: 100%;
        padding: 0;
    }
    button {
        padding: 7px 10px !important;
        font-size: 0.8rem;
        min-width: auto !important;
        max-width: none !important;
        width: auto !important;
        white-space: nowrap;
        flex: none;
    }
    .instructions-toggle {
        padding: 7px 10px !important;
        font-size: 0.8rem;
        flex: none;
        min-width: auto !important;
        max-width: none !important;
        width: auto !important;
    }
    .mobile-controls {
        display: block;
        margin: 10px auto 20px !important;
        padding: 5px !important;
        flex-shrink: 0;
        max-width: 270px;
        width: 100%;
    }
    .d-pad-btn {
        width: 70px !important;
        height: 70px !important;
        font-size: 1.4rem !important;
        border-radius: 12px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .d-pad {
        gap: 4px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    .d-pad-middle {
        gap: 70px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .d-pad-btn.up, .d-pad-btn.down, .d-pad-btn.left, .d-pad-btn.right {
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
    }
    .instructions-content {
        width: 95%;
        margin: 15% auto;
        padding: 15px;
    }
}
