        /* ==========================================================================
           1. CSS & STYLING (Modern, Clean, Responsive)
           ========================================================================== */
        @import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700&display=swap');

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

        body,
        html {
            width: 100%;
            height: 100%;
            overflow: hidden;
            background-color: #ffffff;
            /* Reines Weiß */
            font-family: 'Nunito', sans-serif;
            /* Verhindert Textmarkierung, ungewolltes Scrollen und Pull-to-Refresh auf Mobile */
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            touch-action: none;
            overscroll-behavior: none;
        }

        /* Das Canvas ist unsere Bühne */
        canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 1;
            cursor: crosshair;
        }

        #ui-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            z-index: 2;
            pointer-events: none;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            /* Push dock to bottom */
            padding: 20px;
            padding-bottom: 0px;
            /* Dock touches bottom */
        }

        .top-left-logo {
            position: absolute;
            top: 20px;
            left: 20px;
            pointer-events: none;
            opacity: 0.6;
        }

        .top-left-logo h2 {
            font-family: 'Fredoka One', cursive;
            font-size: 1.2rem;
            color: #33365f;
            margin: 0;
        }

        .header {
            text-align: center;
            background: rgba(255, 255, 255, 0.85);
            padding: 15px 30px;
            border-radius: 50px;
            box-shadow: 0 10px 30px rgba(51, 54, 95, 0.1);
            align-self: center;
            backdrop-filter: blur(8px);
            margin-top: 10px;
            pointer-events: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }

        .header-buttons {
            display: flex;
            gap: 10px;
        }

        .icon-btn {
            background: transparent;
            color: #33365f;
            border: none;
            padding: 8px;
            font-size: 1.2rem;
            cursor: pointer;
            box-shadow: none;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease;
        }

        .icon-btn:hover {
            background: rgba(89, 136, 185, 0.2);
            transform: scale(1.1);
            box-shadow: none;
        }

        .header h2 {
            color: #33365f;
            /* Hauptfarbe */
            font-size: 1.5rem;
            margin-bottom: 5px;
            font-family: 'Fredoka One', cursive;
            letter-spacing: 1px;
        }

        .header p {
            color: #5988b9;
            /* Akzent 2 */
            font-size: 1rem;
            font-weight: 700;
        }

        .controls {
            align-self: center;
            margin-bottom: 20px;
            display: flex;
            gap: 15px;
            pointer-events: auto;
            /* Buttons anklickbar machen */
        }

        button {
            background-color: #a4bd1e;
            /* Akzent 1 (Grün) */
            color: white;
            border: none;
            padding: 12px 25px;
            font-size: 1.1rem;
            font-weight: bold;
            border-radius: 30px;
            cursor: pointer;
            box-shadow: 0 5px 15px rgba(164, 189, 30, 0.4);
            transition: all 0.2s ease;
            font-family: 'Nunito', sans-serif;
            text-transform: uppercase;
            letter-spacing: 1px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        button:hover {
            transform: translateY(-3px) scale(1.05);
            box-shadow: 0 8px 20px rgba(164, 189, 30, 0.6);
        }

        button:active {
            transform: translateY(1px);
        }

        button.blue-btn {
            background-color: #5988b9;
            box-shadow: 0 5px 15px rgba(89, 136, 185, 0.4);
        }

        button.blue-btn:hover {
            box-shadow: 0 8px 20px rgba(89, 136, 185, 0.6);
        }

        button.danger-btn {
            background-color: #e74c3c;
            box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
            margin: 0;
        }

        button.danger-btn:hover {
            box-shadow: 0 8px 20px rgba(231, 76, 60, 0.6);
        }

        button.btn-active {
            box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.2) !important;
            transform: scale(0.95) !important;
            background-color: #c0392b !important;
            border: 2px solid #33365f;
        }

        /* WERKZEUGLEISTE */
        .dock-controls {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .scroll-wrapper {
            overflow-x: hidden;
            overflow-y: auto;
            max-height: 50vh;
            /* Adjust for modal size */
            padding: 10px 15px 15px 15px;
            /* Added padding to prevent box-shadow clipping */
            margin-bottom: -15px;
            /* Offset to keep layout */
            /* Scrollbar styling */
            scrollbar-width: thin;
            scrollbar-color: #a4bd1e rgba(89, 136, 185, 0.1);
        }

        .scroll-wrapper::-webkit-scrollbar {
            height: 8px;
        }

        .scroll-wrapper::-webkit-scrollbar-track {
            background: rgba(89, 136, 185, 0.1);
            border-radius: 4px;
        }

        .scroll-wrapper::-webkit-scrollbar-thumb {
            background-color: #a4bd1e;
            border-radius: 4px;
        }

        .tool-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .tool-grid button {
            padding: 10px 20px;
            font-size: 1rem;
            border-radius: 20px;
            text-transform: none;
            justify-content: center;
            flex-shrink: 0;
        }

        /* TABS inside Modal */
        .tab-buttons {
            display: flex;
            gap: 5px;
            background: rgba(89, 136, 185, 0.1);
            border-radius: 20px;
            padding: 3px;
        }

        /* --- Tool Grid Modal & Settings --- */
        .tutorial-hint {
            position: fixed;
            bottom: 40px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            padding: 15px 25px;
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(51, 54, 95, 0.2);
            display: flex;
            align-items: center;
            gap: 15px;
            z-index: 50;
            color: #33365f;
            border: 2px solid rgba(89, 136, 185, 0.2);
            font-size: 1rem;
            opacity: 1;
            transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            pointer-events: auto;
        }

        .tutorial-hint.hidden {
            opacity: 0;
            transform: translate(-50%, 20px);
            pointer-events: none;
        }

        .tutorial-hint i.fa-lightbulb {
            font-size: 1.5rem;
            color: #f1c40f;
        }

        .tutorial-hint span {
            font-size: 0.85rem;
            color: #5988b9;
        }

        .tools-trigger {
            position: absolute;
            top: 20px;
            right: 20px;
            z-index: 100;
            pointer-events: auto;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            font-size: 1rem;
            padding: 10px 20px;
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            backdrop-filter: blur(5px);
        }

        .modal.active {
            display: flex;
        }

        .modal-content {
            background: white;
            padding: 30px;
            border-radius: 20px;
            width: 90%;
            max-width: 600px;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .tools-modal-content {
            width: 90%;
            max-width: 900px;
            /* Wider tool window */
            max-height: 80vh;
            display: flex;
            flex-direction: column;
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 20px;
            border-bottom: 2px solid rgba(89, 136, 185, 0.2);
            flex-wrap: wrap;
            gap: 10px;
        }

        .modal-header h2 {
            color: #33365f;
            font-family: 'Fredoka One', cursive;
        }

        .modal-header h3 {
            margin: 0;
            font-size: 1.2rem;
            color: #33365f;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .tab-btn {
            background: transparent;
            color: #5988b9;
            box-shadow: none;
            padding: 8px 15px;
            border-radius: 17px;
            font-size: 0.9rem;
        }

        .tab-btn.active {
            background: white;
            color: #33365f;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .tab-btn:hover {
            transform: translateY(0);
            box-shadow: none;
        }

        .tab-btn.active:hover {
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .settings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            gap: 15px;
            margin-top: 15px;
        }

        /* Tooltip styling for Title attribute natively mostly looks fine, 
           custom tooltip on items if needed */
        .setting-item {
            position: relative;
            overflow: visible;
        }

        .setting-tooltip {
            position: absolute;
            bottom: 120%;
            left: 50%;
            transform: translateX(-50%) translateY(10px);
            background: rgba(51, 54, 95, 0.95);
            color: white;
            padding: 10px 15px;
            border-radius: 8px;
            font-size: 0.85rem;
            white-space: pre-wrap;
            width: max-content;
            max-width: 250px;
            text-align: center;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 1000;
            pointer-events: none;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .setting-tooltip::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border-width: 6px;
            border-style: solid;
            border-color: rgba(51, 54, 95, 0.95) transparent transparent transparent;
        }

        .setting-item:hover .setting-tooltip {
            opacity: 1;
            visibility: visible;
            transform: translateX(-50%) translateY(0);
        }

        .intensity-grid {
            display: flex;
            flex-direction: column;
            gap: 15px;
            max-height: 400px;
            overflow-y: auto;
            padding-right: 10px;
        }

        .intensity-item {
            display: flex;
            flex-direction: column;
            background: #f8f9fa;
            padding: 15px;
            border-radius: 15px;
            gap: 8px;
        }

        .intensity-item label {
            display: flex;
            justify-content: space-between;
            font-weight: bold;
            color: #33365f;
        }

        .intensity-item input[type="range"] {
            width: 100%;
        }

        .setting-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px;
            background: #f8f9fa;
            border-radius: 10px;
            cursor: pointer;
            border: 2px solid transparent;
            transition: all 0.2s;
        }

        .setting-item:hover {
            background: #e9ecef;
            border-color: #5988b9;
        }

        .setting-item input[type="checkbox"] {
            width: 20px;
            height: 20px;
            cursor: pointer;
            accent-color: #5988b9;
        }

        .setting-item label {
            cursor: pointer;
            font-weight: bold;
            color: #33365f;
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            pointer-events: none;
        }

        .modal-footer {
            display: flex;
            justify-content: flex-end;
            border-top: 2px solid #eee;
            padding-top: 15px;
        }

        /* Ladebildschirm */
        #loading {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: white;
            z-index: 100;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Fredoka One', cursive;
            font-size: 2rem;
            color: #33365f;
            transition: opacity 0.5s ease;
        }

        /* MOBILE OPTIMIERUNG */
        @media (max-width: 768px) {
            #ui-layer {
                display: none;
            }

            #loading {
                font-size: 1.2rem;
            }

            canvas {
                cursor: default;
            }

            .bottom-dock {
                display: none;
            }
        }