/* ==========================================
   MULTISECT ALIGNED DESIGN TOKENS
   ========================================== */
:root {
    /* Primary Brand Colors */
    --color-primary: #D32F2F;
    --color-secondary: #1B3A57;
    --color-accent: #3B9797;
    
    /* Neutrals */
    --bg-main: #F9FAFB;
    --bg-surface: #FFFFFF;
    --color-border: #E5E7EB;
    --text-main: #111827;
    --text-light: #4B5563;
    
    /* Semantic Colors */
    --easy: #10B981;
    --medium: #F59E0B;
    --hard: #EF4444;
    
    /* Shadows & Radius */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-xl: 1rem;
    
    /* Legacy Hooks (Mapped to new tokens) */
    --primary-color: var(--color-primary);
    --glass-bg: var(--bg-surface);
    --glass-border: var(--color-border);
    --glass-shadow: var(--shadow-sm);
}




* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    background-image: radial-gradient(var(--color-border) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
    height: 100vh;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

/* ==========================================
   GLOBAL APP CONTAINER
   ========================================== */
#app-container {
    width: 100%; max-width: 900px; height: 95vh;
    background: var(--bg-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
    padding: 24px; margin: 10px;
    position: relative;
    z-index: 1;
}

/* ==========================================
   GLOBAL HEADER & SELECTORS
   ========================================== */
header { margin-bottom: 20px; }

.consolidated-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.header-meta-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
h1 { font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 1.5rem; color: var(--color-secondary); }
.topic-headline { font-family: 'Outfit', sans-serif; font-size: 1.35rem; font-weight: 700; text-align:center; margin-top: 5px; color: var(--color-primary); padding: 8px; border-radius: 8px;}


/* Difficulty Pill Logic */
.badge-container { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: white; letter-spacing: 0.5px; }
.badge-easy { background: var(--easy); }
.badge-medium { background: var(--medium); color: #fff; }
.badge-hard { background: var(--hard); }

body.hide-difficulty .badge-container { display: none !important; }

/* Exam Level Badge (Locked per track) */
.exam-level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    white-space: nowrap;
    min-height: 32px;
}

.exam-level-badge.badge-b2 {
    background: #FEE2E2;
    color: #991B1B;
    border: 1.5px solid #FCA5A5;
}

.exam-level-badge.badge-c1 {
    background: #E0E7FF;
    color: #3730A3;
    border: 1.5px solid #A5B4FC;
}

/* Mobile Options Trigger Button */
.btn-mobile-options {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-secondary);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
}

.btn-mobile-options:hover {
    background: #F1F5F9;
    border-color: var(--color-secondary);
}

/* Mobile Options Drawer Styles */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5000;
    display: flex;
    justify-content: flex-end;
    transition: opacity 0.25s ease;
}

.mobile-drawer.hidden {
    display: none;
    pointer-events: none;
}

.mobile-drawer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
}

.mobile-drawer-panel {
    position: relative;
    width: 85%;
    max-width: 340px;
    height: 100%;
    background: #FFFFFF;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 5001;
    overflow-y: auto;
    animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.mobile-drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F8FAFC;
}

.mobile-drawer-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    color: #64748B;
    cursor: pointer;
    padding: 4px;
}

.mobile-drawer-close:hover {
    color: #0F172A;
}

.mobile-drawer-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Global Part Selector Engine */
.part-selector { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.part-tab {
    background: var(--bg-surface); border: 1px solid var(--color-border);
    padding: 8px 18px; border-radius: 50px; font-weight: 600; color: var(--text-light);
    cursor: pointer; transition: all 0.2s ease; font-family: inherit;
    font-size: 0.9rem;
}
.part-tab.active { background: var(--color-secondary); color: white; border-color: var(--color-secondary); box-shadow: var(--shadow-md); }
.part-tab:hover:not(.active) { border-color: var(--color-primary); color: var(--color-primary); }

select.glass-dropdown {
    appearance: none; background: var(--bg-surface); border: 1px solid var(--color-border);
    padding: 8px 32px 8px 16px; border-radius: 8px; font-family: inherit; font-weight: 600;
    color: var(--text-main); outline: none; cursor: pointer; transition: 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
select.glass-dropdown:hover { border-color: var(--color-primary); }
#topic-meta-info { font-weight: 700; color: var(--color-secondary); font-size: 0.9rem; }

/* ==========================================
   DYNAMIC MAIN CONTENT SWAPPING
   ========================================== */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; padding-right: 5px; }
main::-webkit-scrollbar { width: 6px; } main::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 10px; }

