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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(to bottom, #1a1a2e 0%, #2d3561 50%, #4a5899 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: white;
    touch-action: none;
    overflow: hidden;
}

.game-container {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    max-width: 900px;
    width: 100%;
}

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

h1 {
    font-size: 2.5em;
    color: #87CEEB;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 15px;
}

.stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    font-size: 1.2em;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    flex-wrap: wrap;
}

.stat {
    font-weight: bold;
}

.stat span {
    color: #FFD700;
}

.stamina-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stamina-label {
    font-size: 0.9em;
    font-weight: bold;
    color: #FFD700;
}

.stamina-bar-container {
    width: 120px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #FFD700;
    border-radius: 6px;
    overflow: hidden;
}

.stamina-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 50%, #CDDC39 100%);
    transition: width 0.2s ease;
    box-shadow: 0 0 10px rgba(139, 195, 74, 0.6);
}

.pause-btn {
    background: rgba(255, 215, 0, 0.9) !important;
    color: #333 !important;
    border: none !important;
    padding: 8px 16px !important;
    font-size: 0.9em !important;
    font-weight: bold !important;
    border-radius: 8px !important;
    cursor: pointer;
    font-family: 'Courier New', monospace !important;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3) !important;
    margin-left: 20px;
}

.pause-btn:hover {
    background: rgba(255, 165, 0, 0.9) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4) !important;
}

.pause-btn:active {
    transform: translateY(0) !important;
}

.shop-btn {
    background: rgba(76, 175, 80, 0.9) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    font-size: 0.9em !important;
    font-weight: bold !important;
    border-radius: 8px !important;
    cursor: pointer;
    font-family: 'Courier New', monospace !important;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3) !important;
    margin-left: 10px;
}

.shop-btn:hover {
    background: rgba(56, 142, 60, 0.9) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4) !important;
}

.shop-btn:active {
    transform: translateY(0) !important;
}

.canvas-wrapper {
    position: relative;
    margin-bottom: 20px;
}

#gameCanvas {
    display: block;
    background: linear-gradient(to bottom, #87CEEB 0%, #E0F6FF 100%);
    border: 5px solid #333;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    width: 100%;
    max-width: 800px;
    height: auto;
    cursor: pointer;
}

/* On-screen controls */
.on-screen-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(145deg, #4a5899, #2d3561);
    border: 3px solid #87CEEB;
    color: white;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1em;
    padding: 15px 25px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 100px;
    touch-action: manipulation;
    user-select: none;
}

.control-btn .btn-icon {
    font-size: 2em;
}

.control-btn .btn-label {
    font-size: 0.8em;
}

.control-btn:hover {
    background: linear-gradient(145deg, #5a68a9, #3d4571);
    border-color: #FFD700;
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.4);
}

.control-btn:active,
.control-btn.active {
    background: linear-gradient(145deg, #3d4571, #2d3561);
    border-color: #FFD700;
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5) inset;
}

.jump-btn {
    background: linear-gradient(145deg, #FFD700, #FFA500);
    color: #333;
    border-color: #FFD700;
    min-width: 120px;
}

.jump-btn:hover {
    background: linear-gradient(145deg, #FFA500, #FF8C00);
}

.jump-btn:active,
.jump-btn.active {
    background: linear-gradient(145deg, #FF8C00, #FFA500);
}

.controls {
    text-align: center;
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.instructions p {
    margin: 8px 0;
    font-size: 0.95em;
    line-height: 1.5;
}

button:not(.control-btn) {
    background: #FFD700;
    color: #333;
    border: none;
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

button:not(.control-btn):hover {
    background: #FFA500;
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.4);
}

button:not(.control-btn):active {
    transform: translateY(0);
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 5px solid #FFD700;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

.game-over h2 {
    font-size: 3em;
    margin-bottom: 30px;
    color: #FFD700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

.pause-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 5px solid #87CEEB;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    min-width: 300px;
}

.pause-menu h2 {
    font-size: 3em;
    margin-bottom: 20px;
    color: #87CEEB;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

.pause-menu p {
    font-size: 1.2em;
    margin-bottom: 30px;
    color: #FFFFFF;
}

.pause-menu button {
    display: block;
    width: 100%;
    margin: 15px 0;
}

.pause-hint {
    margin-top: 20px;
    font-size: 0.9em;
    color: #87CEEB;
    font-style: italic;
}

.shop-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 5px solid #4CAF50;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    min-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.shop-menu h2 {
    font-size: 3em;
    margin-bottom: 20px;
    color: #4CAF50;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
}

.shop-menu > p {
    font-size: 1.4em;
    margin-bottom: 30px;
    color: #FFD700;
}

.upgrade-section {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.upgrade-item {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #4CAF50;
    border-radius: 15px;
    padding: 20px;
    width: 160px;
    text-align: center;
}

.upgrade-item h3 {
    font-size: 1.5em;
    color: #FFD700;
    margin-bottom: 10px;
}

.upgrade-item p {
    font-size: 0.9em;
    margin: 5px 0;
    color: #FFFFFF;
}

.buy-btn {
    background: #4CAF50 !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    font-size: 1em !important;
    font-weight: bold !important;
    border-radius: 8px !important;
    cursor: pointer;
    margin-top: 10px;
    width: 100%;
    transition: all 0.3s;
}

.buy-btn:hover {
    background: #45a049 !important;
    transform: scale(1.05);
}

.buy-btn:disabled {
    background: #666 !important;
    cursor: not-allowed;
    opacity: 0.5;
}

.close-shop-btn {
    background: #f44336 !important;
    color: white !important;
    border: none !important;
    padding: 12px 30px !important;
    font-size: 1.2em !important;
    font-weight: bold !important;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all 0.3s;
}

.close-shop-btn:hover {
    background: #da190b !important;
    transform: scale(1.05);
}

/* Achievements Menu */
.achievements-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 30px;
    border-radius: 20px;
    border: 4px solid #FFD700;
    color: white;
    font-family: 'Courier New', monospace;
    z-index: 1001;
    max-height: 80vh;
    overflow-y: auto;
    min-width: 600px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.achievements-menu h2 {
    text-align: center;
    color: #FFD700;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.achievement-item {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #444;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s;
}

.achievement-item.unlocked {
    border-color: #FFD700;
    background: rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.achievement-item.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.achievement-name {
    font-size: 1.2em;
    color: #FFD700;
    margin: 10px 0 5px 0;
}

.achievement-desc {
    font-size: 0.9em;
    color: #CCC;
    margin: 5px 0;
}

.achievement-reward {
    font-size: 1.1em;
    color: #4CAF50;
    margin-top: 10px;
    font-weight: bold;
}

/* Mobile responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2em;
    }

    .stats {
        font-size: 1em;
        gap: 15px;
    }

    .control-btn {
        min-width: 80px;
        padding: 12px 20px;
    }

    .control-btn .btn-icon {
        font-size: 1.5em;
    }

    .control-btn .btn-label {
        font-size: 0.7em;
    }

    .jump-btn {
        min-width: 100px;
    }

    .instructions p {
        font-size: 0.85em;
    }

    .game-over {
        padding: 30px;
        width: 90%;
    }

    .game-over h2 {
        font-size: 2em;
    }
}

/* Visual feedback for touch */
@media (hover: none) {
    .control-btn:hover {
        transform: none;
    }
}
