/* style.css */

/* Global styles - PREVENT OUTER SCROLL */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #EBF9EE; 
    color: #333;
    height: 100vh;
    width: 100vw;
    margin: 0;
    text-align: center;
    
    /* STOP BODY SCROLLING */
    overflow: hidden; 
    
    /* Center the card */
    display: flex;
    align-items: center;
    justify-content: center;
}

#app-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden; /* STOP WRAPPER SCROLLING */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* --- .screen-container (The White Card) --- */
.screen-container {
    width: 90%;
    max-width: 380px;
    
    /* FIXED SIZE */
    height: 650px !important;
    min-height: 650px !important;
    max-height: 650px !important;
    
    padding: 1.5rem 1.5rem;
    box-sizing: border-box;
    background-color: #ffffff; 
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(136, 212, 152, 0.2); 
    
    position: relative;
    
    /* Layout */
    display: flex;
    flex-direction: column;
    
    /* Ensure nothing spills out */
    overflow: hidden; 
}

/* --- .screen-page (Home Screen) --- */
.screen-page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #EBF9EE; 
    
    /* Allow Home Screen to scroll internally */
    overflow-y: auto; 
    
    border-radius: 24px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
/* Hide Scrollbar for Home Screen */
.screen-page::-webkit-scrollbar {
    display: none;
}

/* --- Home Screen Content --- */
#home-screen {
    padding: 1.5rem 1rem;
    padding-top: 80px; 
    padding-bottom: 120px; 
}
#main-header {
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    font-size: 1.5rem;
    color: #333;
    margin: 0;
    padding: 1.5rem 0;
    background-color: #EBF9EE; 
    z-index: 10;
    font-weight: 600;
}

/* --- UPDATED LIST FOR WIDE BANNERS --- */
#home-category-list {
    display: grid;
    grid-template-columns: 1fr; /* Single column for wide images */
    gap: 1rem; 
    padding: 0 0.5rem; 
    max-width: 380px;
    margin: 0 auto; 
}

.category-chip {
    display: flex;
    flex-direction: column; 
    align-items: center;  
    justify-content: center; 
    gap: 0; 
    padding: 0; 
    border-radius: 16px; 
    background-color: #ffffff;
    border: 3px solid transparent; 
    
    /* UPDATED DIMENSIONS FOR LANDSCAPE IMAGES */
    width: 100%;
    height: 140px; /* Fixed banner height */
    
    font-weight: 600;
    color: #555;
    margin-right: 0; 
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    position: relative;
}

.category-chip:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.category-chip-label { display: none; } /* Hide text, image has text */

.category-chip-icon {
    width: 100%; 
    height: 100%; 
    object-fit: cover; /* Cover ensures image fills the box nicely */
    object-position: center;
}

/* --- Buttons --- */
.btn-start {
    display: block; width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 16px; 
    font-size: 1rem;
    font-weight: 600; 
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    margin-bottom: 0.75rem;
    text-decoration: none;
    box-sizing: border-box;
    color: #111; 
    background-color: #ffffff; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06); 
}
.btn-start:hover:not(:disabled) {
    background-color: #f8f8f8; 
    transform: scale(1.02);
}

#setup-save-btn { 
    background-color: #ffffff;
    color: #1C1C1E;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}
#setup-save-btn:hover:not(:disabled) {
    background-color: #EBF9EE; 
    color: #1C1C1E;
    transform: scale(1.02);
}

/* --- Game Container Styles --- */
#game-container {
    padding: 0 !important; 
    background-color: transparent; 
    box-shadow: none;
    perspective: 1000px; 
    overflow: visible; 
    border-radius: 0; 
    z-index: 5; 
    height: 100%;
}

#question-card {
    position: relative;
    width: 100%;
    height: 100%;
    flex-grow: 1; 
    min-height: 0; 
    transition: transform 0.6s, height 0.3s ease;
    transform-style: preserve-3d;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; 
    backface-visibility: hidden;
    border-radius: 24px;
    padding: 1.5rem 1.5rem;
    box-sizing: border-box;
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    transform: translate3d(0, 0, 0); 
}

#card-front {
    background-color: #ffffff; 
    box-shadow: 0 8px 30px rgba(136, 212, 152, 0.2);
    z-index: 2;
    transform: rotateY(0deg);
}

