diff --git a/templates/gallery.html b/templates/gallery.html
index 0952b06..895b3a7 100644
--- a/templates/gallery.html
+++ b/templates/gallery.html
@@ -100,6 +100,10 @@
             max-width: 80%;
             text-align: left;
             margin-top: 20px;
+            max-height: 25vh;
+            /* NEW: restrict height */
+            overflow-y: auto;
+            /* NEW: allow vertical scroll */
         }
 
         /* Back button fixed top right */
@@ -158,6 +162,10 @@
                 font-size: 14px;
                 max-width: 90%;
                 padding: 8px 16px;
+                max-height: 20vh;
+                /* smaller height for mobile */
+                overflow-y: auto;
+                /* keep scroll on mobile too */
             }
 
             .button-link {