:root {
    --primary: #FF6B6B;
    --primary-hover: #FF5252;
    --secondary: #4ECDC4;
    --secondary-hover: #45b7ae;
    --accent: #FFE66D;
    --bg-color: #F7F9FC;
    --text-color: #2D3436;
    --card-bg: rgba(255, 255, 255, 0.95);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: #F7F9FC url('rainbow_bg.png');
    background-size: 300px;
    background-repeat: repeat;
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px 10px;
    /* Minimal padding */
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    /* Reduced white wash so animal background is clearly visible */
    z-index: -1;
}

.app-container {
    width: 95%;
    max-width: 1200px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: center;
}

@media (max-width: 600px) {
    .app-container {
        padding: 15px;
        width: 100%;
        border-radius: 0;
    }

    .title {
        font-size: 2.2rem;
    }
}

.topics-section {
    margin-bottom: 20px;
    animation: fadeIn 0.8s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tabs-container {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.4);
    padding: 8px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.tab-btn {
    padding: 12px 24px;
    border-radius: 40px;
    border: none;
    background: transparent;
    color: #666;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--primary);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.2);
    transform: scale(1.05);
}

.topic-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #454d5d;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#topicsContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px;
}

.topic-category-card {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 10px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    height: fit-content;
}

.topic-category-card:hover {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.category-title {
    width: 100%;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0 0 10px 0;
    padding: 12px 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.category-title:hover {
    background: white;
    border-color: rgba(0, 0, 0, 0.05);
    transform: none;
    /* Reset transform as card handles it */
}

.category-title::after {
    content: '+';
    font-size: 1.4rem;
    font-weight: 400;
    color: #999;
}

.category-title.active::after {
    content: '-';
    color: var(--primary);
}

.topics-grid.hidden {
    display: none !important;
}

.topics-grid {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0 5px 20px 5px;
}

.topic-bubble {
    background: white;
    padding: 6px 14px;
    /* Slightly smaller padding */
    border-radius: 50px;
    font-size: 1.1rem;
    /* Scaled up for wider screen */
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(0, 0, 0, 0.03);
    user-select: none;
}

.topic-bubble:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.08);
    /* Reduced shadow intensity */
    background: var(--accent);
    color: #444;
}

.topic-bubble:active {
    transform: translateY(0) scale(0.95);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    margin-bottom: 5px;
    position: relative;
}

.top-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
    margin: 0 auto 30px auto;
    max-width: 800px;
    flex-wrap: wrap;
    width: 100%;
    z-index: 100;
    position: relative;
}

@media (max-width: 600px) {
    .top-nav {
        justify-content: center;
    }
}

.lang-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px;
    border-radius: 50px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #666;
    white-space: nowrap;
    cursor: pointer;
}

.lang-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.about-link {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 50px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    white-space: nowrap;
    cursor: pointer;
}

.about-link:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    color: var(--primary-hover);
}

.title {
    font-size: 1.8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 20px;
}

#magicBtn {
    position: relative;
    z-index: 1;
}

#magicBtn::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(135deg, #FF6B6B, #FFE66D, #4ECDC4);
    border-radius: 54px;
    z-index: -1;
    opacity: 0.4;
    filter: blur(12px);
    animation: glow 4s linear infinite;
    transition: opacity 0.3s ease;
}

#magicBtn:hover::after {
    opacity: 0.7;
    filter: blur(16px);
}

@keyframes glow {
    0% {
        filter: blur(10px);
        opacity: 0.4;
    }

    50% {
        filter: blur(20px);
        opacity: 0.6;
    }

    100% {
        filter: blur(10px);
        opacity: 0.4;
    }
}

.magic-btn {
    padding: 0 40px;
    height: 56px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.magic-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(120deg,
            transparent,
            rgba(255, 255, 255, 0.4),
            transparent);
    transition: all 0.6s;
}

.magic-btn:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 30px rgba(255, 107, 107, 0.5);
}

.magic-btn:hover::before {
    left: 100%;
}

.magic-btn:active {
    transform: translateY(-1px) scale(0.97);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0 auto 40px auto;
    max-width: 800px;
}