#card-back {
    background-color: #ffffff; 
    box-shadow: 0 8px 30px rgba(136, 212, 152, 0.2); 
    color: #1C1C1E; 
    z-index: 1;
    transform: rotateY(180deg);
}
#card-back h3 { display: none; }

#question-card.is-flipped {
    transform: rotateY(180deg);
}

#question-card.is-flipped #timer-wrapper {
    opacity: 0;
    transition: opacity 0.2s;
}

.game-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 1rem; 
    font-weight: 500;
    flex-shrink: 0; 
}
#question-counter {
    background-color: #E6F2FF;
    color: #007aff;
    padding: 0.3rem 0.75rem;
    border-radius: 20px; 
    font-size: 0.8rem; 
    font-weight: bold;
}
#timer-text {
    background-color: #a4c844;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    line-height: 32px;
    text-align: center;
    transition: color 0.3s ease, background-color 0.3s ease;
    flex-shrink: 0;
    margin-left: 0.5rem; 
}
.timer-danger {
    background-color: #e57373;
    color: #ffffff;
}
#timer-wrapper {
    position: relative; 
    margin-bottom: 1rem;
    display: flex; 
    align-items: center;
    width: 100%;
    flex-shrink: 0; 
}
#timer-bar-container {
    position: relative;
    flex: 1; 
    height: 28px; 
}
#star-markers {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 2; 
}

.star-marker {
    position: absolute; 
    opacity: 1;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.15));
    height: 35px; 
    width: 35px;
    top: 50%; 
}

#star-marker-1 { left: 0%; transform: translate(-50%, -50%); }
#star-marker-2 { left: 33.33%; transform: translate(-50%, -50%); }
#star-marker-3 { left: 66.67%; transform: translate(-50%, -50%); }

#timer-bar {
    width: 100%;
    height: 14px;
    background-color: #F0F0F0; 
    border-radius: 7px; 
    overflow: hidden;
    position: absolute; 
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1; 
}
#timer-bar-fill {
    height: 100%; width: 100%; 
    background-color: #a4c844;
    border-radius: 7px; 
    transition: width 1s linear, background-color 0.5s;
}

#powerup-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
}

.powerup-btn {
    background-color: #E6F2FF;
    border: 1px solid #007aff;
    color: #007aff;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 100px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px; 
}

.powerup-btn:hover:not(:disabled) {
    background-color: #007aff;
    color: white;
}

.powerup-btn:disabled {
    opacity: 0.5;
    background-color: #f0f0f0;
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
    text-decoration: line-through;
}

#question-text {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
    color: #1C1C1E;
    font-weight: 700;
    text-align: center;
    min-height: 50px; 
    flex-shrink: 0; 
}
#answer-buttons {
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 0.75rem; 
    position: relative; 
    flex-grow: 0;
    flex-shrink: 0; 
    overflow-y: hidden; 
    padding-bottom: 0.5rem; 
    min-height: 0;
    width: 100%;
}

.btn {
    background-color: #ffffff;
    color: #111;
    border: 1px solid #e5e7eb; 
    border-radius: 16px;
    padding: 0.8rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: none; 
    flex-shrink: 0; 
}
.btn:hover:not(:disabled) {
    background-color: #f9fafb; 
    border-color: #d1d5db; 
    transform: scale(1.02);
    box-shadow: none;
}
.btn.correct {
    background-color: #E6F2FF; 
    border-color: #007aff; 
    color: #007aff; 
    font-weight: bold;
    box-shadow: none;
}
.btn.show-correct {
    background-color: #a4c844;
    border-color: #a4c844; 
    color: #ffffff; 
    font-weight: bold;
    box-shadow: none;
}
.btn.wrong {
    background-color: #e57373;
    border-color: #e57373; 
    color: #fff; 
    font-weight: bold;
    box-shadow: none;
}

/* --- Results Screen Styles --- */
#results-screen {
    z-index: 5;
    padding-top: 1.5rem !important; 
    justify-content: flex-start; 
}

/* --- INVISIBLE SCROLLBARS FOR LISTS --- */
#leaderboard-list::-webkit-scrollbar,
#question-results-list::-webkit-scrollbar,
#theme-scores-grid::-webkit-scrollbar,
#collected-cards-grid::-webkit-scrollbar,
#edit-avatar-picker::-webkit-scrollbar {
    display: none; /* Hide for Chrome/Safari */
}

