*{
    user-select: none;
    margin:0;
    padding:0;    
    text-align: center;
    touch-action: pan-x pan-y;
}
body{
    background-color: rgb(169, 155, 221);
    position: absolute;
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Arial', sans-serif;
}
main{
    position: relative;
    width: 80%;
    max-width: 800px;
}
canvas{
    background: rgb(135, 206, 235); /* Sky blue background */
    border: 1rem solid rgb(141, 190, 245);
    width: calc(100% - 2rem);
    display: block;
    max-height: 70vh; /* Prevent canvas from being too tall on mobile */
}
#levelAndScore{
    top: 1rem;
    width: 100%;
    position: absolute;
    display: flex;
    justify-content: space-between;
    z-index: 10;
}

#score, #gravityText{
    font-size: 1.5rem;
    color: rgb(42, 3, 78);
    margin-right: 1.8rem;
    margin-left: 1.2rem;
    text-shadow: 1px 1px 2px white;
}
#gameTitle{
    text-align: center;
    color: rgb(0, 128, 128);
    margin-bottom: 10px;
    position: relative;
    top: -15px;
}

#startScreen, #gameOverScreen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 10px;
    z-index: 10;
    width: 80%;
    max-width: 500px;
}

/* Add a specific class for the planet selection screen to ensure it's hidden */
.planet-selection.hidden {
    display: none !important;
}

#startScreen h2 {
    margin-bottom: 15px;
    color: #333;
}

#planet-selector {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.planet-option {
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    background-color: #f1f1f1;
    width: 100px;
    text-align: center;
    transition: all 0.3s ease;
    min-height: 44px; /* Apple's recommended minimum touch target size */
    min-width: 44px;
    touch-action: manipulation;
}

.planet-option:hover {
    background-color: #e1e1e1;
    transform: scale(1.05);
}

.planet-option.selected {
    background-color: #d1d1d1;
    border: 2px solid #333;
    transform: scale(1.1);
}

.planet-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
}

.moon {
    background-color: #D1D1D1;
    box-shadow: inset -10px -10px 0 #A0A0A0;
}

.earth {
    background-color: #4287f5;
    box-shadow: inset -10px -10px 0 #2559a7;
    position: relative;
}

.earth::after {
    content: "";
    position: absolute;
    width: 60%;
    height: 25%;
    background-color: #3cb043;
    top: 30%;
    left: 20%;
    border-radius: 50%;
    transform: rotate(-20deg);
}

.jupiter {
    background-color: #E8B247;
    position: relative;
    overflow: hidden;
}

.jupiter::after {
    content: "";
    position: absolute;
    width: 120%;
    height: 20%;
    background-color: #D19C3B;
    top: 30%;
    left: -10%;
    border-radius: 50%;
}

.jupiter::before {
    content: "";
    position: absolute;
    width: 120%;
    height: 15%;
    background-color: #D19C3B;
    top: 60%;
    left: -10%;
    border-radius: 50%;
}

.sun {
    background: radial-gradient(circle, #FFA500, #FF4500);
    box-shadow: 0 0 10px 2px #FFFF00;
}

.gravity-info {
    font-size: 0.8rem;
    margin-top: 5px;
    color: #666;
    font-weight: bold;
    padding: 3px;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.planet-option:hover .gravity-info {
    background-color: rgba(0, 0, 0, 0.1);
}

.planet-option.selected .gravity-info {
    background-color: rgba(0, 0, 0, 0.2);
    color: #333;
}

#start-game-btn {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s;
    min-height: 44px; /* Apple's recommended minimum touch target size */
    min-width: 44px;
    touch-action: manipulation;
}

#start-game-btn:hover {
    background-color: #45a049;
}

#gameOverScreen {
    color: red;
}

.hidden {
    display: none;
}

/* Add a pulse animation to the start button to make it more noticeable */
.pulse-button {
    animation: pulse 2s infinite;
    box-shadow: 0 0 0 rgba(76, 175, 80, 0.4);
}

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

@media(max-width:600px){    
    main {
        width: 95%;
    }
    
    #score, #gravityText {
        font-size: 1rem;
    }
    
    .planet-option {
        width: 70px;
        padding: 5px;
    }
    
    .planet-icon {
        width: 35px;
        height: 35px;
    }
}