#wordInput {
    width: 100%;
    min-height: 60px;
    /* Reduced from 120px */
    padding: 10px 15px;
    /* Reduced padding */
    border: 3px solid #eee;
    border-radius: 20px;
    font-size: 1.1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s ease;
    resize: vertical;
}

#wordInput:focus {
    border-color: var(--secondary);
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.styled-select {
    padding: 0 45px 0 25px;
    height: 56px;
    border-radius: 50px;
    border: 3px solid #f0f0f0;
    background: white;
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    color: #444;
    outline: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23FF6B6B' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 18px;
}

.styled-select:hover {
    border-color: var(--secondary);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.styled-select:focus {
    border-color: var(--primary);
}


.workbook-line {
    display: none;
    width: 80%;
    border-bottom: 2px dashed #ccc;
    height: 2rem;
    margin-top: 10px;
}

.workbook-active .voca-term {
    opacity: 0.3;
    /* Faint in browser, hidden in print */
}

@media print {
    .workbook-active .voca-term {
        display: none !important;
    }

    .workbook-active .workbook-line {
        display: block !important;
    }
}

.primary-btn {
    padding: 0 45px;
    height: 56px;
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.primary-btn:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 12px 30px rgba(255, 107, 107, 0.5);
    filter: brightness(1.1);
}

.primary-btn:active {
    transform: translateY(0) scale(0.97);
}

.secondary-btn,
.game-btn {
    padding: 0 30px;
    height: 56px;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.secondary-btn {
    background: var(--secondary);
    color: white;
    box-shadow: 0 6px 15px rgba(78, 205, 196, 0.3);
}

.game-btn {
    background: #FF9F43;
    color: white;
    box-shadow: 0 6px 15px rgba(255, 159, 67, 0.3);
}

.secondary-btn:hover,
.game-btn:hover {
    transform: translateY(-3px);
    filter: brightness(1.05);
}



.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Perfectly center it vertically again */
    padding: 10px;
    box-sizing: border-box;
    z-index: 1000;
}

.game-container {
    width: 95%;
    max-width: 800px;
    max-height: 90vh;
    margin: auto;
    /* Perfectly center */
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
    transition: max-height 0.3s ease;
}

@media (max-width: 600px) {
    .game-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 5px;
        overflow: hidden;
        /* Prevent internal scrollbar if possible */
    }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    color: white;
    border: 4px solid white;
    border-radius: 50%;
    font-size: 32px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(255, 71, 87, 0.4);
    z-index: 1200;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    line-height: 1;
    padding: 0;
    animation: magicalPulse 2s infinite;
}

@media (max-width: 600px) {
    .close-btn {
        width: 45px;
        height: 45px;
        font-size: 24px;
        top: 10px;
        right: 10px;
    }
}

@keyframes magicalPulse {
    0% {
        box-shadow: 0 10px 25px rgba(255, 71, 87, 0.4);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 15px 35px rgba(255, 71, 87, 0.6), 0 0 20px rgba(255, 71, 87, 0.3);
        transform: scale(1.08);
    }

    100% {
        box-shadow: 0 10px 25px rgba(255, 71, 87, 0.4);
        transform: scale(1);
    }
}

.close-btn:hover {
    transform: scale(1.2) rotate(90deg);
    background: linear-gradient(135deg, #ff6b81 0%, #ff4757 100%);
    box-shadow: 0 12px 30px rgba(255, 71, 87, 0.5);
}

.close-btn:active {
    transform: scale(0.9);
}

.game-header {
    flex-shrink: 0;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

@media (max-width: 600px) {
    .game-header {
        padding: 5px 10px;
        gap: 5px;
    }
}

@media (min-width: 600px) {
    .game-header {
        flex-direction: row;
        justify-content: space-between;
    }
}

.game-radio-group {
    display: flex;
    gap: 8px;
    background: #f0f0f0;
    padding: 5px;
    border-radius: 50px;
    width: fit-content;
}

.game-radio-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
}

.game-radio-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#gameContent {
    flex-grow: 1;
    padding: 20px 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    #gameContent {
        padding: 15px 20px;
    }
}

.game-image-wrapper {
    width: 160px;
    height: 160px;
    margin: 0 auto 20px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.game-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.letters-container,
.answer-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    width: 100%;
    /* Ensure they don't shrink to zero */
}

