/* Apply the Pixel font */
@keyframes twinkle {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

@keyframes moveStars {
  from { transform: translateY(0); }
  to { transform: translateY(-2000px); }
}

body {
    font-family: "Pixelify Sans", sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at bottom, #1B2735 0%, #090A0F 100%);
    overflow: hidden;
    position: relative;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 120%;
    animation: moveStars 150s linear infinite;
    z-index: 1;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
}

.container {
    text-align: center;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    position: relative;
    z-index: 2;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5),
                 0 0 20px rgba(255, 255, 255, 0.3),
                 0 0 30px rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

/* Shimmer effect for title */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes letterReveal {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

h1::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        rgba(255, 255, 255, 0.8),
        rgba(255, 255, 255, 0.4),
        transparent
    );
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out;
    animation-delay: 1s;
    pointer-events: none;
}

h1 span {
    display: inline-block;
    animation: letterReveal 0.6s ease-out forwards;
    opacity: 0;
}

h1 span:nth-child(1) { animation-delay: 0.1s; }
h1 span:nth-child(2) { animation-delay: 0.15s; }
h1 span:nth-child(3) { animation-delay: 0.2s; }
h1 span:nth-child(4) { animation-delay: 0.25s; }
h1 span:nth-child(5) { animation-delay: 0.3s; }
h1 span:nth-child(6) { animation-delay: 0.35s; }
h1 span:nth-child(7) { animation-delay: 0.4s; }
h1 span:nth-child(8) { animation-delay: 0.45s; }
h1 span:nth-child(9) { animation-delay: 0.5s; }
h1 span:nth-child(10) { animation-delay: 0.55s; }
h1 span:nth-child(11) { animation-delay: 0.6s; }
h1 span:nth-child(12) { animation-delay: 0.65s; }

#text-selector {
    font-family: "Pixelify Sans", sans-serif;
    padding: 10px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgba(27, 39, 53, 0.7);
    color: white;
    width: 80%;
    max-width: 300px;
    backdrop-filter: blur(5px);
}

.styled-button {
    font-family: "Pixelify Sans", sans-serif;
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    margin-bottom: 20px;
    background-color: rgba(27, 39, 53, 0.7);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    display: none;
}

.styled-button.visible {
    display: inline-block;
}

.styled-button:hover {
    background-color: rgba(27, 39, 53, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.styled-button:active {
    transform: scale(0.98);
}

.styled-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(27, 39, 53, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.styled-button:disabled:hover {
    background-color: rgba(27, 39, 53, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
    text-shadow: none;
    transform: none;
}

#text-selector option {
    background-color: #1B2735;
    color: white;
}

#text-selector:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(27, 39, 53, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.passage {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 20px;
    color: #ffffff;
    padding: 20px;
    border-radius: 5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(27, 39, 53, 0.3);
    backdrop-filter: blur(5px);
    height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(27, 39, 53, 0.3);
    display: block;
    text-align: center;
}

/* Custom scrollbar styles for WebKit browsers */
.passage::-webkit-scrollbar {
    width: 8px;
}

.passage::-webkit-scrollbar-track {
    background: rgba(27, 39, 53, 0.3);
    border-radius: 4px;
}

.passage::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.passage::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Mobile-specific scroll improvements */
@media (max-width: 768px) {
    .passage {
        height: 250px;
        padding: 15px;
        font-size: 1.1rem;
        line-height: 1.7;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    .passage::-webkit-scrollbar {
        width: 6px;
    }
    
    .passage::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.4);
        border-radius: 3px;
    }
    
    .loading-container {
        min-height: 210px;
        gap: 15px;
    }
    
    .mystical-orb {
        width: 50px;
        height: 50px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .passage-reveal {
        padding: 8px 0;
        line-height: 1.8;
    }
}

@media (max-width: 480px) {
    .passage {
        height: 200px;
        padding: 12px;
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .loading-container {
        min-height: 170px;
        gap: 12px;
    }
    
    .mystical-orb {
        width: 40px;
        height: 40px;
    }
    
    .loading-text {
        font-size: 0.9rem;
    }
    
    .passage-reveal {
        padding: 6px 0;
        line-height: 1.7;
    }
}

footer a {
    color: #ffffff;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

footer a:hover {
    text-decoration: underline;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8),
                 0 0 25px rgba(255, 255, 255, 0.5);
}

.site-description {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 15px;
    line-height: 1.4;
    text-align: center;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

/* Loading State Animations */
@keyframes mysticalPulse {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3),
                    0 0 40px rgba(255, 255, 255, 0.2),
                    0 0 60px rgba(255, 255, 255, 0.1);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.5),
                    0 0 60px rgba(255, 255, 255, 0.3),
                    0 0 90px rgba(255, 255, 255, 0.2);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.3),
                    0 0 40px rgba(255, 255, 255, 0.2),
                    0 0 60px rgba(255, 255, 255, 0.1);
    }
}

@keyframes dotPulse {
    0%, 80%, 100% { 
        opacity: 0.3;
        transform: scale(1);
    }
    40% { 
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes textGlow {
    0%, 100% { 
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    }
    50% { 
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.6),
                     0 0 30px rgba(255, 255, 255, 0.4);
    }
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    gap: 20px;
}

.mystical-orb {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.2) 70%, transparent 100%);
    animation: mysticalPulse 2s ease-in-out infinite;
    position: relative;
}

.mystical-orb::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.loading-text {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    animation: textGlow 2s ease-in-out infinite;
    font-style: italic;
}

.loading-dots {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.loading-dots span {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    animation: dotPulse 1.5s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.passage-reveal {
    animation: fadeInUp 0.8s ease-out;
    padding: 10px 0;
    line-height: 1.8;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Home Button Styles */
.home-button {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 0.35rem;
    transition: all 0.3s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none;
    gap: 0.25rem;
}

.home-button:hover {
    background: transparent;
    transform: scale(1.05);
    box-shadow: none;
}

.home-crystal {
    width: 64px;
    height: 64px;
    object-fit: contain;
    transition: all 0.3s ease;
}

.home-button:hover .home-crystal {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.home-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #ffffff;
    font-family: "Pixelify Sans", sans-serif;
    font-size: 0.6rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.home-button:hover .home-tooltip {
    opacity: 1;
}

.home-url {
    font-family: "Pixelify Sans", sans-serif;
    font-size: 0.6rem;
    color: #ffffff;
    text-shadow: 
        0 0 3px rgba(255, 255, 255, 0.8),
        0 0 6px rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.home-button:hover .home-url {
    color: #ffffff;
    text-shadow: 
        0 0 5px rgba(255, 255, 255, 1),
        0 0 10px rgba(255, 255, 255, 0.8);
}

/* Mobile styles for home button */
@media (max-width: 768px) {
    .home-button {
        top: 0.1rem;
        right: 0.1rem;
        padding: 0.15rem;
        gap: 0.1rem;
    }
    
    .home-crystal {
        width: 24px;
        height: 24px;
    }
    
    .home-tooltip {
        font-size: 0.35rem;
        padding: 0.25rem 0.4rem;
        margin-bottom: 0.25rem;
    }
    
    .home-url {
        font-size: 0.3rem;
    }
}