/* Add celestial-specific styles */
.moon-environment canvas {
    background: #1A1A2E; /* Dark blue space background for Moon */
}

.jupiter-environment canvas {
    background: #D19C3B; /* Jupiter colored background */
}

.sun-environment canvas {
    background: #FF8C00; /* Orange background for Sun */
}

.earth-environment canvas {
    background: rgb(135, 206, 235); /* Default blue sky */
}

/* Add subtle animation for the Sun environment */
@keyframes sun-glow {
    0% { box-shadow: 0 0 10px 2px rgba(255, 165, 0, 0.5); }
    50% { box-shadow: 0 0 20px 5px rgba(255, 165, 0, 0.7); }
    100% { box-shadow: 0 0 10px 2px rgba(255, 165, 0, 0.5); }
}

.sun-environment canvas {
    animation: sun-glow 3s infinite;
}

/* Mobile optimizations */
.mobile-device {
    touch-action: none; /* Prevent default touch actions */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Optimize planet selector for portrait mode */
.portrait-layout {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
}

.portrait-layout .planet-option {
    width: 65px;
    height: 90px;
    padding: 5px;
    margin-bottom: 0;
}

.portrait-layout .planet-icon {
    width: 40px;
    height: 40px;
}

.portrait-layout .gravity-info {
    font-size: 0.7rem;
}

/* Tap hint styling */
.tap-hint {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    z-index: 1000;
    display: flex;
    align-items: center;
    animation: pulse-hint 1.5s infinite;
    pointer-events: none;
}

.tap-icon {
    font-size: 24px;
    margin-right: 10px;
    animation: tap-motion 1s infinite;
}

.tap-text {
    font-size: 18px;
    font-weight: bold;
}

.tap-hint.hidden {
    display: none;
}

.tap-hint.fade-out {
    opacity: 0;
    transition: opacity 1s;
}

@keyframes pulse-hint {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes tap-motion {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

/* Enhanced responsive design for various screen sizes */
@media (max-width: 400px) {
    h1#gameTitle {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }
    
    #score, #gravityText {
        font-size: 0.8rem;
        margin-right: 0.8rem;
        margin-left: 0.8rem;
    }
    
    #startScreen, #gameOverScreen {
        width: 90%;
        padding: 15px;
    }
    
    #startScreen h2 {
        font-size: 1.2rem;
    }
    
    #start-game-btn {
        padding: 8px 16px;
    }
    
    .planet-option {
        width: 60px;
        padding: 5px;
    }
    
    .planet-icon {
        width: 30px;
        height: 30px;
    }
}

/* Special fixes for iPhones with notches */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
    canvas {
        touch-action: none !important; /* Prevent browser handling of touch gestures */
        width: calc(100% - 1.5rem) !important; /* Smaller border on mobile */
        border-width: 0.75rem !important;
        -webkit-tap-highlight-color: transparent; /* Remove tap highlight on Safari */
    }
    
    #startScreen, #gameOverScreen {
        width: 90% !important;
        padding: 15px !important;
    }
    
    /* Make gravity and score text more readable on small screens */
    #score, #gravityText {
        font-size: 1.2rem !important;
        margin-right: 1rem !important;
        margin-left: 1rem !important;
    }
}

/* Fix iOS Safari issues with 100vh */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }
    
    html {
        height: -webkit-fill-available;
    }
}

/* Fix for iPhone notch */
@supports (padding: max(0px)) {
    body {
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Ensure responsive canvas scaling */
canvas {
    max-height: 70vh; /* Prevent canvas from being too tall on mobile */
}

/* Optimize touch targets for mobile */
.planet-option, #start-game-btn {
    min-height: 44px; /* Apple's recommended minimum touch target size */
    min-width: 44px;
}

/* Fix tap delay on iOS Safari */
a, button, input, select, textarea, .planet-option {
    touch-action: manipulation;
}

/* Rotate screen message styling */
#rotate-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: white;
    text-align: center;
}

#rotate-screen.hidden {
    display: none;
}

.rotate-message p {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

#rotate-button {
    padding: 10px 20px;
    font-size: 1rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#rotate-button:hover {
    background-color: #45a049;
}