.part-view { flex: 1; display: flex; flex-direction: column; animation: fadeIn 0.4s ease forwards; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.flex-col-gap { display: flex; flex-direction: column; gap: 10px; }
.text-center { text-align: center; }
.mt-4 { margin-top: 24px; }

/* ==========================================
   MODULAR COMPONENTS 
   ========================================== */

/* 1. Universal Question Cards (No AI border stripes) */
.question-card {
    background: #FFFFFF;
    padding: 16px 22px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--color-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    line-height: 1.5;
}
.highlight-q {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

/* Override styling specifically for Part 2 Questions */
#part2-container .question-card {
    font-size: 0.95rem;
    padding: 8px 18px;
    margin-bottom: 6px;
    border-radius: 10px;
}

/* Part 2 Single-Line Task Header */
.p2-task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
    padding: 0 4px;
    gap: 8px;
}
.p2-task-title-group {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.p2-turn-title {
    font-size: 1.15rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--color-secondary);
    white-space: nowrap;
}
.p2-header-dot {
    color: var(--text-light);
    font-weight: 700;
}
.p2-candidate-title {
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.p2-slide-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    background: #F1F5F9;
    padding: 3px 10px;
    border-radius: 12px;
}
.p2-exit-btn {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}
.p2-exit-btn:hover {
    background: #F8FAFC;
    border-color: var(--color-secondary);
}

/* 2. Part 1 Giant Cards (No AI border-top stripe) */
.giant-text { 
    font-size: 2rem;
    padding: 40px;
    font-weight: 700; 
    display: flex;
    align-items: center;
    justify-content: center; 
    min-height: 220px;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: #FFFFFF;
    color: var(--color-secondary);
    box-shadow: var(--shadow-md);
}
.instruction-text { text-align: center; color: var(--text-light); font-weight: 500; font-size: 0.95rem; margin-top: auto; padding: 20px 0; border-top: 1px dashed var(--color-border); }

/* Part 2 Active Screen Container */
#p2-active-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* 3. Part 2 Dynamic Images Engine */
#photos-container { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 16px; 
    margin-top: 10px; 
    width: 100%; 
    flex: 1; 
    min-height: 0; 
    max-height: min(38vh, 380px);
}

.photos-layout-h { 
    flex-direction: column; 
    height: 100%;
    max-height: 100%;
}
.photos-layout-v { 
    flex-direction: row; 
    height: 100%;
    max-height: 100%;
}

.photo-grp-h { 
    display: flex; 
    flex-direction: row; 
    justify-content: center; 
    align-items: center;
    gap: 12px; 
    width: 100%; 
    flex: 1; 
    min-height: 0; 
    height: calc(50% - 6px);
    max-height: 50%;
}
.photo-grp-v { 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    gap: 12px; 
    height: 100%;
    min-height: 0; 
    max-height: 100%;
}

/* B2 First 2-Photo Dedicated Split Layout */
.photos-layout-b2 {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 24px !important;
    width: 100%;
    max-width: 860px;
    margin: 15px auto 0 auto;
    flex: 1;
    min-height: 0;
}

.photos-layout-b2 .photo-card {
    max-width: 380px;
    width: auto;
    height: 100%;
    aspect-ratio: 1 / 1;
    max-height: min(38vh, 380px);
    object-fit: contain;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 4px solid white;
}

.photo-card { 
    height: 100%;
    width: auto;
    max-width: 200px; 
    max-height: 200px;
    aspect-ratio: 1 / 1; 
    object-fit: cover; 
    border-radius: var(--radius-xl); 
    cursor: pointer; 
    border: 4px solid white;
    box-shadow: var(--shadow-md); 
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease; 
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
}
.photo-grp-v .photo-card {
    height: calc(50% - 6px);
    max-height: calc(50% - 6px);
}
.photo-grp-v .photo-card:only-child {
    height: 100%;
    max-height: 200px;
}
.photo-card:hover { transform: scale(1.05) translateY(-5px); box-shadow: var(--shadow-lg); z-index: 10; }

