        :root {
            --bg-color: #0c1222;
            --panel-bg: #111827;
            --border-color: #1f2937;
            --border-hover: #374151;
            --primary: #f3b64a;
            --secondary: #57b8a5;
            --accent: #ef8068;
            --text-main: #f9fafb;
            --text-muted: #9ca3af;
            --success: #10b981;
            --danger: #ef4444;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Outfit', 'Noto Sans TC', sans-serif;
        }

        body {
            background-color: var(--bg-color);
            color: var(--text-main);
            height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        /* Navigation Top Bar */
        .top-bar {
            height: 64px;
            border-bottom: 1px solid var(--border-color);
            background: #0c1222;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 2rem;
            z-index: 10;
            position: relative;
        }

        .project-info {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .brand-logo {
            display: flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
            margin-right: 1.5rem;
        }

        .logo-img {
            height: 32px;
            width: auto;
            transition: transform 0.2s ease;
        }

        .brand-logo:hover .logo-img {
            transform: scale(1.02);
        }

        .brand-name {
            font-size: 1rem;
            font-weight: 700;
            color: #ffffff;
        }

        .btn-back {
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid var(--border-color);
            color: var(--text-main);
            padding: 0.5rem 1.1rem;
            border-radius: 10px;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 600;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-back:hover {
            background: rgba(255, 255, 255, 0.05);
            transform: translateX(-2px);
            border-color: var(--border-hover);
        }

        .project-title-wrapper {
            display: flex;
            flex-direction: column;
        }

        .project-path {
            font-size: 0.75rem;
            color: var(--text-muted);
            letter-spacing: 0.5px;
            font-weight: 600;
        }

        .project-name {
            font-size: 1.05rem;
            font-weight: 700;
            color: #ffffff;
        }

        /* Status Light */
        .status-wrapper {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.82rem;
            background: rgba(243, 182, 74, 0.06);
            color: var(--text-muted);
            padding: 0.35rem 0.9rem;
            border-radius: 30px;
            border: 1px solid rgba(243, 182, 74, 0.15);
            font-weight: 600;
        }

        .status-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background-color: #7d8798;
        }

        .status-connecting .status-dot {
            background-color: var(--primary);
        }

        .status-running {
            background: rgba(16, 185, 129, 0.06);
            color: var(--success);
            border-color: rgba(16, 185, 129, 0.15);
        }

        .status-running .status-dot {
            background-color: var(--success);
            animation: pulse 1.5s infinite;
        }

        .status-stopped {
            background: rgba(239, 68, 68, 0.06) !important;
            color: var(--danger) !important;
            border: 1px solid rgba(239, 68, 68, 0.15) !important;
        }
        .status-stopped .status-dot {
            background-color: var(--danger) !important;
            animation: none;
        }

        .status-idle {
            background: rgba(255, 255, 255, 0.03);
            color: var(--text-muted);
            border-color: var(--border-color);
        }

        /* Main Grid Wrapper */
        .main-container {
            display: grid;
            grid-template-columns: 1fr 380px;
            flex-grow: 1;
            overflow: hidden;
            background-color: #080c14;
            position: relative;
        }

        /* Interactive Screen Area */
        .viewport-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 2rem;
            position: relative;
            background: #080c14;
            width: 100%;
            height: 100%;
            overflow-y: auto;
        }

        .screen-frame {
            position: relative;
            background: #000;
            border-radius: 16px;
            padding: 8px;
            box-shadow: 
                0 0 0 1px var(--border-color), 
                0 20px 40px rgba(0, 0, 0, 0.6);
            display: flex;
            align-items: center;
            justify-content: center;
            max-width: 100%;
            max-height: 85%;
            aspect-ratio: 4/3;
            overflow: hidden;
            width: 100%;
            z-index: 1;
        }

        #game-screen {
            max-width: 100%;
            max-height: 100%;
            border-radius: 8px;
            display: block;
            image-rendering: pixelated;
            cursor: crosshair;
        }

        /* Iframe Viewport for Scratch & HTML5 */
        .screen-frame.iframe-mode {
            aspect-ratio: auto;
            max-height: 100%;
            height: 100%;
            width: 100%;
            padding: 0;
            overflow: auto;
            border-radius: 12px;
            box-shadow: 
                0 0 0 1px var(--border-color), 
                0 20px 40px rgba(0, 0, 0, 0.6);
        }

        .iframe-viewport {
            width: 100%;
            height: 100%;
            border: none;
            background-color: #000;
            border-radius: 10px;
            display: block;
        }

        /* Guide Tip Overlay */
        .focus-prompt {
            margin-top: 1.2rem;
            font-size: 0.82rem;
            color: var(--text-muted);
            background: rgba(255, 255, 255, 0.01);
            padding: 0.4rem 1.2rem;
            border-radius: 30px;
            border: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s;
            z-index: 1;
        }
        
        .focus-prompt.active {
            color: var(--secondary);
            border-color: rgba(87, 184, 165, 0.3);
            background: rgba(87, 184, 165, 0.05);
        }

        /* Right Panel styling */
        .control-panel {
            border-left: 1px solid var(--border-color);
            background: var(--panel-bg);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            z-index: 1;
        }

        /* Top Panel settings */
        .device-section {
            padding: 1.5rem;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .device-title {
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .btn-webcam {
            background: rgba(255, 255, 255, 0.01);
            border: 1px solid var(--border-color);
            color: var(--text-main);
            padding: 0.8rem 1.2rem;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            font-size: 0.88rem;
        }

        .btn-webcam:hover {
            background: rgba(255, 255, 255, 0.03);
            border-color: var(--border-hover);
        }

        .btn-webcam.active {
            background: rgba(87, 184, 165, 0.06);
            border-color: var(--secondary);
            color: var(--secondary);
        }

        /* Layout modifications */
        .action-buttons {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.8rem;
        }

        .btn-action {
            padding: 0.75rem;
            border-radius: 10px;
            border: none;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            font-size: 0.85rem;
        }

        .btn-restart {
            background: var(--primary);
            color: #17212b;
        }
        .btn-restart:hover {
            opacity: 0.9;
        }

        .btn-stop {
            background: rgba(239, 68, 68, 0.05);
            color: var(--danger);
            border: 1px solid rgba(239, 68, 68, 0.15);
        }
        .btn-stop:hover {
            background: #b91c1c;
            color: #fff;
        }

        /* Terminal styling */
        .terminal-section {
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            padding: 1.5rem;
        }

        .terminal-header-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 0.8rem;
        }

        .btn-clear {
            background: transparent;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 0.78rem;
            font-weight: 600;
        }
        .btn-clear:hover {
            color: var(--text-main);
        }

        .terminal-box {
            background: #05080f;
            border: 1px solid var(--border-color);
            border-radius: 14px 14px 0 0;
            border-bottom: none;
            padding: 1rem;
            flex-grow: 1;
            overflow-y: auto;
            font-family: 'Fira Code', monospace;
            font-size: 0.8rem;
            color: #e5e7eb;
            line-height: 1.5;
            white-space: pre-wrap;
        }

        .terminal-box::-webkit-scrollbar {
            width: 4px;
        }
        .terminal-box::-webkit-scrollbar-thumb {
            background: #1f2937;
            border-radius: 4px;
        }

        .terminal-input-wrapper {
            display: flex;
            align-items: center;
            background: #05080f;
            border: 1px solid var(--border-color);
            border-top: none;
            border-radius: 0 0 14px 14px;
            padding: 0.5rem 1rem;
            gap: 8px;
        }

        .terminal-prompt {
            color: var(--primary);
            font-family: 'Fira Code', monospace;
            font-size: 0.8rem;
            font-weight: 700;
            user-select: none;
        }

        #terminal-input-field {
            flex-grow: 1;
            background: transparent;
            border: none;
            outline: none;
            color: #e5e7eb;
            font-family: 'Fira Code', monospace;
            font-size: 0.8rem;
            caret-color: var(--primary);
        }

        #terminal-input-field::placeholder {
            color: #4b5563;
        }

        @keyframes pulse {
            0% { opacity: 0.4; }
            50% { opacity: 1; }
            100% { opacity: 0.4; }
        }

        /* Hidden media tools */
        #webcam-video, #webcam-canvas {
            display: none;
        }

        /* Responsive layout for smaller heights */
        @media (max-height: 800px) {
            .viewport-section {
                padding: 1rem;
            }
            .screen-frame:not(.iframe-mode) {
                max-height: 80%;
            }
            .focus-prompt {
                margin-top: 0.5rem;
                padding: 0.3rem 1rem;
                font-size: 0.75rem;
            }
            .device-section {
                padding: 1rem;
                gap: 0.75rem;
            }
            .terminal-section {
                padding: 1rem;
            }
        }

        /* APK Card Tag / Button */
        .btn-launch-apk {
            background: var(--accent) !important;
            color: #17212b !important;
        }
        .btn-launch-apk:hover {
            background: #dc6e58 !important;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
        }

        /* Smartphone Mockup Container */
        .phone-mockup {
            width: 320px;
            height: 640px;
            background: #000000;
            border: 12px solid #1f2937;
            border-radius: 40px;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 2px rgba(255, 255, 255, 0.05);
            display: flex;
            flex-direction: column;
            position: relative;
            overflow: hidden;
            flex-shrink: 0;
            transition: all 0.3s ease;
        }

        /* Notch / Island bezel */
        .phone-mockup::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 140px;
            height: 25px;
            background: #1f2937;
            border-bottom-left-radius: 18px;
            border-bottom-right-radius: 18px;
            z-index: 10;
        }

        .phone-speaker {
            position: absolute;
            top: 5px;
            left: 50%;
            transform: translateX(-50%);
            width: 40px;
            height: 4px;
            background: #374151;
            border-radius: 2px;
            z-index: 11;
        }

        .phone-camera {
            position: absolute;
            top: 4px;
            left: calc(50% + 30px);
            width: 6px;
            height: 6px;
            background: #111827;
            border-radius: 50%;
            z-index: 11;
        }

        .phone-status-bar {
            width: 100%;
            height: 25px;
            padding: 0 1.5rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.7rem;
            color: rgba(255, 255, 255, 0.6);
            position: absolute;
            top: 0;
            left: 0;
            z-index: 5;
            box-sizing: border-box;
        }

        .phone-screen {
            flex-grow: 1;
            background: linear-gradient(135deg, #2b271f 0%, #0f172a 100%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 1.5rem;
            color: #ffffff;
            position: relative;
            text-align: center;
            gap: 1.5rem;
            box-sizing: border-box;
        }

        .phone-screen-iframe {
            width: 100%;
            height: 100%;
            border: none;
            background: #000;
            border-radius: 28px;
        }

        .android-icon-wrapper {
            width: 80px;
            height: 80px;
            background: rgba(239, 128, 104, 0.15);
            border: 2px solid rgba(239, 128, 104, 0.3);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: icon-breathe 2.4s ease-in-out infinite;
        }

        @keyframes icon-breathe {
            0%, 100% {
                transform: scale(1);
            }
            50% {
                transform: scale(1.035);
            }
        }

        /* APK Side Panel Layout and Elements */
        .apk-download-card {
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid var(--border-color);
            padding: 1.2rem;
            border-radius: 12px;
            display: flex;
            flex-direction: column;
            gap: 0.8rem;
            align-items: center;
            text-align: center;
            box-sizing: border-box;
        }

        .apk-info-text {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .apk-file-name {
            font-weight: 700;
            font-size: 0.95rem;
            color: #ffffff;
            word-break: break-all;
        }

        .apk-file-size {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .qr-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.6rem;
            text-align: center;
            border-top: 1px solid var(--border-color);
            padding-top: 1.5rem;
            box-sizing: border-box;
        }

        .qr-code-wrapper {
            background: #ffffff;
            padding: 10px;
            border-radius: 12px;
            width: 160px;
            height: 160px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
            box-sizing: border-box;
        }

        .qr-code-wrapper img {
            width: 140px;
            height: 140px;
            display: block;
        }

        .qr-tip {
            font-size: 0.75rem;
            color: var(--text-muted);
            line-height: 1.4;
            max-width: 280px;
        }

        .guide-section {
            border-top: 1px solid var(--border-color);
            padding-top: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.8rem;
            box-sizing: border-box;
        }

        .guide-item {
            display: flex;
            gap: 12px;
            align-items: flex-start;
        }

        .guide-step-number {
            background: rgba(239, 128, 104, 0.15);
            color: #ef8068;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.75rem;
            font-weight: 700;
            flex-shrink: 0;
        }

        .guide-text {
            font-size: 0.82rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .guide-link {
            color: #ef8068;
            text-decoration: underline;
            transition: color 0.2s;
        }

        .guide-link:hover {
            color: #d8b4fe;
        }
    
/* Loading overlay + webcam denied */
.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(8, 12, 20, 0.88);
    color: #e5e7eb;
    text-align: center;
    padding: 1.5rem;
    pointer-events: none;
}
.loading-overlay p {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f9fafb;
}
.loading-overlay .loading-sub {
    font-size: 0.8rem;
    font-weight: 400;
    color: #9ca3af;
    max-width: 22rem;
}
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(243, 182, 74, 0.2);
    border-top-color: #f3b64a;
    border-radius: 50%;
    animation: telearn-spin 0.8s linear infinite;
}
@keyframes telearn-spin {
    to { transform: rotate(360deg); }
}
.webcam-denied {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    max-width: min(420px, 90%);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fecaca;
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: center;
}
.webcam-denied strong {
    color: #fca5a5;
}
.viewport-section {
    position: relative;
}

.idle-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(3, 7, 18, 0.78);
    backdrop-filter: blur(8px);
}

.idle-dialog-backdrop[hidden] {
    display: none;
}

.idle-dialog-card {
    width: min(420px, 100%);
    box-sizing: border-box;
    padding: 2rem;
    border: 0;
    border-radius: 20px;
    background: #111827;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
    color: #f9fafb;
    text-align: center;
}

.idle-dialog-icon {
    margin-bottom: 0.8rem;
    font-size: 2rem;
}

.idle-dialog-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.45rem;
}

.idle-dialog-card p {
    margin: 0;
    color: #cbd5e1;
    line-height: 1.65;
}

.idle-dialog-card strong {
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
}

.idle-dialog-card button {
    width: 100%;
    margin-top: 1.4rem;
    padding: 0.85rem 1rem;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #17212b;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.idle-dialog-card button:hover,
.idle-dialog-card button:focus-visible {
    background: #dfa12f;
    outline: 3px solid rgba(243, 182, 74, 0.45);
    outline-offset: 3px;
}
