/* Dark Theme Base & Mobile Optimization */
:root {
    --nav-height: 70px;
    --nav-height-actual: 70px;
    --app-height: 100vh;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

body {
    background-color: #111;
    color: #fff;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 480px;
    background-color: #000;
    height: 100vh;
    height: var(--app-height);
    height: 100dvh;
    position: relative;
    overflow-x: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

/* Navbar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.8rem 0 calc(0.8rem + var(--safe-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2000;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-nav.nav-hidden {
    transform: translateY(100%);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #666;
    font-size: 0.7rem;
    gap: 4px;
    transition: color 0.3s ease;
}

.nav-item i {
    font-size: 1.3rem;
    margin-bottom: 2px;
}

.nav-item.active {
    color: #fff;
    font-weight: 600;
}

/* Feed Container */
.content-wrapper {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
    flex: 1;
}
.content-wrapper.feed-mode {
    padding-bottom: 0;
}

.feed {
    height: 100vh;
    height: var(--app-height);
    height: 100dvh;
    width: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

/* Feed Item */
/* Feed Item Layout - Refactored for Flex-based safe positioning */
.feed-item {
    position: relative;
    height: 100vh;
    height: var(--app-height);
    height: 100dvh;
    width: 100%;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Push content to bottom */
    background: #000;
    overflow: hidden;
}

.meme-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 1;
}

/* Sidebar Actions - Optimized Z-index and safe-area */
.side-actions {
    position: absolute;
    right: 12px;
    bottom: calc(var(--nav-height-actual) + var(--safe-bottom) + 20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 100;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-nav.nav-hidden ~ .content-wrapper .side-actions {
    bottom: calc(var(--safe-bottom) + 20px);
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: transparent;
    border: none;
    cursor: pointer;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    color: #fff;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.action-btn i {
    font-size: 32px;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    transition: transform 0.2s, color 0.2s;
}

.action-btn:active i {
    transform: scale(0.85);
}

.action-btn span {
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.profile-action {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #df42d1;
    padding: 2px;
    background: #000;
    position: relative;
}
.profile-action img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Interactive Overlay - Flex based, replaces absolute bottom-0 */
.feed-overlay {
    position: relative;
    z-index: 50;
    width: 100%;
    margin-top: auto; /* Push to bottom of flex container */
    /* Bottom padding reacts to nav state and safe areas */
    padding: 20px 16px calc(var(--nav-height-actual) + var(--safe-bottom) + 10px);
    background: linear-gradient(to top, 
        rgba(0,0,0,0.9) 0%, 
        rgba(0,0,0,0.6) 50%, 
        transparent 100%
    );
    box-sizing: border-box;
    pointer-events: none;
    transition: padding-bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bottom-nav.nav-hidden ~ .content-wrapper .feed-overlay {
    padding-bottom: calc(var(--safe-bottom) + 10px);
}

.feed-overlay * {
    pointer-events: auto;
}
/* Common Modal/Overlay Class for Desktop Adaptation */
.modal-overlay, #reject-modal, #login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.feed-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    color: #fff;
}
.highlight-word {
    color: #fdcb6e;
    font-weight: 700;
}

.feed-tags {
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 15px;
    opacity: 0.9;
}

.btn-reveal {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 25px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}
/* Translation Animation States */
.btn-reveal {
    transform: scale(1);
    opacity: 1;
    transition: 
        background-color 0.3s ease, 
        color 0.3s ease, 
        transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        padding 0.3s ease,
        border-radius 0.3s ease;
}

.btn-reveal.revealed {
    transform: scale(1.05);
    background-color: rgba(255, 255, 255, 0.95) !important;
    color: #000 !important;
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.2);
    border-radius: 12px;
}

.btn-reveal:active {
    transform: scale(0.95);
}


.translation-pill {
    background: rgba(40, 40, 40, 0.95);
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 5px 5px 20px;
    margin-bottom: 15px;
    width: fit-content;
    border: 1px solid rgba(255,255,255,0.1);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}
.translation-pill.active { opacity: 1; transform: translateY(0); }
.translation-pill .meaning-text { color: #fff; font-size: 0.9rem; }
.translation-pill .mini-explain-btn {
    background: #6c5ce7;
    color: white;
    border: none;
    padding: 6px 15px;
    border-radius: 18px;
    font-size: 0.8rem;
    font-weight: 600;
}
/* Toast Notification */
.toast-popup {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: linear-gradient(135deg, #ff9f43 0%, #ff6b6b 100%);
    width: 220px;
    padding: 20px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}
.toast-popup.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.toast-icon-box {
    font-size: 42px;
    color: #fff;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.toast-title {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    text-align: center;
}
.toast-subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Other views */
.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 15px; }
.cat-card { 
    padding: 20px; 
    border-radius: 20px; 
    color: white; 
    text-decoration: none; 
    position: relative; 
    overflow: hidden; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 120px;
    transition: transform 0.2s;
}
.cat-card:active { transform: scale(0.98); }
.cat-card i { font-size: 2.5rem; margin-bottom: 12px; }
.dict-card { background: #111; border-radius: 12px; padding: 15px; margin-bottom: 10px; border: 1px solid #222; color: #fff; }
.practice-header { display: flex; align-items: center; justify-content: space-between; padding: 15px; background: #000; color: #fff; }
.sheet-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 90; display: none; }
.sheet-overlay.active { display: block; }
.comments-sheet { position: fixed; bottom: -100%; left: 0; width: 100%; height: auto; max-height: 85dvh; background: #1a1a1a; border-radius: 20px 20px 0 0; z-index: 2100; transition: bottom 0.3s ease; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); }
.comments-sheet.active { bottom: 0; }
.sheet-header { padding: 15px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; color: #fff; }
.close-sheet { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.comments-list { flex: 1; overflow-y: auto; padding: 15px; color: #fff; }
.comment-input-area { padding: 15px; border-top: 1px solid #333; display: flex; gap: 10px; background: #1a1a1a; }
.comment-input-area input { flex: 1; background: #333; border: none; padding: 10px; border-radius: 20px; color: #fff; }
.comment-input-area button { background: #a29bfe; border: none; width: 40px; height: 40px; border-radius: 50%; color: #fff; cursor: pointer; }

/* --- Desktop / Tablet Adaptation --- */
@media (min-width: 481px) {
    /* Force Fixed elements to stay within the app container width */
    .bottom-nav,
    .feed-overlay,
    .sheet-overlay,
    .comments-sheet,
    .modal-overlay,
    #reject-modal,
    #login-modal {
        width: 480px !important;
        left: 50% !important;
        transform: translateX(-50%);
        right: auto;
    }

    /* Admin badge positioning on desktop */
    .admin-badge-fixed {
        left: 50% !important;
        transform: translateX(-225px); /* -(480/2) + 15px margin */
        width: auto !important;
    }

    /* Toast notification positioning */
    .toast-popup {
        /* It is already centered by transform, just ensure max-width */
        max-width: 440px;
    }

    /* Remove scrollbar from body to make it look like an emulator */
    body::-webkit-scrollbar {
        display: none;
    }
    body {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Practice Redesign */
.practice-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 20px 20px 10px;
}
.practice-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
    color: #fff;
}
.practice-subtitle {
    color: #888;
    font-size: 0.9rem;
    margin-top: 5px;
}
.practice-score {
    text-align: right;
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
}
.practice-progress {
    margin: 0 20px 30px;
    height: 6px;
    background: #2d3436;
    border-radius: 3px;
    overflow: hidden;
}
.practice-bar {
    height: 100%;
    background: #d05ce3;
    width: 0%;
    transition: width 0.3s ease;
}
.question-card-new {
    background: transparent;
    padding: 0 20px;
}
.question-text-new {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 25px;
    min-height: 60px;
    color: #fff;
}
.options-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 42dvh;
    overflow-y: auto;
    padding: 5px 2px;
    -webkit-overflow-scrolling: touch;
}
    overflow-y: auto;
    padding: 5px 2px;
    -webkit-overflow-scrolling: touch;
}
.option-btn-new {
    width: 100%;
    padding: 16px 20px;
    background: #2d3436;
    border: none;
    border-radius: 15px;
    color: #fff;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.option-btn-new:hover { background: #353b48; }
.option-btn-new.correct { background: #2ecc71 !important; color: #fff; border: 1px solid #27ae60; }
.option-btn-new.wrong { background: #ff4757 !important; color: #fff; border: 1px solid #c0392b; }
.feedback-container {
    margin-top: 20px;
    background: #2c3e50;
    padding: 15px;
    border-radius: 12px;
    border-left: 4px solid #3498db;
    animation: fadeIn 0.3s;
    display: none;
}
.next-btn-container {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 440px;
    padding: 0 20px;
    box-sizing: border-box;
    display: none;
    z-index: 100;
}
.next-btn-new {
    width: 100%;
    padding: 16px;
    background: linear-gradient(90deg, #d05ce3, #9b59b6);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(208, 92, 227, 0.4);
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Practice Mode Enhancements */
.lobby-container { padding: 20px; text-align: center; animation: fadeIn 0.4s; }
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 15px; margin: 20px 0; }
.mode-card { background: #1a1a2e; border: 2px solid #333; border-radius: 15px; padding: 20px; cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden; }
.mode-card.selected { border-color: #a29bfe; background: #24243e; box-shadow: 0 0 15px rgba(162, 155, 254, 0.3); }
.mode-icon { font-size: 2rem; margin-bottom: 10px; color: #a29bfe; }
.mode-title { font-weight: bold; font-size: 1.1rem; color: #fff; margin-bottom: 5px; }
.mode-desc { font-size: 0.8rem; color: #888; }

.diff-selector { display: flex; background: #111; padding: 5px; border-radius: 12px; margin: 20px 0; }
.diff-btn { flex: 1; padding: 10px; border: none; background: transparent; color: #666; font-weight: 600; cursor: pointer; border-radius: 8px; transition: all 0.2s; }
.diff-btn.active { background: #333; color: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.hud-container { display: flex; justify-content: space-between; align-items: center; padding: 8px 15px; background: #000; border-bottom: 1px solid #222; margin-bottom: 12px; font-size: 0.85rem; }
.diff-btn[data-level='advanced'].active { color: #f1c40f; }
.diff-btn[data-level='expert'].active { color: #ff4757; }

.hud-container { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background: #000; border-bottom: 1px solid #222; margin-bottom: 15px; font-size: 0.9rem; }
.hud-item { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.lives-box { color: #ff4757; font-size: 1.2rem; display: flex; gap: 2px; }
.timer-box { color: #fff; background: #222; padding: 5px 12px; border-radius: 20px; font-family: monospace; border: 1px solid #333; }
.timer-box.danger { color: #ff4757; border-color: #ff4757; animation: pulse 1s infinite; }
.combo-box { color: #f1c40f; font-style: italic; font-weight: 800; transform: scale(0); transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.combo-box.active { transform: scale(1.2); }

.powerups { display: flex; justify-content: center; gap: 15px; margin-top: 20px; }
.powerup-btn { width: 50px; height: 50px; border-radius: 50%; border: 2px solid #444; background: #1a1a2e; color: #fff; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; font-weight: bold; }
.powerup-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: #a29bfe; }
.powerup-btn:disabled { opacity: 0.3; cursor: not-allowed; }


.btn-practice {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(162, 155, 254, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    text-decoration: none;
    display: block;
    width: 100%;
}
.btn-practice:active {
    transform: scale(0.98);
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
/* Safe Area Spacer for standard layouts */
.bottom-spacer {
    height: calc(var(--nav-height) + var(--safe-bottom));
    width: 100%;
}

/* Profile Navigation Tabs Styling */
.profile-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0 25px;
}

.profile-tab {
    background: #1a1a2e;
    color: #888;
    border: 1px solid #333;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.profile-tab:hover {
    background: #252540;
}

.profile-tab.active {
    background: #a29bfe;
    color: #fff;
    border-color: #a29bfe;
    box-shadow: 0 4px 15px rgba(162, 155, 254, 0.3);
}
