        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, #FFB6D9 0%, #FCD4FF 25%, #B4E7FF 50%, #FFE4B5 100%);
            min-height: 100vh;
            overflow-x: hidden;
        }

        /* 화면 전환 */
        .screen {
            display: none;
        }
        
        .screen.active {
            display: block;
        }

        /* 블록 연결 화면 스타일 */
        .connect-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 16px 20px;
        }

        .connect-header {
            text-align: center;
            margin-bottom: 16px;
        }

        .connect-header h1 {
            color: #495057;
            font-size: 1.8em;
            margin-bottom: 4px;
            font-weight: 700;
        }

        .connect-header p {
            color: #6c757d;
            font-size: 1.1em;
        }

        .group-section {
            background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(233,236,239,0.9) 100%);
            padding: 14px 20px;
            border-radius: 14px;
            margin-bottom: 16px;
        }

        .group-section h2 {
            color: #495057;
            font-size: 1.1em;
            margin-bottom: 10px;
        }

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

        .input-row label {
            font-weight: 600;
            min-width: 90px;
        }

        .input-row input {
            padding: 10px 16px;
            border: 2px solid #ff922b;
            border-radius: 8px;
            font-size: 16px;
            width: 120px;
            text-align: center;
            font-weight: bold;
        }

        .blocks-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }

        .block-card {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border-radius: 18px;
            padding: 16px 12px;
            text-align: center;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
        }

        .block-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
        }

        .block-icon {
            font-size: 2.5em;
            margin-bottom: 8px;
            opacity: 0.6;
            transition: all 0.3s ease;
            height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .block-card.connecting .block-icon {
            animation: connectingPulse 1s ease-in-out infinite;
        }

        @keyframes connectingPulse {
            0%, 100% { opacity: 0.4; }
            50% { opacity: 0.9; }
        }

        .block-card.connected .block-icon {
            opacity: 1;
            filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
        }

        .block-name {
            font-size: 0.9em;
            font-weight: 600;
            color: #495057;
            margin-bottom: 6px;
        }

        .connection-badge {
            display: inline-block;
            padding: 4px 12px;
            border-radius: 16px;
            font-size: 0.78em;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .connection-badge.connected {
            background: #d4edda;
            color: #155724;
        }

        .connection-badge.disconnected {
            background: #f8d7da;
            color: #721c24;
        }

        .block-btn-kid {
            width: 100%;
            padding: 10px 16px;
            border: none;
            border-radius: 14px;
            font-size: 0.95em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
            box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
            margin-top: 8px;
        }

        .block-btn-kid:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
        }

        .block-btn-kid.connected {
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            box-shadow: 0 4px 12px rgba(255, 146, 43, 0.3);
            cursor: default;
            pointer-events: none;
        }

        .block-btn-kid.connected:hover {
            transform: none;
            box-shadow: 0 4px 12px rgba(255, 146, 43, 0.3);
        }

        .block-btn {
            padding: 7px 14px;
            border: none;
            border-radius: 10px;
            font-size: 0.8em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            margin: 2px;
        }

        .block-btn.connect {
            background: #28a745;
            color: white;
        }

        .block-btn.disconnect {
            background: #dc3545;
            color: white;
        }

        .block-btn:hover:not(:disabled) {
            transform: scale(1.05);
        }

        .block-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .action-btn {
            background: rgba(255, 255, 255, 0.9);
            backdrop-filter: blur(10px);
            border: none;
            border-radius: 20px;
            padding: 20px 40px;
            font-size: 1.2em;
            font-weight: 600;
            color: #495057;
            cursor: pointer;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            display: block;
            margin: 20px auto;
        }

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

        /* AI Playground 원본 스타일 */
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 16px;
            background: rgba(255, 255, 255, 0.3);
            backdrop-filter: blur(10px);
            height: 54px;
        }

        .back-btn {
            background: rgba(255, 255, 255, 0.8);
            border: none;
            padding: 10px 20px;
            border-radius: 15px;
            font-size: 1em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }

        .back-btn:hover {
            background: white;
            transform: scale(1.05);
        }

        .block-connect-btn {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 6px 14px;
            border-radius: 20px;
            font-size: 0.85em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            border: 2px solid #ff922b;
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            color: white;
            box-shadow: 0 2px 8px rgba(255, 146, 43, 0.3);
        }

        .block-connect-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 20px rgba(255, 146, 43, 0.5);
        }

        /* 동작 모드 선택 드롭다운 */
        /* 모드 미니 버튼 그리드 */
        .mode-btn-grid {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .mode-btn {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 10px 16px;
            border: 2px solid #ffd8a8;
            border-radius: 16px;
            font-size: 0.85em;
            font-weight: 600;
            min-height: 44px;
            background: white;
            color: #8b7355;
            cursor: pointer;
            transition: all 0.25s ease;
            white-space: nowrap;
        }

        .mode-btn:hover {
            border-color: #ff922b;
            color: #e8590c;
            transform: translateY(-1px);
            box-shadow: 0 3px 10px rgba(255,146,43,0.18);
        }

        .mode-btn.active {
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            border-color: transparent;
            color: white;
            box-shadow: 0 3px 12px rgba(255,146,43,0.35);
        }

        .mode-btn-icon {
            font-size: 1.1em;
            line-height: 1;
        }

        .mode-btn-text {
            font-size: 0.95em;
        }

        /* 토글 스위치 */
        .block-link-badge.disabled {
            background: #f8f9fa;
            border-color: #ddd;
            color: #999;
        }

        /* ===== 헤더 내 기능 탭 ===== */
        .header-tabs {
            display: flex;
            gap: 2px;
            align-items: center;
            flex: 1;
            justify-content: center;
            margin: 0 12px;
        }

        .header-tab {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 6px 14px;
            border: none;
            border-radius: 20px;
            background: rgba(255, 255, 255, 0.5);
            cursor: pointer;
            transition: all 0.25s ease;
            min-height: 40px;
            white-space: nowrap;
        }

        .header-tab:hover {
            background: rgba(255, 255, 255, 0.85);
        }

        .header-tab.active {
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            color: white;
            box-shadow: 0 3px 12px rgba(255,146,43,0.35);
            transform: scale(1.05);
        }

        .header-tab-icon {
            font-size: 1.7rem;
            filter: grayscale(100%);
            transition: filter 0.3s ease;
            line-height: 1;
        }

        .header-tab.active .header-tab-icon {
            filter: grayscale(0%);
        }

        .header-tab-label {
            font-size: 0.8rem;
            font-weight: 700;
        }

        .header-logo {
            flex-shrink: 0;
        }

        /* 모드 선택 바 */
        .mode-selector-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            background: rgba(255, 255, 255, 0.5);
            backdrop-filter: blur(10px);
            border-radius: 16px;
            margin: 0 auto 38px auto;
            max-width: none;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            animation: slideDown 0.3s ease-out;
            flex-wrap: wrap;
        }
        

        /* 탭별 놀이 선택 바 너비 */
        #faceModeSelector,
        #actionModeSelector,
        #handModeSelector,
        #voiceModeSelector,
        #colorModeSelector { width: fit-content; }
        /* mode-selector-bar 내 버튼그룹 (가운데 정렬) */
        .mode-btn-group {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-wrap: nowrap;
            gap: 8px;
        }

        /* 모터 반전 토글 (바 오른쪽 끝) */
        .motor-swap-toggle {
            display: flex;
            visibility: hidden;
            align-items: center;
            gap: 5px;
            padding: 5px 10px;
            background: rgba(255, 255, 255, 0.9);
            border-radius: 20px;
            border: 2px solid #e2e8f0;
            flex-shrink: 0;
            font-size: 13px;
            white-space: nowrap;
            margin-left: 8px;
        }
        
        .motor-swap-toggle.visible {
            visibility: visible;
        }
        
        .toggle-switch {
            position: relative;
            width: 50px;
            height: 26px;
            background: #ccc;
            border-radius: 13px;
            cursor: pointer;
            transition: background 0.3s ease;
        }
        
        .toggle-switch.active {
            background: #4CAF50;
        }
        
        .toggle-slider {
            position: absolute;
            top: 3px;
            left: 3px;
            width: 20px;
            height: 20px;
            background: white;
            border-radius: 50%;
            transition: transform 0.3s ease;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .toggle-switch.active .toggle-slider {
            transform: translateX(24px);
        }
        
        .motor-status {
            font-size: 0.75em;
            color: #666;
            font-weight: 500;
        }

        @keyframes slideDown {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }



        /* 메인 컨텐츠 영역 */
        .main-content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
            padding: 0 16px 16px 16px;
            max-width: 1400px;
            margin: 0 auto;
        }

        /* 출력 영역 */
        .output-panel {
            background: white;
            border-radius: 16px;
            padding: 16px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
        }

        .panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .panel-title {
            font-size: 1.5rem;
            font-weight: bold;
            color: #333;
        }

        .result-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 20px;
            margin-bottom: 15px;
            background: #F8F9FA;
            border-radius: 15px;
            transition: all 0.3s ease;
        }

        .result-item:hover {
            background: #F0F0F0;
            transform: translateX(5px);
        }

        .result-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .result-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: linear-gradient(135deg, #FFB6D9 0%, #FCD4FF 100%);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
        }

        .result-details {
            display: flex;
            flex-direction: column;
        }

        .result-name {
            font-weight: 600;
            color: #333;
            margin-bottom: 5px;
        }

        .result-value {
            color: #666;
            font-size: 0.9rem;
        }

        .status-badge {
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.9rem;
        }

        .status-present {
            background: #C8E6C9;
            color: #2E7D32;
        }

        .status-absent {
            background: #FFCDD2;
            color: #C62828;
        }

        .status-active {
            background: #C8E6C9;
            color: #2E7D32;
        }

        .voice-control-btn {
            width: 100%;
            padding: 15px;
            margin-top: 15px;
            border: none;
            border-radius: 15px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            color: white;
        }

        .voice-control-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(255, 146, 43, 0.4);
        }

        .voice-control-btn.listening {
            background: linear-gradient(135deg, #FF6B6B 0%, #FF4757 100%);
            animation: pulse 2s infinite;
        }

        /* 비디오 영역 (로봇 화면) */
        .video-panel {
            background: white;
            border-radius: 16px;
            padding: 12px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
            position: relative;
        }

        .live-badge {
            position: absolute;
            top: 30px;
            left: 30px;
            background: rgba(255, 255, 255, 0.9);
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: bold;
            color: #333;
            z-index: 10;
            font-size: 1.1rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .live-dot {
            width: 10px;
            height: 10px;
            background: #FF4757;
            border-radius: 50%;
            animation: pulse 2s infinite;
        }

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

        .video-container {
            position: relative;
            border-radius: 16px;
            overflow: hidden;
            background: #f5f1ec;
        }

        #video {
            width: 100%;
            display: block;
            border-radius: 0;
            object-fit: cover;
        }

        #canvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }

        .loading {
            text-align: center;
            padding: 10px;
            color: white;
            font-size: 1rem;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            margin: 8px 16px;
            backdrop-filter: blur(10px);
        }

        /* 반응형 디자인 */
        @media (max-width: 1024px) {
            .main-content {
                gap: 12px;
                padding: 0 12px 12px;
            }

            .blocks-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (max-width: 768px) {
            .main-content {
                grid-template-columns: 1fr;
            }
            
            .header-tabs {
                gap: 1px;
                margin: 0 6px;
            }
            
            .header-tab {
                padding: 4px 6px;
                min-height: 32px;
            }
            
            .header-tab-label {
                display: none;
            }
            
            .header-tab-icon {
                font-size: 1.3rem;
            }
        }

        /* 태블릿 가로모드 최적화 */
        @media (min-width: 768px) and (max-height: 700px) {
            .header {
                height: 46px;
                padding: 4px 12px;
            }
            .header img {
                height: 28px !important;
            }
            .header-tabs {
                gap: 1px;
            }
            .header-tab {
                padding: 4px 8px;
            }
            .mode-selector-bar {
                padding: 8px 14px;
                margin-bottom: 8px;
            }
            .main-content {
                gap: 10px;
                padding: 0 10px 10px;
            }
            .output-panel {
                padding: 12px;
            }
        }

        /* === Green AI Run 게임 스타일 === */
        .game-container {
            max-width: 900px;
            width: 100%;
            margin: 8px auto;
            overflow: hidden;
            display: none;
            text-align: center;
        }

        .game-container.active {
            display: block;
        }

        .game-score-big {
            font-size: 2.2em;
            font-weight: 800;
            color: #f59e0b;
            text-align: center;
            padding: 8px 0 4px;
            text-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
        }

        .game-canvas-container {
            position: relative;
            background: #f8f9fa;
            padding: 0;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 8px 30px rgba(0,0,0,0.15);
        }

        #gameCanvas {
            display: block;
            margin: 0 auto;
            background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 100%);
            max-width: 100%;
        }

        .game-btn-kid {
            display: block;
            width: 100%;
            max-width: 400px;
            margin: 16px auto 0;
            padding: 18px 32px;
            border: none;
            border-radius: 20px;
            font-size: 1.3em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s;
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            color: white;
            box-shadow: 0 6px 20px rgba(255, 146, 43, 0.3);
        }

        .game-btn-kid:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 30px rgba(255, 146, 43, 0.4);
        }

        .game-btn-kid.ready {
            background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
            box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
            animation: pulseGlow 2s ease-in-out infinite;
        }

        .game-btn-kid.ready:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 30px rgba(76, 175, 80, 0.5);
        }

        .game-btn-kid.stop {
            background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
            box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
            max-width: 250px;
            white-space: nowrap;
        }

        .game-btn {
            padding: 12px 28px;
            border: none;
            border-radius: 20px;
            font-size: 1.1em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
        }

        .game-btn-start {
            background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
            color: white;
        }

        .game-btn:hover {
            transform: translateY(-2px);
        }

        .game-over-screen {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: rgba(0,0,0,0.9);
            color: white;
            padding: 40px;
            border-radius: 20px;
            text-align: center;
            display: none;
            z-index: 100;
        }

        .game-over-screen h2 {
            font-size: 3em;
            margin-bottom: 20px;
        }

        .game-final-score {
            font-size: 2.5em;
            margin: 16px 0;
            color: #FFC107;
            font-weight: 800;
        }

        .game-over-stats {
            display: flex;
            gap: 20px;
            justify-content: center;
            margin-bottom: 20px;
            font-size: 1.1em;
            opacity: 0.8;
        }

        /* === 토스트 메시지 스타일 (추가됨) === */
        #toast-container {
            visibility: hidden;
            min-width: 250px;
            background-color: rgba(50, 50, 50, 0.95);
            color: #fff;
            text-align: center;
            border-radius: 50px;
            padding: 16px 24px;
            position: fixed;
            z-index: 10000; /* 모든 화면보다 위에 표시 */
            left: 50%;
            bottom: 30px;
            transform: translateX(-50%);
            font-size: 16px;
            font-weight: 500;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            opacity: 0;
            transition: opacity 0.3s, bottom 0.3s;
            white-space: nowrap; /* 줄바꿈 방지 */
        }

        #toast-container.show {
            visibility: visible;
            opacity: 1;
            bottom: 80px; /* 나타날 때 살짝 위로 올라오는 효과 */
        }
        /* 모드 버튼 반응형 */
        @media (max-width: 600px) {
            .mode-selector-bar {
                padding: 10px 12px;
                gap: 8px;
            }
            .mode-btn {
                padding: 6px 10px;
                font-size: 0.75em;
            }
            .mode-btn-grid {
                gap: 6px;
            }
        }

        /* ===== 모드 도움말 팝업 ===== */
        .mode-help-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0, 0, 0, 0.4);
            backdrop-filter: blur(3px);
            z-index: 1000;
            justify-content: center;
            align-items: center;
            padding: 20px;
            animation: fadeIn 0.2s ease-out;
        }

        .mode-help-overlay.active {
            display: flex;
        }

        .mode-help-popup {
            background: white;
            border-radius: 20px;
            max-width: 700px;
            width: 100%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
            animation: popIn 0.25s ease-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes popIn {
            from { opacity: 0; transform: scale(0.9) translateY(10px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        .help-popup-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 18px 20px 14px;
            border-bottom: 1px solid #f0f0f0;
        }

        .help-popup-title {
            font-size: 1.15em;
            font-weight: 700;
            color: #2d3748;
        }

        .help-popup-close {
            width: 32px; height: 32px;
            border: none;
            background: #f7fafc;
            border-radius: 50%;
            font-size: 1.1em;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #718096;
            transition: all 0.2s;
        }

        .help-popup-close:hover {
            background: #edf2f7;
            color: #2d3748;
        }

        .help-popup-body {
            padding: 16px 20px 20px;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px 20px;
        }

        .help-popup-left,
        .help-popup-right {
            min-width: 0;
        }

        .help-popup-left {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .help-popup-right {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .help-section {
            margin-bottom: 0;
        }

        .help-section-label {
            font-size: 0.8em;
            font-weight: 700;
            color: #718096;
            margin-bottom: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .help-block-tags {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        .help-block-tag {
            display: inline-block;
            padding: 4px 12px;
            background: linear-gradient(135deg, #ff922b15, #f7670715);
            border: 1.5px solid #ffd8a860;
            border-radius: 14px;
            font-size: 0.82em;
            font-weight: 600;
            color: #e8590c;
        }

        .help-assembly {
            background: #f7fafc;
            border-radius: 12px;
            padding: 16px;
            text-align: center;
            min-height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .help-assembly img {
            max-width: 100%;
            max-height: 250px;
            border-radius: 8px;
        }

        .help-no-img {
            color: #a0aec0;
            font-size: 0.85em;
            font-style: italic;
        }

        .help-actions {
            background: #f7fafc;
            border-radius: 12px;
            padding: 12px 16px;
        }

        .help-action-line {
            font-size: 0.88em;
            color: #4a5568;
            padding: 4px 0;
            line-height: 1.6;
        }

        /* 사용법 태그 (활성 모드 버튼 아래) */
        .mode-btn {
            position: relative;
        }

        .mode-usage-tag {
            display: none;
            position: absolute;
            bottom: -44px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 1em;
            color: #e8590c;
            cursor: pointer;
            white-space: nowrap;
            padding: 8px 20px;
            border-radius: 16px;
            background: white;
            border: 2.5px solid #ff922b;
            transition: all 0.2s;
            z-index: 1;
            font-weight: 700;
            box-shadow: 0 3px 12px rgba(255, 146, 43, 0.2);
            min-height: 40px;
            line-height: 1;
        }

        .mode-btn.active .mode-usage-tag {
            display: flex;
            align-items: center;
            animation: fadeIn 0.2s ease-out;
        }

        .mode-usage-tag:hover {
            color: white;
            background: #ff922b;
            border-color: #e8590c;
        }

        /* 팝업 내 블록 연결 카드 */
        .help-block-card {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            background: #f7fafc;
            border-radius: 14px;
            margin-bottom: 8px;
        }

        .help-block-img {
            width: 72px;
            height: 72px;
            object-fit: contain;
        }

        .help-block-info {
            flex: 1;
        }

        .help-block-name {
            font-size: 1em;
            font-weight: 700;
            color: #2d3748;
        }

        .help-block-status {
            font-size: 0.8em;
            color: #a0aec0;
            margin-top: 2px;
        }

        .help-block-status.connected {
            color: #48bb78;
        }

        .help-connect-btn {
            padding: 10px 18px;
            border: 2px solid #ff922b;
            border-radius: 16px;
            background: white;
            color: #e8590c;
            font-size: 0.88em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }

        .help-connect-btn:hover {
            background: #ff922b;
            color: white;
        }

        .help-connect-btn.connected {
            border-color: #48bb78;
            color: #48bb78;
            cursor: default;
        }

        @media (max-width: 600px) {
            .mode-help-popup {
                max-width: 95%;
                max-height: 75vh;
                border-radius: 16px;
            }
            .help-popup-header {
                padding: 14px 16px 12px;
            }
            .help-popup-body {
                padding: 12px 16px 16px;
                grid-template-columns: 1fr;
            }
        }

        /* 모드 바 라벨 */
        .mode-bar-label {
            font-size: 0.8em;
            font-weight: 700;
            color: #e8590c;
            white-space: nowrap;
            flex-shrink: 0;
        }

        /* ===== 유아용 결과 패널 ===== */
        
        /* 안내 (미감지) */
        .kid-result-guide {
            text-align: center;
            padding: 24px 20px;
        }

        .kid-guide-emoji {
            font-size: 3rem;
            margin-bottom: 12px;
            opacity: 0.7;
        }

        .kid-guide-text {
            font-size: 1.2em;
            font-weight: 700;
            color: #a0aec0;
            line-height: 1.4;
        }

        @keyframes gentleBounce {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }

        /* 히어로 카드 (감지 성공) */
        .kid-result-hero {
            text-align: center;
            padding: 16px;
            background: linear-gradient(135deg, #f0f4ff 0%, #fdf2f8 100%);
            border-radius: 20px;
            margin-bottom: 12px;
        }

        .kid-hero-emoji {
            font-size: 3.5rem;
            line-height: 1;
            margin-bottom: 8px;
        }

        .kid-hero-text {
            font-size: 0.85em;
            color: #718096;
            font-weight: 600;
            margin-bottom: 4px;
        }

        .kid-hero-value {
            font-size: 1.4em;
            font-weight: 800;
            color: #2d3748;
        }

        /* 팝 애니메이션 */
        .pop-in {
            animation: popBounce 0.4s ease-out;
        }

        @keyframes popBounce {
            0% { transform: scale(0.95); opacity: 0.7; }
            100% { transform: scale(1); opacity: 1; }
        }

        /* 펄스 (듣는 중) */
        .pulse {
            animation: pulseGlow 1.5s ease-in-out infinite;
        }

        @keyframes pulseGlow {
            0%, 100% { box-shadow: 0 0 0 0 rgba(255, 146, 43, 0.2); }
            50% { box-shadow: 0 0 0 15px rgba(255, 146, 43, 0); }
        }

        /* 미니 카드 그리드 */
        .kid-result-cards {
            display: flex;
            gap: 10px;
            justify-content: center;
        }

        .kid-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 2px;
            padding: 12px 20px;
            background: white;
            border-radius: 16px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            min-width: 100px;
        }

        .kid-card-emoji {
            font-size: 1.8rem;
        }

        .kid-card-label {
            font-size: 0.7em;
            color: #a0aec0;
            font-weight: 600;
        }

        .kid-card-value {
            font-size: 0.95em;
            font-weight: 700;
            color: #2d3748;
        }

        /* 색상 스왓치 */
        .kid-color-swatch {
            height: 40px;
            border-radius: 14px;
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
        }

        /* 음성 버튼 */
        .kid-voice-btn {
            display: block;
            width: 100%;
            padding: 14px;
            border: none;
            border-radius: 16px;
            font-size: 1.1em;
            font-weight: 700;
            cursor: pointer;
            margin-top: 12px;
            background: linear-gradient(135deg, #ff922b, #f76707);
            color: white;
            transition: all 0.3s;
        }

        .kid-voice-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(255, 146, 43, 0.4);
        }

        .kid-voice-btn.listening {
            background: linear-gradient(135deg, #fc5c65, #eb3b5a);
            animation: pulseGlow 1.5s ease-in-out infinite;
        }

        /* 음성 인식 기록 */
        .voice-history {
            margin-top: 8px;
            max-height: 120px;
            overflow-y: auto;
            padding: 0 4px;
        }

        .voice-history-item {
            padding: 6px 12px;
            background: white;
            border-radius: 12px;
            margin-bottom: 4px;
            font-size: 0.9em;
            font-weight: 600;
            color: #4a5568;
            box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        }

        /* 액션 가이드 */
        .action-guide {
            margin-top: 12px;
            background: linear-gradient(135deg, #f0f4ff 0%, #fef3f2 100%);
            border-radius: 16px;
            padding: 14px 16px;
            border: 2px dashed #c7d2fe;
        }

        .action-guide-title {
            font-size: 0.95em;
            font-weight: 700;
            color: #e8590c;
            margin-bottom: 10px;
            text-align: center;
        }

        .action-guide-item {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 8px;
            margin-bottom: 4px;
            background: white;
            border-radius: 12px;
            font-size: 0.88em;
            font-weight: 600;
            box-shadow: 0 1px 3px rgba(0,0,0,0.04);
        }

        .action-guide-item:last-child {
            margin-bottom: 0;
        }

        .action-guide-do {
            color: #4a5568;
            flex: 1;
        }

        .action-guide-arrow {
            color: #e8590c;
            font-weight: 800;
            flex-shrink: 0;
        }

        .action-guide-result {
            color: #e53e3e;
            font-weight: 700;
            flex: 1;
            text-align: right;
        }

        /* 게임 내 연결 바로가기 */
        .game-connect-shortcut {
            display: inline-block;
            margin-left: 12px;
            padding: 6px 16px;
            border: 2px solid #ff922b;
            border-radius: 16px;
            background: white;
            color: #e8590c;
            font-size: 0.9em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
        }

        .game-connect-shortcut:hover {
            background: #ff922b;
            color: white;
        }

        .game-status.connected .game-connect-shortcut {
            display: none;
        }

        /* ===== 조합 모드 스타일 ===== */
        .combo-status {
            text-align: center;
            padding: 10px 20px;
            border-radius: 16px;
            font-size: 1.1em;
            font-weight: 700;
            margin: 8px 0 12px;
            animation: pop-in 0.3s ease;
        }

        .combo-status.combo-waiting {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            color: #868e96;
        }

        .combo-status.combo-ready {
            background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
            color: #856404;
            animation: pulse 1.5s infinite;
        }

        .combo-status.combo-go {
            background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
            color: #155724;
        }

        .combo-status.combo-stop {
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
            color: #721c24;
        }

        .combo-voice-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            margin-top: 12px;
            padding: 12px;
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            border-radius: 16px;
        }

        .combo-voice-result {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 1em;
        }

        .combo-voice-icon {
            font-size: 1.3em;
        }

        .combo-voice-text {
            font-weight: 600;
            color: #495057;
        }


        /* ===== 자유모드 · 유아 친화 UI ===== */
        /* 색상 팔레트: 따뜻한 톤 (밝은 노랑, 민트, 하늘, 산호) */

        .free-mode-header {
            text-align: center;
            padding: 12px 12px 4px;
            font-size: 1.1em;
            font-weight: 800;
            color: #5c4a3a;
            letter-spacing: -0.02em;
        }

        /* 감지 상태 배지 — 따뜻한 톤 */
        .fm-current-badge {
            display: block;
            text-align: center;
            margin: 6px auto 12px;
            padding: 8px 22px;
            font-size: 1.05em;
            font-weight: 700;
            color: #9e8a78;
            background: linear-gradient(135deg, #fff8f0 0%, #ffecd2 100%);
            border-radius: 22px;
            border: 1.5px solid #ffd8a8;
            width: fit-content;
            transition: all 0.35s cubic-bezier(.4,0,.2,1);
        }

        .fm-current-badge.fm-badge-active {
            color: #e8590c;
            background: linear-gradient(135deg, #fff4e6 0%, #ffe8cc 100%);
            border-color: #ffa94d;
            box-shadow: 0 3px 14px rgba(232,89,12,0.12);
        }

        /* 테이블 */
        .free-mode-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0 8px;
            font-size: 0.88em;
        }

        .free-mode-table th {
            font-weight: 700;
            color: #9e8a78;
            padding: 0 6px 8px;
            font-size: 0.78em;
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 0.04em;
        }

        .free-mode-table td {
            padding: 0 4px;
            text-align: center;
            vertical-align: middle;
        }

        .free-mode-table .fm-label {
            font-weight: 700;
            text-align: left;
            white-space: nowrap;
            padding: 10px 10px 10px 14px;
            font-size: 1em;
            border-radius: 14px 0 0 14px;
            transition: all 0.3s;
            color: #5c4a3a;
        }

        /* 행 카드 — 둥글고 따뜻한 그림자 */
        .free-mode-table tr.fm-row {
            background: #fff;
            box-shadow: 0 2px 8px rgba(180,140,100,0.07);
            border-radius: 14px;
            transition: all 0.3s cubic-bezier(.4,0,.2,1);
        }

        .free-mode-table tr.fm-row td:first-child { border-radius: 14px 0 0 14px; }
        .free-mode-table tr.fm-row td:last-child { border-radius: 0 14px 14px 0; padding-right: 8px; }

        .free-mode-table tr.fm-row:hover {
            box-shadow: 0 4px 16px rgba(180,140,100,0.12);
            transform: translateY(-1px);
        }

        /* 드롭다운 — 크고 둥글고 이모지 중심 */
        .free-mode-table select {
            width: 100%;
            min-height: 44px;
            padding: 8px 6px;
            border: 2px solid transparent;
            border-radius: 12px;
            font-size: 1.1em;
            font-weight: 500;
            background: #fdf8f3;
            color: #5c4a3a;
            cursor: pointer;
            transition: all 0.25s;
            -webkit-appearance: none;
            text-align: center;
        }

        .free-mode-table select:hover {
            background: #fff4e6;
            border-color: #ffd8a8;
        }

        .free-mode-table select:focus {
            border-color: #ff922b;
            background: #fff;
            box-shadow: 0 0 0 3px rgba(255,146,43,0.18);
            outline: none;
        }

        /* 현재 감지 행 = 하늘색 글로우 */
        .free-mode-table tr.fm-current {
            background: linear-gradient(90deg, #e7f5ff 0%, #fff 60%);
            box-shadow: 0 0 0 2px #74c0fc, 0 3px 12px rgba(51,154,240,0.1);
        }

        .free-mode-table tr.fm-current .fm-label {
            color: #1971c2;
        }

        /* 규칙 실행 행 = 민트 글로우 */
        .free-mode-table tr.fm-active {
            background: linear-gradient(90deg, #ebfbee 0%, #fff 60%) !important;
            box-shadow: 0 0 0 2px #69db7c, 0 3px 14px rgba(64,192,87,0.15) !important;
            transform: scale(1.015);
        }

        .free-mode-table tr.fm-active .fm-label {
            color: #2b8a3e !important;
        }

        /* 액션 버튼 영역 */
        .free-mode-actions {
            display: flex;
            gap: 10px;
            justify-content: center;
            align-items: center;
            padding: 16px 0 10px;
            flex-wrap: wrap;
        }

        .free-mode-actions button {
            padding: 10px 24px;
            border: none;
            border-radius: 16px;
            font-weight: 700;
            font-size: 0.92em;
            cursor: pointer;
            transition: all 0.25s cubic-bezier(.4,0,.2,1);
            letter-spacing: -0.01em;
        }

        /* 시작 버튼 — 따뜻한 오렌지 */
        .fm-run-btn {
            background: linear-gradient(135deg, #ff922b 0%, #f76707 100%);
            color: white;
            box-shadow: 0 4px 16px rgba(255,146,43,0.35);
            min-height: 48px;
            min-width: 120px;
            font-size: 1em;
        }

        .fm-run-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 24px rgba(255,146,43,0.45);
        }

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

        .fm-run-btn.fm-running {
            background: linear-gradient(135deg, #51cf66 0%, #37b24d 100%) !important;
            box-shadow: 0 4px 16px rgba(81,207,102,0.4) !important;
            animation: fm-pulse 2s ease-in-out infinite;
        }

        @keyframes fm-pulse {
            0%, 100% { box-shadow: 0 4px 16px rgba(81,207,102,0.35); }
            50% { box-shadow: 0 4px 28px rgba(81,207,102,0.55); }
        }

        /* 보조 버튼 — 부드러운 베이지 */
        .fm-test-btn {
            background: #fff;
            color: #5c4a3a;
            border: 2px solid #ffd8a8 !important;
            box-shadow: 0 2px 6px rgba(180,140,100,0.06);
            min-height: 44px;
        }

        .fm-test-btn:hover {
            border-color: #ff922b !important;
            color: #e8590c;
            background: #fff8f0;
        }

        /* 프리셋 버튼 — 둥글고 큰 이모지 */
        .fm-preset-btn {
            padding: 10px 18px;
            border: 2px solid #ffd8a8;
            border-radius: 16px;
            background: #fff;
            color: #5c4a3a;
            font-size: 1.1em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.25s;
            box-shadow: 0 2px 6px rgba(180,140,100,0.06);
            min-height: 44px;
        }

        .fm-preset-btn:hover {
            border-color: #ff922b;
            color: #e8590c;
            background: linear-gradient(135deg, #fff8f0 0%, #ffecd2 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 14px rgba(255,146,43,0.15);
        }

        /* 유아/고급 모드 스위치 — 따뜻한 톤 */
        .mode-switch-group {
            display: flex;
            gap: 3px;
            background: linear-gradient(135deg, #fff4e6 0%, #ffecd2 100%);
            border-radius: 16px;
            padding: 4px;
            box-shadow: inset 0 1px 4px rgba(180,140,100,0.1);
        }

        .mode-switch-btn {
            padding: 7px 18px;
            border: none;
            border-radius: 13px;
            background: transparent;
            color: #c2a58a;
            font-size: 0.88em;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(.4,0,.2,1);
        }

        .mode-switch-btn.active {
            background: #fff;
            color: #5c4a3a;
            box-shadow: 0 2px 10px rgba(180,140,100,0.12);
        }

        .mode-switch-btn:hover:not(.active) {
            color: #8b7355;
        }

        /* 음성 자유모드 입력 */
        .free-mode-table input[type="text"] {
            width: 72px;
            min-height: 44px;
            padding: 8px 10px;
            border: 2px solid transparent;
            border-radius: 12px;
            font-size: 0.95em;
            font-weight: 600;
            background: #fdf8f3;
            color: #5c4a3a;
            transition: all 0.25s;
            text-align: center;
        }

        .free-mode-table input[type="text"]:focus {
            border-color: #ff922b;
            background: #fff;
            box-shadow: 0 0 0 3px rgba(255,146,43,0.18);
            outline: none;
        }

        .free-mode-table input[type="text"]::placeholder {
            color: #d4b99a;
            font-weight: 500;
        }

        /* 삭제 버튼 — 둥글고 큰 타겟 */
        .free-mode-table button[onclick*="remove"] {
            width: 36px;
            height: 36px;
            border: none;
            background: #fdf8f3;
            border-radius: 10px;
            color: #c2a58a;
            font-size: 1.1em;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .free-mode-table button[onclick*="remove"]:hover {
            background: #fff0f0;
            color: #e03131;
        }

        /* 조합 모드 바 라벨 */
        #comboModeSelector .mode-bar-label {
            font-weight: 800;
            color: #5c4a3a;
            font-size: 1em;
        }

        /* ===== 반응형 ===== */
        @media (max-width: 768px) {
            .free-mode-table {
                display: block;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                font-size: 0.82em;
            }

            .free-mode-table select {
                min-width: 48px;
                min-height: 40px;
                font-size: 1em;
                padding: 6px 3px;
            }

            .free-mode-table th {
                font-size: 0.68em;
                padding: 2px 3px 6px;
            }

            .free-mode-table .fm-label {
                font-size: 0.92em;
                padding: 8px 6px 8px 10px;
            }

            .fm-preset-btn {
                font-size: 1em;
                padding: 8px 14px;
                min-height: 40px;
            }

            .combo-rule-table select {
                min-width: 44px;
            }

            .mode-switch-group {
                padding: 3px;
                gap: 2px;
            }

            .mode-switch-btn {
                padding: 5px 12px;
                font-size: 0.82em;
            }

            .free-mode-actions button {
                padding: 8px 18px;
                font-size: 0.88em;
                min-height: 40px;
            }
        }

        @media (max-width: 480px) {
            .free-mode-table select {
                min-width: 40px;
                min-height: 38px;
                font-size: 0.95em;
            }

            .free-mode-actions {
                flex-wrap: wrap;
            }

            .free-mode-table input[type="text"] {
                width: 58px;
                min-height: 38px;
                font-size: 0.88em;
            }
        }

        /* 음성 키워드 입력 — 넉넉한 크기 */
        .fm-voice-input {
            width: 100px !important;
            min-height: 44px;
            padding: 8px 10px;
            border: 2px solid transparent;
            border-radius: 12px;
            font-size: 1em !important;
            font-weight: 600;
            background: #fdf8f3;
            color: #5c4a3a;
            text-align: center;
            transition: all 0.25s;
        }

        .fm-voice-input:focus {
            border-color: #ff922b;
            background: #fff;
            box-shadow: 0 0 0 3px rgba(255,146,43,0.18);
            outline: none;
        }

        .fm-voice-input::placeholder {
            color: #d4b99a;
            font-weight: 500;
        }