#question-results-list, 
#leaderboard-list,
#theme-scores-grid,
#collected-cards-grid,
#edit-avatar-picker {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem; 
    
    /* ENABLE INTERNAL SCROLL */
    overflow-y: auto; 
    
    /* HIDE SCROLLBARS (Firefox/IE) */
    -ms-overflow-style: none;
    scrollbar-width: none;
    
    flex-grow: 1; 
    flex-shrink: 1; 
    min-height: 100px; 
    margin-bottom: 0.75rem; 
}

/* --- CHALLENGE BUTTON --- */
.btn-challenge {
    display: block; 
    background-color: #a4c844; 
    color: white;
    border: none;
    border-radius: 16px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(164, 200, 68, 0.4); 
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
    z-index: 10; 
}
.btn-challenge:hover {
    transform: scale(1.02);
    background-color: #8dc030;
}

.result-card {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 0.6rem 0.8rem; 
    font-size: 0.95rem;
    background-color: #ffffff; 
    border-radius: 16px; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03); 
    flex-shrink: 0; 
}
.result-q-badge {
    background-color: #f5f5f5;
    color: #333; 
    border: 2px solid #eee; 
    height: 28px; 
    width: 28px; 
    line-height: 28px; 
    text-align: center;
    border-radius: 8px; 
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0; 
    margin-right: 0.75rem; 
}

.result-card-left {
    display: flex;
    align-items: center;
    gap: 0.75rem; 
    flex-grow: 1; 
}
.result-card-right {
    display: flex;
    align-items: center;
    gap: 0.25rem; 
    flex-shrink: 0; 
    font-weight: 700;
    color: #555;
    font-size: 0.95rem;
}
.result-time {
    color: #555;
    font-weight: 500;
}
.result-icon {
    font-weight: bold;
    font-size: 1.1rem;
}
/* FIXED COLORS FOR ICONS */
.result-card.correct .result-icon { color: #a4c844; }
.result-card.wrong .result-icon { color: #e57373; }

.result-star-icon {
    font-size: 1.1rem; 
    color: #f39c12; 
    opacity: 1 !important; 
}

.result-card.wrong .result-time {
    color: #e57373; 
}
.result-card.wrong .result-star-score {
    color: #aaa; 
}


/* --- Modal / Setup Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}
.modal-overlay .screen-container {
    /* Override for modal to just be centered */
    margin: 0;
    top: auto;
    left: auto;
    transform: none;
    position: relative;
    z-index: 1001;
    min-height: auto !important; /* Allow modal to shrink if needed */
    height: auto !important;
}
.name-input { 
    width: 100%; padding: 0.75rem; box-sizing: border-box;
    border-radius: 8px; border: 1px solid #ddd; font-size: 1rem;
    text-align: center; margin-bottom: 1rem;
}
.avatar-picker-grid { 
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 0.5rem; margin-bottom: 1.5rem;
}
#setup-avatar-picker {
    max-height: 150px;
    overflow-y: auto;
    background: #f0f2f5;
    padding: 0.5rem;
    border-radius: 8px;
}
#edit-avatar-picker {
    background: #f0f2f5;
    padding: 0.75rem;
    border-radius: 12px;
    overflow-y: auto; 
    -ms-overflow-style: none;  
    scrollbar-width: none;  
}
.avatar-option {
    font-size: 2rem; cursor: pointer; padding: 0.25rem;
    border-radius: 8px; transition: background-color 0.2s;
}
.avatar-option.selected {
    background-color: #a4c844;
    box-shadow: 0 0 0 3px #ffffff;
}
.avatar-option.hover {
    background-color: #EBF9EE;
}
#explanation-text {
    padding: 1.5rem; 
    text-align: center;
    box-sizing: border-box; 
    font-size: 1.4rem;
    color: #1C1C1E;
    font-weight: 700;
}

/* --- Transition Animations --- */
@keyframes slideOutLeft { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(-100vw, 0); opacity: 0; } }
@keyframes slideInRight { from { transform: translate(100vw, 0); opacity: 0; } to { transform: translate(0, 0); opacity: 1; } }
@keyframes slideInUp { from { transform: translate(0, 100vh); opacity: 0; } to { transform: translate(0, 0); opacity: 1; } }
@keyframes slideOutDown { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(0, 100vh); opacity: 0; } }