.letter-bubble {
    width: 50px;
    height: 50px;
    background: white;
    border: 3px solid var(--secondary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    /* Scaled up for 1200px */
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.letter-bubble:hover {
    transform: scale(1.1);
    background: var(--secondary);
    color: white;
}

.answer-bubble {
    width: 50px;
    height: 50px;
    border-bottom: 4px solid var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    /* Scaled up for 1200px */
    font-weight: 800;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.2s;
}

.answer-bubble:hover {
    background: rgba(255, 107, 107, 0.05);
}

.clear-btn-bubble {
    border-color: #ff6b6b !important;
    background: #fff5f5;
}

.clear-btn-bubble:hover {
    background: #ff6b6b !important;
    color: white !important;
}

.game-feedback {
    min-height: 40px;
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .game-feedback {
        min-height: 30px;
        font-size: 1.2rem;
        margin-top: 10px;
    }
}

.feedback-success {
    color: #2ecc71;
    animation: bounce 0.5s ease;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.score-board {
    background: var(--accent);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.2rem;
    /* Make the score more readable */
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* Standard 4 columns on large screens */
    gap: 25px;
    margin-top: 30px;
    width: 100%;
}

@media (max-width: 1200px) {
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3 columns on smaller desktops/tablets */
    }
}

@media (max-width: 768px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns on mobile */
        gap: 15px;
    }
}

.voca-card {
    background: white;
    padding: 15px;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: cardAppear 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    position: relative;
    overflow: hidden;
    border: 4px solid white;
}

.voca-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

/* Colorful Variants for Kids */
.voca-card:nth-child(5n+1) {
    background: linear-gradient(to bottom, #ffffff, #e3f2fd);
    border-color: #bbdefb;
}

.voca-card:nth-child(5n+2) {
    background: linear-gradient(to bottom, #ffffff, #fce4ec);
    border-color: #f8bbd0;
}

.voca-card:nth-child(5n+3) {
    background: linear-gradient(to bottom, #ffffff, #e8f5e9);
    border-color: #c8e6c9;
}

.voca-card:nth-child(5n+4) {
    background: linear-gradient(to bottom, #ffffff, #f3e5f5);
    border-color: #e1bee7;
}

.voca-card:nth-child(5n+5) {
    background: linear-gradient(to bottom, #ffffff, #fff3e0);
    border-color: #ffe0b2;
}

.voca-card:nth-child(5n+1) .voca-term {
    color: #1565c0;
}

.voca-card:nth-child(5n+2) .voca-term {
    color: #c2185b;
}

.voca-card:nth-child(5n+3) .voca-term {
    color: #2e7d32;
}

.voca-card:nth-child(5n+4) .voca-term {
    color: #7b1fa2;
}

.voca-card:nth-child(5n+5) .voca-term {
    color: #ef6c00;
}

.voca-card.matched {
    border-color: #2ecc71 !important;
    pointer-events: none;
    transform: none !important;
}

.upload-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.voca-card:hover .upload-overlay {
    opacity: 1;
    transform: translateY(0);
}

.upload-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.upload-btn::after {
    content: '📤';
}

.mini-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
    position: absolute;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.voca-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 15px;
    margin-bottom: 15px;
}

.voca-term {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-color);
    text-transform: capitalize;
    display: flex;
    align-items: center;
    gap: 10px;
}

.speaker-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 1;
}

.speaker-btn:hover {
    background: #f0f0f0;
}

@media print {
    .speaker-btn {
        display: none !important;
    }
}

.error-card {
    border: 2px dashed #ff6b6b;
    opacity: 0.8;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.error-reason {
    font-size: 0.8rem;
    color: #ff6b6b;
    margin-top: 10px;
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        padding: 0;
    }

    .app-container {
        max-width: none;
        padding: 0;
        box-shadow: none;
        background: transparent;
        backdrop-filter: none;
    }

    .top-nav,
    header,
    .input-section,
    .topics-section,
    .result-actions,
    .history-section,
    footer {
        display: none !important;
    }

    .image-grid {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        /* 5 columns for maximum density */
        gap: 8px !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .voca-card {
        page-break-inside: avoid;
        border: 1px solid #eee;
        border-radius: 6px;
        box-shadow: none;
        margin: 0;
        padding: 6px !important;
        /* Minimal padding */
        height: auto !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .voca-card img {
        width: 100% !important;
        max-height: 3.5cm;
        /* Limit image height to fit more rows */
        height: auto !important;
        margin-bottom: 2px !important;
        object-fit: contain;
    }

    .voca-term {
        font-size: 0.9rem !important;
        /* Compact text */
        margin-top: 2px !important;
    }
}

.hidden {
    display: none !important;
}

.result-section {
    margin-bottom: 50px;
    animation: fadeIn 0.5s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-actions {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeIn 0.8s ease;
}

.loader {
    text-align: center;
}

/* Magic loader sparkles */
.sparkles {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border: 5px solid rgba(78, 205, 196, 0.2);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-section h3 {
    color: white;
    margin-bottom: 20px;
    font-size: 1.8rem;
    /* Scaled up for 1200px width */
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    /* Allow 4-5 cards on 1200px width */
    gap: 20px;
    padding: 10px;
}

.history-item {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
    aspect-ratio: 1;
}

.history-item:hover {
    transform: scale(1.05);
}

.picture-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.choice-placeholder {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(255, 255, 255, 0.8);
    padding: 2px;
}

footer {
    margin-top: 40px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.source-tag {
    display: inline-block;
    padding: 5px 12px;
    background: var(--accent);
    color: #555;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 5px;
}

/* Radio Group Style replaced dropdown */
.game-type-select {
    display: none;
}

/* Match-up Game Styles */
.matchup-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
}

.matchup-container::-webkit-scrollbar {
    width: 8px;
}

.matchup-container::-webkit-scrollbar-thumb {
    background-color: var(--secondary);
    border-radius: 10px;
}

/* --- Legacy Drag & Drop Match-up (Renamed to avoid conflict) --- */
.drag-matchup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    justify-items: center;
    width: 100%;
}

.matchup-target {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.matchup-image-box {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.matchup-image-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.matchup-slot {
    width: 100%;
    height: 36px;
    border: 3px dashed #ddd;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.02);
}

.matchup-slot.over {
    border-color: var(--secondary);
    background: rgba(78, 205, 196, 0.1);
    transform: scale(1.05);
}

.matchup-slot.matched {
    border-color: #2ecc71;
    border-style: solid;
    background: rgba(46, 204, 113, 0.1);
}

.matchup-words-pool {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    min-height: 60px;
}

.draggable-word {
    padding: 8px 20px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 50px;
    font-weight: 800;
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.draggable-word:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.draggable-word.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.draggable-word.placed {
    border-color: #2ecc71 !important;
    color: #27ae60;
    cursor: default;
}

/* Auth Modal & Login Styles */
.auth-container {
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    /* Limit height */
    overflow-y: auto;
    /* Enable scrolling */
    padding: 40px 30px;
    position: relative;
    background: white;
    border-radius: 30px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.auth-input {
    padding: 12px 20px;
    border: 2px solid #eee;
    border-radius: 15px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.auth-input:focus {
    border-color: var(--secondary);
}

/* Admin Topics Styles */
.admin-topics-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 25px;
    text-align: left;
    margin-top: 10px;
}

@media (max-width: 600px) {
    .admin-topics-layout {
        grid-template-columns: 1fr;
    }
}

.admin-form-section h3,
.admin-list-section h3 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 5px;
}

.admin-topics-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.admin-cat-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
    border-left: 5px solid var(--primary);
}

.admin-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
    margin-bottom: 8px;
    color: #333;
}

.admin-topic-sub-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 10px;
}

.admin-topic-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.admin-topic-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
}

.admin-topic-words {
    font-size: 0.75rem;
    color: #888;
    font-style: italic;
    word-break: break-all;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.admin-edit-btn {
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-right: 5px;
}

.admin-delete-btn {
    background: #ff7675;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.2s;
}

.admin-delete-btn:hover {
    background: #d63031;
    transform: scale(1.1);
}

.auth-switch {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-divider {
    margin: 25px 0;
    position: relative;
    text-align: center;
}

.auth-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #eee;
    z-index: 1;
}

.auth-divider span {
    background: white;
    padding: 0 15px;
    color: #999;
    font-size: 0.8rem;
    position: relative;
    z-index: 2;
}

.google-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: 2px solid #eee;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.google-btn:hover {
    background: #f8f8f8;
    border-color: #ddd;
}

.google-btn img {
    width: 20px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px 15px;
    border-radius: 20px;
}

#userName {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
}

.logout-btn {
    background: none;
    border: none;
    color: #999;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.logout-btn:hover {
    color: var(--primary);
}

/* Library & Sets Styles */
.library-container {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    padding: 40px;
    overflow-y: auto;
}

.sets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.set-card {
    background: white;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.set-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary);
}

.set-card h3 {
    font-size: 1rem;
    color: var(--text-color);
    margin: 5px 0;
}

.set-card .set-meta {
    font-size: 0.8rem;
    color: #999;
}

.set-card .set-preview {
    width: 100%;
    height: 120px;
    background: #f0f0f0;
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    overflow: hidden;
}

.set-card .set-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.set-card .set-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
}

.set-action-btn {
    border: none;
    background: none;
    padding: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s;
}

.set-action-btn:hover {
    transform: scale(1.2);
}

.delete-set-btn {
    color: #ff7675;
}

.play-set-btn {
    color: var(--secondary);
}

/* Picture Match Game Styles */
.picture-match-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    width: 100%;
    margin: 10px auto;
}

@media (max-width: 600px) {
    .picture-match-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 5px;
    }

}

