/* Basic CSS reset and dark mode theme */
        html, body {
            margin: 0; padding: 0; width: 100%; height: 100%;
            background-color: #121212; color: #e0e0e0;
            font-family: 'Georgia', 'Times New Roman', serif;
            overflow: hidden;
        }

        #canvas-container { 
            position: absolute; 
            top: 0; 
            left: 0; 
            width: 100%; 
            height: 100%; 
            z-index: 1; 
            transition: all 0.8s ease-in-out;
            border-radius: 0;
        }
        
        /* Elegant inner glow effect for OOP mode */
        #canvas-container.oop-mode {
            box-shadow: 
                inset 0 0 80px rgba(138, 43, 226, 0.4),
                inset 0 0 120px rgba(75, 0, 130, 0.3),
                inset 0 0 160px rgba(106, 90, 205, 0.25),
                inset 0 0 240px rgba(72, 61, 139, 0.2),
                inset 0 0 320px rgba(138, 43, 226, 0.15);
            background: 
                radial-gradient(ellipse at center, rgba(138, 43, 226, 0.12) 0%, transparent 50%),
                radial-gradient(ellipse at 25% 25%, rgba(75, 0, 130, 0.08) 0%, transparent 40%),
                radial-gradient(ellipse at 75% 75%, rgba(106, 90, 205, 0.08) 0%, transparent 40%);
        }
        
        /* Alternative pseudo-element glow overlay */
        #canvas-container.oop-mode::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: 
                radial-gradient(ellipse at center, rgba(138, 43, 226, 0.15) 0%, transparent 60%),
                radial-gradient(ellipse at 20% 20%, rgba(75, 0, 130, 0.1) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 80%, rgba(106, 90, 205, 0.1) 0%, transparent 50%);
            box-shadow: 
                inset 0 0 100px rgba(138, 43, 226, 0.3),
                inset 0 0 200px rgba(75, 0, 130, 0.2);
            pointer-events: none;
            z-index: 1;
        }
        
        /* Additional subtle glow enhancement for p5.js canvas */
        #canvas-container.oop-mode canvas {
            filter: drop-shadow(0 0 25px rgba(138, 43, 226, 0.4)) brightness(1.05);
            position: relative;
            z-index: 2;
        }
        
        canvas { display: block; }
        
        /* Floating Panels General Styling */
        .floating-panel {
            position: absolute;
            background-color: rgba(26, 26, 26, 0.95);
            backdrop-filter: blur(10px);
            border: 1px solid #333;
            border-radius: 8px;
            box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
            z-index: 10;
            min-width: 280px;
            min-height: 150px;
            resize: none; /* Handled by custom handle */
            display: flex;
            flex-direction: column;
            box-sizing: border-box; /* Fix for dragging size change */
        }
        .panel-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 0.5rem 1rem;
            cursor: grab;
            border-bottom: 1px solid #333;
            flex-shrink: 0;
            user-select: none;
        }
        .panel-header:active {
            cursor: grabbing;
        }
        .panel-header h1 {
            font-size: 1.2rem; 
            margin: 0; 
            font-weight: 300; 
            letter-spacing: 1px; 
            color: #aaa;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .panel-controls button {
            background: none; border: 1px solid #555; color: #aaa; cursor: pointer;
            border-radius: 5px; padding: 0.25rem 0.5rem; margin-left: 0.5rem; transition: all 0.3s ease;
        }
        .panel-controls button:hover { background: #333; color: #fff; }

        /* Main Controls Panel */
        #controls-panel { top: 1rem; left: 1rem; max-width: 400px; width: 90%; min-height: 0; }
        .controls-content {
            display: flex; flex-direction: column; gap: 1rem; padding: 1rem;
            max-height: 500px; overflow: hidden;
            transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out, padding 0.5s ease-in-out, border 0.5s;
        }
        .controls-content.collapsed { max-height: 0; opacity: 0; padding: 0 1rem; gap: 0; border-top: none; }
        #controls-panel.collapsed .panel-header { border-bottom: none; }

        /* Top-Right UI Container (Hidden) */
        #top-right-container {
            display: none; /* Hide character icons as requested */
            position: absolute;
            top: 1rem;
            right: 1rem;
            z-index: 20;
            display: flex;
            flex-direction: column;
            align-items: flex-end; 
            gap: 1rem;
        }
        
        /* Character Icon Container */
        #character-icon-container {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }
        .char-icon-wrapper {
            position: relative;
        }
        .char-icon {
            font-size: 2rem;
            cursor: pointer;
            padding: 0.5rem;
            background-color: rgba(26, 26, 26, 0.8);
            border: 1px solid #333;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: all 0.3s ease;
        }
        .char-icon:hover {
            background-color: #333;
            transform: scale(1.1);
        }
        #add-char-icon, #feeling-lucky-icon {
            font-size: 1.5rem;
            font-weight: bold;
            color: #888;
        }
        .remove-char-btn {
            position: absolute;
            top: -5px;
            right: -5px;
            width: 20px;
            height: 20px;
            background: #a04040;
            color: white;
            border: 1px solid #fff;
            border-radius: 50%;
            font-size: 12px;
            line-height: 18px;
            text-align: center;
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.3s;
            pointer-events: none;
        }
        .char-icon-wrapper:hover .remove-char-btn {
            opacity: 0.8;
            pointer-events: all;
        }
        .remove-char-btn:hover {
            opacity: 1;
        }

        /* Character Chat Panels - compact & sleek */
        .chat-panel {
            display: none; /* Hidden by default */
            min-width: 300px;
            min-height: 320px;
            width: 340px;
            height: 380px;
        }

        .chat-panel .panel-header {
            padding: 0.4rem 0.75rem;
        }
        .chat-panel .panel-header h1 {
            font-size: 1rem;
            letter-spacing: 0.2px;
            color: #cfcfcf;
        }
        .chat-panel .panel-controls button {
            padding: 0.2rem 0.45rem;
            font-size: 0.8rem;
            border-radius: 4px;
        }

        .edit-char-btn {
            background: #4a5568;
            color: #e2e8f0;
            border: 1px solid #6b7280;
        }

        .edit-char-btn:hover {
            background: #2d3748;
            color: #f7fafc;
        }

        .chat-panel .controls-content {
            flex-grow: 1; /* Allow content to fill space */
            min-height: 0; /* Important for flex child */
            display: flex;
            flex-direction: column;
            padding: 0.75rem;
            gap: 0.6rem;
            max-height: 1000px; /* for collapse animation */
            overflow: hidden; /* hide during collapse */
            transition: max-height 300ms ease, opacity 200ms ease, padding 220ms ease;
        }
        .chat-panel .controls-content.collapsed {
            max-height: 0;
            opacity: 0;
            padding-top: 0;
            padding-bottom: 0;
        }
        
        .chat-log { 
            height: 100%; 
            overflow-y: auto; 
            padding: 0.75rem; 
            background: #181818; 
            border: 1px solid #2d2d2d;
            border-radius: 10px; 
            margin-bottom: 0.5rem; 
            font-size: 0.9rem; 
            flex-grow: 1; 
            line-height: 1.45;
            max-height: 260px; /* Ensure scrollable area */
        }
        
        /* Custom scrollbar for chat log */
        .chat-log::-webkit-scrollbar {
            width: 8px;
        }
        .chat-log::-webkit-scrollbar-track {
            background: #2a2a2a;
            border-radius: 4px;
        }
        .chat-log::-webkit-scrollbar-thumb {
            background: #555;
            border-radius: 4px;
        }
        .chat-log::-webkit-scrollbar-thumb:hover {
            background: #777;
        }
        .chat-log p { 
            margin: 0 0 0.5rem; 
            padding: 0.45rem 0.6rem;
            border-radius: 8px;
            line-height: 1.35;
            word-wrap: break-word;
            max-width: 100%;
        }
        .chat-log .user-msg { 
            color: #eef6ff; 
            background-color: rgba(17, 113, 201, 0.15);
            border-left: 2px solid #1171c9;
            font-weight: 500;
        }
        .chat-log .char-msg { 
            color: #e8e8e8; 
            background-color: rgba(40, 40, 40, 0.5);
            border-left: 2px solid #5d5d5d;
        }
        .chat-log .thinking-msg { 
            color: #999; 
            font-style: italic; 
            background-color: rgba(128, 128, 128, 0.1);
            border-left: 3px solid #555;
        }

        /* Typing effect styles */
        .typing-cursor {
            display: inline-block;
            width: 2px;
            height: 1.2em;
            background-color: #fff;
            margin-left: 2px;
            animation: blink 1s infinite;
            vertical-align: text-bottom;
        }

        @keyframes blink {
            0%, 50% { opacity: 1; }
            51%, 100% { opacity: 0; }
        }

        .typing-message {
            position: relative;
            cursor: pointer;
            transition: background-color 0.2s ease;
        }

        .typing-message:hover {
            background-color: rgba(60, 60, 60, 0.7) !important;
        }

        .typing-message .typing-cursor {
            background-color: #e8e8e8;
        }

        .typing-message::after {
            content: "Click to skip typing";
            position: absolute;
            top: -25px;
            right: 10px;
            background: rgba(0, 0, 0, 0.8);
            color: #fff;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
            white-space: nowrap;
            z-index: 1000;
        }

        .typing-message:hover::after {
            opacity: 1;
        }
        .chat-input-form { 
            display: flex; 
            gap: 0.6rem; 
            align-items: stretch;
            flex-shrink: 0;
        }
        .chat-input-form input { 
            flex-grow: 1; 
            background: #2b2b2b; 
            border: 2px solid #444; 
            color: #fff; 
            padding: 0.6rem; 
            border-radius: 6px; 
            font-size: 0.9rem;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        .chat-input-form input:focus {
            outline: none;
            border-color: #007bff;
            box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.18);
        }
        .chat-input-form button { 
            padding: 0.6rem 0.9rem; 
            background: #007bff;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 500;
            font-size: 0.9rem;
            transition: background-color 0.2s ease, transform 0.1s ease;
        }
        .chat-input-form button:hover {
            background: #0056b3;
        }
        .chat-input-form button:active {
            transform: translateY(1px);
        }
        .chat-input-form button:disabled {
            background: #555;
            cursor: not-allowed;
        }

    /* Group Discussion extras */
    #group-chat .participants-section { display: flex; flex-direction: column; gap: 0.35rem; }
    #group-chat .participants-label { font-size: 0.8rem; color: #9a9a9a; }
    .participants-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    .participant-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; background: #222; border: 1px solid #3a3a3a; color: #dcdcdc; font-size: 0.85rem; }
    .participant-pill .remove { background: none; border: none; color: #aaa; cursor: pointer; padding: 0 4px; }
    .participant-pill .remove:hover { color: #fff; }
    .participants-list .add-select { background: #2b2b2b; border: 1px solid #444; color: #ddd; border-radius: 6px; padding: 4px 8px; }
    .participants-list .add-btn { background: #1b5e20; border: 1px solid #2e7d32; color: #fff; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
    .participants-list .add-btn:hover { background: #2e7d32; }
    .group-controls-row { display: flex; gap: 8px; align-items: stretch; }
    #group-topic-input { flex: 1; background: #2b2b2b; border: 2px solid #444; color: #fff; padding: 0.5rem 0.6rem; border-radius: 6px; font-size: 0.9rem; }
    #group-topic-input:focus { outline: none; border-color: #1171c9; box-shadow: 0 0 0 2px rgba(17,113,201,0.18); }
    /* Group discussion specific button styling */
    #group-seek-consensus { background: #2a2a4a; border-color: #a2a2ff; }

        /* Resizing Handle */
        .resize-handle {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 15px;
            height: 15px;
            cursor: nwse-resize;
            border-right: 2px solid #555;
            border-bottom: 2px solid #555;
        }

        /* UI elements styling */
        textarea#story-input { width: 100%; height: 80px; background-color: #1f1f1f; color: #e0e0e0; border: 1px solid #333; border-radius: 8px; padding: 0.5rem; font-family: 'Georgia', serif; font-size: 0.9rem; resize: vertical; box-sizing: border-box; }
        textarea:focus { outline: none; border-color: #00c8ff; }
        .button-group { display: flex; justify-content: center; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
        .button-group button#generate-btn { flex-grow: 1; }
        .icon-button { font-size: 1.2rem; padding: 0.5rem 0.8rem; }
        button { padding: 0.5rem 1rem; font-size: 0.9rem; background: linear-gradient(145deg, #2c2c2c, #1a1a1a); color: #00c8ff; border: 1px solid #00c8ff; border-radius: 8px; cursor: pointer; transition: all 0.3s ease; }
        button:hover:not(:disabled) { background: linear-gradient(145deg, #3a3a3a, #2b2b2b); color: white; }
        button:disabled { cursor: not-allowed; opacity: 0.5; }
        .tts-button { 
            font-size: 0.9rem; 
            padding: 0.25rem 0.5rem; 
            background: #333; 
            border: 1px solid #555; 
            color: #aaa; 
            flex-shrink: 0; 
            cursor: pointer;
            border-radius: 3px;
            transition: all 0.2s ease;
            margin-right: 0.5rem;
            min-width: 32px;
            text-align: center;
        }
        .tts-button:hover {
            background: #444;
            color: #fff;
            border-color: #666;
        }
        .tts-button.speaking {
            background: #d32f2f;
            color: #fff;
            border-color: #f44336;
            animation: pulse 1.5s infinite;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
        #unveil-story-btn { display: none; }
        #clear-btn { background: #4a2a2a; border-color: #ff8c8c; }
        #settings-btn { background: #2a2a4a; border-color: #a2a2ff; }
        .status-bar { width: 100%; background-color: transparent; border-radius: 8px; padding-top: 0.5rem; color: #aaa; font-style: italic; font-size: 0.9rem; transition: color 0.5s; text-align: left; box-sizing: border-box; }
        
        /* Timer Container for bottom-left positioning */
        #timer-container {
            position: absolute;
            bottom: 1rem;
            left: 1rem;
            z-index: 20;
        }

        /* Mode Indicator Styling */
        .mode-indicator {
            background-color: rgba(26, 26, 26, 0.9);
            border: 1px solid #444;
            border-radius: 6px;
            padding: 0.4rem 0.6rem;
            margin-bottom: 0.5rem;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.8rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            min-width: 140px;
        }

        .mode-label {
            color: #888;
            font-weight: 500;
        }

        .mode-text {
            color: #00c8ff;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .mode-text.object-oriented {
            color: #ff6b6b;
        }

        .mode-text.traditional {
            color: #00c8ff;
        }

        /* API Counter Styling */
        .api-counter {
            background-color: rgba(26, 26, 26, 0.9);
            border: 1px solid #444;
            border-radius: 6px;
            padding: 0.5rem;
            margin-bottom: 0.5rem;
            font-family: 'Courier New', Courier, monospace;
            font-size: 0.8rem;
            color: #00c8ff;
            min-width: 140px;
        }

        .counter-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.2rem;
        }

        .counter-row:last-child {
            margin-bottom: 0;
        }

        .counter-label {
            color: #ccc;
        }

        #api-calls-count {
            color: #ff6b6b;
            font-weight: bold;
        }

        #token-estimate {
            color: #feca57;
            font-weight: bold;
        }

        /* Timer Display Styling */
        .timer-display {
            text-align: center; /* Center the text */
            font-family: 'Courier New', Courier, monospace;
            font-size: 1rem;
            color: #ccc; /* Default color */
            background-color: rgba(26, 26, 26, 0.8);
            padding: 0.25rem 0.75rem;
            border-radius: 6px;
            border: 1px solid #333;
            min-width: 130px; /* Ensure it doesn't jump around too much */
            transition: all 0.5s ease;
        }
        .timer-display.running {
            font-size: 1.5rem;
            color: #ffffff; /* Changed to white */
            animation: pulse-timer 1.5s infinite;
        }
        @keyframes pulse-timer {
            0% { text-shadow: 0 0 3px rgba(0, 200, 255, 0.7); } /* Adjusted glow for white text */
            50% { text-shadow: 0 0 12px rgba(0, 200, 255, 1); }
            100% { text-shadow: 0 0 3px rgba(0, 200, 255, 0.7); }
        }

        /* Modal & Tooltip */
        .modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(5px); z-index: 1000; align-items: center; justify-content: center; }
        .modal-content { background: #1a1a1a; border: 1px solid #444; border-radius: 8px; padding: 2rem; width: 90%; max-width: 600px; max-height: 80vh; box-shadow: 0 5px 25px rgba(0,0,0,0.5); position: relative; display: flex; flex-direction: column; }
        .modal-body { overflow-y: auto; padding-top: 0; }
        .modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; font-size: 1.5rem; color: #888; cursor: pointer; z-index: 10; }
        .modal-title { font-size: 1.5rem; margin-bottom: 1rem; color: #00c8ff; }
        .modal-footer { 
            margin-top: 1.5rem; 
            text-align: right; 
            display: flex;
            justify-content: flex-end;
            align-items: center;
            gap: 0.75rem;
        }
        .modal-footer .tts-button {
            margin-right: 0;
        }
        .image-gen-button {
            background: linear-gradient(45deg, #ff6b6b, #feca57);
            color: white;
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .image-gen-button:hover {
            background: linear-gradient(45deg, #ff5252, #feb47b);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
        }
        .image-gen-button:disabled {
            background: #666;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        #conclusion-image-container {
            border-top: 1px solid #444;
            padding-top: 1rem;
            margin-top: 1rem;
        }
        #conclusion-image {
            box-shadow: 0 4px 12px rgba(0,0,0,0.5);
            transition: transform 0.3s ease;
        }
        #conclusion-image:hover {
            transform: scale(1.02);
        }
        #add-clue-modal textarea, #add-char-modal textarea { width: 100%; height: 60px; margin-bottom: 1rem; background-color: #2b2b2b; }
        
        /* Settings Modal UI improvements */
        .settings-modal {
            max-width: 700px !important;
            max-height: 85vh !important;
            padding: 0 !important;
        }
        
        .modal-header {
            background: linear-gradient(135deg, #2d3748, #4a5568);
            padding: 1rem 1.5rem;
            border-bottom: 1px solid #444;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-radius: 8px 8px 0 0;
        }
        
        .modal-header .modal-title {
            margin: 0;
            font-size: 1.3rem;
            color: #00c8ff;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        .modal-header .modal-close {
            position: static;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }
        
        .modal-header .modal-close:hover {
            background: rgba(255, 107, 107, 0.2);
            border-color: #ff6b6b;
            color: #ff6b6b;
        }
        
        .settings-modal .modal-body {
            padding: 1.5rem;
            overflow-y: auto;
            max-height: calc(85vh - 80px);
        }
        
        .settings-group {
            padding-bottom: 0.75rem;
            margin-bottom: 1rem;
            border-bottom: 1px solid #333;
        }
        .settings-group:last-of-type {
            border-bottom: none;
            padding-bottom: 0;
            margin-bottom: 0;
        }
        .settings-group h3 {
            margin-top: 0;
            margin-bottom: 0.75rem;
            font-size: 0.85rem;
            color: #888;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 600;
        }
        .settings-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
        }
        .settings-toggles {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.75rem;
            align-items: center;
        }
        .setting-item { 
            margin-bottom: 0.75rem; 
        }
        .setting-item:last-child { 
            margin-bottom: 0; 
        }
        .setting-item label { 
            display: block; 
            margin-bottom: 0.4rem; 
            font-size: 0.85rem;
            color: #ccc;
            font-weight: 500;
        }
        .setting-item input, .setting-item select, .setting-item textarea {
            width: 100%;
            background: #2b2b2b;
            color: #fff;
            border: 1px solid #444;
            padding: 0.4rem 0.6rem;
            border-radius: 4px;
            box-sizing: border-box;
            font-family: 'Georgia', serif;
            font-size: 0.9rem;
            transition: border-color 0.3s ease;
        }
        .setting-item input:focus, .setting-item select:focus, .setting-item textarea:focus {
            outline: none;
            border-color: #00c8ff;
            box-shadow: 0 0 0 2px rgba(0, 200, 255, 0.1);
        }
        .setting-item textarea { 
            resize: vertical; 
            min-height: 36px; 
        }
        .setting-item input[type="range"] { 
            padding: 0; 
            height: 6px;
            background: #444;
            border-radius: 3px;
        }
        .setting-item input[type="range"]::-webkit-slider-thumb {
            appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #00c8ff;
            cursor: pointer;
            border: 2px solid #1a1a1a;
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        .setting-item .checkbox-label { 
            display: flex; 
            align-items: center; 
            gap: 0.5rem; 
            margin-bottom: 0.5rem;
            font-size: 0.85rem;
        }
        .setting-item .checkbox-label input { 
            width: auto; 
            margin: 0;
        }

        /* Premium section styling */
        .premium-section {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 8px;
            padding: 1rem;
            margin: 1rem 0;
            color: white;
            box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .premium-section h3 {
            margin: 0 0 0.75rem 0 !important;
            color: white !important;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
            padding-bottom: 0.5rem;
            display: flex;
            align-items: center;
            gap: 8px;
            text-transform: none !important;
            letter-spacing: normal !important;
            font-size: 1rem !important;
        }

        .premium-badge {
            background: linear-gradient(45deg, #FFD700, #FFA500);
            color: #333;
            font-size: 9px;
            font-weight: bold;
            padding: 2px 6px;
            border-radius: 10px;
            box-shadow: 0 2px 6px rgba(255, 215, 0, 0.2);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .premium-feature {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 6px;
            padding: 0.75rem;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .premium-toggle-container {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .premium-checkbox-label {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            font-size: 0.95rem;
            font-weight: 500;
            cursor: pointer;
            color: white;
        }

        .premium-checkbox-label input[type="checkbox"] {
            width: 18px;
            height: 18px;
            cursor: pointer;
            accent-color: #FFD700;
        }

        .premium-feature-name {
            font-weight: 600;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        }

        .premium-description {
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.8rem;
            line-height: 1.4;
            margin-left: 2rem;
            margin-top: 0.5rem;
            font-style: italic;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }

        #clue-tooltip, #char-tooltip { position: absolute; display: none; background-color: rgba(10, 10, 10, 0.9); color: #e0e0e0; border: 1px solid #555; border-radius: 6px; padding: 0.75rem; font-size: 0.9rem; max-width: 250px; pointer-events: none; z-index: 1001; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
        #char-tooltip b { color: #00c8ff; }
        .confirmation-buttons { display: flex; gap: 1rem; justify-content: flex-end; }
        
        /* Suggestion Modal UI Improvements */
        #suggestion-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1rem; }
        .suggestion-card { background: #2a2a2a; border-left: 4px solid #00c8ff; padding: 1rem; border-radius: 6px; display: flex; flex-direction: column; gap: 0.5rem; }
        .suggestion-card h3 { margin: 0; font-size: 1.1rem; color: #e0e0e0; }
        .suggestion-card p { margin: 0; font-size: 0.9rem; color: #aaa; line-height: 1.4; }
        .suggestion-card .add-btn { align-self: flex-end; padding: 0.4rem 0.8rem; font-size: 0.8rem; }
        .suggestion-card .add-btn:disabled { background: #3a9a3a; border-color: #3a9a3a; color: #fff; }

        /* Animated Loader for Suggestions */
        .suggestion-loader { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; margin: 2rem 0; }
        .magnifying-glass { width: 60px; height: 60px; border: 5px solid #555; border-radius: 50%; position: relative; animation: scan 2s linear infinite; }
        .magnifying-glass::after { content: ''; position: absolute; bottom: -25px; right: -25px; width: 35px; height: 5px; background: #555; transform: rotate(-45deg); }
        @keyframes scan { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        .suggestion-loader p { font-style: italic; color: #aaa; }

        /* Sleek modal enter animation for Suggestions */
        #suggestion-modal .modal-content { max-width: 720px; }
        #suggestion-modal .modal-content.animate-in {
            animation: modal-pop-in 220ms ease-out;
        }
        @keyframes modal-pop-in {
            0% { opacity: 0; transform: translateY(6px) scale(0.98); }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }

        /* Suggestions grid and smoother cards */
        #suggestion-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 12px;
            max-height: 60vh;
            overflow-y: auto;
            padding-right: 6px;
        }
        .suggestion-card {
            background: linear-gradient(180deg, rgba(42,42,42,0.95), rgba(32,32,32,0.95));
            border: 1px solid #333;
            border-left: 4px solid #00c8ff;
            border-radius: 10px;
            padding: 0.9rem 1rem;
            transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
        }
        .suggestion-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(0,0,0,0.35);
            border-left-color: #35d1ff;
        }
        .suggestion-card h3 { font-weight: 600; letter-spacing: 0.2px; }
        .suggestion-card p { color: #b8b8b8; }
        .suggestion-card .add-btn {
            align-self: flex-end;
            padding: 0.45rem 0.9rem;
            font-size: 0.85rem;
            background: #0b5aa0;
            border: 1px solid #1f78c1;
            color: #fff;
            border-radius: 6px;
            transition: transform 120ms ease, background-color 160ms ease, box-shadow 160ms ease;
        }
        .suggestion-card .add-btn:hover:not(:disabled) {
            background: #1171c9;
            box-shadow: 0 4px 14px rgba(17, 113, 201, 0.35);
            transform: translateY(-1px);
        }
        .suggestion-card .add-btn:active:not(:disabled) {
            transform: translateY(0);
        }
        #suggestion-list::-webkit-scrollbar { width: 8px; }
        #suggestion-list::-webkit-scrollbar-track { background: #202020; border-radius: 4px; }
        #suggestion-list::-webkit-scrollbar-thumb { background: #3e3e3e; border-radius: 4px; }
        #suggestion-list::-webkit-scrollbar-thumb:hover { background: #4e4e4e; }
        
        /* Game Toolbar */
        #game-toolbar {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(10, 10, 10, 0.8);
            backdrop-filter: blur(10px);
            border: 1px solid #333;
            border-radius: 12px;
            padding: 8px;
            display: flex;
            gap: 8px;
            z-index: 100;
        }
        #game-toolbar button {
            background: #2b2b2b;
            border: 1px solid #444;
            color: #ccc;
            font-size: 1.5rem;
            width: 50px;
            height: 50px;
            border-radius: 8px;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        #game-toolbar button:hover {
            transform: scale(1.1);
            background: #3c3c3c;
            color: #fff;
            border-color: #00c8ff;
        }
        
        /* Thinking Visualization Button States */
        .thinking-viz-btn.active {
            background: #4a4a4a !important;
            border-color: #9c27b0 !important;
            color: #e1bee7 !important;
            box-shadow: 0 0 10px rgba(156, 39, 176, 0.3);
        }
        
        .thinking-viz-btn.inactive {
            background: #2b2b2b !important;
            border-color: #555 !important;
            color: #888 !important;
            opacity: 0.6;
        }
        
        .thinking-viz-btn.active:hover {
            background: #5a3a7a !important;
            border-color: #ba68c8 !important;
            box-shadow: 0 0 15px rgba(156, 39, 176, 0.5);
        }
        
        .thinking-viz-btn.inactive:hover {
            background: #3c3c3c !important;
            border-color: #777 !important;
            opacity: 0.8;
        }

        /* Communication Log Window */
        #comm-log-panel {
            min-width: 400px;
            min-height: 300px;
            max-width: 90vw;
            max-height: 80vh;
        }

        .comm-log-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 1rem;
            overflow: hidden;
        }

        .comm-log-tabs {
            display: flex;
            border-bottom: 2px solid #333;
            margin-bottom: 1rem;
        }

        .comm-tab-button {
            background: #2b2b2b;
            border: none;
            color: #aaa;
            padding: 0.8rem 1.2rem;
            cursor: pointer;
            border-radius: 8px 8px 0 0;
            margin-right: 4px;
            transition: all 0.3s ease;
            font-size: 0.9rem;
            border-bottom: 2px solid transparent;
        }

        .comm-tab-button:hover {
            background: #3c3c3c;
            color: #fff;
        }

        .comm-tab-button.active {
            background: #4a4a4a;
            color: #e1bee7;
            border-bottom: 2px solid #9c27b0;
        }

        .comm-tab-content {
            display: none;
            flex: 1;
            flex-direction: column;
            overflow: hidden;
        }

        .comm-tab-content.active {
            display: flex;
        }

        .log-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.8rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid #444;
        }

        .log-title {
            font-weight: bold;
            color: #e0e0e0;
            font-size: 1rem;
        }

        .log-controls {
            display: flex;
            gap: 1rem;
            align-items: center;
        }

        .log-controls label {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: #aaa;
            font-size: 0.85rem;
        }

        .log-controls input[type="checkbox"] {
            accent-color: #9c27b0;
        }

        .log-controls button {
            background: #2b2b2b;
            border: 1px solid #555;
            color: #aaa;
            padding: 0.3rem 0.8rem;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: all 0.3s ease;
        }

        .log-controls button:hover {
            background: #3c3c3c;
            color: #fff;
            border-color: #9c27b0;
        }

        .log-container {
            flex: 1;
            background: #1a1a1a;
            border: 1px solid #333;
            border-radius: 6px;
            padding: 1rem;
            overflow-y: auto;
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
            font-size: 0.85rem;
            line-height: 1.4;
        }

        .log-placeholder {
            color: #666;
            font-style: italic;
            text-align: center;
            margin-top: 2rem;
        }

        .log-entry {
            margin-bottom: 1rem;
            padding: 0.8rem;
            border-radius: 6px;
            border-left: 4px solid #555;
        }

        .log-entry.message {
            background: rgba(138, 43, 226, 0.1);
            border-left-color: #9c27b0;
        }

        .log-entry.api-request {
            background: rgba(0, 150, 255, 0.1);
            border-left-color: #0096ff;
        }

        .log-entry.api-response {
            background: rgba(0, 200, 100, 0.1);
            border-left-color: #00c864;
        }

        .log-entry.error {
            background: rgba(255, 69, 0, 0.1);
            border-left-color: #ff4500;
        }

        .log-timestamp {
            font-size: 0.75rem;
            color: #888;
            margin-bottom: 0.3rem;
        }

        .log-content {
            color: #e0e0e0;
        }

        .log-content pre {
            background: #0d0d0d;
            padding: 0.5rem;
            border-radius: 4px;
            overflow-x: auto;
            margin: 0.5rem 0;
            font-size: 0.8rem;
        }

        .log-object-id {
            color: #9c27b0;
            font-weight: bold;
        }

        .log-api-method {
            color: #0096ff;
            font-weight: bold;
        }

        .log-status-code {
            color: #00c864;
            font-weight: bold;
        }

        .log-error-code {
            color: #ff4500;
            font-weight: bold;
        }

        /* Resize handle for communication log */
        .resize-handle {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 20px;
            height: 20px;
            background: linear-gradient(-45deg, transparent 30%, #555 30%, #555 40%, transparent 40%, transparent 60%, #555 60%, #555 70%, transparent 70%);
            cursor: nw-resize;
            border-bottom-right-radius: 8px;
        }

        .resize-handle:hover {
            background: linear-gradient(-45deg, transparent 30%, #9c27b0 30%, #9c27b0 40%, transparent 40%, transparent 60%, #9c27b0 60%, #9c27b0 70%, transparent 70%);
        }

        /* Character Edit Modal Styles */
        #character-edit-modal .modal-content {
            max-width: 500px;
        }

        #character-edit-modal .setting-item {
            margin-bottom: 1.2rem;
        }

        #character-edit-modal .setting-item label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: 600;
            color: #e2e8f0;
        }

        #character-edit-modal .setting-item input,
        #character-edit-modal .setting-item textarea {
            width: 100%;
            padding: 0.6rem;
            background: #2d3748;
            border: 1px solid #4a5568;
            border-radius: 6px;
            color: #e2e8f0;
            font-size: 0.95rem;
            resize: vertical;
        }

        #character-edit-modal .setting-item input:focus,
        #character-edit-modal .setting-item textarea:focus {
            outline: none;
            border-color: #63b3ed;
            box-shadow: 0 0 0 2px rgba(99, 179, 237, 0.2);
        }

        #character-edit-modal .modal-footer {
            display: flex;
            gap: 1rem;
            justify-content: flex-end;
            padding-top: 1.5rem;
            border-top: 1px solid #4a5568;
        }

        .primary-button {
            background: #3182ce;
            color: white;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s ease;
        }

        .primary-button:hover {
            background: #2c5282;
        }

        .secondary-button {
            background: #4a5568;
            color: #e2e8f0;
            border: 1px solid #6b7280;
            padding: 0.75rem 1.5rem;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .secondary-button:hover {
            background: #2d3748;
            border-color: #9ca3af;
        }

        /* Help Modal Styles */
        .help-modal {
            max-width: 900px;
            max-height: 80vh;
            width: 90vw;
        }

        .help-tabs {
            display: flex;
            border-bottom: 2px solid #333;
            margin-bottom: 1.5rem;
            overflow-x: auto;
        }

        .help-tab {
            background: transparent;
            border: none;
            color: #e0e0e0;
            padding: 0.75rem 1.5rem;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            transition: all 0.3s ease;
            white-space: nowrap;
            font-size: 0.9rem;
        }

        .help-tab.active,
        .help-tab:hover {
            color: #4a90e2;
            border-bottom-color: #4a90e2;
            background: rgba(74, 144, 226, 0.1);
        }

        .help-content {
            max-height: 60vh;
            overflow-y: auto;
            padding-right: 10px;
        }

        .help-tab-content {
            display: none;
        }

        .help-tab-content.active {
            display: block;
        }

        .help-tab-content h3 {
            color: #4a90e2;
            margin-bottom: 1rem;
            font-size: 1.5rem;
        }

        .help-tab-content h4 {
            color: #e0e0e0;
            margin: 1.5rem 0 0.75rem 0;
            font-size: 1.2rem;
        }

        .help-tab-content h5 {
            color: #b0b0b0;
            margin: 1rem 0 0.5rem 0;
            font-size: 1rem;
        }

        .help-feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
            margin: 1.5rem 0;
        }

        .help-feature {
            background: rgba(74, 144, 226, 0.1);
            border: 1px solid #4a90e2;
            border-radius: 8px;
            padding: 1.5rem;
            text-align: center;
        }

        .help-icon {
            font-size: 2rem;
            margin-bottom: 0.75rem;
        }

        .help-feature h4 {
            color: #4a90e2;
            margin: 0.5rem 0;
            font-size: 1.1rem;
        }

        .help-feature p {
            color: #c0c0c0;
            font-size: 0.9rem;
            line-height: 1.4;
        }

        .help-step {
            display: flex;
            margin: 2rem 0;
            gap: 1rem;
        }

        .help-step-number {
            background: #4a90e2;
            color: white;
            width: 2rem;
            height: 2rem;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            flex-shrink: 0;
        }

        .help-step-content h4 {
            margin-top: 0;
            color: #e0e0e0;
        }

        .help-example {
            background: rgba(255, 255, 255, 0.05);
            border-left: 4px solid #4a90e2;
            padding: 1rem;
            margin: 1rem 0;
            border-radius: 4px;
        }

        .help-toolbar-guide {
            margin: 1.5rem 0;
        }

        .help-toolbar-item {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.75rem 0;
            border-bottom: 1px solid #333;
        }

        .help-toolbar-icon {
            background: #4a90e2;
            padding: 0.5rem;
            border-radius: 6px;
            font-size: 1.1rem;
            width: 2rem;
            height: 2rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .help-interactions ul,
        .help-ai-features ul,
        .help-tips ul {
            list-style: none;
            padding: 0;
        }

        .help-interactions li,
        .help-ai-features li,
        .help-tips li {
            background: rgba(255, 255, 255, 0.05);
            padding: 0.75rem;
            margin: 0.5rem 0;
            border-radius: 6px;
            border-left: 3px solid #4a90e2;
        }

        .help-system-comparison {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2rem;
            margin: 2rem 0;
        }

        .help-system {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 8px;
            padding: 1.5rem;
            border: 1px solid #333;
        }

        .traditional-system {
            border-left: 4px solid #28a745;
        }

        .oo-system {
            border-left: 4px solid #4a90e2;
        }

        .system-pros ul {
            list-style: none;
            padding: 0;
        }

        .system-pros li {
            padding: 0.25rem 0;
            color: #c0c0c0;
        }

        .system-description {
            margin-top: 1rem;
            padding-top: 1rem;
            border-top: 1px solid #333;
        }

        .help-when-to-use {
            margin: 2rem 0;
        }

        .help-usage-guide {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2rem;
        }

        .usage-scenario {
            background: rgba(255, 255, 255, 0.05);
            padding: 1.5rem;
            border-radius: 8px;
            border: 1px solid #333;
        }

        .usage-scenario strong {
            color: #4a90e2;
            display: block;
            margin-bottom: 0.75rem;
            font-size: 1.1rem;
        }

        .usage-scenario ul {
            list-style: none;
            padding: 0;
        }

        .usage-scenario li {
            padding: 0.25rem 0;
            color: #c0c0c0;
        }

        .help-faq {
            margin: 1.5rem 0;
        }

        .faq-item {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 8px;
            padding: 1.5rem;
            margin: 1rem 0;
            border: 1px solid #333;
        }

        .faq-item h4 {
            color: #4a90e2;
            margin-top: 0;
        }

        .faq-item ul {
            list-style: none;
            padding: 0;
        }

        .faq-item li {
            padding: 0.25rem 0;
            color: #c0c0c0;
        }

        .help-tips {
            background: rgba(74, 144, 226, 0.1);
            border: 1px solid #4a90e2;
            border-radius: 8px;
            padding: 1.5rem;
            margin: 1.5rem 0;
        }

        .help-tips h4 {
            color: #4a90e2;
            margin-top: 0;
        }

        /* Mobile responsiveness for help modal */
        @media (max-width: 768px) {
            .help-modal {
                width: 95vw;
                max-height: 90vh;
            }

            .help-tabs {
                flex-wrap: wrap;
            }

            .help-tab {
                padding: 0.5rem 1rem;
                font-size: 0.8rem;
            }

            .help-feature-grid {
                grid-template-columns: 1fr;
            }

            .help-system-comparison {
                grid-template-columns: 1fr;
            }

            .help-usage-guide {
                grid-template-columns: 1fr;
            }

            .help-step {
                flex-direction: column;
            }

            .help-step-number {
                align-self: flex-start;
            }
        }

/* State Modal Styles */
.state-modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.state-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid #444;
}

.state-tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    font-size: 0.9rem;
}

.state-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.state-tab-btn.active {
    color: #4CAF50;
    border-bottom-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.state-tab-content {
    display: none;
}

.state-tab-content.active {
    display: block;
}

.state-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid #4CAF50;
}

.state-section h4 {
    margin: 0 0 1rem 0;
    color: #4CAF50;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.state-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
}

.state-item {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    font-size: 0.9rem;
}

.state-item strong {
    color: #fff;
}

.state-description {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.state-description > div {
    margin-bottom: 0.75rem;
}

.state-description > div:last-child {
    margin-bottom: 0;
}

.state-relationships, .state-evidence {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    padding: 1rem;
}

.relationships-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.relationship-item {
    padding: 0.5rem;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    font-size: 0.9rem;
}

.state-insights {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.insight-item {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border-left: 3px solid #FF9800;
}

.insight-type {
    font-weight: bold;
    color: #FF9800;
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.insight-content {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.insight-confidence {
    font-size: 0.8rem;
    color: #aaa;
}

.reasoning-chain {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.reasoning-step {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border-left: 3px solid #2196F3;
    font-size: 0.9rem;
    line-height: 1.5;
}

.reasoning-step strong {
    color: #2196F3;
    display: block;
    margin-bottom: 0.5rem;
}

.comm-log {
    max-height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    padding: 1rem;
}

.comm-entry {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border-left: 3px solid #9C27B0;
}

.comm-timestamp {
    font-size: 0.7rem;
    color: #aaa;
    margin-bottom: 0.25rem;
}

.comm-message {
    font-size: 0.85rem;
    line-height: 1.4;
}

.state-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}

/* Responsive adjustments for state modal */
@media (max-width: 768px) {
    .state-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .state-grid {
        grid-template-columns: 1fr;
    }
    
    .state-tabs {
        flex-wrap: wrap;
    }
    
    .state-tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}