.screen-slide-out { animation: slideOutLeft 0.3s ease-out forwards; }
.screen-slide-in { animation: slideInRight 0.3s ease-in forwards; }
.screen-slide-in-up { animation: slideInUp 0.3s ease-out forwards; }
.screen-slide-out-down { animation: slideOutDown 0.3s ease-out forwards; }
.page-slide-out { animation: pageSlideOutLeft 0.3s ease-out forwards; }
.page-slide-in { animation: pageSlideInRight 0.3s ease-in forwards; }
.page-slide-in-up { animation: pageSlideInUp 0.3s ease-out forwards; }
.page-slide-out-down { animation: pageSlideOutDown 0.3s ease-out forwards; }

@keyframes shake { 0% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } 100% { transform: translateX(0); } }
.shake { animation: shake 0.4s ease-in-out 1; }

/* --- Home Nav Bar Styles --- */
#home-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1rem 1.5rem; 
    box-sizing: border-box;
    background: transparent;
    z-index: 100;
}
.nav-btn {
    background-color: #ffffff;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    border-radius: 20px;
    padding: 0.75rem 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}
.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}
.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
}
.nav-icon-ref {
    font-size: 1.5rem;
}
.nav-btn.play {
    flex: 1.2; 
    background: #8860EB; 
    color: #ffffff;
    font-size: 1.8rem; 
    margin: 0 1rem;
    padding-top: 0.75rem; 
    padding-bottom: 0.75rem; 
    border-radius: 24px; 
    box-shadow: 0 6px 20px rgba(110, 72, 216, 0.4);
}
.nav-btn.play:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 25px rgba(110, 72, 216, 0.5);
}
.nav-btn.play .nav-label {
    display: none;
}

/* --- Back Button Style (Generic) --- */
.back-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: #888;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    z-index: 10; 
}
.back-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* --- PROFILE SCREEN --- */
#profile-screen {
    justify-content: flex-start; 
    padding-top: 3.5rem !important; 
    gap: 1.5rem; 
    text-align: center;
}

#profile-screen .back-btn {
    top: 1.5rem;
    left: 1.5rem;
}

/* Header Section */
.profile-header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
#profile-avatar-display {
    font-size: 4rem; 
    background-color: #f0f2f5; 
    border-radius: 50%;
    width: 90px; 
    height: 90px; 
    line-height: 90px; 
    margin: 0 auto; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
#profile-name-display {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1C1C1E;
    margin: 0;
}
.btn-pill-outline {
    background: transparent;
    border: 1px solid #e0e0e0;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.25rem;
}
.btn-pill-outline:hover {
    background-color: #f9f9f9;
    border-color: #ccc;
    color: #111;
}

/* Stats Stack */
.profile-stats-stack {
    display: flex;
    flex-direction: column;
    gap: 0.8rem; 
    width: 100%;
}
.profile-stat-row {
    background-color: #F7F7F9; 
    border-radius: 16px; 
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between; 
    align-items: center;
    transition: transform 0.2s, background-color 0.2s;
}
.profile-stat-row.clickable {
    cursor: pointer;
}
.profile-stat-row.clickable:hover {
    background-color: #efeff4;
    transform: scale(1.01);
}
.stat-label {
    font-size: 1rem;
    font-weight: 600;
    color: #555;
}
.stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1C1C1E;
}
.btn-large-action {
    background-color: #F7F7F9;
    color: #1C1C1E;
    border: none;
    width: 100%;
    padding: 1rem;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: auto; 
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
}
.btn-large-action:hover {
    background-color: #efeff4;
}

/* --- LEADERBOARD SCREEN UPDATED --- */

#leaderboard-screen {
    padding-top: 4rem !important; 
    background-color: #ffffff;
}

#leaderboard-back-btn {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #f0f2f5; 
    border: none;
    font-size: 1.5rem;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    z-index: 10;
    padding-bottom: 4px; 
}
#leaderboard-back-btn:hover {
    background-color: #e0e0e0;
}

#leaderboard-subtitle {
    text-align: center;
    color: #888;
    font-weight: 500;
    margin-top: -0.5rem;
    margin-bottom: 1rem; 
}

/* Updated List Container for Scrolling */
#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; 
    width: 100%;
    padding: 0.5rem;
    box-sizing: border-box;
}

/* Updated Card Design (Rectangular, Light BG) */
.leaderboard-card {
    display: flex;
    align-items: center;
    background-color: #f9f9f9; /* Light gray background */
    border-radius: 16px;       /* Rounded corners */
    padding: 1rem 1.2rem; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    margin-bottom: 0.5rem;
    flex-shrink: 0; /* Prevent squashing */
}

