/* iPad-optimized CSS with -webkit- prefixes and mobile Safari fixes */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Prevent iOS text size adjustment */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Orbitron', sans-serif;
    background: #000000;
    overflow: hidden;
    width: 100vw;
    /* iOS Safari 100vh fix - use dvh or fallback */
    height: 100vh;
    height: 100dvh;
    color: white;
    /* Prevent pull-to-refresh and bounce */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Prevent tap highlight */
    -webkit-tap-highlight-color: transparent;
    /* Enable touch action */
    touch-action: manipulation;
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 30px;
    /* Safe area insets for notch/home indicator */
    padding-top: max(30px, env(safe-area-inset-top));
    padding-bottom: max(30px, env(safe-area-inset-bottom));
    padding-left: max(30px, env(safe-area-inset-left));
    padding-right: max(30px, env(safe-area-inset-right));
}

.title {
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 6px;
    z-index: 10;
    -webkit-transition: all 4s ease;
    transition: all 4s ease;
    position: absolute;
    top: 15vh;
    left: 0;
    width: 100%;
    text-align: center;
}

.title.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Singularity - 5px white dot */
.singularity {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px #ffffff;
    z-index: 5;
    -webkit-transition: transform 0.5s ease-in, opacity 0.5s;
    transition: transform 0.5s ease-in, opacity 0.5s;
    cursor: pointer;
}

/* Larger touch target for iPad */
.singularity::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 6;
}

.singularity.hidden {
    opacity: 0;
}

/* Start Button - larger for touch */
.start-button {
    padding: 20px 60px;
    margin-top: auto;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #000000;
    background: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    -webkit-transition: all 4s ease;
    transition: all 4s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 10;
    /* Larger touch target */
    min-height: 60px;
    min-width: 180px;
}

.start-button:hover,
.start-button:active {
    background: #eeeeee;
    -webkit-transform: scale(1.05);
    transform: scale(1.05);
}

.start-button.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    -webkit-transform: scale(0.8);
    transform: scale(0.8);
}

/* Particles - optimized for iPad performance */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: white;
    /* Use transform for better performance on iOS */
    -webkit-will-change: transform;
    will-change: transform;
    /* Enable GPU acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.particle.yellow {
    background: #ffff00;
    box-shadow: 0 0 4px #ffff00;
}

.particle.white {
    background: #ffffff;
    box-shadow: 0 0 4px #ffffff;
}

.particle.fading-out {
    opacity: 0 !important;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
}

/* Navigation Buttons - larger for touch */
.nav-button {
    position: absolute;
    left: 20px;
    top: 25vh;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    -webkit-transition: all 2s ease;
    transition: all 2s ease;
    z-index: 20;
    /* Backdrop filter with webkit prefix - simplified for iOS */
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 1;
    visibility: visible;
    min-height: 50px;
}

.nav-button:hover,
.nav-button:active {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
}

.nav-button.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    -webkit-transform: translateY(-50%) translateX(-20px);
    transform: translateY(-50%) translateX(-20px);
}

/* Info Label & Line */
.info-label {
    position: absolute;
    left: 20px;
    top: 18vh;
    -webkit-transform: translateY(0);
    transform: translateY(0);
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: white;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    z-index: 15;
}

.info-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 14;
}

.info-line {
    stroke: white;
    stroke-width: 1;
    opacity: 0.6;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
}

.info-label.hidden,
.info-line.hidden,
.description-text.hidden,
.time-box.hidden,
#startInfoBox.hidden,
#tempInfoBox.hidden {
    opacity: 0;
}

.description-text {
    position: absolute;
    left: 75%;
    top: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    width: 280px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    z-index: 15;
    text-align: center;
}

.time-box {
    position: absolute;
    bottom: 60px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    z-index: 10;
    border-radius: 4px;
}

.premium-box {
    background: rgba(0, 0, 0, 0.7);
    /* Reduced blur for better iOS performance */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    font-weight: 700;
}

.temperature-box {
    bottom: calc(60px + 45px);
}

/* Burning/Fire Effect for Particles */
.particle.fire {
    background: #ff4500 !important;
    box-shadow: 0 0 6px #ff4500;
    -webkit-transition: background 2s ease, box-shadow 2s ease;
    transition: background 2s ease, box-shadow 2s ease;
}

/* Proton & Neutron - larger for touch */
.nucleon {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    -webkit-transition: transform 1.5s ease-out;
    transition: transform 1.5s ease-out;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Larger touch target */
    min-width: 50px;
    min-height: 50px;
}

.proton {
    background: #b74538;
    box-shadow: 0 0 12px rgba(183, 69, 56, 0.5);
}

