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

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: #1a202c;
            overflow: hidden;
        }

        .app-container {
            display: grid;
            grid-template-columns: 320px 1fr 350px;
            grid-template-rows: 80px 1fr;
            height: 100vh;
            max-width: 1800px;
            margin: 0 auto;
            gap: 15px;
            padding: 15px;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 25px 50px rgba(0,0,0,0.15);
            overflow: hidden;
        }

        .header {
            grid-column: 1 / -1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
            background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
            color: white;
            border-radius: 15px;
            box-shadow: 0 8px 25px rgba(66, 153, 225, 0.3);
        }

        .header h1 {
            font-size: 2em;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header .status-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #48bb78;
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.7; transform: scale(1.1); }
        }

        .controls-panel {
            background: white;
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            overflow-y: auto;
            height: calc(100vh - 110px);
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .controls-panel::-webkit-scrollbar {
            width: 6px;
        }

        .controls-panel::-webkit-scrollbar-track {
            background: #f1f5f9;
            border-radius: 3px;
        }

        .controls-panel::-webkit-scrollbar-thumb {
            background: #4299e1;
            border-radius: 3px;
        }

        .experiment-area {
            position: relative;
            overflow: hidden;
            border-radius: 15px;
            background: radial-gradient(circle at 50% 50%, #f8fafc 0%, #e2e8f0 100%);
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            display: flex;
            flex-direction: column;
        }

        .observations-panel {
            background: white;
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            overflow-y: auto;
            height: calc(100vh - 110px);
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .observations-panel::-webkit-scrollbar {
            width: 6px;
        }

        .observations-panel::-webkit-scrollbar-track {
            background: #f1f5f9;
            border-radius: 3px;
        }

        .observations-panel::-webkit-scrollbar-thumb {
            background: #4299e1;
            border-radius: 3px;
        }

        .control-section {
            background: white;
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.08);
        }

        .control-section h3 {
            color: #2d3748;
            margin-bottom: 15px;
            font-size: 1.1em;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .control-section h3::before {
            content: '⚙️';
            font-size: 1.2em;
        }

        .input-group {
            margin-bottom: 20px;
            padding: 15px;
            background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
            border-radius: 10px;
            border: 1px solid #e2e8f0;
        }

        .input-group label {
            display: block;
            margin-bottom: 8px;
            font-size: 0.875rem;
            font-weight: 500;
            color: #374151;
        }

        .control-row {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .btn {
            width: 100%;
            padding: 12px 16px;
            border: none;
            border-radius: 8px;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 8px;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }

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

        .btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .btn-primary {
            background: linear-gradient(135deg, #3b82f6, #1e40af);
            color: white;
        }

        .btn-secondary {
            background: linear-gradient(135deg, #10b981, #059669);
            color: white;
        }

        .btn-danger {
            background: linear-gradient(135deg, #ef4444, #dc2626);
            color: white;
        }

        .btn-warning {
            background: linear-gradient(135deg, #f59e0b, #d97706);
            color: white;
        }

        select {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            font-size: 0.9rem;
            background: white;
            color: #2d3748;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        select:focus {
            outline: none;
            border-color: #3182ce;
            box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
        }

        .simulation-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 20px;
            overflow: hidden;
            position: relative;
            min-height: 500px;
        }

        .control-section {
            background: #f8fafc;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 20px;
            border: 1px solid #e2e8f0;
        }

        .control-section h3 {
            color: #2d3748;
            margin-bottom: 15px;
            font-size: 1rem;
            font-weight: 600;
        }

        .control-group {
            margin-bottom: 15px;
        }

        .control-group:last-child {
            margin-bottom: 0;
        }

        .control-label {
            display: block;
            font-weight: 500;
            color: #4a5568;
            margin-bottom: 5px;
            font-size: 0.9rem;
        }

        select, input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #e2e8f0;
            border-radius: 6px;
            font-size: 0.9rem;
            background: white;
            color: #2d3748;
            transition: all 0.2s ease;
        }

        select:focus, input:focus {
            outline: none;
            border-color: #3182ce;
            box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
        }

        .btn {
            background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
            color: white;
            border: none;
            padding: 10px 16px;
            border-radius: 6px;
            font-size: 0.9rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            width: 100%;
            margin-bottom: 10px;
        }

        .btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(49, 130, 206, 0.3);
        }

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

        .btn:disabled {
            background: #a0aec0;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .btn-secondary {
            background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
        }

        .btn-danger {
            background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
        }

        .coordinator {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 120px;
            height: 120px;
            background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: white;
            font-size: 0.9rem;
            box-shadow: 0 8px 20px rgba(49, 130, 206, 0.3);
            transition: all 0.3s ease;
            z-index: 10;
            border: 4px solid white;
        }

        .coordinator.active {
            animation: coordinatorPulse 2s infinite;
        }

        @keyframes coordinatorPulse {
            0%, 100% { transform: translate(-50%, -50%) scale(1); }
            50% { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 12px 30px rgba(49, 130, 206, 0.4); }
        }

        .participants {
            position: relative;
            width: 100%;
            height: 100%;
        }

        .participant {
            width: 90px;
            height: 90px;
            background: linear-gradient(135deg, #63b3ed 0%, #4299e1 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: white;
            font-size: 0.8rem;
            box-shadow: 0 6px 15px rgba(66, 153, 225, 0.3);
            transition: all 0.3s ease;
            position: relative;
            border: 3px solid white;
        }

        .participant.failed {
            background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
            animation: shake 0.5s;
        }

        .participant.voted-yes {
            background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
        }

        .participant.voted-no {
            background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
        }

        .participant.committed {
            background: linear-gradient(135deg, #68d391 0%, #48bb78 100%);
            animation: success 0.8s;
        }

        .participant.aborted {
            background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
            color: #742a2a;
        }

        @keyframes shake {
            0%, 100% { transform: translateX(0); }
            25% { transform: translateX(-3px); }
            75% { transform: translateX(3px); }
        }

        @keyframes success {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.15); }
        }

        .message {
            position: absolute;
            background: white;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: 600;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            animation: messageFlow 2s ease-in-out;
            z-index: 20;
            border: 2px solid #3182ce;
            color: #2d3748;
        }

        @keyframes messageFlow {
            0% { opacity: 0; transform: scale(0.8); }
            20% { opacity: 1; transform: scale(1); }
            80% { opacity: 1; transform: scale(1); }
            100% { opacity: 0; transform: scale(0.8); }
        }

        .phase-indicator {
            position: absolute;
            top: 20px;
            left: 20px;
            background: white;
            padding: 12px 20px;
            border-radius: 8px;
            font-weight: 600;
            color: #2d3748;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border: 1px solid #e2e8f0;
            font-size: 0.9rem;
            z-index: 10;
        }

        .status-section {
            background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
            border-radius: 12px;
            padding: 15px;
            border: 1px solid #e2e8f0;
        }

        .status-section h4 {
            color: #2d3748;
            margin-bottom: 12px;
            font-size: 1em;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .status-section h4::before {
            content: '📊';
            font-size: 1.1em;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-bottom: 20px;
        }

        .stat-card {
            background: white;
            border-radius: 12px;
            padding: 15px;
            text-align: center;
            border: 1px solid #e2e8f0;
            transition: all 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        }

        .stat-value {
            font-size: 1.4rem;
            font-weight: 700;
            margin-bottom: 5px;
        }

        .stat-label {
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .stat-description {
            font-size: 0.7rem;
            color: #94a3b8;
            margin-top: 3px;
        }

        #successCount { color: #10b981; }
        #abortCount { color: #f59e0b; }
        #failureCount { color: #ef4444; }
        #totalTransactions { color: #3b82f6; }

        .logs {
            height: 400px;
            overflow-y: auto;
            font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
            font-size: 0.8rem;
            line-height: 1.4;
            background: white;
            border-radius: 8px;
            padding: 15px;
            border: 1px solid #e2e8f0;
            box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.05);
        }

        .log-entry {
            margin: 4px 0;
            padding: 6px 10px;
            border-radius: 6px;
            background: #f8fafc;
            border-left: 3px solid #94a3b8;
            animation: fadeIn 0.3s ease-in;
        }

        .log-entry.info {
            border-left-color: #3b82f6;
            background: #eff6ff;
            color: #2563eb;
        }

        .log-entry.success {
            border-left-color: #10b981;
            background: #f0fdf4;
            color: #059669;
        }

        .log-entry.error {
            border-left-color: #ef4444;
            background: #fef2f2;
            color: #dc2626;
        }
        
        .log-entry.warning {
            border-left-color: #f59e0b;
            background: #fffbeb;
            color: #d97706;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(5px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .connection-line {
            position: absolute;
            height: 2px;
            background: linear-gradient(90deg, transparent, #3182ce, transparent);
            transform-origin: left;
            animation: connectionPulse 1s ease-in-out;
            z-index: 5;
        }

        .connection-line::after {
            content: '';
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 0;
            height: 0;
            border-left: 15px solid #3182ce;
            border-top: 8px solid transparent;
            border-bottom: 8px solid transparent;
            animation: arrowPulse 1s ease-in-out;
        }

        @keyframes connectionPulse {
            0% { width: 0; opacity: 0; }
            50% { opacity: 1; }
            100% { width: 100%; opacity: 0; }
        }

        @keyframes arrowPulse {
            0% { opacity: 0; transform: translateY(-50%) scale(0); }
            50% { opacity: 1; transform: translateY(-50%) scale(1); }
            100% { opacity: 0; transform: translateY(-50%) scale(1); }
        }

        .failure-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(245, 101, 101, 0.1);
            backdrop-filter: blur(3px);
            display: none;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            font-weight: 700;
            color: #e53e3e;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            z-index: 100;
            border-radius: 15px;
        }

        .failure-overlay.active {
            display: flex;
        }

        .floating-controls {
            position: absolute;
            top: 20px;
            left: 20px;
            display: flex;
            gap: 10px;
            z-index: 10;
        }

        .floating-btn {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: none;
            background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
            color: white;
            cursor: pointer;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            transition: all 0.3s ease;
        }

        .floating-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
        }

        .floating-btn.active {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
        }

        .legend-panel {
            position: absolute;
            top: 20px;
            right: 20px;
            background: white;
            border-radius: 12px;
            padding: 15px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            border: 1px solid #e2e8f0;
            z-index: 10;
            min-width: 200px;
        }

        .legend-panel h4 {
            color: #2d3748;
            margin-bottom: 12px;
            font-size: 0.9rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .legend-panel h4::before {
            content: '🔍';
            font-size: 1em;
        }

        .legend-items {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 0.8rem;
            color: #4a5568;
        }

        .legend-color {
            width: 15px;
            height: 15px;
            border-radius: 50%;
            border: 1px solid #e2e8f0;
        }

        .scenario-section {
            background: linear-gradient(135deg, #f0f8ff 0%, #e0f2fe 100%);
            border-radius: 12px;
            padding: 15px;
            border: 1px solid #bee3f8;
        }

        .scenario-section h4 {
            color: #2c5282;
            margin-bottom: 10px;
            font-size: 0.9rem;
            font-weight: 600;
        }

        .tooltip {
            position: absolute;
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 6px 10px;
            border-radius: 4px;
            font-size: 0.8rem;
            pointer-events: none;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
            white-space: nowrap;
        }

        .tooltip.show {
            opacity: 1;
        }

        #animationSpeed::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #3b82f6, #1e40af);
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
        }

        #animationSpeed::-moz-range-thumb {
            width: 20px;
            height: 20px;
            background: linear-gradient(135deg, #3b82f6, #1e40af);
            border-radius: 50%;
            cursor: pointer;
            border: none;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
        }

        /* Mobile Landscape Support - Phones */
        @media screen and (max-width: 768px) and (orientation: landscape) {
            .app-container {
                grid-template-columns: 280px 1fr 300px;
                grid-template-rows: 60px 1fr;
                height: 100vh;
                gap: 8px;
                padding: 8px;
                overflow: hidden;
            }

            .header {
                grid-column: 1 / -1;
                padding: 0 15px;
            }

            .header h1 {
                font-size: 1.4em;
            }

            .controls-panel {
                height: calc(100vh - 76px);
                padding: 15px;
                gap: 15px;
            }

            .control-section {
                padding: 15px;
            }

            .control-section h3 {
                font-size: 1em;
                margin-bottom: 12px;
            }

            .input-group {
                padding: 12px;
                margin-bottom: 15px;
            }

            .btn {
                padding: 10px 12px;
                font-size: 0.8rem;
                margin-bottom: 6px;
            }

            select {
                padding: 8px 10px;
                font-size: 0.85rem;
            }

            .experiment-area {
                height: calc(100vh - 76px);
            }

            .simulation-area {
                padding: 15px;
                min-height: 350px;
            }

            .coordinator {
                width: 80px;
                height: 80px;
                font-size: 0.7rem;
            }

            .participant {
                width: 60px;
                height: 60px;
                font-size: 0.65rem;
            }

            .legend-panel {
                padding: 10px;
                min-width: 140px;
                font-size: 0.75rem;
                top: 15px;
                right: 15px;
            }

            .legend-panel h4 {
                font-size: 0.8rem;
                margin-bottom: 8px;
            }

            .legend-item {
                font-size: 0.7rem;
                gap: 6px;
            }

            .legend-color {
                width: 10px;
                height: 10px;
            }

            .phase-indicator {
                font-size: 0.8rem;
                padding: 8px 12px;
                top: 15px;
                left: 15px;
            }

            .message {
                font-size: 0.65rem;
                padding: 4px 8px;
            }

            .observations-panel {
                height: calc(100vh - 76px);
                padding: 15px;
                gap: 12px;
            }

            .status-section {
                padding: 12px;
            }

            .status-section h4 {
                font-size: 0.9rem;
                margin-bottom: 10px;
            }

            .stats-grid {
                grid-template-columns: 1fr 1fr;
                gap: 8px;
            }

            .stat-card {
                padding: 10px;
            }

            .stat-value {
                font-size: 1.1rem;
            }

            .stat-label {
                font-size: 0.7rem;
            }

            .stat-description {
                font-size: 0.6rem;
            }

            .logs {
                height: 200px;
                font-size: 0.7rem;
                padding: 10px;
            }

            .log-entry {
                padding: 4px 8px;
                font-size: 0.65rem;
            }

            .tooltip {
                font-size: 0.7rem;
                padding: 4px 8px;
            }
        }

        /* Mobile Landscape Support - Tablets */
        @media screen and (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
            .app-container {
                grid-template-columns: 300px 1fr 320px;
                grid-template-rows: 70px 1fr;
                gap: 12px;
                padding: 12px;
            }

            .header h1 {
                font-size: 1.6em;
            }

            .controls-panel {
                height: calc(100vh - 94px);
                padding: 18px;
            }

            .experiment-area {
                height: calc(100vh - 94px);
            }

            .simulation-area {
                padding: 18px;
                min-height: 400px;
            }

            .coordinator {
                width: 100px;
                height: 100px;
                font-size: 0.8rem;
            }

            .participant {
                width: 75px;
                height: 75px;
                font-size: 0.75rem;
            }

            .observations-panel {
                height: calc(100vh - 94px);
                padding: 18px;
            }

            .logs {
                height: 250px;
            }

            .stats-grid {
                grid-template-columns: 1fr 1fr;
            }
        }

        @media (max-width: 1200px) {
            .app-container {
                grid-template-columns: 1fr;
                grid-template-rows: 80px 1fr auto auto;
                height: 100vh;
                gap: 10px;
                padding: 10px;
            }
            
            .controls-panel {
                height: 300px;
                order: 2;
            }
            
            .experiment-area {
                order: 1;
                min-height: 400px;
            }
            
            .observations-panel {
                height: 250px;
                order: 3;
            }
        }
        
        @media (max-width: 768px) {
            .header h1 {
                font-size: 1.5em;
            }
            
            .participants {
                gap: 40px;
            }
            
            .participant {
                width: 75px;
                height: 75px;
                font-size: 0.75rem;
            }
            
            .coordinator {
                width: 100px;
                height: 100px;
                font-size: 0.8rem;
            }

            .legend-panel {
                position: relative;
                top: auto;
                left: auto;
                margin-bottom: 15px;
                min-width: auto;
                width: 100%;
            }

            .legend-items {
                display: grid;
                grid-template-columns: 1fr 1fr;
                gap: 6px;
            }

            .legend-item {
                font-size: 0.75rem;
                gap: 8px;
            }

            .legend-color {
                width: 12px;
                height: 12px;
            }
        }
        
        /* Mobile Portrait Orientation Overlay */
        .rotate-device-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            z-index: 10000;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: white;
            text-align: center;
            padding: 20px;
        }

        .rotate-device-overlay .rotate-icon {
            font-size: 4rem;
            margin-bottom: 20px;
            animation: rotateAnimation 2s ease-in-out infinite;
        }

        .rotate-device-overlay h2 {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 15px;
        }

        .rotate-device-overlay p {
            font-size: 1rem;
            opacity: 0.9;
            line-height: 1.5;
            max-width: 300px;
        }

        @keyframes rotateAnimation {
            0%, 100% { transform: rotate(0deg); }
            25% { transform: rotate(-15deg); }
            75% { transform: rotate(15deg); }
        }

        @media screen and (max-width: 768px) and (orientation: portrait) {
            .rotate-device-overlay {
                display: flex !important;
            }
            
            .app-container {
                display: none !important;
            }
        }