
        :root{
            --bg1:#0f172a;
            --bg2:#1e293b;
            --accent1:#f59e0b;
            --accent2:#10b981;
            --accent3:#3b82f6;
            --text-light:#f1f5f9;
            --text-dark:#0f172a;
            --step-w:180px;
            --step-h:70px;
            --radius:20px;
            --glow:0 0 30px rgba(245, 158, 11, 0.3);
        }
        
        *{box-sizing:border-box}
        
        body{
            margin:0;
            font-family:"Poppins",system-ui,Roboto,Segoe UI,Arial;
            background: linear-gradient(135deg, var(--bg1), var(--bg2));
            color:var(--text-light);
            min-height:100vh;
            display:flex;
            flex-direction:column;
            padding:0;
        }

        /* OVERRIDE NAVBAR.CSS STYLES FOR SECONDARY HEADER */
        .secondaryHeader .lazy {
            opacity: 1 !important;
            background: none !important;
            animation: none !important;
        }
        
        .secondaryHeader img.lazy {
            display: block !important;
            visibility: visible !important;
        }

        .secondaryHeader img {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }

        /* Navbar Styles */
        #navbar {
            background: linear-gradient(145deg, rgba(30,41,59,0.95), rgba(15,23,42,0.98));
            padding: 15px 20px;
            border-bottom: 2px solid rgba(255,255,255,0.1);
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }

        /* Secondary Header Styles */
        .secondaryHeader {
            background: linear-gradient(145deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
            padding: 15px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 2px solid rgba(255,255,255,0.1);
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
            position: relative;
            z-index: 9999;
        }

        .secondaryHeader a {
            transition: transform 0.3s ease;
            display: flex;
            align-items: center;
        }

        .secondaryHeader a:hover {
            transform: scale(1.1);
        }

        .secondaryHeader p {
            margin: 0;
            font-weight: 700;
            font-size: 18px;
            background: linear-gradient(135deg, var(--accent1), var(--accent2));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-align: center;
            flex-grow: 1;
        }

        .secondaryHeader img.lazy {
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            width: 80px !important;
            height: 80px !important;
            object-fit: contain;
            opacity: 1 !important;
            visibility: visible !important;
            background: transparent !important;
        }

        .secondaryHeader .lazy:not(.loaded) {
            background: transparent !important;
            animation: none !important;
        }

        .wrap{
            width:1200px;
            max-width:95vw;
            background: linear-gradient(145deg, rgba(30,41,59,0.95), rgba(15,23,42,0.98));
            border-radius:24px;
            padding:24px;
            box-shadow:0 25px 60px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
            border:1px solid rgba(255,255,255,0.1);
            backdrop-filter:blur(10px);
            margin: 20px auto;
            flex-grow: 1;
        }
        
        header{
            display:flex;
            gap:16px;
            align-items:center;
            margin-bottom:20px;
            padding-bottom:16px;
            border-bottom:2px solid rgba(255,255,255,0.1);
        }
        
        h1{
            margin:0;
            font-size:28px;
            font-weight:800;
            background:linear-gradient(135deg, var(--accent1), var(--accent2));
            -webkit-background-clip:text;
            -webkit-text-fill-color:transparent;
        }
        
        p.lead{
            margin:8px 0 0 0;
            color:#94a3b8;
            font-size:14px;
            font-weight:600;
        }
        
        .layout{
            display:flex;
            gap:24px;
            align-items:flex-start;
        }
        
        .left{
            flex:1;
            min-width:700px;
            position: relative;
        }
        
        .right{
            width:350px;
        }

        /* STAIR AREA - Gaming Style */
        .stair-area{
            position:relative;
            height:580px;
            border-radius:20px;
            padding:24px;
            overflow:visible;
            background: linear-gradient(160deg, rgba(30,41,59,0.8), rgba(15,23,42,0.9));
            border:2px solid rgba(255,255,255,0.1);
            box-shadow:inset 0 0 50px rgba(0,0,0,0.3), 0 20px 40px rgba(0,0,0,0.2);
            transition: all 0.5s ease;
        }

        .stair-area.hidden {
            display: none !important;
            opacity: 0;
            height: 0;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }
        
        /* Steps - Gaming Style */
        .step{
            position:absolute;
            width:var(--step-w);
            height:var(--step-h);
            border-radius:var(--radius);
            display:flex;
            align-items:center;
            justify-content:center;
            font-weight:800;
            font-size:18px;
            color:var(--text-light);
            box-shadow: 0 12px 30px rgba(0,0,0,0.3), inset 0 4px 12px rgba(255,255,255,0.1);
            border:2px solid rgba(255,255,255,0.15);
            text-shadow:0 2px 4px rgba(0,0,0,0.3);
            transition:all 0.3s ease;
            z-index: 30;
        }
        
        .step:hover{
            transform:translateY(-2px);
            box-shadow:0 15px 35px rgba(0,0,0,0.4), inset 0 4px 12px rgba(255,255,255,0.15);
        }
        
        /* Fix stair positioning for arrows */
        .step.km  {background: linear-gradient(145deg,#f59e0b,#d97706); left:30px; top:25px; box-shadow:var(--glow), 0 12px 30px rgba(0,0,0,0.3); }
        .step.hm  {background: linear-gradient(145deg,#10b981,#059669); left:105px; top:105px; box-shadow:0 0 25px rgba(16,185,129,0.3), 0 12px 30px rgba(0,0,0,0.3);}
        .step.dam { background: linear-gradient(145deg,#3b82f6,#2563eb);left:180px; top:185px;  box-shadow:0 0 25px rgba(59,130,246,0.3), 0 12px 30px rgba(0,0,0,0.3);}
        .step.m   {background: linear-gradient(145deg,#8b5cf6,#7c3aed); left:255px; top:265px; box-shadow:0 0 25px rgba(139,92,246,0.3), 0 12px 30px rgba(0,0,0,0.3);}
        .step.dm  {background: linear-gradient(145deg,#ec4899,#db2777); left:330px; top:345px;box-shadow:0 0 25px rgba(236,72,153,0.3), 0 12px 30px rgba(0,0,0,0.3); }
        .step.cm  {background: linear-gradient(145deg,#06b6d4,#0891b2); left:405px; top:425px;box-shadow:0 0 25px rgba(6,182,212,0.3), 0 12px 30px rgba(0,0,0,0.3); }
        .step.mm  {background: linear-gradient(145deg,#f97316,#ea580c); left:480px; top:505px;box-shadow:0 0 25px rgba(249,115,22,0.3), 0 12px 30px rgba(0,0,0,0.3); }

        .step::after{
            content:"";
            position:absolute;
            left:8px; right:-8px; bottom:-12px;
            height:20px;
            border-radius:12px;
            filter: blur(12px);
            opacity:0.2;
            background: currentColor;
            transform: translateY(6px);
            z-index:-1;
        }

        /* SVG overlay for arrows */
        svg.arrow-layer{
            position:absolute; 
            left:0; 
            top:0; 
            width:100%; 
            height:100%; 
            pointer-events:none; 
            overflow:visible; 
            z-index: 45;
        }

        /* arrow path styles - Gaming */
        .curve{ 
            fill:none; 
            stroke:rgba(255,255,255,0.9); 
            stroke-width: 4; 
            stroke-linecap:round; 
            stroke-linejoin:round; 
            filter:drop-shadow(0 0 10px rgba(255,255,255,0.3)); 
        }
        
        .draw{ 
            stroke-dasharray:1000; 
            stroke-dashoffset:1000; 
            transition: stroke-dashoffset 1.2s cubic-bezier(.2,.9,.2,1); 
        }

        /* Operation labels */
        .op-label{
            position:absolute; 
            transform:translate(-50%,-50%);
            background: linear-gradient(145deg, rgba(30,41,59,0.95), rgba(15,23,42,0.98));
            padding: 6px 12px;
            border-radius:16px;
            font-weight:800; 
            font-size: 14px;
            box-shadow:0 8px 25px rgba(0,0,0,0.3), 0 0 15px rgba(255,255,255,0.1);
            border:2px solid rgba(255,255,255,0.15);
            color:var(--accent1);
            opacity:0; 
            transition:all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            pointer-events:none; 
            z-index: 999 !important;
            text-shadow:0 0 10px currentColor;
        }
        
        .op-label.show{ 
            opacity:1; 
            transform:translate(-50%,-70%) scale(1.1); 
        }

        /* Squirrel character */
        .squirrel{
            position:absolute; 
            width:100px; 
            height:100px; 
            transform-origin:center bottom; 
            z-index: 1000 !important;
            transition:all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
            will-change:left,top,transform;
            filter:drop-shadow(0 5px 15px rgba(0,0,0,0.3));
        }

        /* Enhanced animations */
        @keyframes hopBounce{ 
            0%{transform:translateY(0) scale(1);} 
            30%{transform:translateY(-25px) scale(1.1);} 
            60%{transform:translateY(0) scale(1);} 
            100%{transform:translateY(0) scale(1);} 
        }
        
        @keyframes tailWiggle{ 
            0%{transform:rotate(0);} 
            25%{transform:rotate(12deg);} 
            50%{transform:rotate(-8deg);} 
            75%{transform:rotate(6deg);} 
            100%{transform:rotate(0);} 
        }
        
        @keyframes squirrelGlow{
            0%{filter:drop-shadow(0 5px 15px rgba(245,158,11,0.4));}
            50%{filter:drop-shadow(0 5px 25px rgba(245,158,11,0.6));}
            100%{filter:drop-shadow(0 5px 15px rgba(245,158,11,0.4));}
        }
        
        .squirrel.hop{ 
            animation: hopBounce 600ms ease, squirrelGlow 600ms ease; 
        }
        
        .squirrel .tail{ 
            transform-origin:center bottom; 
            animation: tailWiggle 700ms ease; 
        }

        /* Enhanced speech bubble */
        .speech{
            position:absolute; 
            padding:12px 18px; 
            border-radius:18px; 
            background: linear-gradient(145deg, var(--accent2), var(--accent3));
            color:white; 
            font-weight:800; 
            font-size:18px; 
            box-shadow:0 12px 30px rgba(16,185,129,0.3), 0 0 20px rgba(59,130,246,0.4); 
            z-index: 1500 !important;
            border:2px solid rgba(255,255,255,0.2);
            transform:translate(-50%, -15px) scale(0.8); 
            opacity:0; 
            transition:all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
            pointer-events:none; 
            text-shadow:0 2px 4px rgba(0,0,0,0.3);
        }
        
        .speech.show{ 
            opacity:1; 
            transform:translate(-50%, -25px) scale(1.1); 
        }

        /* Gaming UI Panels */
        .panel{ 
            background: linear-gradient(145deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
            border-radius:20px; 
            padding:20px; 
            box-shadow:0 15px 35px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
            border:2px solid rgba(255,255,255,0.1);
            backdrop-filter:blur(10px);
        }
        
        .panel-title{
            font-weight:800; 
            margin-bottom:16px; 
            font-size:18px;
            background:linear-gradient(135deg, var(--accent1), var(--text-light));
            -webkit-background-clip:text; 
            -webkit-text-fill-color:transparent;
        }
        
        .controls{ 
            display:flex; 
            gap:10px; 
            align-items:center; 
            flex-wrap:wrap; 
            margin-bottom:12px; 
        }
        
        label{ 
            color:#94a3b8; 
            font-weight:600; 
            font-size:14px; 
        }
        
        select, button{ 
            padding:12px 16px; 
            border-radius:14px; 
            border:2px solid rgba(255,255,255,0.15); 
            background: linear-gradient(145deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
            font-weight:700; 
            color:var(--text-light);
            transition:all 0.3s ease;
            box-shadow:0 4px 15px rgba(0,0,0,0.2);
        }
        
        select:hover, button:hover{ 
            border-color:var(--accent1); 
            transform:translateY(-2px); 
        }
        
        select:focus, button:focus{ 
            outline:none; 
            border-color:var(--accent2); 
            box-shadow:0 0 20px rgba(16,185,129,0.3); 
        }
        
        button.primary{ 
            background:linear-gradient(145deg, var(--accent1), #d97706); 
            color:var(--text-dark); 
            border:none; 
            box-shadow:0 8px 25px rgba(245,158,11,0.3), 0 0 15px rgba(245,158,11,0.2);
            font-weight:800;
        }
        
        button.primary:hover{ 
            transform:translateY(-3px) scale(1.05); 
            box-shadow:0 12px 30px rgba(245,158,11,0.4), 0 0 20px rgba(245,158,11,0.3); 
        }

        .quick-btn{ 
            background:linear-gradient(145deg, rgba(59,130,246,0.2), rgba(30,41,59,0.8));
            border:2px solid rgba(59,130,246,0.3);
            color:var(--text-light);
        }
        
        .quick-btn:hover{ 
            border-color:var(--accent3); 
            background:linear-gradient(145deg, rgba(59,130,246,0.3), rgba(30,41,59,0.9)); 
        }

        .reset-btn{ 
            background:linear-gradient(145deg, rgba(239,68,68,0.2), rgba(30,41,59,0.8));
            border:2px solid rgba(239,68,68,0.3);
            color:var(--text-light);
            margin-top:8px;
        }
        
        .reset-btn:hover{ 
            border-color:#ef4444; 
            background:linear-gradient(145deg, rgba(239,68,68,0.3), rgba(30,41,59,0.9)); 
        }

        /* QUIZ SECTION STYLES - FIXED */
       .quiz-section {
    margin-top: 15px;
    display: none;
    height: auto;
    min-height: 0;
}
.quiz-section * {
    box-sizing: border-box;
}

.quiz-container {
    overflow-x: hidden;
}
        .quiz-section.active {
            display: block !important;
        }

       .quiz-container {
            background: linear-gradient(145deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
            border-radius: 20px;
            padding: 25px;
            border: 2px solid rgba(255,255,255,0.1);
            box-shadow: 0 15px 35px rgba(0,0,0,0.2);
        }

        .quiz-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid rgba(255,255,255,0.1);
        }

       .quiz-stats {
    display: flex;
    gap: 15px;
    font-weight: 600;
    color: var(--accent1);
    font-size: 14px;
}

      
.quiz-progress {
    background: rgba(255,255,255,0.1);
    height: 6px;
    border-radius: 8px;
    overflow: hidden;
    margin: 10px 0;
}

     
.quiz-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent2), var(--accent3));
    transition: width 0.3s ease;
    border-radius: 8px;
}

      .quiz-question {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 15px;
    text-align: center;
    color: var(--text-light);
    padding: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    line-height: 1.4;
}

     .quiz-options {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-bottom: 25px;
        }

        .quiz-option {
            background: linear-gradient(145deg, rgba(59,130,246,0.2), rgba(30,41,59,0.8));
            border: 2px solid rgba(59,130,246,0.3);
            padding: 20px;
            border-radius: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 600;
            text-align: center;
            font-size: 16px;
            color: var(--text-light);
        }

        .quiz-option:hover {
            transform: translateY(-3px);
            border-color: var(--accent3);
            background: linear-gradient(145deg, rgba(59,130,246,0.3), rgba(30,41,59,0.9));
            box-shadow: 0 8px 20px rgba(59,130,246,0.2);
        }


      .quiz-option.correct {
    background: linear-gradient(145deg, rgba(16,185,129,0.3), rgba(30,41,59,0.9)) !important;
    border-color: var(--accent2) !important;
    color: var(--accent2) !important;
    box-shadow: 0 0 15px rgba(16,185,129,0.3) !important;
}
      /* Wrong answer should be RED */
.quiz-option.incorrect {
    background: linear-gradient(145deg, rgba(239,68,68,0.3), rgba(30,41,59,0.9)) !important;
    border-color: #ef4444 !important;
    color: #ef4444 !important;
    box-shadow: 0 0 15px rgba(239,68,68,0.2) !important;
}

    .quiz-feedback {
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: 600;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

   /* Feedback messages */
.feedback-correct {
    background: rgba(16,185,129,0.1) !important;
    border: 2px solid var(--accent2) !important;
    color: var(--accent2) !important;
    font-weight: 700 !important;
}


     .feedback-incorrect {
    background: rgba(239,68,68,0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}
.feedback-incorrect {
    background: rgba(239,68,68,0.1) !important;
    border: 2px solid #ef4444 !important;
    color: #ef4444 !important;
    font-weight: 700 !important;
}

/* Add animations for correct/wrong answers */
@keyframes correctPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16,185,129,0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(16,185,129,0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16,185,129,0);
    }
}

@keyframes incorrectShake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Apply animations when answers are shown */
.quiz-option.correct {
    animation: correctPulse 2s ease !important;
}

.quiz-option.incorrect {
    animation: incorrectShake 0.5s ease !important;
}

/* Also fix the text colors in the feedback */
#quizFeedback.feedback-correct {
    color: #10b981 !important;
    text-shadow: 0 0 10px rgba(16,185,129,0.3) !important;
}

#quizFeedback.feedback-incorrect {
    color: #ef4444 !important;
    text-shadow: 0 0 10px rgba(239,68,68,0.2) !important;
}

/* Make sure the correct answer has a checkmark */
.quiz-option.correct::before {
    content: '✓ ';
    font-weight: bold;
    margin-right: 5px;
}

/* Make sure the incorrect answer has an X */
.quiz-option.incorrect::before {
    content: '✗ ';
    font-weight: bold;
    margin-right: 5px;
}

/* Fix any !important overrides that might be causing issues */
.quiz-option {
    transition: all 0.3s ease !important;
}

/* Ensure these styles override any others */
.quiz-option.correct,
.quiz-option.incorrect,
.feedback-correct,
.feedback-incorrect {
    z-index: 10;
    position: relative;
}

/* Add a subtle glow effect for correct answers */
.quiz-option.correct {
    border-width: 2px !important;
    animation: glowGreen 2s ease-in-out infinite alternate !important;
}

@keyframes glowGreen {
    from {
        box-shadow: 0 0 5px rgba(16,185,129,0.5),
                    inset 0 0 5px rgba(16,185,129,0.2);
    }
    to {
        box-shadow: 0 0 15px rgba(16,185,129,0.8),
                    inset 0 0 10px rgba(16,185,129,0.4);
    }
}

/* Add a subtle pulse for incorrect answers */
.quiz-option.incorrect {
    border-width: 2px !important;
    animation: pulseRed 2s ease-in-out infinite alternate !important;
}

@keyframes pulseRed {
    from {
        box-shadow: 0 0 5px rgba(239,68,68,0.5),
                    inset 0 0 5px rgba(239,68,68,0.2);
    }
    to {
        box-shadow: 0 0 15px rgba(239,68,68,0.8),
                    inset 0 0 10px rgba(239,68,68,0.4);
    }
}
       /* Quiz Type Selection - More Compact */
.quiz-type-selection {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

     .quiz-type-btn {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 12px;
}

.quiz-type-btn:hover {
    border-color: var(--accent1);
    transform: translateY(-1px);
}
.quiz-type-btn.active {
    background: linear-gradient(145deg, var(--accent1), #d97706);
    color: var(--text-dark);
    border-color: var(--accent1);
}
        /* Show Quiz Button */
        .show-quiz-btn {
            width: 100%;
            padding: 15px;
            margin-top: 20px;
            background: linear-gradient(145deg, var(--accent3), #2563eb);
            color: white;
            border: none;
            border-radius: 12px;
            font-weight: 700;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .show-quiz-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(59,130,246,0.3);
        }

/* Quiz Results - More Compact */
.quiz-result {
    display: none;
    padding: 15px;
    text-align: center;
    animation: fadeIn 0.5s ease-in;
}

/* Show quiz content by default */
#quizContent {
    display: block !important;
}

/* Hide quiz content when results are active */
.quiz-results-active #quizContent {
    display: none !important;
}

.quiz-results-active .quiz-result {
    display: block !important;
}

.quiz-score {
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 15px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.quiz-percentage {
    font-size: 18px;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 20px;
}

.quiz-message {
    font-size: 16px;
    color: #e2e8f0;
    margin: 15px 0;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Quiz Actions - More Compact */
.quiz-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px !important;
}

.quiz-actions .quiz-btn {
    padding: 15px 30px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 15px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-actions .quiz-restart {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: white;
}

.quiz-actions .quiz-restart:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
}

.back-to-stairs {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: white;
}

.back-to-stairs:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}
      .quiz-btn {
    padding: 10px 15px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 48%;
}

.quiz-next {
    background: linear-gradient(145deg, var(--accent2), #059669);
    color: white;
}

.quiz-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}


        .quiz-restart {
            background: linear-gradient(145deg, var(--accent1), #d97706);
            color: white;
        }

        .quiz-restart:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(245,158,11,0.3);
        }
.show-explanation-btn {
    background: linear-gradient(145deg, var(--accent1), #d97706);
    color: white;
}

.show-explanation-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245,158,11,0.3);
}
        /* Hide Quiz Button */
        .hide-quiz-btn {
            width: 100% !important;
            padding: 12px !important;
            background: linear-gradient(145deg, #ef4444, #dc2626) !important;
            color: white !important;
            border: none !important;
            border-radius: 10px !important;
            font-weight: 600 !important;
            font-size: 14px !important;
            cursor: pointer !important;
            transition: all 0.3s ease !important;
            text-align: center !important;
            display: block !important;
            visibility: visible !important;
            opacity: 1 !important;
            position: relative !important;
            z-index: 1000 !important;
            pointer-events: auto !important;
            margin-top: 15px !important;
        }

        .hide-quiz-btn:hover {
            transform: translateY(-2px) !important;
            box-shadow: 0 6px 15px rgba(239,68,68,0.3) !important;
        }

        #quizSection.active #hideQuizBtn {
            display: block !important;
        }

        /* Ensure show quiz button is hidden during quiz and explanation */
        .quiz-section.active ~ .show-quiz-btn,
        .layout.explanation-mode .show-quiz-btn {
            display: none !important;
        }

        .show-quiz-btn {
            display: block;
        }

        /* Go Back to Quiz Button */
        .back-to-quiz-btn {
            width: 100%;
            padding: 12px;
            margin-top: 15px;
            background: linear-gradient(145deg, var(--accent1), #d97706);
            color: white;
            border: none;
            border-radius: 10px;
            font-weight: 600;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
        }

        .back-to-quiz-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(245, 158, 11, 0.3);
            background: linear-gradient(145deg, #d97706, var(--accent1));
        }

        /* EXPLANATION PANEL STYLES */
        .explanation-panel {
            display: none !important;
        }

       .layout.explanation-mode {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    align-items: flex-start !important;
    width: 100% !important;
}

.layout.explanation-mode .left {
    flex: 1 !important;
    min-width: 0 !important; /* Allow shrinking */
    max-width: 65% !important;
    position: relative !important;
}

.layout.explanation-mode .right {
    width: 35% !important;
    min-width: 350px !important; /* Minimum width for readability */
    max-width: 450px !important;
    flex-shrink: 0 !important; /* Prevent shrinking */
    display: block !important;
    position: relative !important;
}

        /* Hide ALL regular panels in right column during explanation */
        .layout.explanation-mode .right > .panel:not(.explanation-panel) {
            display: none !important;
        }

        /* Show explanation panel during explanation mode */
      .layout.explanation-mode .explanation-panel {
    display: block !important;
    position: relative !important;
    height: 100% !important;
    max-height: 580px !important;
            animation: slideInRight 0.4s ease-out;
        }

        @keyframes slideInRight {
            0% {
                opacity: 0;
                transform: translateX(30px);
            }
            100% {
                opacity: 1;
                transform: translateX(0);
            }
        }

        /* Ensure stair area is properly shown during explanation */
        .layout.explanation-mode .stair-area {
            display: block !important;
            height: 580px !important;
            opacity: 1 !important;
            visibility: visible !important;
        }

        /* Hide quiz section during explanation */
        .layout.explanation-mode .quiz-section {
            display: none !important;
        }

        .layout.explanation-mode .show-quiz-btn {
            display: none !important;
        }

        /* Explanation panel specific styles */
        .explanation-panel .panel {
            background: linear-gradient(145deg, rgba(30,41,59,0.97), rgba(15,23,42,0.98)) !important;
            border-radius: 20px;
            padding: 25px !important;
            border: 2px solid rgba(245, 158, 11, 0.3) !important;
            box-shadow: 0 20px 50px rgba(0,0,0,0.4), 0 0 30px rgba(245, 158, 11, 0.2) !important;
            backdrop-filter: blur(15px);
            height: auto;
            max-height: 580px;
            overflow: auto;
            margin: 0 !important;
        }

        .explanation-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid rgba(255,255,255,0.15);
        }

        .explanation-title {
            font-size: 22px;
            font-weight: 800;
            background: linear-gradient(135deg, var(--accent1), var(--accent2));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin: 0;
            text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
        }

        .close-explanation {
            background: rgba(239,68,68,0.1);
            border: 2px solid rgba(239,68,68,0.3);
            color: var(--text-light);
            font-size: 20px;
            cursor: pointer;
            padding: 8px 12px;
            border-radius: 10px;
            transition: all 0.3s ease;
            line-height: 1;
            font-weight: bold;
        }

        .close-explanation:hover {
            background: rgba(239,68,68,0.3);
            transform: scale(1.1);
            box-shadow: 0 0 15px rgba(239,68,68,0.3);
        }

        /* Explanation content */
        .explanation-content {
            margin-top: 15px;
        }

        .explanation-steps {
            display: flex !important;
            flex-direction: column;
            gap: 15px;
            margin-bottom: 25px;
        }

        /* Explanation Step States */
        .explanation-step {
            display: flex !important;
            align-items: flex-start;
            gap: 15px;
            padding: 0;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            border-left: 4px solid rgba(255, 255, 255, 0.1);
            transition: all 0.5s ease;
            backdrop-filter: blur(10px);
            margin-bottom: 10px;
            opacity: 0;
            max-height: 0;
            overflow: hidden;
            transform: translateX(-20px);
        }

        .explanation-step.completed {
            opacity: 0.7;
            max-height: 200px;
            padding: 15px;
            transform: translateX(0);
            border-left: 4px solid var(--accent2);
        }

        .explanation-step.active {
            opacity: 1;
            max-height: 500px;
            padding: 18px;
            transform: translateX(0);
            border-left: 4px solid var(--accent1);
            background: rgba(255, 255, 255, 0.08);
        }

        .explanation-step.highlight {
            background: rgba(245, 158, 11, 0.1);
            box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
        }

        /* Ensure step content is properly contained */
        .step-content {
            width: 100%;
            transition: all 0.3s ease;
        }

        .step-number {
            background: linear-gradient(135deg, var(--accent1), #d97706);
            color: var(--text-dark);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex !important;
            align-items: center;
            justify-content: center;
            font-weight: 800;
            font-size: 16px;
            flex-shrink: 0;
            box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
            transition: all 0.3s ease;
        }

        .step-number.active {
            transform: scale(1.1);
            box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
        }

        /* Enhanced Pulse animation for highlighted units */
        .unit-highlight {
            color: var(--accent1);
            background: rgba(245, 158, 11, 0.3);
            padding: 4px 12px;
            border-radius: 8px;
            font-weight: 800;
            animation: strongPulse 1.5s infinite;
            display: inline-block;
            border: 2px solid rgba(245, 158, 11, 0.5);
            text-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
        }

        @keyframes strongPulse {
            0% {
                box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.8);
                transform: scale(1);
                background: rgba(245, 158, 11, 0.4);
            }
            50% {
                box-shadow: 0 0 0 15px rgba(245, 158, 11, 0.2);
                transform: scale(1.1);
                background: rgba(245, 158, 11, 0.6);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
                transform: scale(1);
                background: rgba(245, 158, 11, 0.4);
            }
        }

        /* Enhanced step pulse animation */
        .step.pulsing {
            animation: stepPulse 2s infinite !important;
            z-index: 100;
        }

        @keyframes stepPulse {
            0% {
                box-shadow: var(--glow), 0 0 0 0 rgba(245, 158, 11, 0.8);
                transform: scale(1);
            }
            50% {
                box-shadow: var(--glow), 0 0 0 20px rgba(245, 158, 11, 0.4);
                transform: scale(1.05);
            }
            100% {
                box-shadow: var(--glow), 0 0 0 0 rgba(245, 158, 11, 0);
                transform: scale(1);
            }
        }

        .step.pulsing.to-unit {
            animation: stepPulseTo 2s infinite !important;
        }

        @keyframes stepPulseTo {
            0% {
                box-shadow: var(--glow), 0 0 0 0 rgba(16, 185, 129, 0.8);
                transform: scale(1);
            }
            50% {
                box-shadow: var(--glow), 0 0 0 20px rgba(16, 185, 129, 0.4);
                transform: scale(1.05);
            }
            100% {
                box-shadow: var(--glow), 0 0 0 0 rgba(16, 185, 129, 0);
                transform: scale(1);
            }
        }

        /* Text pulse animation for step descriptions */
        @keyframes textPulse {
            0% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.02);
            }
            100% {
                transform: scale(1);
            }
        }

        /* Math expression styling */
        .math-expression {
            background: rgba(59, 130, 246, 0.1);
            border: 2px solid rgba(59, 130, 246, 0.3);
            padding: 10px 15px;
            border-radius: 8px;
            margin: 10px 0;
            font-family: 'Courier New', monospace;
            font-weight: 700;
            color: var(--accent3);
            text-align: center;
        }

        .final-answer {
            background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
            border: 2px solid var(--accent2);
            padding: 15px;
            border-radius: 10px;
            margin: 15px 0;
            font-weight: 800;
            color: var(--accent2);
            text-align: center;
            font-size: 18px;
            animation: glowGreen 2s ease-in-out;
        }

        @keyframes glowGreen {
            0% {
                box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
            }
            50% {
                box-shadow: 0 0 20px 10px rgba(16, 185, 129, 0.2);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
            }
        }

        /* Navigation Styles */
        .explanation-navigation {
            display: flex;
            gap: 10px;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding: 15px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 12px;
            border: 2px solid rgba(255, 255, 255, 0.1);
        }

       /* BOTTOM NAVIGATION - appears right after steps */
.explanation-navigation-bottom {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 15px !important;
    margin-top: 20px !important; /* Space after the last step */
    margin-bottom: 15px !important;
    flex-shrink: 0 !important; /* Don't let it shrink */
    position: relative !important; /* NOT sticky */
    z-index: 50;
}

        .step-nav-btn {
            padding: 10px 20px;
            border: 2px solid var(--accent3);
            background: rgba(59, 130, 246, 0.1);
            color: var(--text-light);
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .step-nav-btn:hover:not(:disabled) {
            background: rgba(59, 130, 246, 0.3);
            transform: translateY(-2px);
        }

        .step-nav-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            border-color: rgba(255,255,255,0.2);
        }

        .step-progress {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 14px;
            color: #94a3b8;
            margin: 0 15px;
        }

        .step-description {
            flex: 1;
            font-size: 15px;
            line-height: 1.6;
            color: var(--text-light);
            display: block !important;
        }

        .step-description strong {
            color: var(--accent1);
            background: rgba(245, 158, 11, 0.1);
            padding: 2px 6px;
            border-radius: 4px;
        }

        .explanation-tips {
            background: rgba(59, 130, 246, 0.15);
            border: 2px solid rgba(59, 130, 246, 0.4);
            border-radius: 15px;
            padding: 20px;
            margin-top: 25px;
            display: block !important;
            backdrop-filter: blur(10px);
        }

        .tip-title {
            font-weight: 700;
            color: var(--accent3);
            margin-bottom: 15px;
            font-size: 17px;
            text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
        }

        .tip-item {
            margin: 10px 0;
            color: #e2e8f0;
            font-size: 14px;
            padding-left: 8px;
            border-left: 2px solid var(--accent3);
        }

        /* STAR RATING SYSTEM */
        .star-rating {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin: 20px 0;
        }

        .star {
            font-size: 40px;
            color: #4b5563;
            transition: all 0.3s ease;
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
        }

        .star.filled {
            color: #fbbf24;
            animation: starGlow 1s ease;
        }

        @keyframes starGlow {
            0% {
                transform: scale(1);
                filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
            }
            50% {
                transform: scale(1.3);
                filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.8));
            }
            100% {
                transform: scale(1);
                filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
            }
        }

        .star-rating-message {
            text-align: center;
            font-size: 18px;
            font-weight: 700;
            margin: 15px 0;
            color: var(--accent1);
        }

        .star-progress {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            margin: 15px 0;
        }

        .star-progress-bar {
            width: 200px;
            height: 12px;
            background: rgba(255,255,255,0.1);
            border-radius: 10px;
            overflow: hidden;
            position: relative;
        }

        .star-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #fbbf24, #f59e0b);
            border-radius: 10px;
            transition: width 0.5s ease;
        }

        .star-count {
            font-weight: 700;
            color: #fbbf24;
            font-size: 16px;
        }

        .star-level {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin: 10px 0;
            font-weight: 600;
            color: var(--accent1);
        }

        .level-badge {
            background: linear-gradient(145deg, var(--accent1), #d97706);
            color: var(--text-dark);
            padding: 4px 12px;
            border-radius: 20px;
            font-weight: 800;
            font-size: 14px;
        }

        /* Star Reward Section - More Compact */
.star-reward-section {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.3));
    border: 2px solid #fbbf24;
    border-radius: 15px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
    animation: glowPulse 2s infinite alternate;
}

        @keyframes glowPulse {
            0% {
                box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
            }
            100% {
                box-shadow: 0 8px 35px rgba(251, 191, 36, 0.5);
            }
        }

       .star-reward-title {
    font-size: 18px;
    font-weight: 800;
    color: #f59e0b;
    margin-bottom: 15px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

      .star-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
}

.star-earned {
    font-size: 40px;
    animation: starBounce 0.6s ease-out, starGlow 2s infinite;
    filter: drop-shadow(0 0 8px rgba(255, 255, 0, 0.8));
    transform-origin: center;
}

        .star-earned.star-1 { animation-delay: 0.1s; }
        .star-earned.star-2 { animation-delay: 0.3s; }
        .star-earned.star-3 { animation-delay: 0.5s; }

        @keyframes starBounce {
            0% {
                transform: scale(0) rotate(0deg);
            }
            50% {
                transform: scale(1.2) rotate(180deg);
            }
            100% {
                transform: scale(1) rotate(360deg);
            }
        }

        @keyframes starGlow {
            0%, 100% {
                filter: drop-shadow(0 0 10px rgba(255, 255, 0, 0.8));
            }
            50% {
                filter: drop-shadow(0 0 20px rgba(255, 255, 0, 1));
            }
        }

        .star-empty {
            font-size: 50px;
            opacity: 0.3;
            filter: grayscale(0.5);
        }

        .no-stars {
            text-align: center;
            padding: 20px;
        }

        .sad-face {
            font-size: 60px;
            margin-bottom: 15px;
            animation: bounce 2s infinite;
        }

        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {
                transform: translateY(0);
            }
            40% {
                transform: translateY(-10px);
            }
            60% {
                transform: translateY(-5px);
            }
        }

        .no-stars-message {
            font-size: 18px;
            color: #94a3b8;
            font-weight: 600;
        }

        .star-message {
            font-size: 20px;
            font-weight: 700;
            color: #f59e0b;
            margin-top: 15px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }

        /* Level Up Celebration */
        .level-up-celebration {
            background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.3));
            border: 3px solid #10b981;
            border-radius: 20px;
            padding: 20px;
            margin: 20px 0;
            text-align: center;
            font-size: 22px;
            font-weight: 800;
            color: #10b981;
            animation: confetti 1s ease-out;
        }

        @keyframes confetti {
            0% {
                transform: scale(0);
                opacity: 0;
            }
            50% {
                transform: scale(1.1);
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }

        .new-level {
            font-size: 28px;
            margin-top: 10px;
            background: linear-gradient(135deg, #10b981, #059669);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 900;
        }

        /* Sound Toggle Button */
        .sound-toggle {
            position: fixed;
            top: 20px;
            right: 20px;
            background: rgba(30, 41, 59, 0.9);
            border: 2px solid var(--accent1);
            border-radius: 50%;
            width: 50px;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            z-index: 1000;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .sound-toggle:hover {
            transform: scale(1.1);
            background: rgba(245, 158, 11, 0.2);
        }

        .sound-toggle.muted {
            opacity: 0.6;
            border-color: #94a3b8;
        }

        .sound-icon {
            font-size: 24px;
            color: var(--accent1);
        }

        .sound-toggle.muted .sound-icon {
            color: #94a3b8;
        }

        /* Layout fixes */
        .layout:not(.explanation-mode) .stair-area:not(.hidden) {
            display: block !important;
        }

        .layout.explanation-mode .stair-area {
            display: block !important;
        }

        .layout.explanation-mode .quiz-section {
            display: none !important;
        }

        /* FIX QUIZ LAYOUT - Hide right panels during quiz */
        .quiz-section.active ~ .right {
            display: none !important;
        }

        /* FIX EXPLANATION LAYOUT - Ensure proper side-by-side display */
        .layout.explanation-mode .right {
            display: block !important;
        }

        .layout.explanation-mode .right > .panel:not(.explanation-panel) {
            display: none !important;
        }

        .layout.explanation-mode .explanation-panel {
            display: block !important;
        }

        /* Ensure proper state transitions */
        #quizSection:not(.active) {
            display: none !important;
        }

        #quizSection.active {
            display: block !important;
            animation: fadeIn 0.3s ease-in !important;
        }

        /* Mobile Responsive Fixes */
        @media (max-width: 1100px) {
            .layout.explanation-mode {
                flex-direction: column;
            }
            
            .layout.explanation-mode .left,
            .layout.explanation-mode .right {
                width: 100% !important;
                min-width: unset;
            }
            
            .layout.explanation-mode .stair-area {
                height: 500px !important;
            }
            
            .explanation-panel .panel {
                max-height: none;
            }
            
            .explanation-title {
                font-size: 20px;
            }
        }

        @media (max-width: 768px) {
            .wrap {
                padding: 16px !important;
                margin: 10px auto !important;
            }
            
            .layout {
                flex-direction: column !important;
                gap: 15px !important;
            }
            
            .left, .right {
                width: 100% !important;
                min-width: unset !important;
            }
            
            /* Fix stair area for mobile */
            .stair-area {
                height: 400px !important;
                padding: 15px !important;
                overflow: hidden !important;
                position: relative;
            }
            
            /* Mobile stair positioning */
            .step {
                width: 120px !important;
                height: 50px !important;
                font-size: 14px !important;
            }
            
            .step.km  { left: 20px !important; top: 20px !important; }
            .step.hm  { left: 60px !important; top: 80px !important; }
            .step.dam { left: 100px !important; top: 140px !important; }
            .step.m   { left: 140px !important; top: 200px !important; }
            .step.dm  { left: 180px !important; top: 260px !important; }
            .step.cm  { left: 220px !important; top: 320px !important; }
            .step.mm  { left: 260px !important; top: 380px !important; }
            
            /* Adjust squirrel size for mobile */
            .squirrel {
                width: 70px !important;
                height: 70px !important;
            }
            
            /* Fix quiz layout for mobile */
            .quiz-options {
                grid-template-columns: .5fr !important;
            }
            
            .quiz-question {
                font-size: 16px !important;
                padding: 12px !important;
            }
            
            /* Fix explanation steps for mobile */
            .explanation-step {
                flex-direction: column;
                gap: 8px;
            }
            
            .step-number {
                align-self: flex-start;
            }
            
            .explanation-navigation {
                padding: 15px;
                gap: 12px;
            }
            
            .step-progress-top {
                font-size: 14px;
                gap: 8px;
            }
            
            .step-progress-number {
                width: 30px;
                height: 30px;
                font-size: 14px;
            }
            
            .step-nav-btn {
                padding: 10px 16px;
                font-size: 13px;
            }
            
            .navigation-buttons {
                gap: 8px;
            }
            
            /* Ensure no horizontal overflow */
            body {
                overflow-x: hidden;
            }
            
            .wrap {
                overflow-x: hidden;
            }
             .quiz-container {
        padding: 12px;
        max-height: calc(100vh - 120px);
    }
    
    .quiz-header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
    
    .quiz-stats {
        gap: 10px;
        font-size: 13px;
    }
    
    .quiz-question {
        font-size: 15px;
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .quiz-option {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 42px;
    }
    
    .quiz-type-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .quiz-btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 38px;
    }
    
    .hide-quiz-btn {
        padding: 8px !important;
        font-size: 12px !important;
        min-height: 42px;
    }
    
    .quiz-score {
        font-size: 40px;
        margin: 10px 0;
    }
    
    .quiz-percentage {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .quiz-message {
        font-size: 14px;
        padding: 10px;
        margin: 10px 0;
    }
        }

        /* Extra small devices */
        @media (max-width: 480px) {
            .stair-area {
                height: 400px !important;
                padding: 10px !important;
                overflow: hidden !important;
            }
            
            .step {
                width: 90px !important;
                height: 40px !important;
                font-size: 11px !important;
            }
            
            .step.km  { left: 15px !important; top: 15px !important; }
            .step.hm  { left: 50px !important; top: 70px !important; }
            .step.dam { left: 85px !important; top: 125px !important; }
            .step.m   { left: 120px !important; top: 180px !important; }
            .step.dm  { left: 155px !important; top: 235px !important; }
            .step.cm  { left: 190px !important; top: 290px !important; }
            .step.mm  { left: 225px !important; top: 345px !important; }
            
            .squirrel {
                width: 50px !important;
                height: 50px !important;
            }
               .quiz-container {
        padding: 10px;
        max-height: calc(100vh - 100px);
    }
    
    .quiz-stats {
        flex-direction: column;
        gap: 5px;
        font-size: 12px;
    }
    
    .quiz-question {
        font-size: 14px;
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .quiz-option {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px;
    }
    
    .quiz-type-selection {
        flex-direction: column;
        gap: 6px;
    }
    
    .quiz-type-btn {
        padding: 8px;
        font-size: 11px;
    }
    
    .quiz-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    .quiz-btn {
        max-width: 100%;
        min-height: 36px;
    }
    
    .hide-quiz-btn {
        padding: 8px !important;
        font-size: 12px !important;
        min-height: 40px;
    }
    
    .star-reward-section {
        padding: 12px;
    }
    
    .star-reward-title {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .star-display {
        gap: 10px;
        margin: 10px 0;
    }
    
    .star-earned {
        font-size: 35px;
    }
    
    .star-empty {
        font-size: 30px;
    }
    
    .star-message {
        font-size: 14px;
    }
     .curve.draw {
        stroke-width: 2px !important;
    }
    
    .op-label {
        font-size: 10px !important;
        padding: 3px 6px !important;
        border-radius: 8px !important;
    }
  
    
    #speech {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 40px !important;
    }
        }

        /* Even smaller screens */
        @media (max-width: 380px) {
            .stair-area {
                height: 380px !important;
            }
            
            .step {
                width: 80px !important;
                height: 35px !important;
                font-size: 15px !important;
            }
            
            .step.km  { left: 10px !important; top: 15px !important; }
            .step.hm  { left: 40px !important; top: 65px !important; }
            .step.dam { left: 70px !important; top: 115px !important; }
            .step.m   { left: 100px !important; top: 165px !important; }
            .step.dm  { left: 130px !important; top: 215px !important; }
            .step.cm  { left: 160px !important; top: 265px !important; }
            .step.mm  { left: 190px !important; top: 315px !important; }
            
            .squirrel {
                width: 45px !important;
                height: 45px !important;
            }
        }

        /* Prevent horizontal overflow globally */
        html, body {
            overflow-x: hidden;
            max-width: 100%;
        }

        .wrap {
            overflow-x: hidden;
        }

        .stair-area {
            overflow: hidden !important;
        }

        /* Force hide show quiz button during quiz and explanation */
        #showQuizBtn {
            display: block;
        }

        .quiz-section.active ~ #showQuizBtn,
        .layout.explanation-mode ~ #showQuizBtn,
        .layout.explanation-mode #showQuizBtn {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            height: 0 !important;
            padding: 0 !important;
            margin: 0 !important;
            overflow: hidden !important;
        }



/* FIX EXPLANATION PANEL WIDTH AND STAIR ADAPTATION */
@media (min-width: 769px) {
    .layout.explanation-mode {
        gap: 15px !important; /* Reduce gap to give more space to stairs */
    }
    
    .layout.explanation-mode .left {
        width: 65% !important; /* Give more space to stairs */
        flex: 0 0 65% !important;
        min-width: 0 !important; /* Allow shrinking */
    }
    
    .layout.explanation-mode .right {
        width: 35% !important; /* Make explanation panel narrower */
        flex: 0 0 35% !important;
        max-width: 400px !important; /* Limit maximum width */
    }
    
    /* Make explanation panel content more compact */
    .explanation-panel .panel {
        padding: 20px !important;
        max-height: 580px;
    }
     .layout.explanation-mode .explanation-panel .panel {
        height: 500px !important;
        padding: 20px !important;
    }
    
    .explanation-header {
        padding: 0 0 15px 0 !important;
        margin-bottom: 15px !important;
    }
    
    .explanation-title {
        font-size: 18px !important;
    }
}

/* MOBILE: Stack vertically in explanation mode */
@media (max-width: 768px) {
    .layout.explanation-mode {
        flex-direction: column !important;
    }
    
    .layout.explanation-mode .left,
    .layout.explanation-mode .right {
        width: 100% !important;
        min-width: unset !important;
    }
    
    .layout.explanation-mode .stair-area {
        height: 400px !important; /* Reduce height for mobile explanation */
    }
     .curve.draw {
        stroke-width: 3px !important;
    }
    
    .op-label {
        font-size: 12px !important;
        padding: 4px 8px !important;
        border-radius: 10px !important;
    }
    
    /* Adjust stair step sizes for mobile */
    .step {
        font-size: 13px !important;
    }
    
    /* Better positioning for speech bubble on mobile */
    #speech {
        font-size: 14px !important;
        padding: 8px 12px !important;
        min-width: 50px !important;
    }
}



/* Ensure arrows and labels are visible */
.curve {
    pointer-events: none;
}

.op-label {
    pointer-events: none;
    position: absolute;
    white-space: nowrap;
}
/* WORKING LANDSCAPE LAYOUT WITH SCROLL - FIXED */
@media (max-width: 768px) and (orientation: landscape) {
    /* CRITICAL: Make body scrollable */
    body.landscape-mode {
        overflow: auto !important;
        height: auto !important;
        min-height: 100vh;
        width: 100%;
        position: relative;
    }
    
    /* Make wrap scrollable */
    body.landscape-mode .wrap {
        max-width: 98vw !important;
        min-height: 90vh;
        height: auto !important;
        display: flex;
        flex-direction: column;
        overflow: visible !important;
        margin: 10px auto;
    }
    
    /* Layout should be visible and scrollable */
    body.landscape-mode .layout {
        flex-direction: row !important;
        min-height: 400px;
        height: auto !important;
        gap: 15px;
        align-items: flex-start;
        overflow: visible !important;
        flex-wrap: nowrap;
    }
    
    /* LEFT SIDE - FIXED WIDTH, SCROLLABLE CONTENT */
    body.landscape-mode .left {
        width: 55% !important;
        flex: 0 0 55% !important;
        min-height: 400px;
        height: auto;
        overflow: visible !important;
        position: relative;
    }
    
    /* STAIR AREA - MAKE IT WIDE AND SCROLLABLE */
    body.landscape-mode .stair-area {
        height: 350px !important;
        min-height: 350px;
        width: 650px !important; /* Wide enough to spread steps */
        padding: 15px !important;
        overflow: auto !important; /* MAKE IT SCROLLABLE */
        position: relative;
        border-radius: 15px;
        border: 2px solid rgba(255,255,255,0.1);
        -webkit-overflow-scrolling: touch;
        background: linear-gradient(160deg, rgba(30,41,59,0.8), rgba(15,23,42,0.9));
    }
    
    /* SPREAD OUT STEPS - MORE SPACE BETWEEN THEM */
    body.landscape-mode .step {
        position: absolute !important;
        width: 70px !important;
        height: 30px !important;
        font-size: 11px !important;
        line-height: 30px !important;
        z-index: 30;
        box-shadow: 0 3px 8px rgba(0,0,0,0.3) !important;
    }
    
    /* SPREAD THEM OUT MORE - INCREASE GAPS */
    body.landscape-mode .step.km  { left: 30px !important; top: 30px !important; }
    body.landscape-mode .step.hm  { left: 75px !important; top: 85px !important; }
    body.landscape-mode .step.dam { left: 120px !important; top: 140px !important; }
    body.landscape-mode .step.m   { left: 165px !important; top: 195px !important; }
    body.landscape-mode .step.dm  { left: 210px !important; top: 250px !important; }
    body.landscape-mode .step.cm  { left: 255px !important; top: 305px !important; }
    body.landscape-mode .step.mm  { left: 300px !important; top: 360px !important; }
    
    /* Adjust squirrel */
    body.landscape-mode .squirrel {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* RIGHT SIDE - SCROLLABLE */
    body.landscape-mode .right {
        width: 45% !important;
        flex: 0 0 45% !important;
        min-height: 400px;
        height: 350px;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    
    /* CRITICAL FIX: Explanation panel should only show in explanation mode */
    body.landscape-mode .layout:not(.explanation-mode) .explanation-panel {
        display: none !important; /* Hide in visualization mode */
    }
    
    /* Only show explanation panel in explanation mode */
    body.landscape-mode .layout.explanation-mode .explanation-panel {
        display: block !important;
        height: auto;
        min-height: 100%;
    }
    
    body.landscape-mode .layout.explanation-mode .explanation-panel .panel {
        max-height: none !important;
        height: auto !important;
        min-height: 500px;
        overflow-y: auto !important;
        padding: 15px !important;
        margin: 0 !important;
    }
    
    /* In visualization mode, show control panel */
    body.landscape-mode .layout:not(.explanation-mode) .control-panel {
        display: block !important;
    }
    
    /* Hide control panel in explanation mode */
    body.landscape-mode .layout.explanation-mode .control-panel {
        display: none !important;
    }
    
    /* Compact styles for landscape */
    body.landscape-mode .explanation-title {
        font-size: 16px !important;
    }
    
    body.landscape-mode .explanation-step {
        padding: 10px !important;
        margin-bottom: 8px !important;
    }
    
    body.landscape-mode .step-description {
        font-size: 13px !important;
        line-height: 1.4;
    }
    
    body.landscape-mode .step-number {
        width: 28px !important;
        height: 28px !important;
        font-size: 13px !important;
    }
    
    body.landscape-mode .explanation-navigation {
        padding: 10px !important;
        margin-bottom: 12px !important;
    }
    
    body.landscape-mode .step-nav-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    /* Hide header text in landscape */
    body.landscape-mode .secondaryHeader p {
        display: none !important;
    }
    
    body.landscape-mode .secondaryHeader img.lazy {
        width: 50px !important;
        height: 50px !important;
    }
    
    /* Adjust speech bubble */
    body.landscape-mode #speech {
        font-size: 11px !important;
        padding: 5px 8px !important;
        max-width: 100px;
    }
    
    /* SCROLLBAR STYLING - MAKE IT VISIBLE */
    body.landscape-mode .stair-area::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    body.landscape-mode .stair-area::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }
    
    body.landscape-mode .stair-area::-webkit-scrollbar-thumb {
        background: rgba(245, 158, 11, 0.5);
        border-radius: 3px;
    }
    
    body.landscape-mode .right::-webkit-scrollbar {
        width: 5px;
    }
    
    body.landscape-mode .right::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
    }
    
    body.landscape-mode .right::-webkit-scrollbar-thumb {
        background: rgba(59, 130, 246, 0.5);
        border-radius: 3px;
    }
    
    /* FORCE SCROLLING WITH JS FALLBACK */
    body.landscape-mode .stair-area {
        touch-action: pan-x pan-y !important;
    }
    
}
/* EXTRA FIX FOR SMALL LANDSCAPE */
@media (max-width: 640px) and (orientation: landscape) {
    body.landscape-mode .stair-area {
        width: 550px !important;
        height: 300px !important;
    }
    
    body.landscape-mode .step {
        width: 60px !important;
        height: 26px !important;
        font-size: 10px !important;
    }
    
    /* Adjust spacing for small landscape */
    body.landscape-mode .step.km  { left: 25px !important; top: 25px !important; }
    body.landscape-mode .step.hm  { left: 65px !important; top: 75px !important; }
    body.landscape-mode .step.dam { left: 105px !important; top: 125px !important; }
    body.landscape-mode .step.m   { left: 145px !important; top: 175px !important; }
    body.landscape-mode .step.dm  { left: 185px !important; top: 225px !important; }
    body.landscape-mode .step.cm  { left: 225px !important; top: 275px !important; }
    body.landscape-mode .step.mm  { left: 265px !important; top: 325px !important; }
}

/* EMERGENCY SCROLL FIX - ADD THIS AT THE VERY END */
@media (max-width: 768px) and (orientation: landscape) {
    /* OVERRIDE ALL OVERFLOW HIDDEN */
    body.landscape-mode,
    body.landscape-mode * {
        overflow: visible !important;
        max-height: none !important;
    }
    
    /* SPECIFIC ELEMENTS THAT NEED SCROLL */
    body.landscape-mode .stair-area,
    body.landscape-mode .right,
    body.landscape-mode .explanation-panel .panel {
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* FIX TOUCH SCROLLING */
    body.landscape-mode {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
      body.landscape-mode .quiz-section.active {
        width: 100% !important;
    }
}



/* UNIT MEANINGS CONTAINER - BELOW STAIRS AND RIGHT PANEL */
.unit-meanings-container {
    margin-top: 25px;
    width: 100%;
    animation: fadeInUp 0.6s ease-out;
}

.unit-meanings-panel {
    background: linear-gradient(145deg, rgba(30,41,59,0.95), rgba(15,23,42,0.98)) !important;
    border: 2px solid rgba(245, 158, 11, 0.3);
    border-radius: 20px;
    padding: 25px !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3), 0 0 25px rgba(245, 158, 11, 0.1);
    position: relative;
    overflow: hidden;
}

.unit-meanings-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        #f59e0b, #10b981, #3b82f6, #8b5cf6, 
        #ec4899, #06b6d4, #f97316);
    z-index: 1;
}

.unit-meanings-panel .panel-title {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--accent1);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 800;
}

.unit-meanings-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 25px;
}

.unit-meaning {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.unit-meaning:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-3px);
    border-color: rgba(255,255,255,0.2);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.unit-meaning::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: currentColor;
    opacity: 0.5;
}