/* 4. Part 3 Spidergram / Collaborative Logic */
#part3-container { align-items: center; padding: 20px 0; }
.spider-node { background: white; padding: 18px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); text-align: center; font-weight: 600; border: 1px solid var(--color-border); transition: all 0.3s ease; color: var(--color-secondary); }
.spider-node.central { border: 3px solid var(--color-primary); font-size: 1.35rem; font-weight: 800; background: #fff; color: var(--color-primary); box-shadow: var(--shadow-lg); }
.spider-node:hover { transform: translateY(-3px); border-color: var(--color-primary); }

.spider-board {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        ". top ."
        "left-top central right-top"
        "left-bot central right-bot";
    gap: 20px;
    column-gap: 30px;
    align-items: center;
    justify-items: center;
    width: 100%;
}
.spider-pos-top { grid-area: top; align-self: end; }
.spider-pos-left-top { grid-area: left-top; align-self: end; justify-self: end; }
.spider-pos-right-top { grid-area: right-top; align-self: end; justify-self: start; }
.spider-pos-left-bot { grid-area: left-bot; align-self: start; justify-self: end; }
.spider-pos-right-bot { grid-area: right-bot; align-self: start; justify-self: start; }
.spider-pos-central { grid-area: central; align-self: center; z-index: 10; max-width: 320px; }

/* 5. Part 4 List Mechanics */
.p4-item { padding: 24px; background: white; border-radius: var(--radius-xl); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); font-size: 1.25rem; font-weight: 600; display: flex; gap: 15px; align-items: center; color: var(--color-secondary); }
.p4-bullet { font-weight: 800; color: var(--color-primary); font-size: 1.5rem; line-height: 1; }

/* 6. Part 3 Navigation Buttons */
#p3-end-controls {
    display: flex !important;
    justify-content: center;
    gap: 15px;
    opacity: 1;
    pointer-events: auto;
}
#p3-end-controls .btn {
    transition: transform 150ms ease-in-out, box-shadow 150ms ease-in-out, border-color 150ms ease-in-out, background 150ms ease-in-out, color 150ms ease-in-out;
    opacity: 1;
}

/* ==========================================
   GLOBAL FOOTERS AND TIMING MODALS
   ========================================== */
footer { display: flex; flex-direction: column; gap: 15px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--color-border); }
.controls-row { display: flex; justify-content: center; align-items: center; gap: 15px; }

.timer-display { font-family: 'Outfit', sans-serif; font-size: 2.25rem; font-weight: 800; color: var(--color-secondary); background: #f3f4f6; padding: 4px 24px; border-radius: 12px; min-width: 140px; text-align: center; transition: all 0.3s ease;}
.timer-warning { background: var(--color-primary); color: white; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.8; } }

