/* START OF FILE index.css */

        @keyframes wobble-animation {
          15% { transform: rotate(5deg); }
          30% { transform: rotate(-5deg); }
          45% { transform: rotate(3deg); }
          60% { transform: rotate(-3deg); }
          75% { transform: rotate(2deg); }
          90% { transform: rotate(-2deg); }
          100% { transform: rotate(0deg); }
        }

        body {
            font-family: 'Inter', sans-serif;
            background-color: #FCF8F0; /* Warm, creamy off-white background */
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            overflow: hidden;
            padding-top: 56px; /* Space for the project controls bar */
        }
        .container-wrapper {
            position: relative; /* Create a positioning context for absolute children */
            display: flex;
            flex-direction: row-reverse;
            justify-content: center;
            align-items: flex-start;
            gap: 1.5rem;
            width: 100%;
            padding: 2rem;
            box-sizing: border-box;
            transition: all 0.3s ease-in-out;
        }
        .left-panel {
            display: flex;
            flex-direction: column;
            width: 35%;
            flex-shrink: 0;
            gap: 1.5rem;
            transition: all 0.3s ease-in-out;
            max-height: calc(100vh - 56px - 4rem); /* Account for top bar + body padding */
            overflow-y: auto;
            padding-right: 8px; /* Add padding to prevent content from hiding behind scrollbar */
        }
        /* Custom scrollbar for left panel */
        .left-panel::-webkit-scrollbar {
            width: 8px;
        }
        .left-panel::-webkit-scrollbar-track {
            background: transparent;
        }
        .left-panel::-webkit-scrollbar-thumb {
            background: #A99985; /* Darker, warm gray/brown scrollbar */
            border-radius: 10px;
        }
        .left-panel::-webkit-scrollbar-thumb:hover {
            background: #9a8a77; /* Even darker on hover */
        }
        .right-panel {
            display: flex;
            flex-direction: column;
            width: 65%;
            gap: 1.5rem;
            transition: all 0.3s ease-in-out;
        }
        #stage-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: -0.5rem; /* Pull stage closer */
            padding-right: 8px; /* Align with panel padding */
        }
        #stage-controls {
            display: flex;
            gap: 0.5rem;
            align-items: center;
        }
        #stage-aspect-ratio-wrapper {
            position: relative;
            width: 100%;
            padding-top: 75%;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            background-color: #fff;
            border: 2px solid #EAE2D3; /* Softer border color */
            transition: all 0.3s ease-in-out;
            flex-shrink: 0; /* Prevent stage from shrinking */
        }
        #stage-area {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            background-size: cover;
            background-position: center;
            border-radius: 12px;
        }
        #scroller-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1; /* Below sprites */
            border-radius: 12px; /* Match stage-area */
            overflow: hidden;
        }
        .sprite-container {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 1px;
            height: 1px;
            visibility: hidden; /* Hide the container itself */
        }
        .sprite-wrapper {
            position: absolute;
            top: 0;
            left: 0;
            width: 160px; /* Base size */
            height: 160px; /* Base size */
            background-color: transparent;
            border-radius: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            transform-origin: center center;
            z-index: 10;
            opacity: 1;
            cursor: grab;
            visibility: visible; /* Make the wrapper visible */
            transform: translate(-50%, -50%); /* Center the wrapper on the container's point */
        }
        .sprite-wrapper:active {
            cursor: grabbing;
        }
        .sprite-wrapper img, .sprite-wrapper canvas {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 0;
        }
        .speech-bubble {
            position: absolute;
            background: #FFFBEA; /* Lighter, creamier yellow */
            border-radius: 12px;
            padding: 8px 12px;
            border: 1px solid #F5E8C7; /* Soft border for bubble */
            white-space: nowrap;
            font-size: 0.9rem;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            margin-bottom: 10px;
            opacity: 0;
            transition: opacity 0.3s ease;
            z-index: 11; /* Make sure it's above other sprites */
        }
        .speech-bubble::after {
            content: '';
            position: absolute;
            left: 50%;
            top: 100%;
            width: 0;
            height: 0;
            border: 8px solid transparent;
            border-top-color: #FFFBEA;
            border-bottom: 0;
            margin-left: -8px;
            margin-top: -1px;
        }
        .speech-bubble.visible {
            opacity: 1;
        }
        #blockly-area {
            flex-grow: 1;
            background-color: #FDFBF5; /* Match blueprint pattern background */
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            height: calc(100vh - 56px - 4rem); /* Account for top bar + body padding */
            min-height: 500px;
        }
        .section {
            background-color: #fff;
            border-radius: 12px;
            padding: 1rem;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            border: 1px solid #EAE2D3; /* Softer border */
            position: relative;
        }
        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        .section-header h2 {
            font-size: 1.25rem;
            font-weight: bold;
        }
        .header-actions {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        .header-button {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: #3b82f6; /* Blue accent */
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .header-button:hover {
            background-color: #2563eb; /* Darker blue on hover */
        }

        /* Custom button colors for specific sections */
        #backdrops-section .header-button {
            background-color: #9333ea; /* Purple */
        }
        #backdrops-section .header-button:hover {
            background-color: #7e22ce; /* Darker purple */
        }
        #sounds-section .header-button {
            background-color: #22c55e; /* Green */
        }
        #sounds-section .header-button:hover {
            background-color: #16a34a; /* Darker green */
        }

        .header-button svg {
            width: 20px;
            height: 20px;
        }
        .sprite-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            border: 2px solid #EAE2D3; /* Softer border */
            background-color: white;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            border-radius: 12px;
            padding: 0.5rem;
            cursor: pointer;
            transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
            position: relative;
            flex-shrink: 0;
            transform-origin: center;
        }
        .sprite-card.selected {
            border-color: #3b82f6; /* Blue accent for selection */
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .sprite-card.drop-target-hover {
            border-color: #f59e0b; /* Amber color */
            box-shadow: 0 0 15px rgba(245, 158, 11, 0.7);
            animation: wobble-animation 0.6s ease-in-out;
        }
        .sprite-card img {
            width: 48px;
            height: 48px;
            object-fit: contain;
            border-radius: 8px;
        }
        .delete-button {
            position: absolute;
            top: -8px;
            right: -8px;
            background-color: #ef4444;
            color: white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 0.8rem;
            cursor: pointer;
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .edit-button {
            position: absolute;
            top: -8px;
            left: -8px;
            background-color: #3b82f6;
            color: white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .edit-button svg {
            width: 12px;
            height: 12px;
        }
        .duplicate-button {
            position: absolute;
            bottom: -8px;
            left: -8px;
            background-color: #f59e0b; /* Amber */
            color: white;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .duplicate-button svg {
            width: 12px;
            height: 12px;
        }
        .sprite-card:hover .delete-button,
        .sprite-card:hover .edit-button,
        .sprite-card:hover .duplicate-button,
        .backdrop-card:hover .delete-button,
        .sound-card:hover .delete-button {
            visibility: visible;
            opacity: 1;
        }
        .backdrop-card {
            width: 80px;
            height: 60px;
            border: 2px solid transparent;
            border-radius: 8px;
            cursor: pointer;
            background-size: cover;
            background-position: center;
            transition: border-color 0.2s;
            flex-shrink: 0;
            position: relative;
        }
        .backdrop-card.selected {
            border-color: #3b82f6; /* Blue accent for selection */
        }
        .gallery-container {
            width: 100%;
            padding: 1rem;
            background-color: #FFFEFf; /* Ivory white background */
            border-radius: 12px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            display: none;
            transition: all 0.5s ease-in-out;
            border: 2px solid #f08f10; /* Softer border */
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 20;
            max-height: 32rem;
            overflow-y: auto;
        }
        .gallery-container.visible {
            display: block;
        }
        .thumbnail-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, 80px);
            gap: 0.5rem;
            justify-content: center;
        }
        .thumbnail {
            width: 100%;
            aspect-ratio: 1 / 1;
            object-fit: contain;
            background-color: white;
            border: 1px solid #EAE2D3; /* Softer border */
            padding: 4px;
            box-sizing: border-box;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        .thumbnail:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        .thumbnail.selected {
            border: 3px solid #3b82f6; /* Blue accent for selection */
        }
        .close-gallery-button {
            position: absolute;
            top: 1rem;
            right: 1rem;
            background-color: #ef4444; /* Red */
            color: white;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.5rem;
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: background-color 0.2s;
        }
        .close-gallery-button:hover {
            background-color: #dc2626; /* Darker red on hover */
        }
        /* Colorful Number Pad Styles */
        .number-pad-container {
            position: fixed; /* Use fixed positioning for viewport-relative logic */
            z-index: 10000;
            background-color: #FCF8F0; /* Warm background */
            border: 2px solid #F5B041; /* Warm orange accent border */
            border-radius: 12px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
            display: none;
            width: 150px; /* Further reduced width */
            padding: 8px; /* Further reduced padding */
            user-select: none;
        }
        .number-pad-display {
            background-color: #FFFFFF; /* White background as requested */
            border: 1px solid #E0E0E0; /* Adjusted border for white background */
            border-radius: 6px;
            padding: 6px; /* Further reduced padding */
            text-align: left;
            font-size: 1.25rem; /* Further reduced font size */
            margin-bottom: 8px; /* Further reduced margin */
            min-height: 36px; /* Further reduced height */
            color: #78350f; /* Dark brown/orange text */
            font-weight: bold;
        }
        .number-pad-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 5px; /* Further reduced gap */
        }
        .number-pad-grid button {
            padding: 10px 0; /* Further reduced padding */
            font-size: 1rem; /* Further reduced font size */
            font-weight: bold;
            color: white;
            border: none;
            border-radius: 6px; /* Further smaller radius */
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px #00000033; /* Further reduced shadow */
            margin-bottom: 2px; /* Further reduced margin */
        }
        .number-pad-grid button:active {
            transform: translateY(2px); /* Match shadow reduction */
            box-shadow: 0 0 #00000033;
        }
        .number-pad-grid button[data-value="7"],
        .number-pad-grid button[data-value="4"],
        .number-pad-grid button[data-value="1"] { background-color: #ef4444; }
        .number-pad-grid button[data-value="8"],
        .number-pad-grid button[data-value="5"],
        .number-pad-grid button[data-value="2"],
        .number-pad-grid button[data-value="0"] { background-color: #3b82f6; }
        .number-pad-grid button[data-value="9"],
        .number-pad-grid button[data-value="6"],
        .number-pad-grid button[data-value="3"] { background-color: #f97316; }
        .number-pad-grid button[data-value="."],
        .number-pad-grid button[data-value="-"] { background-color: #8b5cf6; }
        .number-pad-grid button[data-value="backspace"] { background-color: #eab308; }
        .number-pad-done {
            width: 100%;
            margin-top: 6px; /* Further reduced margin */
            padding: 8px 0; /* Further reduced padding */
            background-color: #22c55e;
            color: white;
            border: none;
            border-radius: 6px; /* Further reduced radius */
            font-size: 0.9rem; /* Further reduced font size */
            font-weight: bold;
            cursor: pointer;
            transition: all 0.2s ease;
            box-shadow: 0 2px #00000033; /* Further reduced shadow */
            margin-bottom: 2px; /* Further reduced margin */
        }
        .number-pad-done:active {
            transform: translateY(2px); /* Match shadow reduction */
            box-shadow: 0 0 #00000033;
        }

        /* Sprite Properties Panel - New Icon Styles */
        .prop-control-group {
            display: flex;
            align-items: center;
            background-color: #E5E7EB; /* Light gray background */
            border: 1px solid #D1D5DB; /* Subtle border */
            border-radius: 20px; /* Fully rounded ends */
            padding: 4px;
            box-shadow: 0 1px 2px rgba(0,0,0,0.05);
            transition: all 0.2s ease;
        }
        
        .prop-icon-wrapper {
            background-color: #3b82f6; /* Blue accent, like add sprite button */
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-shrink: 0;
        }
        
        .prop-icon {
            width: 18px;
            height: 18px;
            filter: brightness(0) invert(1); /* Make icon white */
        }
        
        #sprite-properties-panel input[type="text"],
        #sprite-properties-panel input[type="number"] {
            border: none;
            background: white;
            padding: 4px 8px;
            margin-right: 4px;
            border-radius: 16px;
            font-weight: 500;
            color: #333;
            outline: none;
            transition: box-shadow 0.2s;
            height: 28px;
            box-sizing: border-box;
        }
        
        #sprite-properties-panel #prop-name { width: 80px; }
        #sprite-properties-panel #prop-size { 
            width: 50px; 
        }
        #sprite-properties-panel #prop-direction {
            width: 60px;
        }
        #sprite-properties-panel #prop-x,
        #sprite-properties-panel #prop-y { 
            width: 60px; /* Accommodate up to 4 characters (e.g., -240) */
        }
        
        #sprite-properties-panel input:focus {
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4); /* Blue focus ring */
        }
        
        /* Specific styling for show/hide and rotation controls */
        .prop-control-group .control-set {
            display: flex;
            background-color: white;
            border-radius: 16px;
            padding: 2px;
            margin-right: 4px;
            height: 28px;
            box-sizing: border-box;
            gap: 2px;
        }
        
        .prop-control-group .control-set button {
            background-color: transparent;
            border-radius: 14px;
            padding: 2px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        
        .prop-control-group .control-set button.active {
            background-color: #fee2e2; /* Light red for active background */
        }
        
        .prop-control-group .control-set button.active svg {
            color: #ef4444; /* Red for active icon */
        }
        .prop-control-group .control-set button svg {
            width: 20px;
            height: 20px;
            color: #22c55e; /* Green icon color */
            pointer-events: none;
            transition: color 0.2s;
        }
        
        #prop-direction {
            cursor: pointer;
        }

        /* Custom Angle Picker */
        #angle-picker-widget {
            position: absolute;
            width: 120px;
            height: 120px;
            background-color: #fff;
            border: 2px solid #F5B041; /* Warm orange accent */
            border-radius: 50%;
            box-shadow: 0 5px 15px rgba(0,0,0,0.15);
            z-index: 10001;
            display: none;
            user-select: none;
            justify-content: center;
            align-items: center;
        }
        #angle-picker-dial {
            width: 100%;
            height: 100%;
            position: relative;
            cursor: pointer;
            background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><g stroke="%239ca3af"><circle cx="50" cy="50" r="48" stroke-width="2" fill="none"/><line x1="50" y1="2" x2="50" y2="12" stroke-width="2"/><line x1="98" y1="50" x2="88" y2="50" stroke-width="2"/><line x1="50" y1="98" x2="50" y2="88" stroke-width="2"/><line x1="2" y1="50" x2="12" y2="50" stroke-width="2"/><g stroke-width="1.5"><line x1="50" y1="2" x2="50" y2="10" transform="rotate(30 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(60 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(120 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(150 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(210 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(240 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(300 50 50)"/><line x1="50" y1="2" x2="50" y2="10" transform="rotate(330 50 50)"/></g></g></svg>');
            background-size: 80%;
            background-position: center;
            background-repeat: no-repeat;
        }
        #angle-picker-handle {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 50%;
            height: 2px;
            background: #3b82f6; /* Blue accent */
            transform-origin: 0% 50%;
        }
        
        /* Sprites Carousel with Slider */
        #sprites-list {
            flex-wrap: nowrap;
            overflow-x: auto;
            scroll-behavior: smooth;
            padding-bottom: 1rem;
        }
        #sprites-list::-webkit-scrollbar {
          height: 12px;
        }
        #sprites-list::-webkit-scrollbar-track {
          background: #fde8d7; /* Light warm orange */
          border-radius: 10px;
        }
        #sprites-list::-webkit-scrollbar-thumb {
          background-color: #F5B041; /* Warm orange */
          border-radius: 10px;
          border: 3px solid #fde8d7;
        }
        #sprites-list::-webkit-scrollbar-thumb:hover {
          background-color: #f3a02c; /* Darker warm orange */
        }
        
        /* Backdrops Carousel with Slider */
        #backdrops-list {
            flex-wrap: nowrap;
            overflow-x: auto;
            scroll-behavior: smooth;
            padding-bottom: 1rem;
        }
        #backdrops-list::-webkit-scrollbar {
          height: 12px;
        }
        #backdrops-list::-webkit-scrollbar-track {
          background: #dbeafe; /* Light blue */
          border-radius: 10px;
        }
        #backdrops-list::-webkit-scrollbar-thumb {
          background-color: #3b82f6; /* Blue accent */
          border-radius: 10px;
          border: 3px solid #dbeafe;
        }
        #backdrops-list::-webkit-scrollbar-thumb:hover {
          background-color: #2563eb; /* Darker blue */
        }

        /* Sounds Carousel Styles */
        #sounds-list {
            flex-wrap: nowrap;
            overflow-x: auto;
            scroll-behavior: smooth;
            padding-bottom: 1rem;
        }
        #sounds-list::-webkit-scrollbar {
          height: 12px;
        }
        #sounds-list::-webkit-scrollbar-track {
          background: #e9d5ff; /* Light purple */
          border-radius: 10px;
        }
        #sounds-list::-webkit-scrollbar-thumb {
          background-color: #9333ea; /* Purple */
          border-radius: 10px;
          border: 3px solid #e9d5ff;
        }
        #sounds-list::-webkit-scrollbar-thumb:hover {
          background-color: #7e22ce; /* Darker purple */
        }
        .sound-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            border: 2px solid #EAE2D3;
            background-color: white;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
            border-radius: 12px;
            padding: 0.5rem;
            cursor: pointer;
            transition: border-color 0.2s, box-shadow 0.2s;
            position: relative;
            flex-shrink: 0;
            width: 80px;
            height: 60px;
        }
        .sound-card-icon {
            width: 32px;
            height: 32px;
            color: #9333ea;
        }
        .sound-card-name {
            font-size: 0.7rem;
            margin-top: 4px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: 100%;
        }

        /* Sound Gallery Styles - New Grid Layout */
        .sound-thumbnail {
            position: relative;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 0.5rem;
            width: 100%;
            aspect-ratio: 1 / 1; /* Make it square like other thumbnails */
            object-fit: contain;
            background-color: white;
            border: 2px solid #EAE2D3;
            padding: 8px;
            box-sizing: border-box;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
            text-align: center;
        }

        .sound-thumbnail:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        
        .sound-thumbnail.selected-for-add {
            border-color: #22c55e; /* Green to indicate selection */
            box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
        }

        .sound-thumbnail-checkbox {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 18px;
            height: 18px;
            cursor: pointer;
            z-index: 2; /* Ensure it's above other elements */
        }
        
        .sound-thumbnail-icon {
            width: 48px;
            height: 48px;
            color: #9333ea; /* Purple theme for sound */
            pointer-events: none; /* Make sure clicks go through to the parent */
        }

        .sound-thumbnail-name {
            font-size: 0.75rem;
            font-weight: 500;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            pointer-events: none; /* Make sure clicks go through to the parent */
        }

        /* Sound Recorder Modal Styles */
        #sound-recorder-modal {
            z-index: 110; /* Above other modals */
        }
        .recorder-content {
            position: relative;
        }
        #recorder-visualizer {
            transition: all 0.2s ease-in-out;
        }
        #recorder-visualizer.is-recording {
            animation: pulse 1.2s infinite ease-out;
        }
        @keyframes pulse {
          0% { 
            transform: scale(1); 
            box-shadow: 0 0 0 0 rgba(147, 51, 234, 0.7); 
          }
          70% { 
            transform: scale(1.05); 
            box-shadow: 0 0 0 25px rgba(147, 51, 234, 0); 
          }
          100% { 
            transform: scale(1); 
            box-shadow: 0 0 0 0 rgba(147, 51, 234, 0); 
          }
        }
        #recorder-record-btn, #recorder-stop-btn {
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
            transition: all 0.2s ease;
        }
        #recorder-record-btn:hover, #recorder-stop-btn:hover {
            transform: scale(1.05);
        }
        #recorder-record-btn:active, #recorder-stop-btn:active {
            transform: scale(0.98);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }

        /* Fullscreen Controls */
        #fullscreen-controls-container {
            position: absolute;
            top: 0.5rem; /* Align with parent wrapper padding */
            left: 1rem;
            z-index: 25;
            display: none;
            gap: 0.5rem;
            height: 3.5rem; /* Define vertical space for controls */
            align-items: center; /* Center buttons vertically in this space */
        }

        /* Stage Expanded Styles */
        .container-wrapper.stage-expanded {
            padding: 0.5rem;
            gap: 0;
        }
        .container-wrapper.stage-expanded #fullscreen-controls-container {
            display: flex;
        }
        .container-wrapper.stage-expanded .left-panel {
            width: 100%;
            height: calc(100vh - 1rem);
            gap: 0;
            padding-top: 0; /* Let flexbox handle centering */
            box-sizing: border-box;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .container-wrapper.stage-expanded .right-panel,
        .container-wrapper.stage-expanded .section,
        .container-wrapper.stage-expanded #sprite-properties-panel {
            display: none;
        }
        .container-wrapper.stage-expanded #stage-aspect-ratio-wrapper {
            padding-top: 0;
            aspect-ratio: 4 / 3;
            width: auto;
            height: 100%;
            max-width: 100%;
        }
        /* Keep stage controls visible in fullscreen but hide unnecessary buttons */
        .container-wrapper.stage-expanded #stage-header {
            display: block; /* Make sure the container is visible */
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            z-index: 20;
        }
        .container-wrapper.stage-expanded #stage-header h2,
        .container-wrapper.stage-expanded #run-button,
        .container-wrapper.stage-expanded #reset-button,
        .container-wrapper.stage-expanded #toggle-grid-button {
            display: none;
        }
        .hidden {
            display: none !important;
        }

        /* Category Icon Styles */
        .blocklyTreeRow {
            min-height: 72px !important; /* Increased by 7px as requested */
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            border-bottom: 1px solid #e0e0e0;
            padding: 4px 0 !important;
            transition: background-color 0.2s, border-left-color 0.2s;
            border-left: 5px solid transparent; /* Prepare for selected state */
        }
        .blocklyTreeLabel {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px; /* Space between icon and text */
            position: relative; /* Add for positioning context of the background circle */
        }
        .blocklyTreeLabelText {
            font-weight: bold;
            color: #5f6368;
            font-size: 13px;
            transition: color 0.2s;
        }
        .kidi-category-icon {
            width: 28px;
            height: 28px;
            transition: filter 0.2s;
            position: relative; /* Ensure it's on top of the pseudo-element */
            z-index: 1;
        }
        .value-bubble {
            position: fixed; /* Use fixed to position relative to viewport */
            background-color: white;
            border: 1px solid #999;
            border-radius: 20px;
            padding: 5px 12px;
            font-size: 14px;
            font-weight: bold;
            color: #555;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.4s ease-out, top 0.1s, left 0.1s;
            pointer-events: none; /* So it doesn't interfere with future clicks */
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            transform: translate(-50%, -110%); /* Center horizontally and place above */
        }
        .blocklyTreeRow.kidi-category-selected {
            background-color: var(--category-color);
            border-left-color: var(--category-color);
        }

        .blocklyTreeRow.kidi-category-selected .blocklyTreeLabel::before {
            content: '';
            position: absolute;
            z-index: 0;
            width: 36px;
            height: 36px;
            background-color: white;
            border-radius: 50%;
            top: -4px; /* (28px icon height - 36px circle height) / 2 */
            left: 50%;
            transform: translateX(-50%);
            transition: all 0.2s;
        }

        .blocklyTreeRow.kidi-category-selected .blocklyTreeLabelText {
            color: white;
        }

        /* Character Creator Modal Styles */
        #character-creator-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 100;
        }
        #character-creator-modal.visible {
            display: flex;
        }
        .creator-content {
            background-color: #FCF8F0; /* Warm background */
            width: 90%;
            max-width: 1200px;
            height: 90vh;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        .creator-header {
            padding: 1rem 1.5rem;
            background-color: #fff;
            border-bottom: 1px solid #ddd;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }
        .creator-header h2 {
            font-size: 1.5rem;
            font-weight: bold;
        }
        .creator-main {
            display: flex;
            flex-grow: 1;
            overflow: hidden;
        }
        .creator-controls {
            width: 65%;
            background-color: #fff;
            display: flex;
            flex-direction: column;
        }
        .creator-categories {
            display: flex;
            flex-wrap: wrap;
            gap: 1rem;
            padding: 1rem;
            border-bottom: 1px solid #ddd;
            background-color: #f9fafb;
            overflow-x: auto;
            justify-content: center;
        }
        .category-button {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            width: 80px;
            height: 80px;
            border: 2px solid #e5e7eb;
            background-color: #fff;
            cursor: pointer;
            transition: all 0.2s;
            border-radius: 12px;
            padding: 0.5rem;
            box-sizing: border-box;
        }
        .category-icon {
            width: 40px;
            height: 40px;
            object-fit: contain;
            pointer-events: none;
            color: #4b5563;
            transition: color 0.2s;
        }
        .category-label {
            font-size: 0.75rem;
            font-weight: 600;
            color: #4b5563;
            pointer-events: none;
            transition: color 0.2s;
        }
        .category-button:hover {
            border-color: #9ca3af;
            background-color: #f9fafb;
        }
        .category-button.active {
            background-color: #dbeafe;
            border-color: #3b82f6;
            box-shadow: 0 4px 8px rgba(59, 130, 246, 0.2);
        }
        .category-button.active .category-icon,
        .category-button.active .category-label {
            color: #2563eb;
        }
        .creator-parts-grid {
            flex-grow: 1;
            padding: 1rem;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
            gap: 1rem;
            overflow-y: auto;
        }
        .part-thumbnail {
            width: 100%;
            aspect-ratio: 1 / 1;
            background-color: #e5e7eb;
            border: 2px solid transparent;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 8px;
        }
        .part-thumbnail img {
             max-width: 100%;
             max-height: 100%;
             object-fit: contain;
        }
        .part-thumbnail:hover {
            border-color: #9ca3af;
        }
        .part-thumbnail.selected {
            border-color: #3b82f6; /* Blue accent */
            box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
        }

        .creator-preview {
            width: 35%;
            padding: 2rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 1.5rem;
        }
        #character-canvas {
            width: 400px;
            height: 400px;
            background-color: #fff;
            border-radius: 12px;
            border: 2px dashed #d4c4b0; /* Soft beige dashed border */
            /* cursor is handled dynamically by JS */
            flex-shrink: 0;
        }
        #creator-controls-panel {
            width: 100%;
            max-width: 400px;
            padding: 1rem;
            background-color: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        .control-group {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        .control-group label {
            font-weight: bold;
            width: 50px;
            text-align: left;
            flex-shrink: 0;
        }
        #creator-color-palette {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
            justify-content: flex-start;
            flex-grow: 1;
        }
        .color-swatch {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid #e5e7eb;
            transition: transform 0.2s;
        }
        .color-swatch:hover {
            transform: scale(1.1);
        }

        .value-stepper {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            background-color: #f3f4f6;
            border: 1px solid #e5e7eb;
            border-radius: 16px;
            padding: 4px;
            flex-grow: 1;
            justify-content: space-between;
        }
        .value-stepper button {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background-color: #60a5fa;
            color: white;
            font-weight: bold;
            font-size: 1.25rem;
            line-height: 1;
            border: none;
            cursor: pointer;
            transition: background-color 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .value-stepper button:hover {
            background-color: #3b82f6;
        }
        .value-stepper span {
            font-family: monospace;
            font-size: 0.9rem;
            background-color: white;
            padding: 4px 8px;
            border: 1px solid #d1d5db;
            border-radius: 12px;
            min-width: 45px;
            text-align: center;
        }

        #creator-d-pad {
            display: grid;
            grid-template-columns: repeat(3, 34px);
            grid-template-rows: repeat(3, 34px);
            width: 102px;
            height: 102px;
            gap: 2px;
            flex-grow: 1;
            margin: 0 auto;
        }

        .d-pad-button {
            background-color: #60a5fa;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: background-color 0.2s, transform 0.1s;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            padding: 0;
        }
        .d-pad-button:hover {
            background-color: #3b82f6;
        }
        .d-pad-button:active {
            background-color: #2563eb;
            transform: scale(0.95);
        }
        .d-pad-button svg {
            width: 24px;
            height: 24px;
            pointer-events: none;
        }

        .d-pad-up { grid-area: 1 / 2 / 2 / 3; }
        .d-pad-left { grid-area: 2 / 1 / 3 / 2; }
        .d-pad-center {
            grid-area: 2 / 2 / 3 / 3;
            background-color: #e5e7eb;
            border-radius: 50%;
            border: 2px solid #d1d5db;
        }
        .d-pad-right { grid-area: 2 / 3 / 3 / 4; }
        .d-pad-down { grid-area: 3 / 2 / 4 / 3; }

        /* Generic Custom Slider Styles */
        input[type=range] {
          -webkit-appearance: none;
          width: 100%;
          background: transparent;
        }

        input[type=range]::-webkit-slider-thumb {
          -webkit-appearance: none;
          border: 1px solid #3b82f6; /* Blue accent */
          height: 16px;
          width: 16px;
          border-radius: 50%;
          background: #ffffff;
          cursor: pointer;
          margin-top: -6px;
          box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        input[type=range]::-webkit-slider-runnable-track {
          width: 100%;
          height: 4px;
          cursor: pointer;
          background: #fbdba7; /* Light warm orange */
          border-radius: 5px;
        }

        input[type=range]:focus::-webkit-slider-runnable-track {
          background: #F5B041; /* Warm orange */
        }

        input[type=range]::-moz-range-track {
          width: 100%;
          height: 4px;
          cursor: pointer;
          background: #fbdba7; /* Light warm orange */
          border-radius: 5px;
        }

        input[type=range]::-moz-range-thumb {
          border: 1px solid #3b82f6; /* Blue accent */
          height: 16px;
          width: 16px;
          border-radius: 50%;
          background: #ffffff;
          cursor: pointer;
          box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }

        /* Specific styles for GIF speed slider */
        #gif-speed-slider::-webkit-slider-runnable-track {
            background: #93c5fd; /* Lighter blue */
            height: 6px;
        }
        #gif-speed-slider::-moz-range-track {
            background: #93c5fd; /* Lighter blue */
            height: 6px;
        }
         #gif-speed-slider::-webkit-slider-thumb {
            height: 18px;
            width: 18px;
            margin-top: -6px;
         }
         #gif-speed-slider::-moz-range-thumb {
            height: 18px;
            width: 18px;
         }

        /* Grid Canvas Styles */
        #grid-canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none; /* Make it non-interactive */
            z-index: 5; /* Above background, below sprites */
            border-radius: 12px;
        }

        #toggle-grid-button.active {
            background-color: #f59e0b; /* Amber color for active state */
        }

        #toggle-grid-button.active:hover {
            background-color: #d97706; /* Darker amber on hover */
        }
        
        /* Panel Scroll Controls */
        #panel-scroll-controls {
            position: absolute;
            right: 10px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 10;
        }

        .panel-scroll-button {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: #f59e0b;
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: background-color 0.2s, transform 0.2s;
            border: none;
            box-shadow: 0 2px 5px rgba(0,0,0,0.15);
        }

        .panel-scroll-button:hover {
            background-color: #d97706;
            transform: scale(1.05);
        }

        .panel-scroll-button:active {
            transform: scale(0.98);
        }
        
        #prop-center-edit-btn.active {
             background-color: #f59e0b; /* Amber color */
             box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
        }
        
        /* Styles for Sprite Center Editor Modal */
        .center-editor-modal {
            display: none; /* Controlled by JS */
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.6);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        .center-editor-modal.visible {
            display: flex;
        }
        .center-editor-content {
            background-color: #FCF8F0;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            display: flex;
            flex-direction: column;
            gap: 1rem;
            max-width: 90vw;
            max-height: 90vh;
        }
        .center-editor-content h2 {
            text-align: center;
            font-size: 1.5rem;
            font-weight: bold;
            margin: 0 0 1rem 0;
        }
        #center-editor-preview {
            position: relative;
            border: 2px dashed #d4c4b0;
            background-color: white;
            cursor: crosshair;
            display: flex; /* center the image */
            justify-content: center;
            align-items: center;
            overflow: hidden; /* contain the image */
            padding: 1rem;
        }
        #center-editor-preview img {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            user-select: none;
            -webkit-user-drag: none;
        }
        #center-editor-marker {
            position: absolute;
            width: 20px;
            height: 20px;
            transform: translate(-50%, -50%);
            pointer-events: none;
            box-sizing: border-box;
        }
        #center-editor-marker::before,
        #center-editor-marker::after {
            content: '';
            position: absolute;
            background-color: #ef4444; /* Red */
            box-shadow: 0 0 3px rgba(0,0,0,0.5);
        }
        #center-editor-marker::before { /* Vertical line */
            left: 50%;
            top: -5px;
            width: 2px;
            height: 30px;
            margin-left: -1px;
        }
        #center-editor-marker::after { /* Horizontal line */
            top: 50%;
            left: -5px;
            height: 2px;
            width: 30px;
            margin-top: -1px;
        }
        .center-editor-buttons {
            display: flex;
            justify-content: flex-end;
            gap: 1rem;
        }
        .center-editor-buttons button {
            color: white;
            font-weight: bold;
            padding: 0.5rem 1rem;
            border-radius: 8px;
            border: none;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        #center-editor-cancel-btn {
            background-color: #ef4444; /* red */
        }
        #center-editor-cancel-btn:hover {
            background-color: #dc2626;
        }
        #center-editor-save-btn {
            background-color: #22c55e; /* green */
        }
        #center-editor-save-btn:hover {
            background-color: #16a34a;
        }

        /* Mobile layout adjustments */
        @media (max-width: 768px) {
            .container-wrapper {
                flex-direction: column;
                padding: 1rem;
            }
            .left-panel, .right-panel {
                width: 100%;
            }
            #blockly-area {
                height: 60vh;
            }
        }

        /* Responsive adjustments for sprite properties panel on medium screens */
        @media (max-width: 1300px) {
            #sprite-properties-row-1,
            #sprite-properties-row-2 {
                display: grid;
                grid-template-columns: repeat(2, auto);
                justify-content: center;
                gap: 0.5rem 1rem; /* row-gap column-gap */
                width: fit-content; /* Ensure the grid itself doesn't stretch unnecessarily */
                margin: 0 auto; /* Center the grid within its container */
            }
        }
/* END OF FILE index.css */
