/* WORK PAGE CORE */
.work-main { padding-top: 60px; min-height: 100vh; display: flex; justify-content: center; padding-bottom: 50px; }

/* BACKGROUND ANIMATIONS */
@keyframes twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.2; transform: scale(0.8); } }
.star.blink { animation: twinkle 2s infinite ease-in-out; }
@keyframes drift { from { transform: translateX(-200px); } to { transform: translateX(110vw); } }
.moving-cloud-1, .moving-cloud-2 { 
    position: absolute; animation: drift 65s linear infinite; 
    z-index: 0; pointer-events: none; opacity: 0.4;
}

/* ========================================= */
/* SHOP UI REDESIGN (DARK RETRO THEME)       */
/* ========================================= */
.shop-ui {
    background: #081225; 
    border: 4px solid #4a4a8c; 
    box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.6);
    width: 95%; max-width: 1200px; 
    position: relative; 
    border-radius: 4px; 
    z-index: 10;
    display: flex;
    flex-direction: column;
}

/* 1. Store Graphic Section */
.shop-graphic {
    width: 100%;
    height: 250px;
    border-bottom: 4px solid #4a4a8c;
    background: #050d1f;
    overflow: hidden;
}
.shop-graphic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.store-fallback {
    display: none; width: 100%; height: 100%;
    align-items: center; justify-content: center;
    font-family: 'Press Start 2P', cursive;
    color: #4a4a8c; font-size: 1.2rem;
    background: repeating-linear-gradient(45deg, #050d1f, #050d1f 10px, #0a1530 10px, #0a1530 20px);
}

/* 2. Tabs Section & Hire Me Button */
.shop-tabs {
    display: flex;
    justify-content: space-between; /* Pushes tabs left, button right */
    align-items: flex-end; /* Aligns them to the bottom line */
    background: #07152c;
    border-bottom: 4px solid #4a4a8c;
    padding: 15px 20px 0;
    gap: 10px;
}
.tabs-group {
    display: flex;
    gap: 10px;
}
.shop-tab-btn {
    background: #10213f;
    border: 4px solid #4a4a8c;
    border-bottom: none;
    color: #83d6ff;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    padding: 15px 25px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    border-radius: 6px 6px 0 0;
    transform: translateY(4px);
}
.shop-tab-btn:hover {
    background: #1a3668;
    color: #fff;
}
.shop-tab-btn.active {
    background: #ff77da;
    border-color: #ff77da;
    color: #0d1117;
    transform: translateY(4px);
    padding-bottom: 19px;
    z-index: 2;
}

/* New Green Hire Me Button */
.hire-me-btn {
    background: #0d1117;
    color: #7cff9b;
    border: 3px solid #7cff9b;
    box-shadow: 4px 4px 0 rgba(124, 255, 155, 0.2);
    font-family: 'Press Start 2P', cursive;
    font-size: 0.75rem;
    padding: 12px 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
    margin-bottom: 10px; /* Space off the border */
    border-radius: 4px;
}
.hire-me-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(124, 255, 155, 0.4);
    background: rgba(124, 255, 155, 0.1);
    color: #fff;
}

/* 3. Shop Body Layout */
.shop-layout {
    display: flex;
    flex-direction: row;
    padding: 25px 20px;
    gap: 25px;
    background: #0a1833;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.4);
    min-height: 500px;
}

/* 4. Sidebar */
.shop-sidebar {
    width: 250px;
    flex-shrink: 0;
    transition: opacity 0.3s;
}

.role-list {
    list-style: none; padding: 0; margin: 0;
}
.role-list li {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    color: #83d6ff;
    padding: 12px 15px;
    margin-bottom: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
    border: 3px solid #1b5e78;
    background: #0d1e38;
    border-radius: 6px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
}
.role-list li:hover { 
    background: #163b67; 
    color: #ffd84f; 
    border-color: #ffd84f;
}
.role-list li.active {
    background: #ff77da;
    border-color: #ffb7ec;
    color: #0d1117;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}
.role-list li i { width: 16px; height: 16px; }

/* 5. Inventory Grid */
.shop-inventory {
    flex-grow: 1;
    display: grid;
    gap: 20px;
    align-content: start;
}
.shop-inventory.grid-snapshots { grid-template-columns: repeat(2, 1fr); }
.shop-inventory.grid-archives { grid-template-columns: repeat(2, 1fr); }

/* 6. Horizontal Card Design (Snapshots) */
.shop-card {
    display: flex;
    flex-direction: row;
    background: #10213f;
    border: 3px solid #4cc8ff;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: 6px 6px 0 #06101d, inset 0 0 0 2px rgba(255,255,255,0.05);
    min-height: 150px;
}
.shop-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 9px 9px 0 #06101d;
    border-color: #ff77da;
}