.proton::after {
    content: "+";
    color: black;
    font-size: 28px;
    font-weight: bold;
    line-height: 0;
    margin-top: -2px;
}

.neutron {
    background: #A07FB3;
    box-shadow: 0 0 12px rgba(160, 127, 179, 0.5);
}

.nucleon.expanded-left {
    -webkit-transform: translate(calc(-50% - 28px), -50%) scale(1);
    transform: translate(calc(-50% - 28px), -50%) scale(1);
}

.nucleon.expanded-right {
    -webkit-transform: translate(calc(-50% + 28px), -50%) scale(1);
    transform: translate(calc(-50% + 28px), -50%) scale(1);
}

.nucleon {
    cursor: pointer;
}

/* Label Styles */
.nucleon::before {
    content: attr(data-label);
    position: absolute;
    top: -35px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    color: white;
    font-size: 13px;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
}

.nucleon.show-label::before {
    opacity: 1;
}

.nucleons-text {
    position: absolute;
    left: calc(50% + 60px);
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    color: white;
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 250px;
    z-index: 25;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    opacity: 1;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.nucleons-text.hidden {
    opacity: 0;
}

.atoms-text {
    position: absolute;
    left: calc(50% + 120px);
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    color: white;
    font-size: 0.95rem;
    font-weight: 400;
    max-width: 250px;
    z-index: 25;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    opacity: 1;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.atoms-text.hidden {
    opacity: 0;
}

/* Navigation Arrow - larger for touch */
.nav-arrow {
    position: absolute;
    right: 20px;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 9999;
    -webkit-transition: all 0.5s ease;
    transition: all 0.5s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 5px;
}

.nav-arrow:hover,
.nav-arrow:active {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    -webkit-transform: translateY(-50%) scale(1.1);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.hidden {
    opacity: 0;
    pointer-events: none;
    -webkit-transform: translateY(-50%) translateX(20px);
    transform: translateY(-50%) translateX(20px);
}

/* Merged Atomic Nuclei - larger for touch */
.atomic-nucleus {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    z-index: 40;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    -webkit-transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.27);
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.27);
    display: flex;
    justify-content: center;
    align-items: center;
    color: black;
    font-size: 20px;
    font-weight: 900;
    font-family: 'Orbitron', sans-serif;
    cursor: pointer;
}

/* Atom Labels */
.atomic-nucleus::before {
    content: attr(data-label);
    position: absolute;
    top: -35px;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    opacity: 0;
    -webkit-transition: opacity 0.3s ease;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    font-weight: 400;
}

.atomic-nucleus.show-label::before {
    opacity: 1;
}

.atom-he {
    background: #9CF5F7;
    box-shadow: 0 0 25px rgba(156, 245, 247, 0.6);
}

.atom-h {
    background: #9CF7C0;
    box-shadow: 0 0 25px rgba(156, 247, 192, 0.6);
}

.atom-li {
    background: #F7CE9C;
    box-shadow: 0 0 25px rgba(247, 206, 156, 0.6);
}

.atomic-nucleus.visible {
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
}

.top-info-text {
    position: absolute;
    top: 15vh;
    left: 0;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 0.95rem;
    font-weight: 400;
    z-index: 25;
    -webkit-transition: opacity 2s ease;
    transition: opacity 2s ease;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    padding: 0 20px;
}

.top-info-text.hidden {
    opacity: 0;
}

/* Gas Cloud - reduced blur for iOS performance */
.gas-cloud {
    position: absolute;
    width: 200px;
    height: 200px;
    background: #6AC4F1;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    z-index: 10;
    border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
    /* Reduced blur for better iOS performance */
    -webkit-filter: blur(12px);
    filter: blur(12px);
    opacity: 0.6;
    -webkit-transition: opacity 1s, transform 2s ease-out;
    transition: opacity 1s, transform 2s ease-out;
    -webkit-animation: morphCloud 10s infinite alternate;
    animation: morphCloud 10s infinite alternate;
}

@-webkit-keyframes morphCloud {
    0% {
        border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
    }

    100% {
        border-radius: 40% 60% 45% 55% / 50% 60% 40% 50%;
    }
}

@keyframes morphCloud {
    0% {
        border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
    }

    100% {
        border-radius: 40% 60% 45% 55% / 50% 60% 40% 50%;
    }
}

.gas-cloud.visible {
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
}

/* Mini Atoms inside Cloud */
.mini-atom {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 12;
    -webkit-transition: all 2s ease-in-out;
    transition: all 2s ease-in-out;
}

.mini-atom.spawn-large {
    width: 50px;
    height: 50px;
    z-index: 50;
    box-shadow: 0 0 12px currentColor;
}

/* Star - smaller for iPad */
.star {
    position: absolute;
    width: 200px;
    height: 200px;
    background: white;
    border-radius: 50%;
    z-index: 20;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    box-shadow: 0 0 40px white, 0 0 80px rgba(255, 255, 255, 0.7), 0 0 120px rgba(255, 255, 255, 0.4);
    -webkit-transition: all 2s ease-in-out;
    transition: all 2s ease-in-out;
}

.star.visible {
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
}

.star.red-planet {
    width: 140px;
    height: 140px;
    background: radial-gradient(circle at 30% 30%, #b22222, #8b0000);
    box-shadow: inset -8px -8px 15px rgba(0, 0, 0, 0.8), 0 0 15px rgba(200, 50, 50, 0.5);
    -webkit-transform: translate(-50%, -50%) scale(0.5);
    transform: translate(-50%, -50%) scale(0.5);
}

/* Mini Atom Colors */
.mini-atom.he {
    background: #9CF5F7;
    box-shadow: 0 0 4px #9CF5F7;
}

.mini-atom.h {
    background: #9CF7C0;
    box-shadow: 0 0 4px #9CF7C0;
}

.mini-atom.li {
    background: #F7CE9C;
    box-shadow: 0 0 4px #F7CE9C;
}

/* Generic Planet - smaller for iPad */
.planet {
    position: absolute;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    z-index: 20;
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    -webkit-transition: transform 2s ease-in-out;
    transition: transform 2s ease-in-out;
}

/* Earth Planet */
.planet.earth {
    background: radial-gradient(circle at 40% 40%, #228B22 30%, #104E8B 70%);
    box-shadow: inset -8px -8px 15px rgba(0, 0, 0, 0.9), 0 0 12px rgba(30, 144, 255, 0.4);
}

/* Ice Planet */
.planet.icy {
    background: radial-gradient(circle at 30% 30%, #40E0D0, #00008B);
    box-shadow: inset -8px -8px 15px rgba(0, 0, 0, 0.8), 0 0 18px rgba(64, 224, 208, 0.6);
}

/* Sun/Star */
.planet.sun {
    background: radial-gradient(circle at 30% 30%, #FFD700, #FF8C00);
    box-shadow: 0 0 30px #FFD700, 0 0 60px rgba(255, 140, 0, 0.8);
}

/* Orbit Line - smaller for iPad */
.orbit-line {
    position: absolute;
    width: 400px;
    height: 400px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    top: 50%;
    left: calc(50% - 200px);
    -webkit-transform: translate(-50%, -50%) scale(0);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 10;
    -webkit-transition: transform 2s ease-out, opacity 2s ease-in;
    transition: transform 2s ease-out, opacity 2s ease-in;
    opacity: 0;
}

.orbit-line.visible {
    -webkit-transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.orbit-line.earth-orbit {
    width: 560px;
    height: 560px;
}

.orbit-line.icy-orbit {
    width: 720px;
    height: 720px;
}

/* Orbit animations with -webkit- prefixes */
@-webkit-keyframes orbitRotation {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(200px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(200px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(200px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(200px) scale(0.5);
    }
}

@keyframes orbitRotation {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(200px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(200px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(200px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(200px) scale(0.5);
    }
}

@-webkit-keyframes orbitRotationEarth {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(280px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(280px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(280px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(280px) scale(0.5);
    }
}

@keyframes orbitRotationEarth {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(280px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(280px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(280px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(280px) scale(0.5);
    }
}

@-webkit-keyframes orbitRotationIcy {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(360px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(360px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(360px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(360px) scale(0.5);
    }
}

@keyframes orbitRotationIcy {
    0% {
        -webkit-transform: translate(-50%, -50%) rotate(0deg) translateX(360px) scale(0.5);
        transform: translate(-50%, -50%) rotate(0deg) translateX(360px) scale(0.5);
    }

    100% {
        -webkit-transform: translate(-50%, -50%) rotate(360deg) translateX(360px) scale(0.5);
        transform: translate(-50%, -50%) rotate(360deg) translateX(360px) scale(0.5);
    }
}

.planet.in-orbit {
    left: calc(50% - 200px) !important;
    top: 50% !important;
    -webkit-transition: none !important;
    transition: none !important;
    -webkit-animation: orbitRotation 7s linear infinite !important;
    animation: orbitRotation 7s linear infinite !important;
    z-index: 100 !important;
}

.planet.earth.in-orbit {
    -webkit-animation: orbitRotationEarth 12s linear infinite !important;
    animation: orbitRotationEarth 12s linear infinite !important;
}

.planet.icy.in-orbit {
    -webkit-animation: orbitRotationIcy 18s linear infinite !important;
    animation: orbitRotationIcy 18s linear infinite !important;
}