/* Professional yet kid-friendly color palette with dark mode design */

/* Professional yet kid-friendly color palette with dark mode design */
:root {
    --primary-color: #4A6FA5;
    --secondary-color: #39A0ED;
    --accent-color-1: #FF6B6B;
    --accent-color-2: #7971EA;
    --accent-color-3: #4ECDC4;
    --background-color: #121212;
    --card-background: #1E1E1E;
    --text-color: #E0E0E0;
    --shadow-light: 0 1px 4px rgba(0, 0, 0, 0.15);
    --shadow-medium: 0 2px 8px rgba(0, 0, 0, 0.2);
    --border-radius: 10px;
    --chinese-font: 'KaiTi', 'STKaiti', '楷体', '楷書', 'DFKai-SB', 'Kaiti', 'Kai', serif;
    --character-size: 85px; /* Added consistent character size variable */
    --control-btn-size: 44px; /* Increased size for control buttons */
    --sound-btn-size: 38px; /* Increased size for sound buttons */
    --random-btn-size: 52px; /* Increased size for random button */
}

/* Rest of the CSS remains the same until .character-item */

.character-item {
    width: var(--character-size); /* Use consistent size variable */
    height: var(--character-size); /* Use consistent size variable */
    background-color: #333333;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-family: var(--chinese-font);
}

/* Rest of the CSS remains the same until the media query */

/* Responsive design */
@media (max-width: 480px) {
    :root {
        --character-size: 80px; /* Adjust character size for small screens */
        --control-btn-size: 40px; /* Adjust control button size for small screens */
        --sound-btn-size: 34px; /* Adjust sound button size for small screens */
        --random-btn-size: 46px; /* Adjust random button size for small screens */
    }
    
    .app-container {
        padding: 8px;
    }
    
    .rainbow-text {
        font-size: 1.6rem;
    }
    
    .chinese-word {
        font-size: 2rem;
    }
    
    .english-word {
        font-size: 1.4rem;
    }
    
    /* These are now controlled by CSS variables
    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    #random-btn {
        width: 38px;
        height: 38px;
    }

    .sound-btn {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    */
}

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

body {
    font-family: 'Comic Neue', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    line-height: 1.3;
}

.app-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card-background);
    border-radius: var(--border-radius);
    padding: 10px;
    box-shadow: var(--shadow-medium);
    position: relative;
    overflow: hidden;
}

header {
    text-align: center;
    margin-bottom: 8px;
    width: 100%;
}

.rainbow-text {
    font-size: 1.8rem;
    font-weight: bold;
    background-image: linear-gradient(
        to right,
        var(--accent-color-1),
        var(--primary-color),
        var(--secondary-color),
        var(--accent-color-2),
        var(--accent-color-3)
    );
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow-animation 8s linear infinite;
    background-size: 400% 100%;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

@keyframes rainbow-animation {
    0% { background-position: 0 0; }
    100% { background-position: 400% 0; }
}

.category-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
    width: 100%;
    padding: 0 2px;
}

.category-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 8px;
    background-color: var(--secondary-color);
    color: white;
    cursor: pointer;
    font-family: var(--chinese-font);
    font-weight: bold;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.category-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-btn.active {
    background-color: var(--accent-color-2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.word-card {
    width: 100%;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 10px;
    box-shadow: var(--shadow-medium);
    margin-bottom: 8px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

/* Add subtle decorative elements */
.word-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to right, var(--accent-color-1), var(--accent-color-3));
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.word-display {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 4px;
}

.word-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
}

.chinese-word {
    font-size: 2.2rem;
    color: var(--accent-color-1);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    font-family: var(--chinese-font);
}

.english-word {
    font-size: 1.8rem;
    color: var(--secondary-color);
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    margin: 0 10px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
}

.control-btn {
    width: var(--control-btn-size); /* Use CSS variable for size */
    height: var(--control-btn-size); /* Use CSS variable for size */
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.3rem; /* Slightly increased font size */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    background-color: var(--accent-color-2);
}

.sound-btn {
    width: var(--sound-btn-size); /* Use CSS variable for size */
    height: var(--sound-btn-size); /* Use CSS variable for size */
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 1.1rem; /* Increased font size */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.sound-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

#chinese-sound-btn, #chinese-sound-btn-animation {
    background-color: var(--accent-color-1);
    margin-left: 10px;
    width: var(--sound-btn-size); /* Use CSS variable for size */
    height: var(--sound-btn-size); /* Use CSS variable for size */
    font-size: 1.1rem; /* Increased font size */
}

#chinese-sound-btn:hover, #chinese-sound-btn-animation:hover {
    background-color: #ff5252;
}

#english-sound-btn {
    background-color: var(--secondary-color);
    margin-left: 10px;
    width: var(--sound-btn-size); /* Use CSS variable for size */
    height: var(--sound-btn-size); /* Use CSS variable for size */
    font-size: 1.1rem; /* Increased font size */
}

#english-sound-btn:hover {
    background-color: #2b8cd8;
}

#random-btn {
    background-color: var(--accent-color-3);
    width: var(--random-btn-size); /* Use CSS variable for size */
    height: var(--random-btn-size); /* Use CSS variable for size */
    font-size: 1.4rem; /* Increased font size */
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.bounce {
    animation: bounce 0.4s cubic-bezier(0.28, 0.84, 0.42, 1);
}

/* Add subtle hover effect to words */
.word-row:hover .chinese-word,
.word-row:hover .english-word {
    transform: scale(1.02);
}

/* Chinese text section */
.chinese-text-section {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0;
}

#chinese-word-fallback {
    color: var(--accent-color-1);
    text-shadow: 0 0 6px rgba(255, 131, 131, 0.2);
    font-size: 2.4rem;
    margin: 4px 0;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--chinese-font);
}

/* Hanzi Writer container styles */
.hanzi-container {
    display: flex;
    flex-direction: row; /* Changed from column to row */
    align-items: center;
    justify-content: center; /* Center items horizontally */
    width: 100%;
    margin-top: 6px;
}

/* Fix for horizontal character display */
.character-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
    width: calc(100% - 50px); /* Make room for the larger sound button */
}

.character-item {
    width: 80px;
    height: 80px;
    background-color: #333333;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-family: var(--chinese-font);
}

.animations-section {
    width: 100%;
    margin: 4px 0;
}

.english-section {
    display: flex;
    flex-direction: row; /* Changed to row */
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

/* Position the English word to take up most of the space but leave room for the button */
.english-section .english-word {
    width: calc(100% - 50px); /* Adjusted for larger button */
    text-align: center;
}

/* Position the Chinese sound button for animation section */
#chinese-sound-btn-animation {
    margin-left: 10px;
    align-self: center; /* Align vertically in the flex container */
}

/* Light mode overrides */
@media (prefers-color-scheme: light) {
    :root {
        --background-color: #F7F9FC;
        --card-background: #FFFFFF;
        --text-color: #2D3748;
    }
    
    .character-item {
        background-color: #f8f8f8;
    }
    
    .english-section {
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
}

/* Responsive design */
@media (max-width: 480px) {
    .app-container {
        padding: 8px;
    }
    
    .rainbow-text {
        font-size: 1.6rem;
    }
    
    .chinese-word {
        font-size: 2rem;
    }
    
    .english-word {
        font-size: 1.4rem;
    }
    
    .character-item {
        width: 70px;
        height: 70px;
    }
}