:root {
    /* --- Light Mode (Default) --- */
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #2c3e50;
    --text-sub: #7f8c8d;
    --border-color: #ddd;
    --header-bg: rgba(255, 255, 255, 0.95);
    --shadow: rgba(0,0,0,0.1);
    --btn-text: #2c3e50;
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    /* --- Dark Mode Overrides --- */
    --bg-body: #121213;         /* Very dark grey (almost black) */
    --bg-card: #1e1e1e;         /* Slightly lighter for cards */
    --text-main: #ecf0f1;       /* White-ish text */
    --text-sub: #bdc3c7;        /* Light grey text */
    --border-color: #2c3e50;    /* Dark borders */
    --header-bg: rgba(30, 30, 30, 0.95);
    --shadow: rgba(0,0,0,0.5);  /* Stronger shadow for depth */
    --btn-text: #ecf0f1;
    --input-bg: #2c3e50;
}

/* --- 1. GLOBAL STYLES --- */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s; /* Smooth toggle animation */
}

.word-card, .share-card, .welcome-card, .reward-card, .win-card, .week-tracker-container {
    background: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-color);
    box-shadow: 0 4px 15px var(--shadow);
}

/* --- 2. LAYOUT: SCROLLING TOP AREA --- */
.top-scroll-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px 15px 10px;
    background: var(--bg-body); /* FIXED */
    gap: 12px;
}

.controls-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    padding-bottom: 5px;
}

.language-settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.language-settings label {
    font-weight: bold;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #95a5a6;
}

#lang-select {
    border: 1px solid var(--border-color); /* Updated to var */
    border-radius: 8px;
    padding: 6px 12px;
    background: var(--input-bg); /* Use this var */
    color: var(--text-main);     /* Use this var */
    font-family: inherit;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    outline: none;
}

#lang-select:hover {
    border-color: #3498db;
    background-color: #f0f7ff;
}

.secondary-share-btn {
    padding: 6px 16px;
    font-size: 0.75rem;
    background: var(--bg-card); /* FIXED */
    color: var(--text-main);    /* Add this */
    border: 1px solid #bdc3c7;
    color: #7f8c8d;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-share-btn:hover {
    background: #f1f2f6;
    border-color: #95a5a6;
}

header h1, .mini-logo {
    color: var(--text-main);
}

/* Fix for the definitions and inputs */
.definition { color: var(--text-main); }
.translation-word { color: var(--text-main); }
.translation-box { background: var(--bg-body); }

/* --- 3. LAYOUT: SLIM STICKY HEADER --- */
.slim-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    /* FIX: Use variable, remove the hardcoded rgba white */
    background: var(--header-bg); 
    backdrop-filter: blur(8px);
    /* FIX: Use variable for border */
    border-bottom: 1px solid var(--border-color); 
    padding: 10px 15px;
}

.header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.header-left { display: flex; justify-content: flex-start; }
.header-center { display: flex; justify-content: center; }
.header-right { display: flex; justify-content: flex-end; }

.streak-container {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    padding: 3px 10px;
    border-radius: 15px;
    font-weight: 800;
    color: #e67e22;
    border: 2px solid #f39c12;
    font-size: 0.8rem;
    animation: pulse-glow 2s infinite;
}

#score-board {
    background: #2c3e50;
    color: white;
    padding: 3px 15px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 800;
}

.mini-logo {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-main); /* <--- THE FIX (Will turn white in Dark Mode) */
    font-weight: 900;
    letter-spacing: -0.5px;
}

/* --- 4. MAIN CONTENT & CARDS --- */
#word-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 0 15px 100px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dual-translation-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.translation-mini-box {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    align-items: flex-start;
}

.flag-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin-top: 2px; /* Slight alignment fix */
}

/* Update translation text styles for the new layout */
.translation-word {
    display: block;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

.translation-example {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-style: italic;
    margin: 0;
    line-height: 1.4;
}

.word-card {
    position: relative;
    background: var(--bg-card); /* FIXED */
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e1e8ed;
    overflow: hidden;
}

.rarity-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 900;
    text-transform: uppercase;
    color: white;
}

