/* ============================
           CSS Custom Properties
           ============================ */
:root {
    --bg: #f0f4f8;
    /* Latar lebih cerah */
    --fg: #1a1a2e;
    --muted: #607D8B;
    --accent: #fffcda;
    --accent-glow: rgba(245, 166, 35, 0.4);
    --red: #E74C3C;
    --red-glow: rgba(231, 76, 60, 0.4);
    --green: #43A047;
    --green-hover: #2E7D32;
    --card: rgba(255, 255, 255, 0.95);
    /* Kartu putih cerah */
    --card-border: rgba(0, 0, 0, 0.1);
    --font-display: 'Fredoka', cursive, sans-serif;
    --font-body: 'Nunito', sans-serif;
}

/* ============================
           Reset & Base
           ============================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--fg);
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}


/* ============================
           Loading Screen
           ============================ */
#loading {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    transition: opacity 0.9s ease;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-ring {
    width: 52px;
    height: 52px;
    border: 5px solid rgba(0, 0, 0, 0.05);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--muted);
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* ============================
           Background Layer (Playful Vibe)
           ============================ */
#bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center bottom;
    /* Fokus ke bawah agar bangunan terlihat */
    background-repeat: no-repeat;
    background-color: #87CEEB;
    /* Fallback sky blue */
    transform: scale(1);
    transition: transform 20s ease-out;
}

#bg-layer.slow-zoom {
    transform: scale(1.1);
}

/* Overlay cerah, hanya menggelapkan sedikit bagian bawah agar teps baca */
#vignette {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: radial-gradient(ellipse at 50% 30%, transparent 50%, rgba(0, 0, 0, 0.1) 100%);
    pointer-events: none;
}

#overlay {
    position: fixed;
    inset: 0;
    z-index: 2;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0) 40%,
            rgba(255, 255, 255, 0.3) 70%,
            rgba(255, 255, 255, 0.85) 100%);
    pointer-events: none;
}

/* ============================
           Partikel Playful (Balon/Warna-warni)
           ============================ */
#particles {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: float-up-bounce linear infinite;
    will-change: transform, opacity;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes float-up-bounce {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0) scale(0.4);
    }

    8% {
        opacity: 0.8;
    }

    50% {
        transform: translateY(-50vh) translateX(20px) scale(1);
        opacity: 0.6;
    }

    85% {
        opacity: 0.2;
    }

    100% {
        opacity: 0;
        transform: translateY(-105vh) translateX(-20px) scale(0.8);
    }
}

/* ============================
           Title Screen
           ============================ */
#title-screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    /* Dorong ke bawah menempel bangunan */
    padding-bottom: 15vh;
    gap: 12px;
    opacity: 0;
    transition: opacity 1.4s ease;
    cursor: pointer;
}

#title-screen.visible {
    opacity: 1;
}

#title-screen.fade-out {
    opacity: 0;
    transition: opacity 0.7s ease;
    pointer-events: none;
}

/* Logo disembunyikan karena sudah ada di gambar background */
.game-logo,
.logo-line,
.game-subtitle {
    display: none;
}

/* Prompt ketuk dibesar dan playful */
.start-prompt {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fg);
    background: rgba(255, 255, 255, 0.8);
    padding: 12px 32px;
    border-radius: 50px;
    border: 3px solid var(--fg);
    box-shadow: 0 4px 0 var(--fg);
    animation: bounce-btn 2s ease-in-out infinite;
    backdrop-filter: blur(4px);
}

@keyframes bounce-btn {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* Ikon ketuk dihapus, diganti tombol besar */

/* ============================
           Input Screen (Nama Pemain)
           ============================ */
#input-screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    background: rgba(255, 255, 255, 0.4);
    /* Kaca pembatas cerah */
    backdrop-filter: blur(8px);
}

#input-screen.visible {
    opacity: 1;
    pointer-events: auto;
}

.input-card {
    background: var(--card);
    backdrop-filter: blur(24px);
    border: 4px solid var(--fg);
    border-radius: 24px;
    padding: 36px 40px;
    display: flex;
    align-items: center;
    gap: 30px;
    max-width: 520px;
    width: 90%;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.15);
    transform: translateY(30px) scale(0.96);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

#input-screen.visible .input-card {
    transform: translateY(0) scale(1);
}

.chara-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.chara-sprite {
    width: 100px;
    height: auto;
    filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.2));
    animation: chara-idle 2.5s ease-in-out infinite;
}

@keyframes chara-idle {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-5px) rotate(2deg);
    }
}

.chara-name {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--fg);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.input-label {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--fg);
    letter-spacing: 0.5px;
}

.name-input {
    width: 100%;
    padding: 12px 18px;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fg);
    background: #f0f4f8;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    outline: none;
    text-align: center;
    letter-spacing: 1px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.name-input::placeholder {
    color: rgba(0, 0, 0, 0.3);
    font-weight: 600;
}

.name-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: #fff;
}

.btn-lanjut {
    padding: 12px 24px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    background: var(--green);
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
    position: relative;
    overflow: hidden;
}

.btn-lanjut::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
    border-radius: inherit;
    pointer-events: none;
}

.btn-lanjut:hover:not(:disabled) {
    background: var(--green-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
}

.btn-lanjut:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.btn-lanjut:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-hint {
    font-size: 0.8rem;
    color: var(--red);
    text-align: center;
    min-height: 1.2em;
    opacity: 0;
    transition: opacity 0.3s;
}

.input-hint.show {
    opacity: 1;
}

/* ============================
           Transisi Fade
           ============================ */
#transition {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.1s ease;
}

#transition.active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================
           Responsif
           ============================ */
@media (max-width: 560px) {
    .input-card {
        flex-direction: column;
        padding: 28px 24px;
        gap: 16px;
    }

    .chara-sprite {
        width: 80px;
    }

    .chara-wrap {
        flex-direction: row;
        gap: 12px;
    }

    .input-label {
        text-align: center;
    }

    .start-prompt {
        font-size: 1.1rem;
        padding: 10px 24px;
    }

    #title-screen {
        padding-bottom: 10vh;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.2s !important;
    }

    #bg-layer {
        transition: none !important;
        transform: scale(1) !important;
    }
}