:root {
    --primary-red: #D93C3C;
    --dark-red: #A61B1B;
    --primary-gold: #FFD700;
    --light-gold: #FFF3B0;
    --text-color: #333;
    --bg-color: #FFF5E6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: "Microsoft YaHei", sans-serif;
    background-color: var(--primary-red);
    color: var(--text-color);
    overflow: hidden; /* Prevent scrolling on main page */
    height: 100vh;
    width: 100vw;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, #E74C3C 0%, #C0392B 100%);
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s;
}

.page.active {
    display: flex;
}

.modal {
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    z-index: 100;
}

/* Header */
.header {
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--light-gold);
    z-index: 20;
}

.lang-switch span {
    margin-right: 10px;
    cursor: pointer;
    opacity: 0.6;
    font-weight: bold;
}

.lang-switch span.active {
    opacity: 1;
    text-decoration: underline;
    color: var(--primary-gold);
}

.music-toggle {
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    border: 1px solid var(--light-gold);
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-toggle svg {
    display: none;
}

.music-toggle.on .icon-music-on {
    display: block;
}

.music-toggle:not(.on) .icon-music-off {
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}

.app-title {
    font-size: 2.5rem;
    color: var(--primary-gold);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
    font-family: "Kaiti", "STKaiti", serif;
}

.countdown-container {
    background: rgba(0,0,0,0.2);
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
    margin-bottom: 30px;
    font-size: 0.9rem;
}

#countdown-num {
    color: var(--primary-gold);
    font-weight: bold;
    font-size: 1.2rem;
    margin: 0 5px;
}

/* Shaker Animation */
.shaker-container {
    width: 160px;
    height: 240px;
    position: relative;
    cursor: pointer;
    margin-bottom: 20px;
}

.shaker-body {
    width: 100%;
    height: 100%;
    background: #8B4513; /* Wood color */
    border-radius: 10px 10px 30px 30px;
    position: relative;
    box-shadow: inset 5px 0 10px rgba(0,0,0,0.3), 5px 5px 15px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    border: 4px solid #D2691E;
}

.shaker-body::before {
    content: "签";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    color: var(--primary-gold);
    font-family: "Kaiti", serif;
    border: 2px solid var(--primary-gold);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #A0522D;
}

.shaker-container.shaking {
    animation: shake-hard 0.5s ease-in-out infinite;
}

@keyframes shake-hard {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-5px, -5px) rotate(-10deg); }
    50% { transform: translate(0, -10px) rotate(0deg); }
    75% { transform: translate(5px, -5px) rotate(10deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

.instruction {
    color: white;
    margin-top: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.user-input input {
    margin-top: 20px;
    padding: 10px;
    border-radius: 20px;
    border: none;
    text-align: center;
    width: 200px;
    background: rgba(255,255,255,0.9);
    font-size: 1rem;
}

/* Footer */
.footer-controls {
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.trivia-box {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 5px;
    color: var(--light-gold);
    font-size: 0.8rem;
    max-width: 90%;
    text-align: center;
}

/* Buttons */
.btn {
    padding: 10px 30px;
    border-radius: 25px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s;
    margin: 5px;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background: var(--primary-gold);
    color: var(--dark-red);
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.4);
}

.btn.secondary {
    background: transparent;
    color: var(--dark-red);
    border: 2px solid var(--dark-red);
    font-weight: 600;
}

.btn.secondary:active {
    background: rgba(166, 27, 27, 0.1);
    transform: scale(0.95);
}

/* Modal Content */
.modal-content {
    background: var(--bg-color);
    width: 90%;
    max-width: 400px;
    border-radius: 15px;
    padding: 20px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    border: 5px solid var(--primary-gold);
}

.result-card {
    text-align: center;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M50 0 L100 50 L50 100 L0 50 Z" fill="%23FFF0D0" opacity="0.2"/></svg>');
}

.result-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

.poster-container, .history-list-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-header h2 {
    color: var(--dark-red);
    font-size: 2rem;
    margin-bottom: 10px;
    font-family: "Kaiti", serif;
}

.result-body {
    margin: 20px 0;
}

.poem {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 15px;
    font-style: italic;
}

.meaning {
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255,215,0,0.1);
    border-radius: 5px;
}

.scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.stars {
    color: var(--primary-gold);
}

/* Poster */
.poster-wrapper {
    width: 100%;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
}

#poster-img {
    max-width: 100%;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-radius: 5px;
}

.hint {
    color: #ccc;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 10px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent; 
}

::-webkit-scrollbar-thumb {
    background: rgba(166, 27, 27, 0.3); 
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(166, 27, 27, 0.6); 
}

/* History */
.history-list-container h2 {
    text-align: center;
    color: var(--dark-red);
    margin-bottom: 15px;
}

#history-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
}

#history-list li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

#history-list li:active {
    background-color: #f5f5f5;
}

#history-list li .date {
    font-size: 0.8rem;
    color: #999;
}

#history-list li .title {
    font-weight: bold;
    color: var(--dark-red);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .shaker-container {
        width: 200px;
        height: 300px;
    }
    .app-title {
        font-size: 3.5rem;
    }
}
