:root {
    --primary-red: #B71C1C;
    --primary-gold: #FFD700;
    --wood-dark: #3E2723;
    --wood-light: #A0522D;
    --bg-color: #F5F5DC;
    --text-color: #2c1810;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Serif TC', serif;
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4c5a9' fill-opacity='0.2'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    text-align: center;
    width: 100%;
    max-width: 600px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    position: relative;
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 3.5rem;
    color: var(--primary-red);
    text-shadow: 2px 2px 0px var(--primary-gold);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--wood-dark);
    letter-spacing: 0.2em;
    opacity: 0.8;
}

.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chim-container {
    width: 200px;
    height: 300px;
    position: relative;
    transform-origin: bottom center;
}

.chim-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Sticks inside the container */
.stick-group-svg {
    transform-origin: 100px 80px;
}

.action-btn {
    margin-top: 3rem;
    padding: 1rem 3rem;
    font-size: 1.5rem;
    font-family: 'Ma Shan Zheng', cursive;
    background: var(--primary-red);
    color: var(--primary-gold);
    border: 2px solid var(--primary-gold);
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(183, 28, 28, 0.4);
    transition: all 0.3s ease;
    outline: none;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(183, 28, 28, 0.6);
}

.action-btn:active {
    transform: translateY(1px);
}

/* Animations */
@keyframes shake {
    0% { transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(5deg) translateY(-5px); }
    50% { transform: rotate(0deg) translateY(0); }
    75% { transform: rotate(-5deg) translateY(-5px); }
    100% { transform: rotate(0deg) translateY(0); }
}

.shaking {
    animation: shake 0.15s infinite;
}

/* Result Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(5px);
}

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

.result-card {
    background: #FFF8E1;
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    border-radius: 8px;
    border: 4px double var(--primary-red);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay:not(.hidden) .result-card {
    transform: scale(1);
    opacity: 1;
}

.stick-display {
    flex: 0 0 60px;
    display: flex;
    justify-content: center;
}

.stick-large {
    width: 40px;
    height: 300px;
    background: linear-gradient(to right, #d2b48c, #8b4513);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    border: 1px solid #5D4037;
}

.stick-number {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.5rem;
    color: #3E2723;
    letter-spacing: 0.5rem;
}

.fortune-content {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.fortune-title {
    font-family: 'Ma Shan Zheng', cursive;
    color: var(--primary-red);
    font-size: 1.8rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--primary-red);
    padding-bottom: 0.5rem;
}

.fortune-poem {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    white-space: pre-line;
    font-weight: bold;
    color: #333;
}

.fortune-meaning h3 {
    font-size: 1rem;
    color: var(--wood-light);
    margin-bottom: 0.5rem;
}

.fortune-meaning p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
}

.reset-btn {
    margin-top: auto;
    align-self: flex-end;
    background: transparent;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Noto Serif TC', serif;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: var(--primary-red);
    color: #fff;
}

/* Falling Stick Animation Class */
.falling-stick {
    transition: transform 0.5s ease-in;
}

@media (max-width: 480px) {
    .result-card {
        flex-direction: column;
        align-items: center;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .stick-large {
        height: 40px;
        width: 200px;
        writing-mode: horizontal-tb;
        margin-bottom: 1rem;
    }
    
    .stick-number {
        letter-spacing: 0.5rem;
    }
}