.picture-option {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    flex: 0 1 180px;
    min-width: 130px;
}

.game-question-text {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.4rem;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .picture-option {
        padding: 5px;
        min-width: unset;
        flex: 1;
    }

    .game-question-text {
        font-size: 0.95rem;
        margin-bottom: 2px;
        margin-top: 2px;
    }
}

.picture-option img {
    width: 100%;
    max-height: 120px;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 5px;
}

@media (max-width: 600px) {
    .picture-option img {
        max-height: 80px;
        margin-bottom: 2px;
    }

    .picture-option p {
        font-size: 0.8rem;
    }
}

.picture-option p {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
    margin: 0;
}

.picture-option:hover {
    transform: scale(1.03);
}

.picture-option.correct {
    border-color: #2ecc71;
    transform: scale(1.05);
}

.picture-option.wrong {
    border-color: #ff6b6b;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.listen-btn-large {
    width: 80px;
    height: 80px;
    background: var(--accent);
    color: #444;
    border: none;
    border-radius: 50%;
    font-size: 2.5rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.listen-btn-large:hover {
    transform: scale(1.1);
    background: #ffd93d;
}

.listen-btn-large:active {
    transform: scale(0.9);
}


/* --- Gamification & New Features --- */

.user-stats-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 10px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 800;
    font-size: 1rem;
    padding: 5px 12px;
    border-radius: 50px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-stars {
    color: #f1c40f;
}

.stat-level {
    color: var(--primary);
}

/* --- Premium Match-up (Memory Match) Styles --- */
.matchup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
    padding: 20px;
    perspective: 1500px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.memory-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    border-radius: 18px;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
    /* Force GPU acceleration on iOS */
    -webkit-transform: translateZ(0);
}

