/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: #f9f9f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #333;
}

/* Top Navigation Bar */
.top-nav {
    background: #ffffff;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e5e5e5;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    height: 20px;
    width: auto;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
}

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.nav-menu a:hover {
    color: #666;
}

.nav-menu a.external-link svg {
    opacity: 0.7;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-menu a.external-link:hover svg {
    opacity: 1;
    transform: translate(2px, -2px);
}

/* Header Styles */
header {
    background: #ffffff;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e5e5;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-left h1 {
    font-size: 2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.header-left h1 .letter-a {
    color: #E63C2A;
    font-weight: 700;
}

.header-left h1 .letter-b {
    color: #7B73D6;
    font-weight: 700;
}

.header-left h1 .letter-c {
    color: #2EBCC6;
    font-weight: 700;
}

.header-left h1 .title-rest {
    font-weight: 400;
    color: #333;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Language Selector */
#language-select {
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #ffffff;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    transition: all 0.2s ease;
}

#language-select:hover {
    border-color: #999;
}

#language-select:focus {
    outline: none;
    border-color: #666;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    gap: 0.5rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 0.25rem;
    background: #ffffff;
}

.toggle-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    background-color: transparent;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
}

.toggle-option:hover {
    background-color: #f5f5f5;
}

.toggle-option.active {
    background-color: #f0f0f0;
    color: #333;
}

.toggle-icon {
    font-size: 1.3rem;
    font-weight: bold;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem 2rem 3rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Grid Container */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

/* Card Styles */
.card {
    aspect-ratio: 1 / 1;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 1rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #ccc;
}

.card:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Letter Mode Card */
.card.letter-card {
    background: #fafafa;
}

.card.letter-card .letter {
    font-size: 3.5rem;
    font-weight: bold;
    line-height: 1;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, Arial, sans-serif;
}

/* Colorful letters - YouKids color scheme from colors.png */
.card.letter-card:nth-child(6n+1) .letter { color: #E63C2A; } /* Red */
.card.letter-card:nth-child(6n+2) .letter { color: #7B73D6; } /* Purple */
.card.letter-card:nth-child(6n+3) .letter { color: #FFC933; } /* Yellow */
.card.letter-card:nth-child(6n+4) .letter { color: #2EBCC6; } /* Cyan */
.card.letter-card:nth-child(6n+5) .letter { color: #FF9347; } /* Orange */
.card.letter-card:nth-child(6n+6) .letter { color: #6BC75F; } /* Green */

/* Object Mode Card */
.card.object-card {
    background: #fafafa;
}

.card.object-card .letter-corner {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    z-index: 5;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, Arial, sans-serif;
}

.card.object-card .emoji {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    line-height: 1;
    user-select: none;
}

.card.object-card .word {
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    text-align: center;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, Arial, sans-serif;
}

.card.object-card .word .special-letter {
    color: #FF0000;
    font-weight: 900;
}

/* Play Icon */
.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: white;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.card:hover .play-icon {
    opacity: 1;
}

.play-icon::before {
    content: '▶';
    margin-left: 2px;
}

/* Footer */
footer {
    background-color: #ffffff;
    border-top: 1px solid #e5e5e5;
    color: #999;
    text-align: center;
    padding: 1.5rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .top-nav {
        padding: 0.75rem 1.5rem;
    }

    .logo img {
        height: 16px;
    }

    .nav-menu {
        gap: 1rem;
        font-size: 0.9rem;
    }

    header {
        padding: 1rem 1.5rem;
    }

    .controls {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-left h1 {
        font-size: 1.5rem;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 0.75rem;
    }

    .card.letter-card .letter {
        font-size: 2.5rem;
    }

    .card.object-card .emoji {
        font-size: 2.5rem;
    }

    .card.object-card .word {
        font-size: 0.75rem;
    }

    .card.object-card .letter-corner {
        font-size: 1rem;
        top: 0.4rem;
        left: 0.4rem;
    }
}

@media (max-width: 480px) {
    .nav-menu {
        display: none;
    }

    .logo img {
        height: 14px;
    }

    .header-left h1 {
        font-size: 1.2rem;
    }

    #language-select {
        font-size: 0.9rem;
        padding: 0.5rem 2rem 0.5rem 0.8rem;
    }

    .toggle-option {
        padding: 0.4rem 0.8rem;
        min-width: 40px;
    }

    .toggle-icon {
        font-size: 1.1rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 0.5rem;
    }

    .card.letter-card .letter {
        font-size: 2rem;
    }

    .card.object-card .emoji {
        font-size: 2rem;
    }

    .card.object-card .letter-corner {
        font-size: 0.85rem;
        top: 0.3rem;
        left: 0.3rem;
    }
}
