* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', monospace;
    background-color: #f7f7f7;
    color: #535353;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 24px;
    color: #535353;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.score-container {
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 12px;
}

.score-label {
    color: #535353;
}

.high-score, .score, .level-display {
    min-width: 60px;
    text-align: right;
}

.level-display {
    color: #ff6b35;
    font-weight: bold;
}

#gameCanvas {
    border: 2px solid #535353;
    background-color: #f7f7f7;
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
}

.game-instructions {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #535353;
    font-weight: bold;
}

.mobile-instruction {
    display: none;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(247, 247, 247, 0.95);
    padding: 30px;
    border: 2px solid #535353;
    text-align: center;
    display: none;
    z-index: 100;
}

.game-over h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #535353;
}

.game-over p {
    font-size: 12px;
    margin-bottom: 10px;
    font-weight: bold;
}

.mobile-restart {
    display: none;
}

.level-selection {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(247, 247, 247, 0.95);
    padding: 20px;
    border: 2px solid #535353;
    text-align: center;
    display: none; /* Hidden by default, shown only for original mode */
    z-index: 100;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 8px;
}

.level-selection h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #535353;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.level-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 18px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.level-btn {
    font-family: 'Press Start 2P', monospace;
    background-color: #535353;
    color: #f7f7f7;
    border: none;
    padding: 14px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid #535353;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1.3;
    border-radius: 4px;
    font-weight: bold;
}

.level-btn:hover {
    background-color: #f7f7f7;
    color: #535353;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.level-btn:active {
    transform: scale(0.95);
}

.level-btn span {
    font-size: 9px;
    opacity: 0.9;
    display: block;
    margin-top: 3px;
    line-height: 1.2;
    font-weight: normal;
}

.level-instruction {
    font-size: 12px;
    color: #535353;
    margin: 0;
    font-weight: bold;
}

.pause-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(247, 247, 247, 0.95);
    padding: 30px;
    border: 2px solid #535353;
    text-align: center;
    display: none;
    z-index: 100;
}

.pause-overlay h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #535353;
}

.pause-overlay p {
    font-size: 12px;
    font-weight: bold;
}

.mobile-controls {
    display: none;
    gap: 20px;
    margin-top: 20px;
}

.jump-button, .pause-button {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 15px 25px;
    background-color: #535353;
    color: #f7f7f7;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    touch-action: manipulation;
}

.jump-button:hover, .pause-button:hover {
    background-color: #333333;
}

.jump-button:active, .pause-button:active {
    background-color: #1a1a1a;
    transform: scale(0.95);
}

/* Mobile and Tablet Responsive Design */
/* Large screens and laptops */
@media screen and (min-width: 1200px) {
    .game-container {
        padding: 30px;
    }
    
    .game-header {
        max-width: 1000px;
        margin-bottom: 30px;
    }
    
    .game-header h1 {
        font-size: 28px;
    }
    
    .score-container {
        font-size: 14px;
        gap: 25px;
    }
    
    #gameCanvas {
        max-width: 1000px;
        border-width: 3px;
    }
    
    .game-instructions {
        font-size: 14px;
        margin-top: 25px;
    }
}

/* Tablets and medium screens */
@media screen and (min-width: 769px) and (max-width: 1199px) {
    .game-container {
        padding: 20px;
    }
    
    .game-header {
        max-width: 800px;
    }
    
    .game-header h1 {
        font-size: 26px;
    }
    
    .score-container {
        font-size: 13px;
        gap: 22px;
    }
    
    #gameCanvas {
        max-width: 800px;
    }
    
    .game-instructions {
        font-size: 13px;
    }
}

@media screen and (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        margin-bottom: 15px;
    }
    
    .game-header h1 {
        font-size: 18px;
    }
    
    .score-container {
        font-size: 10px;
        gap: 15px;
    }
    
    .desktop-instruction {
        display: none;
    }
    
    .mobile-instruction {
        display: block;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    .mobile-restart {
        display: block;
    }
    
    .game-over p:not(.mobile-restart) {
        display: none;
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 720px;
        height: auto;
    }
}

@media screen and (max-width: 480px) {
    .game-header h1 {
        font-size: 14px;
    }
    
    .score-container {
        font-size: 8px;
        gap: 10px;
    }
    
    .game-instructions {
        font-size: 10px;
    }
    
    .jump-button, .pause-button {
        font-size: 10px;
        padding: 12px 20px;
    }
    
    .game-over {
        padding: 20px;
        width: 90%;
        max-width: 300px;
    }
    
    .game-over h2 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .game-over p {
        font-size: 10px;
    }
    
    .pause-overlay {
        padding: 20px;
        width: 90%;
        max-width: 300px;
    }
    
    .pause-overlay h2 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .pause-overlay p {
        font-size: 10px;
    }
}

