body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #b0b0b0;
    font-family: sans-serif;
    touch-action: none; /* Prevent pull-to-refresh */
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: opacity 0.3s;
}

#controls {
    pointer-events: auto;
    width: 100%;
    height: 150px;
    position: absolute;
    bottom: 20px;
    display: none;
    justify-content: space-between;
    padding: 0 40px;
    box-sizing: border-box;
    align-items: center;
}

/* New move buttons container and arrow buttons for mobile */
#move-buttons {
    display: flex;
    gap: 20px;
    align-items: center;
}

.arrow-button {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    font-weight: bold;
    font-size: 32px;
    user-select: none;
    -webkit-user-select: none;
}

.arrow-button:active {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.95);
}

#jump-button {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    font-weight: bold;
    font-size: 50px;
    user-select: none;
    -webkit-user-select: none;
    align-self: center;
}

#jump-button:active {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.95);
}

#instructions {
    padding: 20px;
    color: rgba(0,0,0,0.7);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

/* Lives Container */
#lives-container {
    position: fixed;
    top: 20px;
    left: 20px;
    display: none; /* Hidden in menu */
    flex-direction: row;
    gap: 5px;
    pointer-events: none;
}

#jump-counter {
    position: fixed;
    top: 70px;
    left: 20px;
    display: none;
    color: black;
    font-weight: bold;
    font-size: 20px;
    pointer-events: none;
    padding-left: 5px;
}

/* New Distance Display */
#distance-display {
    position: fixed;
    top: 20px;
    right: 20px;
    color: black;
    font-weight: bold;
    font-size: 24px;
    font-family: monospace;
    pointer-events: none;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.5);
}

.heart-icon {
    width: 40px;
    height: 40px;
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.3));
}

/* Leaderboard Modal */
#leaderboard-modal, #pause-modal, #settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    border: 4px solid black;
    width: 80%;
    max-width: 400px;
    text-align: center;
    font-family: monospace;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.5);
}

.modal-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.leaderboard-list {
    text-align: left;
    margin-bottom: 20px;
    max-height: 60vh;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 2px dashed #ccc;
}

.close-btn {
    background: black;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 18px;
    font-family: monospace;
    cursor: pointer;
    border-radius: 10px;
}

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

#leaderboard-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none; /* Allow seeing through, but children will catch events */
    justify-content: center;
    align-items: center;
}

.leaderboard-container {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.9);
    border: 4px solid black;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    height: 80%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.3);

    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.leaderboard-container.visible {
    opacity: 1;
    transform: translateX(0);
}

.leaderboard-header {
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 2px solid black;
    padding-bottom: 10px;
}

.back-btn {
    margin-top: 15px;
    background: black;
    color: white;
    border: none;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 10px;
    font-family: inherit;
    align-self: center;
    min-width: 120px;
}

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

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
    text-align: left;
    width: 100%;
}

.setting-row label {
    flex: 1;
}

.setting-row input[type="range"] {
    flex: 1;
}

.setting-row select {
    font-family: monospace;
    font-size: 16px;
    padding: 5px;
    border: 2px solid black;
    border-radius: 5px;
}

.setting-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
    accent-color: black;
}

/* Range Slider Styling */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 0 10px;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 14px;
    cursor: pointer;
    background: #ffffff;
    border: 2px solid #000000;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 2px solid #000000;
    height: 28px;
    width: 16px;
    background: #ffffff;
    cursor: pointer;
    margin-top: -9px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

input[type=range]::-webkit-slider-thumb:active {
    transform: scale(0.95);
    background: #e0e0e0;
}

/* Firefox Support */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 14px;
    cursor: pointer;
    background: #ffffff;
    border: 2px solid #000000;
}

input[type=range]::-moz-range-thumb {
    border: 2px solid #000000;
    height: 28px;
    width: 16px;
    background: #ffffff;
    cursor: pointer;
}

/* Scrollbar Styling */
.leaderboard-list::-webkit-scrollbar {
    width: 16px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
    border-left: 2px solid black;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: #ffffff;
    border: 2px solid black;
    box-shadow: inset -2px -2px 0px rgba(0,0,0,0.1);
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: #f0f0f0;
}

/* Pixelated Intro Modal */
#intro-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.pixel-window {
    background-color: #fff;
    background-image: 
        linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
        linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;

    width: 85%;
    max-width: 450px;
    padding: 30px;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    position: relative;

    /* Pixel Art Border Effect */
    box-shadow: 
        -6px 0 0 0 black,
        6px 0 0 0 black,
        0 -6px 0 0 black,
        0 6px 0 0 black,
        0 0 0 4px white; /* Inner spacing */
    border: 4px solid transparent; /* Spacer */
    margin: 6px;
}

.pixel-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 20px;
    text-transform: uppercase;
    text-shadow: 2px 2px 0px #ccc;
}

.pixel-content {
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 25px;
    font-weight: bold;
    color: #222;
}

.pixel-link {
    display: inline-block;
    margin-top: 15px;
    background: #444;
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    padding: 10px 15px;
    border: 2px solid black;
    box-shadow: 3px 3px 0px black;
    transition: transform 0.1s;
}

.pixel-link:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px black;
}

.pixel-btn {
    background: #000;
    color: #fff;
    border: 4px solid black;
    padding: 15px 40px;
    font-family: inherit;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 25px;
    display: inline-block;

    /* Pixel button corners */
    box-shadow: 
        inset 3px 3px 0px #444,
        inset -3px -3px 0px #444;
}

.pixel-btn:hover {
    background: #222;
}

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

#settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

#shop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.palette-option {
    background: #f0f0f0;
    border: 3px solid #ccc;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.palette-option:hover {
    transform: scale(1.05);
    border-color: #888;
}

.palette-option.selected {
    border-color: #000;
    background: #fff;
    box-shadow: 0 0 0 3px #000;
}

.palette-preview {
    width: 100%;
    height: 60px;
    border: 2px solid #000;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    display: flex;
}

.palette-inside {
    flex: 2;
}

.palette-outline {
    flex: 1;
}

.palette-name {
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
}