.btn { 
    display: inline-block;
    padding: var(--spacing-3, 0.75rem) var(--spacing-6, 2rem); 
    border-radius: var(--radius-md); 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 150ms ease-in-out; 
    font-family: inherit;
    border: 2px solid transparent;
    text-align: center;
    line-height: 1.375;
}
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-secondary); border-color: var(--color-secondary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-secondary { background: white; color: var(--color-secondary); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.glass-btn-icon { font-size: 1.5rem; padding: 8px 16px; }
.dropdown-item:hover { background: #f3f4f6 !important; }

.nav-row { gap: 20px; }
.nav-btn { background: none; border: none; font-weight: 800; color: var(--text-light); cursor: pointer; transition: 0.2s ease; font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; }
.nav-btn:hover { color: var(--color-primary); transform: translateX(2px); }
#btn-prev:hover { transform: translateX(-2px); }

.progress-bar-container { flex: 1; height: 10px; background: #e5e7eb; border-radius: 10px; overflow: hidden; }
#progress-bar { height: 100%; width: 0%; background: var(--color-accent); transition: width 0.4s ease; }

/* Lightbox Sub-module Overlay */
#lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; margin: 0; background: rgba(27, 58, 87, 0.95); z-index: 1000; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s ease; }
#lightbox.hidden { opacity: 0; pointer-events: none; }
#lightbox-img { max-width: 90%; max-height: 90%; border-radius: var(--radius-xl); border: 8px solid white; box-shadow: var(--shadow-lg); transition: transform 0.3s ease; }
#lightbox.hidden #lightbox-img { transform: scale(0.9); }
#lightbox-close { position: absolute; top: 20px; right: 30px; background: none; border: none; color: white; font-size: 3.5rem; cursor: pointer; line-height: 1; transition: transform 0.2s ease; }
#lightbox-close:hover { transform: scale(1.1); }

@media (max-width: 600px) {
    /* 1. Global Viewport & Flex Enforcer */
    body {
        overflow: hidden;
        height: 100dvh;
        width: 100vw;
    }

    #app-container {
        height: 100dvh;
        margin: 0;
        border-radius: 0;
        padding: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* 2. Mobile App Bar Layout */
    header {
        margin-bottom: 6px;
        flex-shrink: 0;
    }

    .desktop-control {
        display: none !important;
    }

    .btn-mobile-options {
        display: inline-flex !important;
    }

    .consolidated-header {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 4px;
        padding: 0;
        width: 100%;
    }

    /* Top Bar: Centered Progress Counter, Options Button on right */
    .consolidated-header .header-meta-group {
        order: 0;
        width: 100%;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding: 0 4px;
        position: relative;
        min-height: 38px;
    }

    #topic-meta-info {
        font-size: 0.85rem;
        font-weight: 800;
        color: var(--color-secondary);
        background: #F1F5F9;
        padding: 4px 14px;
        border-radius: 20px;
        letter-spacing: 0.5px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    /* Horizontal Part Bar: Clean, Evenly Spaced, No Wrap */
    .consolidated-header .part-selector {
        order: 1;
        display: flex;
        width: 100%;
        gap: 5px;
        justify-content: space-between;
        flex-wrap: nowrap;
        padding: 2px 0;
    }

    .part-tab {
        flex: 1;
        text-align: center;
        padding: 7px 4px;
        font-size: 0.75rem;
        font-weight: 700;
        white-space: nowrap;
        border-radius: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .part-tab.active {
        background: var(--color-secondary);
        color: white;
        box-shadow: 0 2px 4px rgba(27, 54, 93, 0.25);
    }

    .topic-headline {
        font-size: 0.88rem;
        padding: 4px 8px;
        margin-top: 2px;
        border-radius: 6px;
        white-space: normal;
        overflow-wrap: anywhere;
        max-width: 100%;
    }

    .badge-container {
        padding: 2px 8px;
        font-size: 0.65rem;
    }

    /* 3. Main Content Distribution */
    main {
        flex: 1;
        gap: 8px;
        padding-right: 0;
        overflow-y: auto; /* Allow scroll only when content genuinely overflows */
        overflow-x: hidden;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .part-view {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    /* 4. Component Refinement (Zero-Scroll logic & No AI borders) */
    .question-card {
        padding: 10px 16px;
        font-size: 0.88rem;
        margin-bottom: 5px;
        border: 1px solid #E2E8F0;
        border-radius: 10px;
    }

    #part2-container .question-card {
        padding: 6px 14px;
        font-size: 0.85rem;
        margin-bottom: 4px;
        border-radius: 10px;
    }

    .p2-task-header {
        margin-bottom: 6px;
        gap: 4px;
    }
    .p2-turn-title {
        font-size: 0.95rem;
    }
    .p2-candidate-title {
        font-size: 0.82rem;
    }
    .p2-slide-badge {
        font-size: 0.75rem;
        padding: 2px 8px;
    }
    .p2-exit-btn {
        padding: 6px 14px;
        font-size: 0.78rem;
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Part 1 & Part 4 Card Polish */
    .p1-card-header {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 12px 14px !important;
    }

    .p1-theme-badge-wrap {
        width: 100% !important;
        text-align: left !important;
        flex-shrink: 1 !important;
        margin-top: 2px !important;
    }

    #p1-theme-badge {
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
        max-width: 100% !important;
        display: inline-block !important;
        line-height: 1.3 !important;
    }

    .p1-active-card,
    .p4-active-card {
        margin-top: 15px !important;
    }

    .p1-active-card > div:last-child,
    .p4-active-card > div:last-child {
        padding: 16px !important;
    }

    .p4-active-card > div:first-child {
        padding: 12px 14px !important;
    }

    #p4-active-theme-title {
        font-size: 1.25rem !important;
    }

    #p1-candidate-turn {
        font-size: 1.25rem !important;
    }

    #p1-question,
    #p4-question {
        font-size: 1.15rem !important;
        min-height: 100px !important;
    }

    .giant-text {
        font-size: 1.25rem;
        padding: 15px;
        min-height: 100px;
        flex: 1;
    }

    /* 5. Image Scaling (Part 2) */
    #photos-container {
        flex: 1 1 auto;
        min-height: 80px;
        margin-top: 5px;
        gap: 8px;
        max-height: 42vh;
        overflow: hidden;
    }

    .photo-card {
        border-width: 2px;
        max-width: 160px;
        max-height: 100%;
        aspect-ratio: 1 / 1;
        object-fit: cover;
    }

    .photos-layout-b2 {
        flex-direction: row !important;
        gap: 10px !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
    }
    .photos-layout-b2 .photo-card {
        flex: 1 1 0;
        width: calc(50% - 5px) !important;
        max-width: calc(50% - 5px) !important;
        height: auto !important;
        max-height: none !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }

    /* 6. Spidergram / Collaborative Logic */
    .spider-board {
        display: flex;
        flex-direction: column;
        gap: 8px;
        justify-content: flex-start;
        flex: 1;
        min-height: 0;
        margin-top: 6px;
    }
    .spider-node {
        padding: 8px 12px;
        font-size: 0.85rem;
        margin: 0;
    }
    .spider-node.central {
        font-size: 0.95rem;
        margin-bottom: 5px;
        order: -1;
        max-width: 100%;
    }
    .spider-pos-top,
    .spider-pos-left-top,
    .spider-pos-right-top,
    .spider-pos-left-bot,
    .spider-pos-right-bot {
        align-self: stretch;
        width: 100%;
        margin: 0;
    }
    #p3-end-controls {
        flex-direction: column;
        width: 100%;
        gap: 8px;
        margin-top: 10px;
    }
    #p3-end-controls .btn {
        width: 100%;
        min-height: 44px;
    }

    /* 7. Footer & Controls Optimization */
    footer {
        margin-top: 8px;
        padding-top: 8px;
        gap: 10px;
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    /* Tap targets at least 44px (visible elements only) */
    .btn-mobile-options:not(.hidden),
    .p2-exit-btn:not(.hidden),
    .nav-btn:not(.hidden),
    #btn-prev:not(.hidden), #btn-next:not(.hidden),
    #btn-play:not(.hidden), #btn-reset:not(.hidden), #mode-toggle:not(.hidden),
    #p1-exit-btn:not(.hidden), #p4-exit-btn:not(.hidden),
    #p4-bridged-exit-btn:not(.hidden), #p4-exit-session-btn:not(.hidden),
    .mobile-drawer-close:not(.hidden),
    select.glass-dropdown:not(.hidden) {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Enforce hidden elements stay hidden on mobile */
    .hidden,
    [hidden],
    button.hidden {
        display: none !important;
    }

    #p1-exit-btn,
    #p4-exit-btn {
        top: -2px !important;
        padding: 6px 14px !important;
    }

    .controls-row {
        gap: 8px;
    }

    .timer-display {
        font-size: 1.4rem;
        min-width: 85px;
        padding: 2px 10px;
    }

    .btn:not(.hidden) {
        padding: 8px 14px;
        font-size: 0.85rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .glass-btn-icon {
        padding: 6px 10px;
        font-size: 1.1rem;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-btn {
        font-size: 0.8rem;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
    }

    .progress-bar-container {
        height: 6px;
    }

    .instruction-text {
        padding: 5px 0;
        font-size: 0.7rem;
        margin-top: 0;
    }
}

/* ==========================================
   SYNC FOLLOWER MODE
   When body has .sync-follower, disable all
   interactive nav/timer/session buttons.
   ========================================== */
body.sync-follower .part-tab,
body.sync-follower .nav-btn,
body.sync-follower #btn-play,
body.sync-follower #btn-reset,
body.sync-follower #btn-next,
body.sync-follower #btn-prev,
body.sync-follower #mode-toggle,
body.sync-follower #p1-start-btn,
body.sync-follower #p1-pause-btn,
body.sync-follower #p1-back-btn,
body.sync-follower #p1-next-btn,
body.sync-follower #p1-reset-timer-btn,
body.sync-follower #p1-exit-btn,
body.sync-follower #p1-restart-btn,
body.sync-follower #p1-end-session-btn,
body.sync-follower #p2-start-btn,
body.sync-follower #p2-exit-btn,
body.sync-follower #p2-restart-btn,
body.sync-follower #p2-end-session-btn,
body.sync-follower #p2-repeat-btn,
body.sync-follower #p3-next-scenario-btn,
body.sync-follower #p3-proceed-p4-btn,
body.sync-follower #p4-start-btn,
body.sync-follower #p4-exit-btn,
body.sync-follower #p4-pause-btn,
body.sync-follower #p4-back-btn,
body.sync-follower #p4-next-btn,
body.sync-follower #p4-reset-timer-btn,
body.sync-follower #p4-restart-btn,
body.sync-follower #p4-exit-session-btn,
body.sync-follower #p4-end-session-btn,
body.sync-follower #p4-bridged-exit-btn,
body.sync-follower #category-select,
body.sync-follower #candidates-select,
body.sync-follower #p1-mode-select,
body.sync-follower #p1-candidates-select,
body.sync-follower #p1-theme-select,
body.sync-follower #p2-candidates-select,
body.sync-follower #p2-theme-select,
body.sync-follower #p4-theme-select,
body.sync-follower #p4-candidates-select {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}