.shop-card-img {
    width: 40%;
    min-width: 140px;
    background: #000;
    border-right: 3px solid #4cc8ff;
    overflow: hidden;
}
.shop-card:hover .shop-card-img { border-right-color: #ff77da; }
.shop-card-img img {
    width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity 0.2s;
}
.shop-card:hover .shop-card-img img { opacity: 1; }

.shop-card-body { width: 60%; display: flex; flex-direction: column; }

.shop-card-top {
    background: #1b3d6e; color: #ffd84f; padding: 8px 10px; font-family: 'Space Mono', monospace; font-size: 0.65rem; font-weight: bold; text-transform: uppercase; border-bottom: 2px solid #315d82; letter-spacing: 0.5px;
}
.shop-card:hover .shop-card-top { background: #ff77da; color: #0d1117; }

.shop-card-content { padding: 14px 12px; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.shop-card-title { font-family: 'Press Start 2P', cursive; font-size: 0.65rem; color: #fff; line-height: 1.5; margin-bottom: 10px; text-shadow: 2px 2px 0 #09213a; }
.shop-card-icons { display: flex; gap: 8px; font-size: 1.1rem; }

.shop-card-bottom {
    background: #081325; color: #7cff9b; padding: 8px 10px; font-family: 'Press Start 2P', cursive; font-size: 0.55rem; border-top: 2px solid #2f80a7; display: flex; align-items: center; justify-content: space-between;
}

//* Artifact Cards - Now matches your Global Theme and supports Images */
.artifact-card {
    background-color: #10213f; 
    border: 4px solid #58d8ff; 
    box-shadow: inset 0 0 0 4px rgba(88,216,255,0.1), 8px 8px 0 #06101d;
    color: #fff;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    z-index: 10;
    position: relative;
    overflow: hidden; /* Keeps the image cleanly inside the borders */
}

.artifact-card:hover {
    transform: translate(-4px, -4px);
    border-color: #ff77da;
    box-shadow: inset 0 0 0 4px rgba(255,119,218,0.1), 12px 12px 0 #06101d;
}

/* New Image Container */
.artifact-img {
    width: 100%;
    height: 150px;
    border-bottom: 4px solid #58d8ff;
    background: #000;
    overflow: hidden;
    transition: border-color 0.2s ease;
}
.artifact-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.3s ease;
}
.artifact-card:hover .artifact-img { border-bottom-color: #ff77da; }
.artifact-card:hover .artifact-img img { opacity: 1; transform: scale(1.05); }

/* Text Content Container */
.artifact-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex-grow: 1;
}

.artifact-icons {
    font-size: 1.8rem;
    margin-bottom: 15px;
    filter: drop-shadow(2px 2px 0 #000);
}

.artifact-role {
    background: #ff77da;
    color: #0d1117;
    padding: 6px 12px;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    font-weight: bold;
    margin-bottom: 15px;
    border: 2px solid #fff;
}

.artifact-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: #ffd84f;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 20px;
    line-height: 1.5;
}

.artifact-btn {
    margin-top: auto;
    background: #0d1117;
    color: #7cff9b;
    border: 2px solid #7cff9b;
    padding: 8px 15px;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    font-weight: bold;
    transition: 0.2s;
}
.artifact-card:hover .artifact-btn {
    background: #7cff9b;
    color: #0d1117;
}
/* ========================================= */
/* MODALS                                    */
/* ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 999; display: none; justify-content: center; align-items: center; padding: 2rem; }
.modal-overlay.active { display: flex; }
.close-btn { 
    position: absolute; top: 1.5rem; right: 1.5rem; z-index: 100;
    background: #fff; border: 4px solid #000; color: #000; 
    font-family: 'Space Mono', monospace; font-weight: bold; font-size: 0.9rem; 
    padding: 0.5rem 1rem; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: 0.2s; 
}
.close-btn:hover { background: #f864c4; color: #fff; }

.advanced-modal {
    background: #0d1117; border: 4px solid #fff; box-shadow: 15px 15px 0 #5a2146;
    width: 95%; max-width: 1200px; height: 90vh; overflow-y: auto; overflow-x: hidden; padding: 0; position: relative; border-radius: 8px;
}
.advanced-modal::-webkit-scrollbar { width: 10px; }
.advanced-modal::-webkit-scrollbar-thumb { background: #ff77da; }

.modal-hero { padding: 4rem 3rem 2rem; border-bottom: 4px dashed #333; position: relative; z-index: 2; }
.modal-tags { display: flex; gap: 15px; margin-bottom: 1rem; }
.role-tag, .time-tag { font-family: 'Space Mono', monospace; font-size: 0.8rem; font-weight: bold; padding: 5px 10px; border: 2px solid; }
.role-tag { color: #000; background: #f8f66a; border-color: #fff; }
.time-tag { color: #6ce8ff; border-color: #6ce8ff; }
.glitch-title { font-family: 'Press Start 2P', cursive; font-size: 1.8rem; color: #fff; line-height: 1.4; text-transform: uppercase; }

.hero-see-more-btn {
    background: rgba(108, 232, 255, 0.1); border: 2px solid #6ce8ff; color: #6ce8ff;
    font-family: 'Press Start 2P', cursive; font-size: 0.6rem; padding: 10px 15px;
    text-decoration: none; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s;
}
.hero-see-more-btn:hover { background: #6ce8ff; color: #000; box-shadow: 0 0 10px #6ce8ff; }

.tldr-section { padding: 3rem; background: #151b23; }
.tldr-section h3 { font-family: 'Press Start 2P', cursive; font-size: 1rem; color: #fff; margin-bottom: 2rem; }
.tldr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tldr-box { padding: 20px; border: 3px solid #333; font-family: 'Space Mono', monospace; font-size: 0.9rem; line-height: 1.6; color: #ccc; }
.tldr-box h4 { font-family: 'Press Start 2P', cursive; font-size: 0.7rem; margin-bottom: 15px; }
.problem-box h4 { color: #ff5555; }
.solution-box h4 { color: #7cff9b; }
.impact-box h4 { color: #ffd84f; }

.dynamic-content-area { padding: 3rem; overflow-x: hidden;}
.section-heading { font-family: 'Press Start 2P', cursive; font-size: 1.2rem; color: #ff77da; margin-bottom: 2rem; text-transform: uppercase; }

.before-after-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; position: relative; }
.ba-box { border: 4px solid #444; padding: 15px; background: #000; }
.ba-label { font-family: 'Press Start 2P', cursive; font-size: 0.8rem; text-align: center; margin-bottom: 15px; }
.label-before { color: #ff5555; }
.label-after { color: #7cff9b; }

.booklet-carousel { display: flex; overflow-x: auto; overflow-y: hidden; gap: 20px; padding-bottom: 20px; scroll-snap-type: x mandatory; }
.booklet-page { min-width: 90%; scroll-snap-align: center; border: 4px solid #ffd84f; background: #1a1a1a; padding: 20px; box-sizing: border-box; }
.booklet-page img { width: 100%; height: auto; display: block; background: #000; border: 2px solid #444; margin-bottom: 15px; border-radius: 4px; }
.booklet-desc { font-family: 'Space Mono', monospace; color: #ccc; font-size: 0.9rem; }

.theme-graphics { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 1; opacity: 0.1; }
.theme-icon { position: absolute; font-size: 4rem; filter: grayscale(100%); }

/* RETRO COIN POPUP */
.coin-popup {
    position: fixed; top: 70px; right: 5vw; color: #ffd84f; font-family: 'Press Start 2P', cursive, monospace;
    font-size: 14px; text-shadow: 2px 2px 0px #000, -1px -1px 0px #000, 1px -1px 0px #000, -1px 1px 0px #000, 1px 1px 0px #000;
    z-index: 9999; pointer-events: none; animation: coinFloat 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes coinFloat { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-40px) scale(1.4); opacity: 0; } }

/* MOBILE ADJUSTMENTS */
@media (max-width: 900px) {
    .shop-layout { flex-direction: column; padding: 15px; }
    .shop-sidebar { width: 100%; }
    .role-list { display: flex; overflow-x: auto; gap: 10px; padding-bottom: 10px; }
    .role-list li { margin-bottom: 0; white-space: nowrap; flex-shrink: 0; }
    .shop-inventory.grid-snapshots, .shop-inventory.grid-archives { grid-template-columns: 1fr; }
    .shop-tabs { flex-wrap: wrap; padding: 10px; align-items: center; }
    .tabs-group { width: 100%; justify-content: flex-start; margin-bottom: 10px;}
    .shop-tab-btn { transform: none; border-radius: 4px; border-bottom: 4px solid #4a4a8c; flex: 1;}
    .shop-tab-btn.active { transform: none; padding-bottom: 15px; }
    .hire-me-btn { width: 100%; justify-content: center; margin-bottom: 0;}
}

/* ========================================= */
/* THE ARCHIVES (GLOBAL THEME + MARIO SCENE) */
/* ========================================= */

.shop-inventory.grid-archives {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 35px;
    background-color: #0b1831; /* Global Theme dark blue background */
    background-image: radial-gradient(circle, rgba(88,216,255,0.15) 2.5px, transparent 2.5px);
    background-size: 16px 16px;
    padding: 60px 20px 140px 20px; /* Extra padding at bottom for the ground */
    border: 4px solid #4a4a8c;
    border-radius: 8px;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
    position: relative;
    overflow: hidden;
    min-height: 600px;
}

/* Artifact Cards - Now matches your Global Theme */
.artifact-card {
    background-color: #10213f; 
    border: 4px solid #58d8ff; 
    box-shadow: inset 0 0 0 4px rgba(88,216,255,0.1), 8px 8px 0 #06101d;
    padding: 25px 20px;
    color: #fff;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    z-index: 10;
    position: relative;
}

.artifact-card:hover {
    transform: translate(-4px, -4px);
    border-color: #ff77da;
    box-shadow: inset 0 0 0 4px rgba(255,119,218,0.1), 12px 12px 0 #06101d;
}

.artifact-icons {
    font-size: 1.8rem;
    margin-bottom: 15px;
    filter: drop-shadow(2px 2px 0 #000);
}

.artifact-role {
    background: #ff77da;
    color: #0d1117;
    padding: 6px 12px;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    font-weight: bold;
    margin-bottom: 15px;
    border: 2px solid #fff;
}

.artifact-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: #ffd84f;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 20px;
    line-height: 1.5;
}

.artifact-btn {
    margin-top: auto;
    background: #0d1117;
    color: #7cff9b;
    border: 2px solid #7cff9b;
    padding: 8px 15px;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    font-weight: bold;
    transition: 0.2s;
}
.artifact-card:hover .artifact-btn {
    background: #7cff9b;
    color: #0d1117;
}

/* --- DETAILED 8-BIT SCENERY ELEMENTS --- */
.archive-scene-layer {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; z-index: 1;
}

/* Ground */
.archive-ground {
    position: absolute; left: 0; right: 0; bottom: 0; height: 50px;
    background: #8b4513; border-top: 8px solid #2e8b57;
    background-image: 
        linear-gradient(rgba(0,0,0,0.3) 2px, transparent 2px),
        linear-gradient(90deg, rgba(0,0,0,0.3) 2px, transparent 2px);
    background-size: 32px 16px;
}

/* Hills */
.archive-hill {
    position: absolute; bottom: 50px; 
    background: #113826; border: 4px solid #0a2417;
    border-radius: 50% 50% 0 0;
}

/* Pipes */
.archive-pipe {
    position: absolute; bottom: 50px; width: 60px; height: 80px; background: #29b84f;
    border-left: 6px solid #62ef72; border-right: 6px solid #14712e; border-top: 10px solid #14712e;
}
.archive-pipe::after {
    content: ''; position: absolute; top: -14px; left: -10px; right: -10px; height: 20px;
    background: #33d85d; border-bottom: 4px solid #148739;
}

/* Floating Blocks */
.archive-brick {
    position: absolute; width: 32px; height: 32px;
    background: #b05c3c; border: 2px solid #5c2710;
    box-shadow: inset -2px -2px 0 #7a361a, inset 2px 2px 0 #d97d55;
}
.archive-q-block {
    position: absolute; width: 32px; height: 32px;
    background: #ffd84f; border: 2px solid #b38b14;
    box-shadow: inset -2px -2px 0 #d9a012, inset 2px 2px 0 #ffe98a;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Press Start 2P', cursive; font-size: 16px; color: #b38b14;
    animation: blockBop 2s infinite ease-in-out;
}

/* Coins & Clouds */
.archive-scene-coin {
    position: absolute; width: 16px; height: 24px;
    background: #ffd84f; border: 2px solid #b38b14; border-radius: 50%;
    animation: coinSpin 1s infinite linear;
}
.archive-cloud {
    position: absolute; width: 80px; height: 24px; background: rgba(255,255,255,0.4);
    border-radius: 20px; box-shadow: 20px -10px 0 rgba(255,255,255,0.4), 40px 0 0 rgba(255,255,255,0.4);
}
.archive-plant {
    position: absolute; font-size: 2.5rem; filter: drop-shadow(2px 2px 0 #000);
    animation: plantBite 1.5s infinite alternate;
}

/* Animations */
@keyframes plantBite { 0% { transform: translateY(0); } 100% { transform: translateY(12px); } }
@keyframes blockBop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes coinSpin { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.1); } 100% { transform: scaleX(1); } }

/* --- INTERNAL MODAL STYLING (Kept Intact for Popups) --- */
.retro-dialogue-box {
    background-color: #b07064; border: 6px solid #23191f; 
    box-shadow: inset 0 0 0 4px #d49586, 8px 8px 0 rgba(0,0,0,0.4);
    padding: 25px; color: #fff; margin-bottom: 20px; border-radius: 4px; font-family: 'Space Mono', monospace;
}
.punchy-phrase {
    font-family: 'Press Start 2P', cursive; font-size: 1.1rem; color: #ffd84f;
    text-shadow: 3px 3px 0 #000; line-height: 1.6; margin-bottom: 15px; text-transform: uppercase; display: inline-block;
}
.retro-sprite { font-size: 2rem; vertical-align: middle; margin-right: 10px; filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5)); }
.pdf-container { width: 100%; height: 65vh; min-height: 400px; border: 4px solid #23191f; background: #000; margin-top: 15px; }

/* Mobile Optimizations */
@media (max-width: 768px) {
    .shop-inventory.grid-archives { padding: 30px 15px 100px 15px; }
    .artifact-card { max-width: 100%; width: 100%; }
    .archive-hill, .archive-cloud { opacity: 0.3; } /* Dim background elements so text stands out */
    .archive-pipe { display: none; } /* Hide pipes on mobile to prevent overlap */
    .archive-plant { display: none; }
}

/* ========================================= */
/* MODAL MOBILE OPTIMIZATION & VISUAL DEPTH  */
/* ========================================= */

/* Enhancing the TLDR section to look like retro item stats */
.tldr-box {
    background: #10213f; 
    border: 4px solid #4a4a8c;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.05), 6px 6px 0 #06101d;
    transition: transform 0.2s;
}
.tldr-box:hover { transform: translateY(-4px); }
.problem-box { border-color: #ff5555; }
.solution-box { border-color: #7cff9b; }
.impact-box { border-color: #ffd84f; }

/* Pixel divider for breaking up long modal content cleanly */
.pixel-divider {
    height: 4px; 
    background: repeating-linear-gradient(90deg, #4a4a8c, #4a4a8c 12px, transparent 12px, transparent 24px);
    margin: 2.5rem 0;
    opacity: 0.5;
}

/* Ensure Videos and IFrames are responsive */
iframe { max-width: 100%; }

/* --- MOBILE SPECIFIC RULES FOR MODALS --- */
@media (max-width: 768px) {
    /* Make modal take over the screen on phones for maximum space */
    .advanced-modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    /* Close button padding fix for full screen */
    .close-btn { top: 10px; right: 10px; font-size: 0.7rem; padding: 0.4rem 0.6rem; }
    
    /* Adjust padding to maximize reading area on small screens */
    .modal-hero { padding: 4rem 1rem 1rem !important; }
    .tldr-section { padding: 1.5rem 1rem !important; }
    .dynamic-content-area { padding: 1.5rem 1rem !important; }
    
    /* Stack grids vertically */
    .tldr-grid { grid-template-columns: 1fr !important; gap: 15px; }
    .before-after-grid { grid-template-columns: 1fr !important; gap: 20px; }
    
    /* Booklet tweaks for phone */
    .booklet-page { min-width: 100% !important; }
    
    /* Archive Modal Mobile Fixes */
    #artifactModal .modal-hero { padding: 3.5rem 1rem 1rem !important; }
    #artifactContentArea { padding: 1.5rem 1rem !important; }
    .pdf-container { height: 60vh !important; border-width: 2px; }
    
    /* Dialogue boxes shouldn't have massive padding on phones */
    .retro-dialogue-box { padding: 15px; border-width: 4px; }
    .punchy-phrase { font-size: 0.85rem; }
    
    /* Scale down giant titles */
    .glitch-title { font-size: 1.3rem; }
}

/* ========================================= */
/* GLOBAL MOBILE NAV BAR OPTIMIZATION        */
/* ========================================= */
@media (max-width: 768px) {
    .hud { padding: 12px 15px; }
    .hud-inner { 
        display: flex; 
        flex-wrap: wrap; 
        justify-content: space-between; 
        align-items: center; 
        gap: 10px; 
    }
    /* Forces Brand and Stats to the top row */
    .brand { order: 1; font-size: 1.1rem; margin: 0; }
    .hud-stats { order: 2; margin: 0; gap: 8px; }
    .stat-box { padding: 8px 10px; font-size: 0.7rem; }
    
    /* Forces Nav to the bottom row, making it scrollable with large tap targets */
    .nav { 
        order: 3; 
        width: 100%; 
        display: flex; 
        overflow-x: auto; 
        justify-content: flex-start; 
        gap: 12px; 
        padding: 15px 0 5px 0; 
        border-top: 2px dashed #1b5e78; 
        margin-top: 5px;
        -webkit-overflow-scrolling: touch;
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { 
        font-size: 0.75rem !important; 
        padding: 10px 15px !important; 
        white-space: nowrap; 
        background: rgba(255,255,255,0.05); 
        border: 1px solid #1b5e78; 
        border-radius: 4px;
    }
}

/* ========================================= */
/* MOBILE I.A. DIAGRAM & MODAL OPTIMIZATION  */
/* ========================================= */
@media (max-width: 768px) {
    /* 1. Modal takes full screen width and height */
    .advanced-modal {
        width: 100% !important; max-width: 100% !important; height: 100vh !important;
        border-radius: 0 !important; border: none !important; border-top: 4px solid #ff77da !important;
    }

    /* 2. Turn all complex IA diagrams into scrollable, pannable maps */
    .retro-content,
    .dynamic-content-area div[style*="overflow-x: auto"],
    .dynamic-content-area div[style*="overflow: auto"] {
        overflow: auto !important;
        max-height: 70vh !important; /* Enable vertical scrolling */
        padding: 15px !important;
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        display: block !important; 
    }

    /* 3. Prevent text from wrapping inside the tree nodes, ensuring the layout holds its shape */
    .ia-parent, .ia-tag, .v-node, .h-node, .h-leaf, .ia-node-p, .ia-sub-node, .ia-filter, .ia-search {
        white-space: nowrap !important;
        min-width: max-content !important;
        height: auto !important;
    }
    
    /* 4. Keep rows horizontal so the original tree structure does not break */
    .v-row, .h-branch, .dynamic-content-area div[style*="display: flex; align-items: flex-start;"] {
        flex-direction: row !important;
        min-width: max-content !important;
        flex-wrap: nowrap !important;
    }

    /* 5. Fix Images and Videos to fit the mobile screen natively */
    .dynamic-content-area img, 
    .dynamic-content-area video, 
    .dynamic-content-area iframe {
        width: 100% !important;
        min-width: 0 !important; /* Removes the 600px forced width */
        height: auto !important;
        max-width: 100% !important;
        object-fit: contain;
    }
}
