body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #000;
    font-family: 'Courier New', monospace;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

canvas {
    border: 4px solid #fff;
    image-rendering: pixelated;
    width: 100%;
    max-width: 800px;
    height: auto;
    aspect-ratio: 2/1;
    touch-action: none;
}

#score {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 24px;
    z-index: 100;
}

#gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    text-align: center;
    color: #fff;
    border: 4px solid #fff;
    z-index: 200;
    width: 80%;
    max-width: 300px;
}

.hidden {
    display: none !important;
}

.character-select {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border: 4px solid #fff;
    text-align: center;
    color: #fff;
    z-index: 300;
    width: 90%;
    max-width: 300px;
}

.character-options {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
}

.character-option {
    cursor: pointer;
    padding: 10px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.character-option:hover, .character-option.selected {
    border-color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.character-option img {
    width: 50px;
    height: 50px;
    image-rendering: pixelated;
    margin-bottom: 10px;
    pointer-events: none;
}

.character-option span {
    display: block;
    font-size: 14px;
    pointer-events: none;
}

button {
    background-color: #fff;
    border: none;
    padding: 12px 24px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    margin: 8px;
    border-radius: 8px;
    min-width: 120px;
}

button:hover {
    background-color: #ccc;
}

button:active {
    transform: scale(0.95);
}

#mobileControls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 10px;
    z-index: 100;
    gap: 20px;
}

#jumpButton {
    width: 120px;
    height: 60px;
    font-size: 24px;
    border-radius: 15px;
    opacity: 0.8;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#specialAbilityButton {
    width: 60px;
    height: 60px;
    font-size: 16px;
    border-radius: 50%;
    background-color: #4a7cff;
    color: white;
    display: none; /* Hidden by default, shown for premium characters */
    opacity: 0.8;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    animation: pulse 2s infinite;
}

#specialAbilityButton.cooldown {
    background-color: #666;
    animation: none;
    opacity: 0.5;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(74, 124, 255, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(74, 124, 255, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(74, 124, 255, 0);
    }
}

.shield-effect {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 100;
    border: 5px solid rgba(0, 255, 255, 0.5);
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.3);
    animation: shield-pulse 1s infinite alternate;
}

@keyframes shield-pulse {
    from { opacity: 0.3; }
    to { opacity: 0.7; }
}

/* Mobile Optimizations */
@media (max-width: 428px) {
    .game-container {
        padding: 10px;
        justify-content: flex-start;
        padding-top: 60px;
    }

    canvas {
        width: 100%;
        max-width: none;
        border-width: 2px;
    }

    #score {
        font-size: 20px;
        top: 15px;
    }

    button {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 100px;
    }

    #jumpButton {
        width: 140px;
        height: 70px;
        font-size: 22px;
        bottom: 30px;
    }

    .character-option img {
        width: 40px;
        height: 40px;
    }

    .character-option span {
        font-size: 12px;
    }
}

/* Hide mobile controls on desktop */
@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }
}

#leaderboard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border: 4px solid #fff;
    color: #fff;
    z-index: 1000;
    width: 90%;
    max-width: 300px;
    max-height: 80vh;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 16px;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.rank {
    font-weight: bold;
    color: #ffd700;
    margin-right: 10px;
}

/* Achievement system styles */
.achievement-container {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 300px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

/* Achievement notification */
.achievement {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid gold;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    transform: translateX(120%);
    transition: transform 0.3s ease-out;
    pointer-events: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.achievement.show {
    transform: translateX(0);
}

.achievement-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    filter: drop-shadow(0 0 3px gold);
}

.achievement-info {
    flex: 1;
}

.achievement-title {
    color: gold;
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: bold;
}

.achievement-description {
    color: white;
    margin: 0;
    font-size: 12px;
}

/* Animation classes for achievements */
.animate-bounce {
    animation: bounce 0.5s ease infinite alternate;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 1.5s ease infinite;
}

.animate-flip {
    animation: flip 1.2s ease infinite;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes flip {
    0% { transform: rotateY(0); }
    100% { transform: rotateY(180deg); }
}

/* Achievement modal */
.achievement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.achievement-modal.show {
    opacity: 1;
}

.achievement-modal-content {
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid gold;
    border-radius: 12px;
    padding: 24px;
    max-width: 80%;
    width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.achievement-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: gold;
}

.achievement-modal-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 5px gold);
}

.achievement-modal-icon.locked {
    filter: grayscale(100%) brightness(40%);
}

.achievement-modal-title {
    color: gold;
    margin: 5px 0;
    font-size: 22px;
}

.achievement-modal-description {
    color: white;
    margin: 15px 0;
    font-size: 16px;
}

.achievement-modal-date {
    color: #aaa;
    margin-top: 20px;
    font-size: 14px;
    font-style: italic;
}

/* Auth container */
.auth-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border: 4px solid #fff;
    color: #fff;
    width: 90%;
    max-width: 300px;
    text-align: center;
}

.auth-container h2 {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
}

.flash-message {
    background-color: rgba(255, 0, 0, 0.3);
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.auth-container a {
    color: #fff;
    text-decoration: underline;
}

.auth-container button {
    width: 100%;
    margin: 10px 0;
}

/* Store Styles */
.store-container {
    background-color: rgba(0, 0, 0, 0.9);
    border: 4px solid #fff;
    color: #fff;
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 80vh;
    position: relative;
}

.store-container h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

.coins-display {
    font-weight: bold;
    color: #ffd700;
    display: flex;
    align-items: center;
}

.coins-display::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('/static/assets/coin.svg');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 5px;
}

.section-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.section-button {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.section-button.active {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: #fff;
}

.store-section {
    display: none;
}

.store-section.active {
    display: block;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.store-item {
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 15px;
    transition: transform 0.2s, border-color 0.2s;
}

.store-item:hover {
    transform: translateY(-5px);
    border-color: #fff;
}

.item-image {
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.item-image img {
    height: 80px;
    width: 80px;
    object-fit: contain;
    image-rendering: pixelated;
}

.coin-package img {
    width: 50px;
    height: 50px;
    margin: 0 auto 10px;
    display: block;
}

.coin-package {
    text-align: center;
}

.item-details h3 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 18px;
}

.item-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin-bottom: 10px;
    min-height: 40px;
}

.special-ability {
    color: #50fa7b;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
}

.item-price {
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 15px;
    font-size: 16px;
}

.buy-button, .buy-coin-button {
    width: 100%;
    background-color: #4a7cff;
    color: white;
    transition: background-color 0.2s;
}

.buy-button:hover, .buy-coin-button:hover {
    background-color: #3a6ae9;
}

.owned-button {
    width: 100%;
    background-color: #666;
    color: #ccc;
    cursor: not-allowed;
}

.store-footer {
    margin-top: 30px;
    text-align: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: rgba(0, 0, 0, 0.9);
    border: 4px solid #fff;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    color: #fff;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.modal-buttons button {
    width: 48%;
}

#confirmPurchase {
    background-color: #4a7cff;
}

#cancelPurchase {
    background-color: #666;
}

#payment-form {
    margin-top: 20px;
}

#card-element {
    background-color: #fff;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
}

#card-errors {
    color: #ff6b6b;
    margin-bottom: 10px;
    min-height: 20px;
}

@media (max-width: 428px) {
    .items-grid {
        grid-template-columns: 1fr;
    }
    
    .section-selector {
        flex-direction: column;
    }
}