@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;700&family=Noto+Sans+TC:wght@400;700&display=swap');

:root {
    --primary-color: #ffb7c5; /* Sakura pink */
    --text-color: #f0f0f0;
    --box-bg: rgba(20, 20, 30, 0.85); /* Dark transparent */
    --name-bg: rgba(255, 183, 197, 0.9);
    --border-color: rgba(255, 255, 255, 0.2);
    --game-width: 1024px;
    --game-height: 768px; /* 4:3 for iPad */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body, html {
    width: 100vw;
    height: 100vh;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Noto Sans TC', sans-serif;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    max-width: var(--game-width);
    max-height: var(--game-height);
    position: relative;
    background-color: #111;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

/* Background */
#bg-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 1.5s ease, opacity 1s ease;
    z-index: 1;
}

/* Characters */
#char-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
}

#char-sprite {
    height: 90%;
    max-width: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Character Animations */
.slide-in-right {
    animation: slideInRight 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.fade-in {
    animation: fadeIn 0.8s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(30%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* UI Layer */
#ui-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 20px 40px;
    pointer-events: auto;
    cursor: pointer;
}

#dialogue-box {
    width: 100%;
    height: 180px;
    background: var(--box-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    padding: 30px 40px 20px 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 20px rgba(255,255,255,0.05);
    display: none; /* Hidden strictly before start */
}

#char-name {
    position: absolute;
    top: -20px;
    left: 40px;
    background: var(--name-bg);
    color: #333;
    padding: 5px 25px;
    border-radius: 8px;
    font-family: 'Noto Serif TC', serif;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#dialogue-text {
    color: var(--text-color);
    font-size: 1.4rem;
    line-height: 1.8;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    height: 100%;
    overflow: hidden;
}

#next-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    color: var(--primary-color);
    font-size: 1.5rem;
    animation: bounce 1s infinite alternate;
    display: none;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(5px); }
}

/* Options Layer */
#options-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

#options-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 60%;
    max-width: 600px;
}

.option-btn {
    background: rgba(30,30,40,0.9);
    border: 2px solid var(--border-color);
    color: white;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.option-btn:hover, .option-btn:active {
    background: var(--primary-color);
    color: #111;
    border-color: var(--primary-color);
    transform: scale(1.02);
}

/* Overlay Layer for transitions */
#overlay-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.black-screen {
    opacity: 1 !important;
}

/* Start Screen specific styling */
#start-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('assets/images/bg.png') no-repeat center center;
    background-size: cover;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    animation: panBg 30s linear infinite alternate;
}

@keyframes panBg {
    0% { background-position: center 0%; }
    100% { background-position: center 15%; }
}

#start-title {
    color: #cb3e5f; /* Deep sakura red for contrast */
    font-family: 'Noto Serif TC', serif;
    font-size: 4.5rem; /* 大d字 */
    margin-bottom: 20px;
    font-weight: 900;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.9), 
                 -1px -1px 0px rgba(255,255,255,0.9),
                 0 0 20px rgba(255,255,255,1),
                 0 5px 15px rgba(203,62,95,0.4);
    /* Removed floatTitle animation */
}

#start-subtitle {
    font-size: 1.8rem; 
    color: #634b52;
    font-family: 'Noto Sans TC', sans-serif;
    text-shadow: 1px 1px 0px rgba(255,255,255,1);
    font-weight: normal;
    display: block;
    margin-bottom: 20px;
}

#start-btn {
    padding: 15px 50px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    border: 3px solid #cb3e5f;
    color: #cb3e5f;
    font-weight: bold;
    cursor: pointer;
    border-radius: 30px;
    box-shadow: 0 0 10px rgba(203, 62, 95, 0.4); /* Base glow */
    transition: all 0.3s ease;
    animation: pulseBtn 3s infinite;
}

@keyframes pulseBtn {
    0% { box-shadow: 0 0 15px rgba(203,62,95,0.3); }
    50% { box-shadow: 0 0 30px rgba(203,62,95,1); } /* 只有發光特效，不放大 */
    100% { box-shadow: 0 0 15px rgba(203,62,95,0.3); }
}

#start-btn:hover {
    background: #cb3e5f;
    color: #ffffff;
    box-shadow: 0 0 35px rgba(203, 62, 95, 1);
    animation: none;
}

/* Cherry Blossom Petals */
#petals-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 41; /* Behind text but over bg */
}

.petal {
    position: absolute;
    top: -10%;
    background-color: #ffb7c5;
    border-radius: 12px 0px 12px 0px; /* Looks like a sakura petal */
    opacity: 0.8;
    box-shadow: 0 0 5px rgba(255, 183, 197, 0.8);
    animation: fall linear infinite;
    z-index: 41;
}

@keyframes fall {
    0% { transform: translateY(0vh) rotate(0deg) translateX(0); opacity: 0; }
    10% { opacity: 0.9; }
    80% { opacity: 0.7; }
    100% { transform: translateY(115vh) rotate(720deg) translateX(150px); opacity: 0; }
}

#start-credits {
    color: #634b52;
    font-size: 1.1rem;
    text-align: center;
    z-index: 50;
    font-family: 'Noto Sans TC', sans-serif;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.8);
    font-weight: 700;
    margin-bottom: 40px;
}

/* Screen shake effect */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake-effect {
    animation: shake 0.5s;
    animation-iteration-count: infinite;
}

/* Mobile Responsive Adjustments */
@media screen and (max-width: 768px) {
    #game-container {
        aspect-ratio: auto;
        height: 100dvh; /* Fill phone screen fully, respecting iOS Safari safe areas */
        max-height: none;
        box-shadow: none; /* Looks better flush against mobile edge */
    }

    #char-sprite {
        height: 65vh; /* Prevent the character from growing too huge on vertical screens */
    }

    #ui-layer {
        height: auto;
        min-height: 25%;
        padding: 0px 15px 30px 15px; /* Extra bottom padding to stay above iPhone swipe bar */
        align-items: flex-end;
    }
    
    #dialogue-box {
        height: auto;
        min-height: 150px;
        padding: 30px 20px 15px 20px;
    }
    
    #char-name {
        top: -15px;
        left: 20px;
        font-size: 1.1rem;
        padding: 4px 15px;
    }
    
    #dialogue-text {
        font-size: 1.1rem;
        line-height: 1.6;
    }
    
    #options-container {
        width: 90%;
    }
    
    .option-btn {
        padding: 15px 20px;
        font-size: 1.1rem;
    }
    
    #start-title {
        font-size: 3rem;
    }
    
    #start-subtitle {
        font-size: 1.3rem;
    }
}