/* Current User Highlight */
.leaderboard-card.current-user {
    border: 2px solid #a4c844;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(164, 200, 68, 0.2);
}

/* Rank Circle */
.leaderboard-rank-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    margin-right: 1rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.rank-1 { background-color: #FFD700; box-shadow: 0 2px 5px rgba(255, 215, 0, 0.4); } 
.rank-2 { background-color: #C0C0C0; } 
.rank-3 { background-color: #CD7F32; } 
.rank-other { background-color: #E0E0E0; color: #555; } 

/* Avatar & Name */
.leaderboard-avatar {
    font-size: 1.8rem;
    margin-right: 0.75rem;
    line-height: 1;
}
.leaderboard-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1; 
    overflow: hidden;
}
.leaderboard-name {
    font-weight: 700;
    color: #1C1C1E;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Stats Block */
.leaderboard-stats-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 60px;
}
.stat-item {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-item.stars { color: #f39c12; }
.stat-item.cards { color: #8860EB; }

/* --- Theme Scores & Collection Styles --- */
#theme-scores-grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}

#collected-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem; 
    margin-top: 1rem;
    width: 100%;
}

#collected-cards-screen {
    background-color: #EBF9EE; 
}

.theme-score-card {
    background: #f9f9f9;
    border-radius: 16px;
    padding: 1rem 1.25rem; 
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: space-between; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.collection-card-item {
    background: #ffffff;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly; 
    aspect-ratio: 3 / 4; 
    cursor: pointer;
    transition: transform 0.2s;
    text-align: center;
}
.collection-card-item:hover {
    transform: scale(1.05);
}
.collection-card-icon {
    font-size: 2.5rem; 
    margin-bottom: 0.5rem;
}
.collection-card-theme {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

.collection-card-question {
    font-size: 0.9rem; 
    color: #1C1C1E;    
    margin-top: 0;     
    font-weight: 600;  
    line-height: 1.3;  
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4; 
    -webkit-box-orient: vertical;
}

.theme-score-name {
    font-size: 1.1rem; 
    font-weight: 600;
    color: #333;
    text-align: left; 
}
.theme-score-stars {
    font-size: 1.4rem; 
    font-weight: 700;
    color: #6FAA7B; 
    white-space: nowrap; 
}

.screen-container .subtitle {
    font-size: 1rem;
    color: #888;
    margin-top: -0.5rem; 
    margin-bottom: 1rem; 
}

#edit-profile-screen h3 {
    margin-bottom: 0.75rem;
}
#edit-profile-screen .name-input {
    margin-bottom: 1rem; 
}
#edit-save-btn {
    background-color: #a4c844;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(164, 200, 68, 0.3);
    margin-top: 1.5rem; 
    margin-bottom: 0; 
    flex-shrink: 0; 
}
#edit-save-btn:hover:not(:disabled) {
    background-color: #b5d66a;
    color: #ffffff;
    transform: scale(1.02);
}

/* Container Sizing */
#profile-screen,
#leaderboard-screen,
#theme-scores-screen,
#collected-cards-screen, 
#edit-profile-screen,
#results-screen, 
#game-container { 
    padding-top: 1.5rem; 
    padding-bottom: 1.5rem; 
}

#leaderboard-list,
#theme-scores-grid,
#collected-cards-grid, 
#edit-avatar-picker,
#question-results-list { 
    flex-grow: 1; 
    flex-shrink: 1; 
    min-height: 0; 
}

/* Results Icons/Avatars */
#results-avatar {
    font-size: 2.2rem; 
    background-color: #f0f2f5;
    border-radius: 50%;
    width: 60px; 
    height: 60px; 
    line-height: 60px; 
    margin: 0 auto 0.5rem auto; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    position: relative;
}
.results-summary-grid {
    display: flex;
    justify-content: space-around; 
    align-items: flex-start; 
    width: 100%;
    margin: 0.5rem 0 1.25rem 0; 
    flex-shrink: 0; 
}
.results-stars-container,
.results-decks-container {
    display: flex;
    flex-direction: column;
    align-items: center; 
    gap: 0.5rem; 
    flex-basis: 50%; 
}
.results-summary-icon {
    display: block;
    height: 50px; 
    width: 50px; 
    object-fit: contain; 
}
.results-stars-container .results-summary-icon {
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}
#final-score-text,
#final-cards-text { 
    display: flex;
    align-items: baseline; 
    line-height: 1;
    margin-top: 0; 
}
#final-score-value,
#final-cards-value { 
    font-size: 3rem; 
    font-weight: 700;
    color: #1C1C1E; 
}
#final-score-total,
#final-cards-total { 
    font-size: 1.5rem; 
    font-weight: 500;
    color: #888; 
    margin-left: 0.25rem; 
}