.memory-card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
}

.memory-card.flipped {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
}

.memory-card.matched {
    -webkit-transform: rotateY(180deg) scale(0.92) !important;
    transform: rotateY(180deg) scale(0.92) !important;
    pointer-events: none !important;
    box-shadow: 0 0 25px rgba(67, 233, 123, 0.15);
    opacity: 0.8;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border: 4px solid white;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Premium Gradient for Card Covers */
.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 2;
    overflow: hidden;
}

.card-back {
    -webkit-transform: rotateY(180deg);
    transform: rotateY(180deg);
    z-index: 1;
    background: white;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 4px solid #f1f2f6;
    transition: all 0.3s ease;
}

.card-front::after {
    content: "?";
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 900;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.memory-card.matched .card-back {
    background: #f0fff4;
    border-color: #43e97b !important;
    position: relative;
}

.memory-card.matched .card-back::after {
    content: "??";
    position: absolute;
    top: -12px;
    right: -12px;
    font-size: 1.4rem;
    background: #43e97b;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 15;
    border: 3px solid white;
}

.card-back img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.card-back span {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
    text-align: center;
    word-break: break-word;
}

/* Victory Overlay */
.game-victory-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
}

.victory-icon {
    font-size: 5rem;
    margin-bottom: 10px;
}

