/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    font-family: 'Comfortaa', cursive;
    font-weight: 400;
    font-style: normal;
    font-stretch: normal;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
    text-size-adjust: 100%;
    background: #1a0d2e; /* Match index.html background */
}

/* Spline Viewer Background */
spline-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: auto;
}

/* Main Container */
#container {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2;
    opacity: 0;
    animation: fadeIn 0.5s ease-in-out forwards;
    pointer-events: none;
}

/* Aktifkan pointer events untuk elemen yang perlu interaksi */
.text-input,
#context-input-name,
.key-input-grid,
.key-input,
button,
.modal {
    pointer-events: auto;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Text Input Section */
.text-input {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(16, 8, 35, 0.9);
    backdrop-filter: blur(15px);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid #ff69b4;
    position: relative;
    overflow: hidden;
}

.text-input h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: #ff69b4;
    text-shadow: 0 0 10px #ff69b4, 0 0 20px #9400d3, 0 0 30px #4169e1;
    margin-bottom: 10px;
    animation: neonSlideIn 1s ease-out forwards, neonFlicker 6s ease-in-out infinite;
    opacity: 0;
    transform: translateX(-100%);
}

@keyframes neonSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes neonFlicker {
    0%, 100% {
        text-shadow: 0 0 10px #ff69b4, 0 0 20px #9400d3, 0 0 30px #4169e1;
    }
    10%, 30% {
        text-shadow: 0 0 20px #ff69b4, 0 0 40px #9400d3, 0 0 50px #4169e1;
    }
    20% {
        text-shadow: 0 0 5px #ff69b4, 0 0 10px #9400d3, 0 0 15px #4169e1;
    }
}

/* Name Textarea Styling */
#context-input-name {
    width: 100%;
    max-width: 600px;
    padding: 15px;
    margin-top: 20px;
    font-family: 'Comfortaa', cursive;
    font-size: 16px;
    line-height: 1.7;
    background: rgba(16, 8, 35, 0.9);
    color: #87ceeb;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    resize: none;
    overflow-y: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
    height: 100px;
}

#context-input-name:hover,
#context-input-name:focus {
    border-color: #9400d3;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Key Input Grid Styling */
.key-input-grid {
    display: grid;
    grid-template-columns: repeat(9, 50px);
    gap: 10px;
    max-width: 600px;
    margin-top: 20px;
    justify-content: center;
}

.key-input {
    width: 50px;
    height: 50px;
    padding: 10px;
    font-family: 'Comfortaa', cursive;
    font-size: 18px;
    text-align: center;
    background: rgba(16, 8, 35, 0.9);
    color: #87ceeb;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    transition: border-color 0.3s, box-shadow 0.3s;
    text-transform: uppercase;
}

.key-input:hover,
.key-input:focus {
    border-color: #9400d3;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Button Styling */
button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1.3rem;
    padding: 15px 30px;
    margin: 20px;
    background: rgba(16, 8, 35, 0.9);
    color: #ff69b4;
    border: 2px solid #ff69b4;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: color 0.3s, background 0.3s, box-shadow 0.3s;
}

button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 105, 180, 0.3) 10%, transparent 70%);
    animation: neonPulse 1.5s ease-out infinite;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

button:hover::before {
    opacity: 1;
}

button:hover {
    color: #87ceeb;
    background: rgba(148, 0, 211, 0.9);
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.4);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background: rgba(16, 8, 35, 0.9);
    backdrop-filter: blur(15px);
    margin: 10% auto;
    padding: 20px;
    border: 2px solid #ff69b4;
    border-radius: 15px;
    width: 60%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #87ceeb;
    font-family: 'Comfortaa', cursive;
}



/* Responsive Design */
@media (max-width: 900px) {
    #container {
        width: 90%;
        margin: 20px auto;
    }

    .key-input-grid {
        grid-template-columns: repeat(9, 40px);
        gap: 8px;
    }

    .key-input {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    #container {
        padding: 15px;
    }

    .text-input {
        padding: 15px;
        margin-bottom: 30px;
    }

    #context-input-name {
        max-width: 100%;
        height: 80px;
    }

    .key-input-grid {
        grid-template-columns: repeat(9, 30px);
        gap: 6px;
    }

    .key-input {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    button {
        max-width: 100%;
    }

    body::after {
        width: 100px; /* Smaller overlay for mobile */
        height: 80px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    backdrop-filter: blur(10px); 
    transition: all 0.3s ease;
    z-index: 10001;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}