.rare { background-color: #2ecc71; }
.super-rare { background-color: #3498db; }
.epic { background-color: #9b59b6; }
.mythic { background-color: #e74c3c; }
.legendary { background-color: #f1c40f; color: #2c3e50; }

.quiz-section { padding: 30px; }
.definition { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; padding-right: 70px; }

.options-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.option-btn {
    background: var(--bg-card);
    border: 2px solid #3498db;
    color: #3498db;
    padding: 12px 5px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn.correct { background: #2ecc71 !important; border-color: #2ecc71 !important; color: white !important; }
.option-btn.wrong { background: #e74c3c !important; border-color: #e74c3c !important; color: white !important; opacity: 0.6; }

.full-content { display: none; background: var(--bg-body); /* FIXED - Ensures it matches the theme */
    border-top: 1px solid var(--border-color); padding: 25px 30px; }
.word-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.phonetic { color: var(--text-sub); font-family: monospace; }

.translation-box {
    background: var(--bg-card); /* FIXED */
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- 5. WEEK TRACKER --- */
.week-tracker-container {
    background: var(--bg-card); /* FIXED */
    max-width: 600px;
    margin: 10px auto 25px auto;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #e1e8ed;
    text-align: center;
}

.week-dots { display: flex; justify-content: center; gap: 10px; }
.day-dot {
    width: 35px; height: 35px; border-radius: 50%;
    background: var(--bg-body); /* Change #f0f2f5 to variable so they blend in */
    border: 1px solid var(--border-color); /* Add border so they are visible */
    color: var(--text-sub);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: bold; border: 2px solid transparent;
}
.day-dot.completed { background: #2ecc71; color: white; }
.day-dot.today { border-color: #3498db; color: #3498db; }

/* --- 6. MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center; align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card); /* FIXED */
    color: var(--text-main);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    position: relative;
    max-width: 380px;
    width: 90%;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.close-modal {
    position: absolute;
    top: 15px; right: 15px;
    background: none; border: none;
    font-size: 24px; color: #bdc3c7;
    cursor: pointer;
}

#share-preview-text {
    background: var(--bg-body); /* FIXED */
    color: var(--text-main);    /* Add this */
    padding: 15px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    margin: 20px 0;
    white-space: pre-wrap;
}

.share-buttons-grid { display: flex; flex-direction: column; gap: 10px; }
.share-opt {
    border: none; padding: 12px; border-radius: 10px;
    font-weight: bold; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.share-opt.whatsapp { background: #25D366; }
.share-opt.twitter { background: #000000; }
.share-opt.copy { background: #3498db; }

/* --- 7. ANIMATIONS --- */
@keyframes pulse-glow {
    0% { box-shadow: 0 0 5px rgba(243, 156, 18, 0.2); }
    50% { box-shadow: 0 0 15px rgba(243, 156, 18, 0.5); }
    100% { box-shadow: 0 0 5px rgba(243, 156, 18, 0.2); }
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- 8. FOOTER & EXTRAS --- */
footer { padding: 40px 20px; text-align: center; font-size: 0.8rem; color: #95a5a6; }
.youtube-banner {
    display: flex; align-items: center; justify-content: space-between;
    background: white; border-left: 4px solid #ff0000;
    padding: 15px; margin: 20px auto; max-width: 600px;
    border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-decoration: none; color: inherit;
}

@keyframes milestone-pop {
    0% { transform: scale(1); filter: drop-shadow(0 0 0px #f1c40f); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 15px #f1c40f); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0px #f1c40f); }
}

.animate-milestone {
    animation: milestone-pop 0.8s ease-out;
    display: inline-block; /* Required for transform to work */
}

/* --- Header Stats Button --- */
#stats-btn {
    background: transparent;
    border: 1px solid transparent; /* Invisible border for layout stability */
    border-radius: 20px;         /* Pill shape */
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);     /* Ensures white text in Dark Mode */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;                    /* Space between emoji and text */
    margin-left: 8px;
    transition: all 0.2s ease;
}

#stats-btn:hover {
    background: var(--bg-card);  /* Light background on hover */
    border-color: var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    transform: translateY(-1px); /* Subtle lift effect */
}

/* --- Stats Modal Internals --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.stat-box {
    background: var(--bg-body); /* Dark mode friendly */
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: #3498db;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-sub);
    text-transform: uppercase;
    font-weight: bold;
}

/* --- The CSS Bar Chart --- */
.chart-container {
    height: 150px;
    margin-top: 20px;
    display: flex;
    align-items: flex-end; 
    justify-content: center;
    gap: 10px;
    padding-bottom: 45px; /* INCREASED: Space for the hanging labels */
}

/* NEW: The Y-Axis Styles */
.y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes 5 to top, 0 to bottom */
    height: 100%;
    color: var(--text-sub);
    font-size: 0.7rem;
    font-weight: 800;
    
    /* CRITICAL: This pushes the "0" up to align with the bar baseline, 
       ignoring the date labels below the bars */
    padding-bottom: 20px; 
    border-right: 1px solid var(--border-color); /* Optional: A vertical axis line */
    padding-right: 8px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100%;
    flex-grow: 1; /* Fills the rest of the space */
    justify-content: space-around; /* Spreads bars evenly */
}

.axis-label {
    position: absolute;
    
    /* FIX: Anchor to the TOP, not the bottom */
    top: 100%;            /* Starts exactly at the bottom of the bar/chart */
    margin-top: 8px;      /* Adds a consistent gap between bar and number */
    
    left: 50%;
    transform: translateX(-50%); /* Centers text horizontally */
    
    display: flex;
    flex-direction: column; /* Stacks Day on top of Month */
    align-items: center;    /* Centers text */
    width: 40px;
    
    /* Ensure text aligns to the top of this container */
    justify-content: flex-start; 
}

.bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20px;
    position: relative; /* Essential for absolute positioning of children */
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    background: #3498db;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease-out;
    opacity: 0.8;
}

.bar:hover {
    opacity: 1;
    background: #2980b9;
}

.bar.perfect { background: #2ecc71; } /* Green for 5/5 */
.bar.bad { background: #e74c3c; }     /* Red for 0-2/5 */

.bar-label {
    font-size: 0.6rem;
    margin-top: 5px;
    color: var(--text-sub);
}

/* 4. Styling the Text */
.day-num {
    font-size: 0.7rem;
    color: var(--text-sub);
    font-weight: bold;
    line-height: 1.2;
}

.month-marker {
    font-size: 0.6rem;
    color: #3498db;      /* Accent color for the Month */
    font-weight: 800;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Container must be relative so the badge sits on the corner */
.badge-container {
    position: relative !important;
    overflow: visible !important; /* Ensure the badge isn't cut off */
}

/* The "NEW" Label */
.badge-container::after {
    content: "NEW";
    position: absolute;
    top: -8px;
    right: -10px;
    background: #e74c3c; /* Red alert color */
    color: white;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid white; /* Makes it pop against the button */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    animation: gentle-bounce 2s infinite;
    z-index: 10;
}

@keyframes gentle-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* --- Bottom Archive Button --- */
.archive-cta-container {
    max-width: 600px;
    margin: 30px auto 10px auto;
    padding: 0 20px;
}

.big-archive-btn {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 15px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    color: var(--text-main);
}

.big-archive-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.08);
    border-color: #3498db;
}

.book-icon {
    font-size: 1.8rem;
    margin-right: 15px;
}

.btn-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Pushes arrow to the right */
}

.btn-title {
    font-weight: 800;
    font-size: 1rem;
}

.btn-subtitle {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.arrow-icon {
    font-weight: bold;
    color: var(--text-sub);
}

/* Filter Bar Styling */
.filter-scroll-container {
    overflow-x: auto;
    padding-bottom: 10px; /* Space for scrollbar if needed */
    margin-top: 20px;
    -webkit-overflow-scrolling: touch;
}

.filter-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-width: max-content; /* Ensures buttons don't squash on mobile */
    padding: 0 10px;
}

.filter-pill {
    background: #f0f2f5;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    color: #7f8c8d;
    transition: all 0.2s;
}

.filter-pill:hover {
    background: #e1e8ed;
}

.filter-pill.active {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

/* Optional: Color code the active states for fun */
.filter-pill[data-filter="Rare"].active { background: #2ecc71; border-color: #2ecc71; }
.filter-pill[data-filter="Epic"].active { background: #9b59b6; border-color: #9b59b6; }
.filter-pill[data-filter="Legendary"].active { background: #f1c40f; border-color: #f1c40f; color: #2c3e50; }

.visually-hidden { display: none; }


/* --- SEO / Content Section for AdSense --- */
.seo-content-container {
    max-width: 600px;
    margin: 20px auto;
    padding: 0 15px;
}

.seo-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
}

.seo-card h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-main);
}

.seo-card p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-sub);
    margin-bottom: 15px;
}

.seo-card a {
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
}