.victory-title {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

@media (max-width: 600px) {
    .matchup-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .victory-title {
        font-size: 1.8rem;
    }
}

/* --- Reward System Toast --- */
.share-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 3000;
}


/* --- Auth / Password Change Messages --- */
.auth-message {
    padding: 12px;
    border-radius: 12px;
    margin-top: 10px;
    margin-bottom: 20px;
    font-weight: 700;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.auth-message.error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.auth-message.success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.auth-message.hidden {
    display: none;
}

.auth-input {
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 15px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.auth-input:focus {
    border-color: var(--secondary);
}

/* --- Learning Path Roadmap Styles --- */
.roadmap-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding: 20px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.roadmap-stage {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    padding: 25px;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    position: relative;
    transition: all 0.3s ease;
}

.roadmap-stage.locked {
    filter: grayscale(0.8);
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.05);
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stage-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stage-requirement {
    font-size: 0.9rem;
    font-weight: 700;
    color: #666;
    background: white;
    padding: 6px 15px;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.roadmap-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start;
}

.roadmap-lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 20px;
    font-weight: 800;
    color: #999;
    box-shadow: var(--shadow);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.roadmap-bubble {
    padding: 12px 20px;
    background: white;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.roadmap-bubble:hover {
    transform: translateY(-5px) scale(1.05);
    background: var(--accent);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.roadmap-stage.locked .roadmap-bubble {
    cursor: not-allowed;
    pointer-events: none;
}

.roadmap-stage.active {
    border-style: solid;
    border-color: var(--secondary);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 10px 30px rgba(78, 205, 196, 0.15);
}

.roadmap-stage.active .stage-title {
    color: var(--secondary);
}

/* --- Activity Overlay & Tabs --- */
.activity-container {
    width: 95%;
    max-width: 1000px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

/* Allow game container to expand in activity quiz */
.activity-content .game-container {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
}

.activity-header {
    padding: 20px 30px;
    background: white;
    border-bottom: 2px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#activityTitle {
    margin: 0;
    color: var(--primary);
    font-size: 1.8rem;
}

.activity-tabs {
    display: flex;
    gap: 10px;
    background: #f1f2f6;
    padding: 5px;
    border-radius: 50px;
}

.activity-tab-btn {
    padding: 10px 25px;
    border-radius: 40px;
    border: none;
    background: transparent;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #747d8c;
}

.activity-tab-btn.active {
    background: white;
    color: var(--secondary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.activity-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #f9fbff;
}

/* --- Child Mode Active State --- */
body.child-mode-active .input-section,
body.child-mode-active .history-section,
body.child-mode-active #guideLink,
body.child-mode-active #aboutLink,
body.child-mode-active #loginBtn,
body.child-mode-active #usersAdminBtn,
body.child-mode-active #statsBtn,
body.child-mode-active #changePasswordBtn,
body.child-mode-active #magicBtn,
body.child-mode-active #saveSetBtn,
body.child-mode-active .result-actions button:not(#playGameBtn) {
    display: none !important;
}

body.child-mode-active header .subtitle {
    visibility: hidden;
}

#childModeBtn.active {
    background: var(--primary) !important;
}

/* Parental Gate Enhancement */
#parentalGateOverlay .auth-container {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Leaderboard UI --- */
.leaderboard-container {
    width: 95%;
    max-width: 500px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    text-align: center;
    position: relative;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.leaderboard-header {
    margin-bottom: 10px;
}

.leaderboard-header h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.leaderboard-my-result {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    border-radius: 18px;
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 2px solid var(--secondary);
    display: flex;
    justify-content: space-around;
    font-weight: 700;
    color: #444;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.5s ease;
}

.leaderboard-table {
    flex-grow: 1;
    overflow-y: auto;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for Leaderboard */
.leaderboard-table::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-table::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.leaderboard-table::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 45px 1fr 85px 70px;
    align-items: center;
    background: white;
    padding: 12px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
    animation: slideUp 0.4s ease backwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.leaderboard-row:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.leaderboard-rank {
    font-size: 1.3rem;
    font-weight: 800;
    color: #a4b0be;
    text-align: center;
}

.leaderboard-name {
    font-weight: 700;
    color: #2f3542;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
    font-size: 1.05rem;
}

.group-tag {
    font-size: 0.7rem;
    color: #747d8c;
    background: #f1f2f6;
    padding: 2px 8px;
    border-radius: 8px;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.leaderboard-score {
    font-weight: 800;
    color: var(--primary);
    text-align: right;
    font-size: 1.1rem;
}

.leaderboard-time {
    color: #747d8c;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

/* Rank Highlights with Vibrant Backgrounds */
.rank-1 {
    border-color: #f1c40f;
    background: linear-gradient(to right, #ffffff, #fffdf0);
}

.rank-1 .leaderboard-rank {
    font-size: 2rem;
}

.rank-2 {
    border-color: #bdc3c7;
    background: linear-gradient(to right, #ffffff, #f8f9fa);
}

.rank-2 .leaderboard-rank {
    font-size: 1.8rem;
}

.rank-3 {
    border-color: #e67e22;
    background: linear-gradient(to right, #ffffff, #fffaf5);
}

.rank-3 .leaderboard-rank {
    font-size: 1.7rem;
}

.highlight {
    background: #f0f7ff !important;
    border: 3px solid var(--secondary) !important;
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(78, 205, 196, 0.2);
}

.leaderboard-empty {
    padding: 40px;
    color: #a4b0be;
    font-style: italic;
    font-weight: 700;
}

/* --- Sentence Builder Game Styles --- */
.sentence-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    padding: 10px;
}

.sentence-answer-area {
    width: 100%;
    min-height: 80px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.6);
    border: 3px dashed var(--secondary);
    border-radius: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    align-items: center;
    transition: all 0.3s ease;
}

.sentence-answer-area.correct {
    border-color: #2ecc71;
    background: #eafff0;
}

.sentence-pool {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 10px;
}

.word-bubble {
    padding: 10px 20px;
    background: white;
    border: 3px solid var(--secondary);
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.word-bubble:hover {
    transform: translateY(-3px) scale(1.05);
    background: var(--secondary);
    color: white;
}

.word-bubble.clicked {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
}

.word-bubble.placed {
    border-color: var(--primary);
    background: white;
    color: var(--primary);
}

.sentence-controls {
    margin-top: 10px;
}

/* --- Manage Sentences Overlay Styles --- */
.manage-sentences-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    text-align: left;
    margin-top: 15px;
}

@media (max-width: 768px) {
    .manage-sentences-layout {
        grid-template-columns: 1fr;
    }
}

.word-ref-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 12px;
}

.word-ref-pill {
    background: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    border: 1px solid #eee;
}

.ai-box {
    background: #f0f7ff;
    padding: 15px;
    border-radius: 18px;
    border: 2px solid #d0e8ff;
}

.ai-suggestion-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-suggestion-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.ai-suggestion-row button {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    background: var(--secondary);
    color: white;
    border: none;
    cursor: pointer;
}

/* --- Mobile Layout Fixes --- */
@media (max-width: 480px) {
    .tabs-container {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start !important;
        gap: 5px;
        padding: 5px 5px;
        width: 100%;
        box-sizing: border-box;
    }

    .tabs-container::-webkit-scrollbar {
        height: 4px;
    }

    .tabs-container::-webkit-scrollbar-thumb {
        background: var(--secondary);
        border-radius: 4px;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .topics-grid,
    .roadmap-grid {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 0 5px 20px 5px !important;
    }

    .topic-bubble,
    .roadmap-bubble {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
        font-size: 1rem !important;
        padding: 10px 15px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    .roadmap-stage {
        padding: 15px !important;
        margin-bottom: 20px !important;
    }

    .stage-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stage-title {
        font-size: 1.2rem !important;
    }

    .roadmap-lock-overlay {
        width: 85% !important;
        text-align: center;
        padding: 12px !important;
        font-size: 0.9rem !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}