:root {
            --primary: #9945FF;
            --secondary: #14F195;
            --accent: #00FFA3;
            --background: #131419;
            --card-bg: #1E1E24;
            --text: #FFFFFF;
            --zippin-primary: #ff5757;
            --zippin-secondary: #292929;
            --zippin-accent: #4BD6F2;
            --zippin-light: #f5f5f5;
            --zippin-dark: #151515;
            --zippin-gray: #444444;
            --zippin-border-radius: 12px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: var(--background);
            color: var(--text);
            line-height: 1.6;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
            overscroll-behavior: none;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 2rem;
            background-color: rgba(19, 20, 25, 0.9);
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
        }

        .logo {
            font-size: 2rem;
            font-weight: bold;
            color: var(--primary);
            text-decoration: none;
        }

        .logo span {
            color: var(--secondary);
        }

        h1 {
            font-size: 2.5rem;
            margin-bottom: 1.5rem;
            color: var(--zippin-primary);
            text-align: center;
            color: var(--zippin-accent);
        }

        .meme-maker {
            display: grid;
            grid-template-columns: 1fr 2fr;
            gap: 2rem;
            margin-top: 2rem;
        }

        .meme-controls {
            background-color: var(--card-bg);
            padding: 2rem;
            border-radius: var(--zippin-border-radius);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            color: var(--text);
        }

        /* fix canvas aspect ratio and centering on mobile portrait */
        .meme-canvas-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: var(--card-bg);
            padding: 2rem;
            border-radius: var(--zippin-border-radius);
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
            color: var(--text);
            width: 100%;
            box-sizing: border-box;
        }
        /* remove touch-action and user-select from .meme-canvas-inner, keep only on #memeCanvas */
        .meme-canvas-inner {
            width: 100vw;
            max-width: 500px;
            aspect-ratio: 1 / 1;
            background-color: var(--background);
            border-radius: var(--zippin-border-radius);
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto;
            /* remove touch-action and user-select here */
            pointer-events: none;
            /* remove duplicate position, width, height, etc. */
        }
        #memeCanvas {
            width: 100% !important;
            height: 100% !important;
            max-width: 500px;
            max-height: 500px;
            display: block;
            background: white;
            border-radius: 12px;
            touch-action: none;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            cursor: crosshair;
            z-index: 2;
            -webkit-tap-highlight-color: transparent;
        }
        @media (max-width: 768px) {
            .meme-canvas-inner {
                width: 98vw;
                max-width: 98vw;
                aspect-ratio: 1 / 1;
                height: auto;
                min-width: 0;
            }
            #memeCanvas {
                width: 100% !important;
                height: 100% !important;
                max-width: 98vw;
                max-height: 98vw;
            }
            .meme-canvas-container {
                padding: 1.2rem 0.7rem;
            }
        }

        .meme-canvas {
            background-color: var(--background);
            margin-bottom: 1.5rem;
            position: relative;
            overflow: hidden;
            max-width: 100%;
            height: auto;
            aspect-ratio: 1/1;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: var(--zippin-border-radius);
        }

        #memeCanvas {
            touch-action: none;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            cursor: crosshair;
            -webkit-tap-highlight-color: transparent;
        }

        .meme-text {
            position: absolute;
            cursor: move;
            padding: 5px;
            font-size: 24px;
            font-weight: bold;
            color: var(--text);
            text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
            z-index: 10;
            user-select: none;
            text-align: center;
            min-width: 20px;
            min-height: 20px;
        }

        .meme-image {
            position: absolute;
            cursor: move;
            z-index: 5;
            user-select: none;
            max-width: 200px;
            max-height: 200px;
        }

        .background-image {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: 1;
        }

        .resize-handle {
            position: absolute;
            width: 10px;
            height: 10px;
            background-color: var(--zippin-primary);
            border-radius: 50%;
            z-index: 15;
            border: 2px solid white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .resize-handle:hover {
            background-color: var(--zippin-accent);
            transform: scale(1.2);
        }

        .control-section {
            margin-bottom: 1.5rem;
        }

        .control-section h3 {
            margin-bottom: 1rem;
            color: var(--zippin-accent);
            border-bottom: 2px solid var(--zippin-gray);
            padding-bottom: 0.5rem;
        }

        .btn {
            background-color: var(--primary);
            color: white;
            border: none;
            padding: 0.6rem 1.2rem;
            font-size: 1rem;
            border-radius: var(--zippin-border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            margin: 0.5rem 0;
            text-transform: uppercase;
            font-weight: bold;
        }

        .btn:hover {
            background-color: var(--secondary);
            color: var(--background);
            transform: translateY(-2px);
        }

        .btn:active {
            transform: translateY(0);
        }

        .btn-secondary {
            background-color: transparent;
            color: var(--text);
            border: 2px solid var(--secondary);
        }

        .btn-secondary:hover {
            background-color: var(--secondary);
            color: var(--background);
        }

        .btn-accent {
            background-color: var(--accent);
            color: var(--background);
        }

        .btn-accent:hover {
            background-color: var(--secondary);
            color: var(--background);
        }

        .btn-block {
            display: block;
            width: 100%;
            margin-bottom: 0.5rem;
        }

        .form-group {
            margin-bottom: 1rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--zippin-light);
        }

        .form-control {
            width: 100%;
            padding: 0.7rem;
            border: 2px solid var(--primary);
            border-radius: var(--zippin-border-radius);
            background-color: var(--background);
            color: var(--text);
            font-size: 1rem;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--secondary);
        }

        .templates-grid, .stickers-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.5rem;
            margin-bottom: 1rem;
            max-height: 200px;
            overflow-y: auto;
        }

        .template-item, .sticker-item {
            height: 60px;
            background-color: var(--zippin-gray);
            border-radius: 5px;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .template-item:hover, .sticker-item:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        }

        .template-item img, .sticker-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .color-picker {
            display: flex;
            gap: 1rem;
            margin-bottom: 1rem;
        }

        .color-option {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
            border: 3px solid transparent;
            transition: all 0.3s ease;
            display: inline-block;
        }

        .color-option:hover {
            transform: scale(1.1);
            border-color: var(--zippin-accent);
        }

        .color-option.selected {
            border-color: var(--zippin-accent);
            box-shadow: 0 0 10px rgba(75, 214, 242, 0.5);
        }

        .actions-bar {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 1rem;
        }

        .actions-bar .btn {
            flex: 1;
            min-width: 120px;
        }

        /* scrollbar styling */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--zippin-dark);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--primary);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--secondary);
        }

        /* animation keyframes */
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* --- header and Title Layout for Desktop --- */
        .meme-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 100px;
            padding: 0 2rem;
            position: relative;
        }
        .header-logo {
            flex: 0 0 auto;
        }
        .header-back {
            flex: 0 0 auto;
        }
        .btn-back {
            font-size: 1rem;
            padding: 0.7rem 1.5rem;
            font-weight: 600;
        }
        .meme-title {
            text-align: center;
            margin: 2rem 0 0.5rem 0;
            font-size: 2.2rem;
            color: var(--zippin-accent);
            font-weight: bold;
        }

        /* --- mobile styles --- */
        @media (max-width: 768px) {
            .meme-header {
                height: 64px;
                padding: 0 1rem;
                justify-content: flex-start;
            }
            .header-logo {
                flex: 0 0 auto;
                display: flex;
                align-items: center;
            }
            .header-back {
                position: absolute;
                right: 1rem;
                top: 1rem;
                z-index: 10;
            }
            .btn-back {
                font-size: 0.95rem;
                padding: 0.5rem 1.1rem;
                border-radius: 8px;
            }
            .meme-title {
                margin: 1.2rem 0 0.7rem 0;
                font-size: 1.4rem;
                text-align: center;
            }
            .container {
                padding: 0.5rem;
            }
            .meme-maker {
                display: block;
                width: 100%;
                margin-top: 1rem;
            }
            .meme-controls {
                width: 100%;
                box-sizing: border-box;
                margin-bottom: 2rem;
                padding: 1.2rem 0.7rem;
            }
            .meme-canvas-container {
                width: 100%;
                padding: 1.2rem 0.7rem;
                box-sizing: border-box;
            }
            .meme-canvas-inner {
                width: 100% !important;
                max-width: 100vw;
                height: auto;
            }
            .templates-grid {
                grid-template-columns: repeat(3, 1fr);
                gap: 0.5rem;
            }
            .actions-bar {
                flex-direction: column;
                gap: 0.7rem;
            }
        }

        /* additional Feature Styling */
        .font-selector {
            width: 100%;
            margin-bottom: 1rem;
        }

        .text-style-options {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .text-style-btn {
            background-color: var(--zippin-gray);
            color: white;
            border: none;
            width: 36px;
            height: 36px;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .text-style-btn:hover {
            background-color: var(--zippin-primary);
        }

        .text-style-btn.active {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .text-outline-options {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .text-size-slider {
            width: 100%;
            background: var(--zippin-gray);
            height: 5px;
            border-radius: 5px;
            appearance: none;
        }

        .text-size-slider::-webkit-slider-thumb {
            appearance: none;
            width: 15px;
            height: 15px;
            border-radius: 50%;
            background: var(--zippin-accent);
            cursor: pointer;
        }

        .text-size-value {
            display: inline-block;
            margin-left: 0.5rem;
        }

        .loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 4px solid var(--zippin-gray);
            border-top: 4px solid var(--zippin-accent);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        .position-buttons {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .position-btn {
            flex: 1;
            padding: 0.5rem;
            background-color: var(--zippin-gray);
            color: white;
            border: none;
            border-radius: var(--zippin-border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
        }

        .position-btn:hover {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .position-btn.active {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .text-style-options {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .text-style-btn {
            padding: 0.5rem;
            background-color: var(--zippin-gray);
            color: white;
            border: none;
            border-radius: var(--zippin-border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            min-width: 40px;
        }

        .text-style-btn:hover {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .text-style-btn.active {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .font-selector {
            background-color: var(--zippin-dark);
            color: var(--zippin-light);
            border: 2px solid var(--zippin-gray);
            border-radius: var(--zippin-border-radius);
            padding: 0.7rem;
            width: 100%;
            margin-bottom: 1rem;
        }

        .font-selector:focus {
            outline: none;
            border-color: var(--zippin-accent);
        }

        .text-size-slider {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: var(--zippin-gray);
            outline: none;
            margin-bottom: 1rem;
        }

        .text-size-slider::-webkit-slider-thumb {
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--zippin-accent);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .text-size-value {
            font-weight: bold;
            color: var(--zippin-accent);
        }

        .templates-grid, .stickers-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.5rem;
            margin-bottom: 1rem;
            max-height: 200px;
            overflow-y: auto;
        }

        .template-item, .sticker-item {
            aspect-ratio: 1/1;
            border-radius: var(--zippin-border-radius);
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }

        .template-item:hover, .sticker-item:hover {
            transform: scale(1.05);
            border-color: var(--zippin-accent);
        }

        .template-item img, .sticker-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .scrollable {
            overflow-y: auto;
            max-height: 300px;
        }

        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--zippin-gray);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--zippin-accent);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #3ac4e0;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.6); 
            backdrop-filter: blur(5px);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: var(--card-bg);
            margin: 5% auto;
            padding: 2rem;
            border-radius: var(--zippin-border-radius);
            width: 90%;
            max-width: 500px;
            position: relative;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            color: var(--text);
            text-align: center; 
        }

        .close-modal {
            color: var(--zippin-light);
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            transition: color 0.3s ease;
        }

        .close-modal:hover {
            color: var(--zippin-accent);
        }





        @media (max-width: 480px) {
            .actions-bar {
                flex-direction: column;
            }
            
            .actions-bar .btn {
                min-width: auto;
            }
            
            .templates-grid, .stickers-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* Enhanced text styling */
        .meme-text.selected {
            outline: 2px solid var(--secondary);
            outline-offset: 2px;
        }

        /* Improved form controls */
        .form-control:focus {
            outline: none;
            border-color: var(--secondary);
            box-shadow: 0 0 0 3px rgba(75, 214, 242, 0.2);
        }

        /* Enhanced buttons */
        .btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .btn:disabled:hover {
            transform: none;
            background-color: var(--zippin-primary);
        }

        /* Loading animation improvements */
        .loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .loading-spinner {
            width: 50px;
            height: 50px;
            border: 4px solid var(--zippin-gray);
            border-top: 4px solid var(--zippin-accent);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        /* Enhanced position buttons */
        .position-buttons {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .position-btn {
            flex: 1;
            padding: 0.5rem;
            background-color: var(--zippin-gray);
            color: white;
            border: none;
            border-radius: var(--zippin-border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
        }

        .position-btn:hover {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .position-btn.active {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        /* Text style buttons */
        .text-style-options {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .text-style-btn {
            padding: 0.5rem;
            background-color: var(--zippin-gray);
            color: white;
            border: none;
            border-radius: var(--zippin-border-radius);
            cursor: pointer;
            transition: all 0.3s ease;
            min-width: 40px;
        }

        .text-style-btn:hover {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        .text-style-btn.active {
            background-color: var(--zippin-accent);
            color: var(--zippin-dark);
        }

        /* Font selector styling */
        .font-selector {
            background-color: var(--zippin-dark);
            color: var(--zippin-light);
            border: 2px solid var(--zippin-gray);
            border-radius: var(--zippin-border-radius);
            padding: 0.7rem;
            width: 100%;
            margin-bottom: 1rem;
        }

        .font-selector:focus {
            outline: none;
            border-color: var(--zippin-accent);
        }

        /* Text size slider */
        .text-size-slider {
            width: 100%;
            height: 6px;
            border-radius: 3px;
            background: var(--zippin-gray);
            outline: none;
            margin-bottom: 1rem;
        }

        .text-size-slider::-webkit-slider-thumb {
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--zippin-accent);
            cursor: pointer;
            border: 2px solid white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .text-size-value {
            font-weight: bold;
            color: var(--zippin-accent);
        }

        /* Template and sticker grids */
        .templates-grid, .stickers-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.5rem;
            margin-bottom: 1rem;
            max-height: 200px;
            overflow-y: auto;
        }

        .template-item, .sticker-item {
            aspect-ratio: 1/1;
            border-radius: var(--zippin-border-radius);
            overflow: hidden;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }

        .template-item:hover, .sticker-item:hover {
            transform: scale(1.05);
            border-color: var(--zippin-accent);
        }

        .template-item img, .sticker-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* Scrollbar styling */
        .scrollable {
            overflow-y: auto;
            max-height: 300px;
        }

        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: var(--zippin-gray);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--zippin-accent);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #3ac4e0;
        }

        /* Modal improvements */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(5px);
        }

        .modal-content {
            background-color: var(--card-bg);
            margin: 5% auto;
            padding: 2rem;
            border-radius: var(--zippin-border-radius);
            width: 90%;
            max-width: 500px;
            position: relative;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            color: var(--text);
        }

        .close-modal {
            color: var(--zippin-light);
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
            transition: color 0.3s ease;
        }

        .close-modal:hover {
            color: var(--zippin-accent);
        }



        /* Animation keyframes */
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Enhanced actions bar */
        .actions-bar {
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
            justify-content: center;
            margin-top: 1rem;
        }

        .actions-bar .btn {
            flex: 1;
            min-width: 120px;
        }

        /* Responsive improvements */
        @media (max-width: 480px) {
            .actions-bar {
                flex-direction: column;
            }
            
            .actions-bar .btn {
                min-width: auto;
            }
            
            .templates-grid, .stickers-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* Error popup */
        .error-popup {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 2000;
        }

        .error-content {
            background-color: var(--card-bg);
            padding: 2rem;
            border-radius: var(--zippin-border-radius);
            max-width: 400px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            color: var(--text);
        }

        .error-content h3 {
            color: var(--zippin-primary);
            margin-bottom: 1rem;
        }

        .error-content p {
            color: var(--zippin-light);
            margin-bottom: 1.5rem;
            line-height: 1.5;
        }

        .error-content .btn {
            margin: 0 auto;
        }

        /* Sticker size slider */
        .sticker-size-slider {
            width: 100%;
            background: var(--primary);
            height: 5px;
            border-radius: 5px;
            appearance: none;
            margin-bottom: 1rem;
        }
        .sticker-size-slider::-webkit-slider-thumb {
            appearance: none;
            width: 15px;
            height: 15px;
            border-radius: 50%;
            background: var(--secondary);
            cursor: pointer;
            border: 2px solid var(--primary);
        }

        .transform-buttons {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .transform-buttons .btn {
            min-width: 40px;
            padding: 0.5rem;
            background-color: var(--card-bg);
            color: var(--primary);
            border: 2px solid var(--primary);
            border-radius: 50%;
            font-size: 1.2rem;
            transition: background 0.2s, color 0.2s;
        }
        .transform-buttons .btn:hover {
            background-color: var(--primary);
            color: var(--background);
        }

        /* rotate handle for canvas elements */
        .rotate-handle {
            position: absolute;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background: var(--secondary);
            border: 2px solid var(--primary);
            cursor: grab;
            z-index: 20;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }

/* make the instructional modal scrollable on mobile */
#instructionModal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    overflow: auto;
}

#instructionModal .modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--zippin-border-radius);
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: var(--text);
    text-align: center;
    max-height: 80vh;
    overflow-y: auto;
}
#instructionModal .modal-content h2, #instructionModal .modal-content h1 {
    font-size: 1.3rem;
    margin-bottom: 0.7rem;
    line-height: 1.2;
}
#instructionModal .modal-content ol {
    padding-left: 1.1em;
    margin-bottom: 0.7rem;
}
#instructionModal .modal-content li {
    margin-bottom: 0.4em;
    font-size: 1em;
    line-height: 1.3;
    word-break: break-word;
}
#instructionModal .modal-content label {
    font-size: 0.95em;
}
@media (max-width: 768px) {
    #instructionModal .modal-content {
        padding: 0.7rem 0.3rem;
        width: 99vw;
        max-width: 99vw;
        max-height: 80vh;
        font-size: 0.98rem;
    }
    #instructionModal .modal-content h2, #instructionModal .modal-content h1 {
        font-size: 1.05rem;
        margin-bottom: 0.5rem;
    }
    #instructionModal .modal-content ol {
        padding-left: 1em;
        margin-bottom: 0.5rem;
    }
    #instructionModal .modal-content li {
        margin-bottom: 0.25em;
        font-size: 0.97em;
        line-height: 1.2;
    }
    #instructionModal .modal-content label {
        font-size: 0.92em;
    }
}