/* Results Nav Bar */
#results-nav-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding-top: 0.5rem; 
    margin-top: auto; 
    border-top: 1px solid #f0f0f0; 
    flex-shrink: 0; 
    gap: 0.25rem; 
}
#results-nav-bar .nav-btn {
    box-shadow: none;
    flex: 1; 
    padding: 0.5rem; 
    background-color: #f9f9ff; 
    border-radius: 16px;
    margin: 0;
    color: #555;
    font-size: 1.2rem; 
}
#results-nav-bar .nav-btn .nav-label {
    font-size: 0.7rem; 
    font-weight: 600;
    margin-top: 0.2rem; 
}
#results-nav-bar .nav-btn:hover {
    background-color: #f0f0f5; 
    transform: none;
}
#results-nav-bar .nav-btn.play {
    flex: 1.2; 
    background: #8860EB; 
    color: #ffffff;
    font-size: 1.4rem; 
    line-height: 1; 
    margin: 0 0.5rem; 
    border-radius: 20px; 
    padding: 0.5rem; 
}
#results-nav-bar .nav-btn.play:hover {
    background: #997cf0;
    transform: none;
}

/* Flying Clones */
.flying-clone {
    position: fixed; 
    z-index: 10001; 
    pointer-events: none;
    opacity: 1;
    transform: scale(1.2); 
    transition: transform 1.2s cubic-bezier(0.5, 0, 1, 0.5), opacity 1.2s ease-out;
}
.flying-star {
    font-size: 1.5rem; 
    color: #f39c12;
    text-shadow: 0 0 10px #f39c12; 
}
.flying-card {
    font-size: 1.5rem; 
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.flying-badge {
    background-color: #f0f0f0;
    color: #333;
    padding: 0.3rem 0.5rem;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Confetti - UPDATED */
.confetti {
    position: fixed;
    width: 10px;        /* ADDED */
    height: 10px;       /* ADDED */
    opacity: 1;
    z-index: 2000; 
    pointer-events: none;
    animation: confetti-burst 3s cubic-bezier(0.1, 1, 0.5, 1) forwards;
}
@keyframes confetti-burst {
    0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
    100% { transform: translate(var(--x), var(--y)) rotate(var(--rotation)) scale(0); opacity: 0; }
}
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25) rotate(-5deg); }
    100% { transform: scale(1); }
}
.pop { animation: pop 0.3s ease-out 1; }

/* Card Detail Modal */
#card-detail-modal .screen-container { max-height: 70vh; }
#card-detail-content { text-align: left; padding: 1rem 1.5rem; }
#card-detail-theme { font-size: 0.9rem; font-weight: 600; color: #8860EB; margin-bottom: 0.5rem; text-align: left; }
#card-detail-question { font-size: 1.4rem; font-weight: 700; color: #1C1C1E; margin-bottom: 1rem; text-align: left; line-height: 1.4; }
#card-detail-answer { background: #EBF9EE; border: 2px solid #a4c844; border-radius: 12px; padding: 0.75rem 1rem; font-weight: 600; color: #333; margin-bottom: 1rem; text-align: left; font-size: 1rem; }
.answer-prefix { font-weight: 700; color: #a4c844; margin-right: 0.25rem; }
#card-detail-stars { text-align: center; font-size: 1.5rem; margin-bottom: 1rem; }
#card-detail-stars .stars-filled { color: #f39c12; }
#card-detail-stars .stars-empty { color: #e0e0e0; }
#card-detail-explanation { font-size: 0.9rem; color: #555; line-height: 1.5; text-align: left; margin-bottom: 1.5rem; }

.collection-card-answer { font-size: 0.95rem; font-weight: 700; color: #a4c844; margin-top: 0.25rem; padding: 0 0.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.collection-card-stars { font-size: 1.25rem; margin-top: 0.25rem; }
.collection-card-stars .stars-filled { color: #f39c12; }
.collection-card-stars .stars-empty { color: #e0e0e0; }