/* Landscape mode for mobile devices */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .game-container {
        padding: 5px;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .game-header h1 {
        font-size: 12px;
    }
    
    .score-container {
        font-size: 8px;
    }
    
    .game-instructions {
        margin-top: 10px;
        font-size: 10px;
    }
    
    .mobile-controls {
        margin-top: 10px;
    }
    
    .jump-button, .pause-button {
        font-size: 10px;
        padding: 10px 18px;
    }
}

/* Animation for score updates */
@keyframes scoreUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.score-update {
    animation: scoreUpdate 0.3s ease-in-out;
}

/* Level up message */
.level-up-message {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(83, 83, 83, 0.95);
    color: #f7f7f7;
    padding: 20px 30px;
    border-radius: 10px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    z-index: 200;
    animation: levelUpAnimation 2s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #ffff00;
}

.level-up-message h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #ffff00;
    font-weight: bold;
}

.level-up-message p {
    font-size: 12px;
    margin: 0;
    font-weight: bold;
}

@keyframes levelUpAnimation {
    0% { 
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
    20% { 
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    30% { 
        transform: translateX(-50%) scale(1);
    }
    90% { 
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
}

/* Disabled state for buttons */
.jump-button:disabled, .pause-button:disabled {
    background-color: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

.jump-button:disabled:hover, .pause-button:disabled:hover {
    background-color: #cccccc;
    transform: none;
}

/* Mobile responsiveness for level selection */
@media (max-width: 768px) {
    .level-selection {
        padding: 15px;
        width: 95%;
        max-height: 80vh;
        max-width: 400px;
    }
    
    .level-selection h2 {
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .level-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-bottom: 15px;
        max-width: 300px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .level-btn {
        padding: 12px 8px;
        font-size: 10px;
        min-height: 65px;
        border-radius: 4px;
    }
    
    .level-btn span {
        font-size: 7px;
        margin-top: 2px;
    }
    
    .level-instruction {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .level-selection {
        padding: 12px;
        width: 92%;
        max-width: 320px;
    }
    
    .level-selection h2 {
        font-size: 12px;
        margin-bottom: 12px;
    }
    
    .level-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 12px;
        max-width: 280px;
    }
    
    .level-btn {
        padding: 10px 6px;
        font-size: 9px;
        min-height: 60px;
        border-radius: 3px;
    }
    
    .level-btn span {
        font-size: 6px;
        margin-top: 2px;
    }
    
    .level-instruction {
        font-size: 9px;
    }
}

@media (max-width: 360px) {
    .level-selection {
        padding: 10px;
        width: 90%;
        max-width: 300px;
    }
    
    .level-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        max-width: 250px;
    }
    
    .level-btn {
        padding: 10px 5px;
        font-size: 8px;
        min-height: 55px;
    }
    
    .level-btn span {
        font-size: 5px;
        margin-top: 2px;
    }
}

/* Mode Selection Styles */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
}

.overlay-content {
    background-color: rgba(247, 247, 247, 0.95);
    padding: 30px;
    border: 2px solid #535353;
    border-radius: 12px;
    text-align: center;
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.overlay-content h2 {
    font-size: 20px;
    margin-bottom: 25px;
    color: #535353;
    font-weight: bold;
}

#modeSelection {
    background-color: rgba(0, 0, 0, 0.8);
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    max-width: 700px;
    width: 100%;
}

.mode-option {
    background-color: #f7f7f7;
    border: 2px solid #535353;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.mode-option:hover {
    background-color: #e0e0e0;
    border-color: #83A603;
    transform: translateY(-2px);
}

.mode-option h3 {
    font-size: 16px;
    color: #535353;
    margin-bottom: 10px;
    font-weight: bold;
}

.mode-option p {
    font-size: 10px;
    color: #555;
    margin-bottom: 15px;
    line-height: 1.5;
    font-weight: normal;
}

.mode-features {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mode-features span {
    font-size: 8px;
    color: #83A603;
    background-color: rgba(131, 166, 3, 0.1);
    padding: 3px 6px;
    border-radius: 3px;
    font-weight: bold;
}

/* Responsive Mode Selection */
@media (max-width: 768px) {
    .mode-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        max-width: 400px;
    }
    
    .mode-option {
        padding: 15px;
    }
    
    .mode-option h3 {
        font-size: 14px;
    }
    
    .mode-option p {
        font-size: 9px;
    }
    
    .mode-features span {
        font-size: 7px;
    }
}

@media (max-width: 480px) {
    .mode-grid {
        max-width: 300px;
    }
    
    .mode-option {
        padding: 12px;
    }
    
    .mode-option h3 {
        font-size: 12px;
    }
    
    .mode-option p {
        font-size: 8px;
    }
    
    .mode-features span {
        font-size: 6px;
    }
}