.unit-abbr {
    font-weight: 900;
    font-size: 20px;
    min-width: 50px;
    text-align: center;
    padding: 10px 0;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

/* Color code each abbreviation to match the stairs */
.unit-abbr.km {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: var(--text-dark);
}

.unit-abbr.hm {
    background: linear-gradient(145deg, #10b981, #059669);
    color: white;
}

.unit-abbr.dam {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: white;
}

.unit-abbr.m {
    background: linear-gradient(145deg, #8b5cf6, #7c3aed);
    color: white;
}

.unit-abbr.dm {
    background: linear-gradient(145deg, #ec4899, #db2777);
    color: white;
}

.unit-abbr.cm {
    background: linear-gradient(145deg, #06b6d4, #0891b2);
    color: white;
}

.unit-abbr.mm {
    background: linear-gradient(145deg, #f97316, #ea580c);
    color: white;
}

.equals {
    font-weight: 800;
    color: var(--accent1);
    font-size: 20px;
    flex-shrink: 0;
}

.unit-full {
    font-weight: 600;
    color: var(--text-light);
    font-size: 16px;
    flex: 1;
    line-height: 1.4;
}

.unit-conversion {
    font-weight: 700;
    color: var(--accent2);
    font-size: 14px;
    background: rgba(16, 185, 129, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
    margin-left: auto;
}

/* Metric system tips */
.metric-system-tips {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tip {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.tip:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(5px);
}

.tip-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.tip-text {
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.5;
    flex: 1;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

/* Interactive hover effects */
.unit-meaning:hover .unit-abbr {
    animation: pulseGlow 1.5s infinite;
}

/* Responsive design */
@media (max-width: 1100px) {
    .unit-meanings-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .unit-meanings-container {
        margin-top: 20px;
    }
    
    .unit-meanings-panel {
        padding: 20px !important;
    }
    
    .unit-meanings-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .unit-meaning {
        padding: 12px;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .unit-abbr {
        font-size: 18px;
        min-width: 45px;
        padding: 8px 0;
    }
    
    .unit-full {
        font-size: 15px;
        order: 3;
        width: 100%;
        margin-top: 8px;
        padding-left: 60px;
    }
    
    .unit-conversion {
        order: 2;
        margin-left: 0;
        font-size: 13px;
    }
    
    .equals {
        font-size: 18px;
    }
    
    .metric-system-tips {
        padding: 15px;
        gap: 12px;
    }
    
    .tip {
        padding: 10px;
        gap: 10px;
    }
    
    .tip-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .tip-text {
        font-size: 13px;
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .unit-meanings-container {
        margin-top: 15px;
    }
    
    .unit-meanings-panel {
        padding: 15px !important;
    }
    
    .unit-meanings-panel .panel-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .unit-meanings-list {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .unit-meaning {
        padding: 10px;
        gap: 10px;
    }
    
    .unit-abbr {
        font-size: 16px;
        min-width: 40px;
        padding: 6px 0;
    }
    
    .unit-full {
        font-size: 14px;
        padding-left: 50px;
    }
    
    .unit-conversion {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .equals {
        font-size: 16px;
    }
    
    .metric-system-tips {
        padding: 12px;
        gap: 10px;
    }
    
    .tip {
        padding: 8px;
        gap: 8px;
    }
    
    .tip-icon {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .tip-text {
        font-size: 12px;
    }
}

/* Small screens */
@media (max-width: 480px) {
    .unit-meanings-panel .panel-title {
        font-size: 20px;
    }
    
    .unit-meaning {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .unit-abbr, .equals, .unit-conversion {
        align-self: flex-start;
    }
    
    .unit-full {
        padding-left: 0;
        margin-top: 5px;
    }
    
    .metric-system-tips {
        padding: 10px;
    }
    
    .tip {
        flex-direction: column;
        text-align: center;
    }
    
    .tip-icon {
        align-self: center;
    }
}

/* Hide during explanation and quiz modes */
.layout.explanation-mode ~ .unit-meanings-container,
.quiz-section.active ~ .unit-meanings-container  {
    display: none !important;
}

/* Ensure it shows in regular mode */
.unit-meanings-container {
    display: block !important;
}

/* Add a subtle highlight when stairs are being used */
.stair-area:has(.step:hover) ~ .unit-meanings-container .unit-meaning {
    opacity: 0.7;
}

.stair-area:has(.step:hover) ~ .unit-meanings-container 
.unit-meaning:hover {
    opacity: 1;
}
/* SIMPLER CSS SOLUTION - Add these styles */

/* Hide unit meanings when quiz is active */
body:has(#quizSection.active) .unit-meanings-container,
body:has(.layout.explanation-mode) .unit-meanings-container {
    display: none !important;
}

/* Show unit meanings by default */
.unit-meanings-container {
    display: block !important;
}

/* Fallback for browsers that don't support :has() */
@supports not selector(:has(*)) {
    /* Use JavaScript approach instead */
    .unit-meanings-container {
        display: block !important;
    }
}

/*portrait*/
/* FIX FOR EXPLANATION MODE PORTRAIT LAYOUT */
@media (max-width: 1100px) and (orientation: portrait) {
    .layout.explanation-mode {
        flex-direction: row !important; /* Keep side-by-side layout */
        gap: 20px !important;
    }
    
    .layout.explanation-mode .left {
        flex: 1 !important;
        min-width: 0 !important;
        max-width: 60% !important; /* Give more space to stair area */
    }
    
    .layout.explanation-mode .right {
        width: 40% !important;
        min-width: 350px !important;
        flex-shrink: 0 !important;
    }
    
    /* Ensure stair area uses full available width */
    .layout.explanation-mode .stair-area {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
    }
}

/* Adjust for medium tablets */
@media (max-width: 900px) and (orientation: portrait) {
    .layout.explanation-mode {
        gap: 15px !important;
    }
    
    .layout.explanation-mode .left {
        max-width: 65% !important;
    }
    
    .layout.explanation-mode .right {
        width: 35% !important;
        min-width: 320px !important;
    }
}

/* For smaller tablets/phones in portrait, stack vertically */
@media (max-width: 768px) and (orientation: portrait) {
    .layout.explanation-mode {
        flex-direction: column !important;
    }
    
    .layout.explanation-mode .left,
    .layout.explanation-mode .right {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
    }
    
    .layout.explanation-mode .stair-area {
        height: 450px !important;
    }
    
    .layout.explanation-mode .explanation-panel .panel {
        max-height: none !important;
    }
}

/* Add this specific fix to prevent the stair area from shrinking */
.layout.explanation-mode .left {
    flex-shrink: 1 !important; /* Allow it to shrink only if necessary */
    flex-grow: 1 !important; /* Allow it to grow */
    flex-basis: auto !important;
}

/* Make sure stair area doesn't have width constraints */
.layout.explanation-mode .stair-area {
    min-width: 700px !important; /* Match the default min-width */
    width: 100% !important;
}

/* Override any problematic media queries */
@media (max-width: 1200px) {
    .layout.explanation-mode .stair-area {
        min-width: 650px !important;
    }
}

@media (max-width: 1100px) {
    .layout.explanation-mode .stair-area {
        min-width: 600px !important;
    }
}

/* Ensure explanation panel doesn't push stair area to be too narrow */
.layout.explanation-mode .right {
    max-width: 450px !important; /* Limit explanation panel width */
}

/* SINGLE-STEP MODE FOR MOBILE */
@media (max-width: 768px) {
    .layout.explanation-mode .explanation-panel .panel {
        height: 500px !important;
        padding: 20px !important;
    }
    
    .explanation-step {
        display: none !important; /* Hide all steps by default on mobile */
        margin-bottom: 0 !important;
    }
    
    /* Show only active step */
    .explanation-step.active {
        display: flex !important;
        opacity: 1 !important;
        max-height: 300px !important; /* Limit height on mobile */
        padding: 15px !important;
        margin-bottom: 15px !important;
    }
    
    /* Don't show completed steps on mobile */
    .explanation-step.completed {
        display: none !important;
    }
    
    .explanation-navigation:not(.explanation-navigation-bottom),
    .explanation-navigation-bottom {
        padding: 12px !important;
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }
    
    /* Navigation text adjustments */
    .step-progress-top {
        font-size: 13px;
    }
    
    .step-nav-btn {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }
    
    /* Step number sizing */
    .step-number {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }
    
    /* Step description adjustments */
    .step-description {
        font-size: 14px !important;
        line-height: 1.5;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .layout.explanation-mode .explanation-panel .panel {
        height: 450px !important;
        padding: 15px !important;
    }
    
    .explanation-step.active {
        max-height: 250px !important;
        padding: 12px !important;
        margin-bottom: 12px !important;
    }
    
    .step-number {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }
    
    .step-description {
        font-size: 13px !important;
    }
    
   
}