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

/* Tablet layout (601px to 820px) */
@media (min-width: 601px) and (max-width: 820px) {
    body {
        flex-direction: column;
        min-height: 100vh;
        height: auto;
        overflow-y: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .app-container .whiteboard-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        width: 100%;
        max-height: 60vh;
        aspect-ratio: 16 / 9;
        flex: 0 0 auto;
    }

    .app-container .whiteboard-panel .whiteboard-canvas {
        height: 100%;
        width: 100%;
    }

    .chat-drawer {
        position: relative;
        width: 100%;
        max-width: none;
        height: auto;
        max-height: none;
        border-left: none;
        border-top: 1px solid rgba(229,231,235,0.8);
        box-shadow: none;
        transform: none;
        visibility: visible;
        background: #ffffff;
        margin-top: 16px;
    }

    .chat-drawer.collapsed {
        transform: none;
        visibility: visible;
    }

    .chat-drawer-header {
        border-bottom: 1px solid #e5e7eb;
    }

    .chat-drawer-close {
        display: none;
    }

    .chat-messages {
        height: clamp(240px, 38vh, 500px);
        max-height: none;
        padding: 16px;
    }

    .chat-input {
        padding: 16px;
        gap: 10px;
        box-shadow: none;
    }

    .chat-input #chatImageBtn {
        display: flex;
    }

    .input-controls {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .voice-button,
    .send-button {
        width: 100%;
    }

    .voice-feedback {
        padding: 12px;
    }
}

/* Phone-only refinements (exclude tablets): YouTube-like layout */
@media (max-width: 600px) {
    :root {
        --viewport-height: 100vh;
        --whiteboard-height: 46vh;
        --chat-input-height: 70px;
    }
    
    body {
        overflow: hidden;
        height: var(--viewport-height, 100vh);
        position: fixed;
        width: 100%;
        display: flex;
        flex-direction: column;
        top: 0;
        left: 0;
    }

    .app-container {
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        display: flex;
        flex: 1 1 auto;
        position: relative;
    }

    /* Whiteboard behaves like a video player area - YouTube/TikTok style - ALWAYS FIXED AT TOP */
    .whiteboard-panel,
    .app-container .whiteboard-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: var(--whiteboard-height-px, 46vh) !important;
        min-height: var(--whiteboard-height-px, 46vh) !important;
        max-height: var(--whiteboard-height-px, 46vh) !important;
        aspect-ratio: 16 / 9;
        z-index: 100 !important;
        overflow: hidden;
        touch-action: none;
        overscroll-behavior: none;
        background: #f8f9fa;
        transform: translate3d(0, 0, 0);
        will-change: transform;
    }

    /* Chat drawer always visible below whiteboard - STARTS AFTER WHITEBOARD */
    .chat-drawer {
        position: fixed !important;
        top: var(--whiteboard-height-px, 46vh) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: var(--chat-height-px, auto) !important;
        max-height: var(--chat-height-px, calc(100vh - 46vh)) !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: translate3d(0, 0, 0) !important;
        will-change: transform !important;
        visibility: visible !important;
        display: flex !important;
        flex-direction: column;
        border-left: none !important;
        border-right: none !important;
        border-top: 1px solid rgba(229,231,235,0.3);
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 50;
        background: #ffffff;
        overflow: hidden;
        overscroll-behavior: none !important;
    }
    .chat-drawer.collapsed {
        transform: none !important;
        visibility: visible !important;
        display: flex !important;
    }

    /* Chat header - HIDE on mobile for more space */
    .chat-drawer-header {
        display: none !important;
    }

    /* Chat messages - normal scroll, latest messages at bottom */
    .chat-messages {
        flex: 1 1 auto;
        min-height: 100px;
        display: flex;
        flex-direction: column;
        overflow-y: auto !important;
        overflow-x: hidden;
        padding: 10px 8px 96px 8px !important;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        box-sizing: border-box;
        background: #f8f9fa;
        overscroll-behavior: contain;
        overscroll-behavior-y: contain;
        position: relative;
    }

    /* Messages container - normal flow */
    .chat-messages > * {
        flex-shrink: 0;
        width: 100%;
        box-sizing: border-box;
    }

    /* Input at bottom - full width YouTube-style - ultra compact & elegant */
    .chat-input {
        flex: 0 0 auto;
        flex-shrink: 0;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 2px;
        padding: 10px 8px;
        padding-bottom: max(env(safe-area-inset-bottom, 20px), 20px);
        margin: 0;
        border-top: 1px solid rgba(229,231,235,0.3);
        background: #ffffff;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        flex-wrap: nowrap !important;
        box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
        z-index: 5000 !important;
        min-height: 56px;
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    .input-wrapper { 
        flex: 1 1 auto;
        min-width: 0;
        order: 1;
        display: flex;
        align-items: center;
    }

    .chat-input input {
        padding: 6px 10px;
        font-size: 0.8rem;
        width: 100%;
        border-radius: 14px;
        border: 1px solid rgba(229,231,235,0.4);
        background: #f8f9fa;
        transition: all 0.2s ease;
        line-height: 1.3;
        height: 30px;
    }
    
    .chat-input input::placeholder {
        color: #94a3b8 !important;
        font-weight: 300 !important;
    }
    
    .chat-input input::-webkit-input-placeholder {
        color: #94a3b8 !important;
        font-weight: 300 !important;
    }
    
    .chat-input input::-moz-placeholder {
        color: #94a3b8 !important;
        font-weight: 300 !important;
    }
    
    .chat-input input:focus {
        border-color: rgba(102,126,234,0.45);
        background: #ffffff;
        box-shadow: 0 0 0 1.5px rgba(102,126,234,0.08);
    }

    /* Show image, mic and send buttons - elegant minimal design - all inline */
    .input-controls {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 3px;
        flex: 0 0 auto;
        flex-wrap: nowrap !important;
        order: 2;
    }

    /* Send button visible on mobile - ultra compact elegant style */
    .send-button {
        display: inline-flex !important;
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        justify-content: center !important;
        align-items: center !important;
        box-shadow: 0 2px 4px rgba(16, 185, 129, 0.15) !important;
        line-height: 1 !important;
        background: linear-gradient(135deg, #10b981, #059669) !important;
        border: none !important;
    }

    /* Hide all text in send button, show only emoji */
    .send-button {
        font-size: 0 !important;
        text-indent: -9999px !important;
        overflow: hidden !important;
    }
    
    .send-button::before {
        content: '➤' !important;
        font-size: 13px !important;
        line-height: 1 !important;
        text-indent: 0 !important;
        float: left !important;
        margin: 0 !important;
        display: block !important;
        color: white !important;
    }
    
    .send-button::after {
        content: '' !important;
        clear: both !important;
        display: block !important;
    }
    
    .send-button:active {
        transform: scale(0.85);
        box-shadow: 0 1px 2px rgba(16, 185, 129, 0.12) !important;
    }

    /* Show only image upload button - compact elegant */
    .chat-input #chatImageBtn { 
        display: inline-flex !important;
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 50% !important;
        background: rgba(79,70,229,0.06) !important;
        border: 1px solid rgba(79,70,229,0.12) !important;
        transition: all 0.2s ease !important;
        font-size: 13px !important;
        line-height: 1 !important;
    }

    .chat-input #chatImageBtn:active {
        transform: scale(0.85);
        background: rgba(79,70,229,0.14);
        border-color: rgba(79,70,229,0.22);
    }

    /* Voice button - elegant circular design - compact */
    #voiceRecordBtn {
        display: inline-flex !important;
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 50% !important;
        background: rgba(16,185,129,0.06) !important;
        border: 1px solid rgba(16,185,129,0.12) !important;
        transition: all 0.2s ease !important;
        font-size: 13px !important;
        line-height: 1 !important;
    }

    #voiceRecordBtn:active {
        transform: scale(0.85);
        background: rgba(16,185,129,0.14);
        border-color: rgba(16,185,129,0.22);
    }

    #voiceRecordBtn.recording {
        background: rgba(239,68,68,0.18);
        border-color: rgba(239,68,68,0.35);
        animation: pulse 1.5s infinite;
    }

    /* Icon-only, no labels for all buttons */
    .voice-button .label,
    .chat-input .label {
        display: none !important;
    }

    .voice-button .icon,
    .chat-input .icon {
        font-size: 13px;
        margin: 0;
    }

    .voice-feedback {
        display: none;
    }

    /* Hide all whiteboard overlay controls on mobile */
    .app-container .whiteboard-panel .board-overlay-controls {
        display: none !important;
    }

    /* Hide session panel on mobile */
    .session-panel { 
        display: none !important;
    }

    /* Hide coordinate indicator on mobile */
    .coordinate-indicator {
        display: none !important;
    }

    /* Hide connection status on mobile */
    .connection-status {
        display: none !important;
    }

    /* Show welcome splash on mobile - but simplified */
    .welcome-splash {
        display: flex !important;
    }
    
    /* Simplify for mobile */
    .splash-features {
        display: none !important;
    }
    
    .splash-title {
        font-size: 2rem !important;
        margin-bottom: 8px !important;
    }
    
    .splash-subtitle {
        font-size: 1rem !important;
        margin-bottom: 32px !important;
    }
    
    .splash-icon {
        font-size: 64px !important;
        margin-bottom: 16px !important;
    }
    
    .splash-start-btn {
        padding: 14px 32px !important;
        font-size: 1rem !important;
    }
    
    .splash-shape {
        display: none !important;
    }

    /* Hide streak counter, progress bar, connection status, theme toggle on mobile */
    .streak-counter,
    .progress-bar-container,
    .connection-status,
    .theme-toggle {
        display: none !important;
    }

    /* Optimize message styling for mobile */
    .message {
        max-width: 90%;
        font-size: 0.9rem;
        padding: 10px 14px;
    }

    /* Ensure whiteboard canvas doesn't overflow */
    .whiteboard-canvas {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    #whiteboard-svg {
        width: 100%;
        height: 100%;
    }

    /* Keyboard open state - YouTube mobile style: whiteboard fixed, chat adapts to keyboard */
    body.keyboard-open {
        height: 100vh !important;
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        overscroll-behavior: none !important;
    }

    body.keyboard-open .app-container {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        overscroll-behavior: none !important;
    }

    body.keyboard-open .whiteboard-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: var(--whiteboard-height-px) !important;
        min-height: var(--whiteboard-height-px) !important;
        max-height: var(--whiteboard-height-px) !important;
        z-index: 100 !important;
        overflow: hidden !important;
        touch-action: none !important;
        overscroll-behavior: none !important;
        pointer-events: auto !important;
        transform: translate3d(0, 0, 0) !important;
        will-change: transform !important;
        background: #f8f9fa !important;
    }

    body.keyboard-open .chat-drawer {
        position: fixed !important;
        top: var(--whiteboard-height-px) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: var(--chat-height-px) !important;
        max-height: var(--chat-height-px) !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0 !important;
        margin: 0 !important;
        overscroll-behavior: none !important;
        z-index: 50 !important;
        transform: translate3d(0, 0, 0) !important;
        will-change: transform !important;
        background: #ffffff !important;
    }

    body.keyboard-open .chat-messages {
        flex: 1 1 auto !important;
        flex-shrink: 1 !important;
        min-height: 80px !important;
        max-height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
        overscroll-behavior-y: contain !important;
        padding: 4px 6px calc(var(--chat-input-height, 70px) + 8px) 6px !important;
        position: relative !important;
        transform: translate3d(0, 0, 0) !important;
        will-change: scroll-position !important;
    }
    
    body.keyboard-open .chat-input {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px 8px !important;
        padding-bottom: max(env(safe-area-inset-bottom, 20px), 20px) !important;
        margin: 0 !important;
        z-index: 9999 !important;
        background: #ffffff !important;
        min-height: 56px !important;
        transform: translate3d(0, 0, 0) !important;
        will-change: transform !important;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.12) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
    }
    
    /* Chat input always on top on mobile when keyboard is not open too */
    .chat-input {
        position: relative;
        z-index: 100;
    }
}

#latex-zone-concept_zone .concept-title {
    font-weight: 700;
    font-size: 18px;
    margin: 2px 2px 8px 2px;
    color: #0f172a;
}
body.dark-mode #latex-zone-concept_zone .concept-title { color: #e2e8f0; }

#latex-zone-concept_zone .concept-list {
    list-style: decimal inside;
    margin: 0;
    padding: 0;
}
#latex-zone-concept_zone .concept-list .concept-flow-item {
    margin: 6px 2px;
}

/* Highlight current step in concept list */
#latex-zone-concept_zone .concept-list .active-step {
    background: linear-gradient(90deg, rgba(59,130,246,0.08), transparent 60%);
    border-left: 3px solid #3b82f6;
    padding-left: 8px;
    border-radius: 4px;
    font-weight: 600;
}

html, body {
    width: 100%;
    height: 100%;
}

/* Test buttons visible (small variant) */
.toolbar .small {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* Floating Action Buttons */
.fab-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1001;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    background: white;
}

.fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

.fab-mic {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}
.fab-chat {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
}

/* State variations */
.fab.active {
    filter: saturate(1.2) brightness(1.1);
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
    --success-gradient: linear-gradient(135deg, #10b981, #059669);
    --danger-gradient: linear-gradient(135deg, #ef4444, #dc2626);
    --warning-gradient: linear-gradient(135deg, #f59e0b, #d97706);
    --info-gradient: linear-gradient(135deg, #3b82f6, #2563eb);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #334155;
    --text-secondary: #64748b;
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 8px 32px rgba(31, 38, 135, 0.37);
    
    /* Light theme (default) */
    --bg-primary: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    --bg-secondary: #ffffff;
    --bg-pattern: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(99,102,241,0.05)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
}

/* Dark mode variables */
body.dark-mode {
    --bg-primary: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --bg-secondary: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(30, 41, 59, 0.95);
}

body.dark-mode .whiteboard-panel {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    box-shadow: inset 0 0 100px rgba(102,126,234,0.1);
}

body.dark-mode .whiteboard-panel::before {
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(102,126,234,0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118,75,162,0.1) 0%, transparent 50%);
    border-color: rgba(71, 85, 105, 0.3);
}

body.dark-mode .chat-messages {
    background: rgba(15, 23, 42, 0.9);
}

body.dark-mode .chat-input input {
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border-color: #475569;
}

body.dark-mode .chat-input input:focus {
    background: #1e293b;
}

/* ===== MODERN DRAWING CURSORS & EFFECTS ===== */
.whiteboard-canvas {
    cursor: default;
    position: relative;
}

.whiteboard-canvas.drawing-mode {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" fill="%23667eea" opacity="0.3"/><circle cx="12" cy="12" r="4" fill="%23667eea"/></svg>') 12 12, crosshair;
}

.whiteboard-canvas.eraser-mode {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" fill="%23ef4444" opacity="0.3"/><rect x="8" y="8" width="8" height="8" fill="%23ef4444"/></svg>') 12 12, crosshair;
}

/* Drawing Point Feedback */
.draw-point {
    animation: drawPointPulse 0.6s ease-out;
}

@keyframes drawPointPulse {
    0% {
        r: 2;
        opacity: 1;
    }
    100% {
        r: 8;
        opacity: 0;
    }
}

/* Coordinate System Enhancement */
.axis-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-weight: 600;
    fill: #667eea !important;
    font-size: 13px;
}

.grid-line {
    stroke: rgba(148, 163, 184, 0.2) !important;
    stroke-width: 0.5 !important;
    stroke-dasharray: 2, 2;
}

.axis-line {
    stroke: #667eea !important;
    stroke-width: 2.5 !important;
    filter: drop-shadow(0 1px 2px rgba(102,126,234,0.3));
}

body.dark-mode .axis-label {
    fill: #93c5fd !important;
}

body.dark-mode .grid-line {
    stroke: rgba(148, 163, 184, 0.15) !important;
}

body.dark-mode .axis-line {
    stroke: #60a5fa !important;
}

/* Base Layout */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    height: 100vh;
    background: #ffffff;
    overflow: hidden;
    position: relative;
    flex: 1 1 auto;
    transition: background 0.3s ease;
}

body::before { display: none; }

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    flex: 1 1 auto; /* Ensure app-container fills all available space in body */
}

/* Chat Panel */
.chat-panel {
    flex: 0 0 450px;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-heavy);
    z-index: 10;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapse behavior (desktop as well) */
.chat-panel.collapsed {
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
}

/* Fully hide legacy left chat container */
.legacy-hidden {
    display: none !important;
}

.chat-header {
    background: var(--secondary-gradient);
    color: white;
    padding: 25px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.chat-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-header .subtitle {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.95;
    font-size: 0.9rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: rgba(203,213,225,0.5) transparent;
    position: relative;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(180deg, rgba(248,250,252,0.5), transparent);
    pointer-events: none;
    z-index: 1;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* Message Styles */
.message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: 20px;
    max-width: 85%;
    overflow-wrap: break-word;
    animation: slideInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08),
                0 1px 4px rgba(0,0,0,0.04);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 8px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25),
                0 2px 8px rgba(102, 126, 234, 0.15);
    transform-origin: right center;
    position: relative;
    overflow: hidden;
}

.user-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.user-message:hover::before {
    left: 100%;
}

.user-message:hover {
    transform: scale(1.02) translateX(-2px);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.3),
                0 4px 12px rgba(102, 126, 234, 0.2);
}

.ai-message {
    background: white;
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: relative;
    padding-left: 50px;
}

.ai-message::before {
    content: '🎓';
    position: absolute;
    left: 10px;
    top: 10px;
    background: var(--secondary-gradient);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: avatarBounce 2s ease-in-out infinite;
}

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

/* Message type indicators */
.ai-message.hint-message {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.1) 0%, white 10%);
}

.ai-message.hint-message::before {
    content: '💡';
    background: var(--warning-gradient);
}

.ai-message.success-message {
    border-left: 4px solid #10b981;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, white 10%);
}

.ai-message.success-message::before {
    content: '⭐';
    background: var(--success-gradient);
    animation: starPulse 1s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.ai-message.question-message {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, white 10%);
}

.ai-message.question-message::before {
    content: '❓';
    background: var(--info-gradient);
}

.loading-message {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.08));
    backdrop-filter: blur(10px);
    color: var(--text-secondary);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
    overflow: hidden;
}

.loading-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.2), transparent);
    animation: loadingShimmer 2s infinite;
}

@keyframes loadingShimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

.loading-dots {
    display: flex;
    gap: 5px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    animation: loadingBounce 1.4s infinite ease-in-out both;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0s; }

@keyframes loadingBounce {
    0%, 80%, 100% { 
        transform: translateY(0) scale(0.8); 
        opacity: 0.5;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    }
    40% { 
        transform: translateY(-12px) scale(1.2); 
        opacity: 1;
        box-shadow: 0 4px 16px rgba(102, 126, 234, 0.5);
    }
}

/* Input Styles */
.chat-input {
    padding: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,250,252,0.95));
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.04);
}

.chat-input #chatImageBtn {
    display: none;
}

body.dark-mode .chat-input {
    background: linear-gradient(180deg, rgba(30,41,59,0.95), rgba(15,23,42,0.95));
    border-top-color: rgba(71,85,105,0.3);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input input {
    width: 100%;
    padding: 16px 24px;
    border: 2px solid rgba(226, 232, 240, 0.6);
    border-radius: 16px;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
}

.chat-input input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.chat-input input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15),
                inset 0 2px 4px rgba(0,0,0,0.04);
    background: white;
    transform: translateY(-2px);
}

body.dark-mode .chat-input input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.4);
    color: #e2e8f0;
}

body.dark-mode .chat-input input:focus {
    background: rgba(30, 41, 59, 0.8);
    border-color: #667eea;
}

.send-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3),
                0 2px 8px rgba(16, 185, 129, 0.2);
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.send-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.send-button:hover::before {
    width: 300px;
    height: 300px;
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 28px rgba(16, 185, 129, 0.4),
                0 4px 12px rgba(16, 185, 129, 0.25);
}

.send-button:active:not(:disabled) {
    transform: translateY(-1px) scale(0.98);
}

.send-button:disabled {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* Whiteboard Panel - ULTRA MODERN */
.whiteboard-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    position: fixed; /* Fill the entire viewport */
    left: 0; right: 0; top: 0; bottom: 0;
    overflow: hidden;
    box-shadow: inset 0 0 100px rgba(102,126,234,0.03);
    justify-content: stretch;
    align-items: stretch; 
}

.whiteboard-panel::before { display: none; }

.whiteboard-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.math-icon {
    width: 28px;
    height: 28px;
    background: var(--secondary-gradient);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toolbar button {
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clear-btn {
    background: var(--danger-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.clear-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
}

.test-btn {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.test-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

#testWithoutCoordsBtn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

#testWithoutCoordsBtn:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
}

.connection-test-btn {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.connection-test-btn:hover {
    background: linear-gradient(135deg, #0891b2, #0e7490);
    transform: translateY(-1px);
}

.coordinate-btn {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.coordinate-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    transform: translateY(-1px);
}

.whiteboard-canvas {
    flex: 1 1 auto;
    background: transparent;
    box-shadow: none;
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    border-radius: 0;
}

/* Chalkboard texture option (can be toggled) */
body.chalkboard-mode .whiteboard-canvas {
    background: linear-gradient(135deg, #1a3a2e 0%, #0f2419 100%);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255,255,255,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.02) 0%, transparent 50%),
        linear-gradient(135deg, #1a3a2e 0%, #0f2419 100%);
}

body.chalkboard-mode .function-path {
    stroke: #ffffff;
    filter: drop-shadow(0 0 3px rgba(255,255,255,0.5));
}

body.chalkboard-mode .axis-line {
    stroke: rgba(255,255,255,0.6);
}

body.chalkboard-mode .axis-label {
    fill: rgba(255,255,255,0.8);
}

/* On-board overlay controls - ULTRA MODERN */
.board-overlay-controls {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 1400;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: controlsFadeIn 0.6s ease-out;
}

@keyframes controlsFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

body.dark-mode .board-overlay-controls {
    background: rgba(30, 41, 59, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.overlay-btn {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    box-shadow: 0 8px 24px rgba(0,0,0,0.12),
                0 2px 8px rgba(0,0,0,0.08),
                inset 0 1px 0 rgba(255,255,255,0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 22px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.overlay-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay-btn:hover::before {
    opacity: 1;
}

/* Audio visualizer (3-bar) */
.audio-viz {
    display: inline-flex;
    align-items: flex-end;
    gap: 5px;
    padding: 5px 7px;
    border-radius: 12px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 6px 16px rgba(0,0,0,0.16);
    height: 26px;
}
.audio-viz.hidden { display: none; }
.audio-viz .bar {
    width: 5px;
    height: 8px; /* base */
    background: linear-gradient(180deg, #34d399, #10b981);
    border-radius: 3px;
    transform-origin: bottom center;
    transition: height 60ms linear, background 200ms ease, box-shadow 200ms ease;
    box-shadow: 0 0 0 rgba(34,197,94,0.0);
}
.audio-viz.listening .bar { background: linear-gradient(180deg, #60a5fa, #3b82f6); box-shadow: 0 0 8px rgba(59,130,246,0.35); }
.audio-viz.ai .bar { background: linear-gradient(180deg, #a78bfa, #8b5cf6); box-shadow: 0 0 8px rgba(139,92,246,0.35); }

@keyframes aiPulse {
    0% { height: 6px; }
    25% { height: 18px; }
    50% { height: 10px; }
    75% { height: 20px; }
    100% { height: 8px; }
}
.audio-viz.ai .bar:nth-child(1) { animation: aiPulse 900ms infinite ease-in-out; animation-delay: 0ms; }
.audio-viz.ai .bar:nth-child(2) { animation: aiPulse 900ms infinite ease-in-out; animation-delay: 120ms; }
.audio-viz.ai .bar:nth-child(3) { animation: aiPulse 900ms infinite ease-in-out; animation-delay: 240ms; }

.overlay-btn:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 12px 32px rgba(0,0,0,0.2),
                0 4px 12px rgba(0,0,0,0.12),
                inset 0 1px 0 rgba(255,255,255,0.6);
}

.overlay-btn:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

body.dark-mode .overlay-btn {
    background: linear-gradient(135deg, rgba(51,65,85,0.95), rgba(30,41,59,0.9));
    box-shadow: 0 8px 24px rgba(0,0,0,0.3),
                0 2px 8px rgba(0,0,0,0.2),
                inset 0 1px 0 rgba(255,255,255,0.1);
}

.overlay-mic { 
    color: #059669;
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(5,150,105,0.1));
}

.overlay-mic:hover {
    background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(5,150,105,0.15));
    color: #047857;
}

.overlay-chat { 
    color: #4f46e5;
    background: linear-gradient(135deg, rgba(79,70,229,0.15), rgba(99,102,241,0.1));
}

.overlay-chat:hover {
    background: linear-gradient(135deg, rgba(79,70,229,0.25), rgba(99,102,241,0.15));
    color: #4338ca;
}

.overlay-clear {
    color: #dc2626;
    background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(220,38,38,0.1));
}

.overlay-clear:hover {
    background: linear-gradient(135deg, rgba(239,68,68,0.25), rgba(220,38,38,0.15));
    color: #b91c1c;
}

.overlay-pen {
    color: #7c3aed;
    background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(109,40,217,0.1));
}

.overlay-pen:hover {
    background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(109,40,217,0.15));
    color: #6d28d9;
}

.overlay-upload {
    color: #0891b2;
    background: linear-gradient(135deg, rgba(6,182,212,0.15), rgba(8,145,178,0.1));
}

.overlay-upload:hover {
    background: linear-gradient(135deg, rgba(6,182,212,0.25), rgba(8,145,178,0.15));
    color: #0e7490;
}

.overlay-shot {
    color: #ea580c;
    background: linear-gradient(135deg, rgba(234,88,12,0.15), rgba(194,65,12,0.1));
}

.overlay-shot:hover {
    background: linear-gradient(135deg, rgba(234,88,12,0.25), rgba(194,65,12,0.15));
    color: #c2410c;
}

/* Popup Chat Modal */
/* Right-side Chat Drawer */
.chat-drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(92vw, 420px);
    max-width: 90%;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(229,231,235,0.5);
    box-shadow: -16px 0 48px rgba(0,0,0,0.12),
                -4px 0 16px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transform: translateX(0%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-drawer.collapsed { 
    transform: translateX(100%);
    box-shadow: none;
    border-left: none;
    visibility: hidden;
}

body.dark-mode .chat-drawer {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-left-color: rgba(71,85,105,0.5);
}

.chat-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.chat-drawer-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.1), transparent),
                radial-gradient(circle at 80% 80%, rgba(255,255,255,0.08), transparent);
    pointer-events: none;
}

.chat-drawer-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-drawer-header h2::before {
    content: '🎓';
    font-size: 1.5rem;
    animation: headerIconFloat 3s ease-in-out infinite;
}

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

.chat-drawer-close {
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 24px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(10px);
}

.chat-drawer-close:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg) scale(1.1);
}

.chat-drawer-close:active {
    transform: rotate(90deg) scale(0.95);
}

.chat-drawer .chat-messages { flex: 1; }
.chat-drawer .chat-input { border-top: 1px solid #e5e7eb; }

#whiteboard-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.05));
    display: block;
    pointer-events: auto;
}

/* Concept Zone: Frosted "Kavram Kartı" inside overlay */
#latex-zone-concept_zone {
    /* overlay container already absolutely positioned by JS */
    pointer-events: auto;
}

#latex-zone-concept_zone .concept-card {
    position: absolute;
    left: 8px;
    top: 8px;
    right: 8px;
    bottom: 8px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 12px 30px rgba(2,6,23,0.05), inset 0 1px 0 rgba(255,255,255,0.4);
    overflow-y: auto;
    overflow-x: auto; /* allow horizontal scroll if math is wider */
    color: var(--text-primary);
    user-select: text;
    -webkit-user-select: text;
    word-break: break-word; /* wrap long text */
    overflow-wrap: anywhere;
}

body.dark-mode #latex-zone-concept_zone .concept-card {
    background: rgba(30, 41, 59, 0.55);
    border-color: rgba(71, 85, 105, 0.5);
    color: var(--text-primary);
}

#latex-zone-concept_zone .concept-card::-webkit-scrollbar {
    width: 8px;
}
#latex-zone-concept_zone .concept-card::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.6);
    border-radius: 6px;
}

#latex-zone-concept_zone .concept-flow-item {
    display: block;
    position: relative;
    margin: 8px 2px;
    line-height: 1.35;
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Ensure MathJax blocks fit card width or scroll horizontally */
#latex-zone-concept_zone .concept-card mjx-container {
    max-width: 100%;
    overflow-x: auto;
}
#latex-zone-concept_zone .concept-card mjx-container > svg {
    max-width: 100%;
    height: auto;
}
#latex-zone-concept_zone .concept-card mjx-container[display="true"] {
    display: block;
    overflow-x: auto;
}
#latex-zone-concept_zone .concept-card * { max-width: 100%; }

/* Ensure MathJax inline content wraps nicely inside the card */
#latex-zone-concept_zone .concept-flow-item mjx-container[jax="CHTML"][display="true"] {
    display: block;
}
#latex-zone-concept_zone .concept-flow-item mjx-container[jax="CHTML"][display="false"] {
    display: inline;
}

/* Modern Drawing Styles */
#whiteboard-svg path {
    transition: stroke-width 0.1s ease;
    position: absolute;
    pointer-events: none;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    animation: fadeInScale 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* SVG Animation Classes */
.svg-element {
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.function-path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.function-path.animate {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawPath 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

.axis-line {
    stroke: #64748b;
    stroke-width: 1.5;
    opacity: 0.8;
}

.grid-line {
    stroke: #e2e8f0;
    stroke-width: 0.5;
    opacity: 0.7;
}

.axis-label {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    fill: #64748b;
    font-weight: 500;
}

.math-point {
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.math-point:hover {
    transform: scale(1.2);
}

/* Problem Type Indicators */
.problem-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin: 4px 0;
}

.problem-function {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.problem-geometry {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.problem-algebra {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.problem-calculus {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

/* Enhanced Message Styling */
.message strong {
    color: #4f46e5;
    font-weight: 600;
}

.message code {
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
}

.math-formula {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    margin: 8px 0;
    text-align: center;
}

/* Connection Status - ULTRA MODERN */
.connection-status {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 1500;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: statusFloat 3s ease-in-out infinite;
}

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

.connection-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

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

.connection-online {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.9));
    color: white;
}

.connection-online::before {
    background: #ffffff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.connection-offline {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.9));
    color: white;
}

.connection-offline::before {
    background: #ffffff;
    animation: statusBlink 1s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.connection-status:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2),
                0 4px 12px rgba(0, 0, 0, 0.1);
    animation: none;
}

/* ===== MOBILE RESPONSIVE SPLASH SCREEN ===== */
@media (max-width: 768px) {
    .splash-title {
        font-size: 2.5rem;
    }
    
    .splash-subtitle {
        font-size: 1rem;
    }
    
    .splash-icon {
        font-size: 72px;
    }
    
    .splash-features {
        gap: 16px;
        flex-direction: column;
    }
    
    .feature-item {
        padding: 16px 24px;
        flex-direction: row;
        gap: 12px;
    }
    
    .feature-icon {
        font-size: 28px;
    }
    
    .splash-start-btn {
        padding: 14px 36px;
        font-size: 1rem;
    }
    
    .shape-1, .shape-2, .shape-3 {
        width: 300px;
        height: 300px;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    /* Bottom drawer chat on mobile */
    .chat-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 55vh;
        max-height: 75vh;
        flex: 0 0 auto;
        order: 2;
        transform: translateY(0%);
        border-right: none;
        border-top: 1px solid var(--glass-border);
    }
    .chat-panel.collapsed {
        transform: translateY(100%);
    }
    
    .whiteboard-panel {
        flex: 1;
        order: 1;
    }
    
    .message {
        max-width: 95%;
        font-size: 0.9rem;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .toolbar button {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Enhanced LaTeX Container Styles */
.latex-container {
    position: absolute;
    pointer-events: auto;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(148, 163, 184, 0.2);
    animation: fadeInScale 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: move;
    user-select: none;
    max-width: 350px;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.3;
}

.latex-container:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transform: translate(-50%, -50%) scale(1.02);
}

.latex-delete-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 101;
    font-weight: bold;
}

.latex-container:hover .latex-delete-btn {
    opacity: 1;
}

/* Error and Success Message Styles */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
    color: #dc2626;
}

.success-message {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
    color: #059669;
}

.warning-message {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
    color: #d97706;
}

/* Coordinate System Indicators */
.coordinate-system-active {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.coordinate-system-inactive {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ===== CONFETTI ANIMATION ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f59e0b;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ===== ACHIEVEMENT POPUP - ULTRA PREMIUM ===== */
.achievement-popup {
    position: fixed;
    top: 100px;
    right: 24px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    color: white;
    padding: 20px 24px;
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.5),
                0 4px 16px rgba(245, 158, 11, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 2000;
    animation: achievementSlideIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 360px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

@keyframes achievementSlideIn {
    0% {
        transform: translateX(450px) scale(0.3) rotate(10deg);
        opacity: 0;
    }
    60% {
        transform: translateX(-10px) scale(1.05) rotate(-2deg);
    }
    100% {
        transform: translateX(0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

.achievement-popup::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: achievementShine 2s ease-in-out infinite;
}

@keyframes achievementShine {
    0% { left: -100%; }
    100% { left: 200%; }
}

.achievement-popup .icon {
    font-size: 48px;
    animation: achievementIconBounce 0.8s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes achievementIconBounce {
    0%, 100% { 
        transform: scale(1) rotate(0deg); 
    }
    25% {
        transform: scale(1.15) rotate(-5deg);
    }
    75% {
        transform: scale(1.15) rotate(5deg);
    }
}

.achievement-popup .content {
    flex: 1;
}

.achievement-popup .title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.achievement-popup .description {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* ===== PROGRESS BAR - ULTRA MODERN ===== */
.progress-bar-container {
    position: fixed;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    backdrop-filter: blur(20px);
    padding: 16px 28px;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 2px 12px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255,255,255,0.5);
    z-index: 1500;
    min-width: 320px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: progressContainerFloat 3s ease-in-out infinite;
}

@keyframes progressContainerFloat {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-3px); }
}

.progress-bar-container:hover {
    transform: translateX(-50%) translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15),
                0 4px 16px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255,255,255,0.6);
    animation: none;
}

body.dark-mode .progress-bar-container {
    background: linear-gradient(135deg, rgba(51,65,85,0.95), rgba(30,41,59,0.9));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 2px 12px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255,255,255,0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.progress-bar-container .label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--success-gradient);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== THEME TOGGLE BUTTON - ULTRA PREMIUM ===== */
.theme-toggle {
    position: fixed;
    top: 24px;
    right: 90px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1500;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: themeButtonFloat 3s ease-in-out infinite;
}

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

.theme-toggle:hover {
    transform: scale(1.1) rotate(180deg) translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2),
                0 4px 12px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255,255,255,0.6);
    animation: none;
}

.theme-toggle:active {
    transform: scale(1.05) rotate(180deg);
}

body.dark-mode .theme-toggle {
    background: linear-gradient(135deg, rgba(51,65,85,0.95), rgba(30,41,59,0.9));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
                0 2px 8px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255,255,255,0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 12px;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingDotBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDotBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* ===== MESSAGE REACTIONS ===== */
.message-reactions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.reaction-btn {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reaction-btn:hover {
    background: #f3f4f6;
    transform: scale(1.05);
}

.reaction-btn.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tooltip.show {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ===== ENHANCED BUTTON TOOLTIPS ===== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 10000;
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ===== STREAK COUNTER - ULTRA MODERN ===== */
.streak-counter {
    position: fixed;
    top: 24px;
    left: 24px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    backdrop-filter: blur(20px);
    padding: 14px 20px;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1500;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: streakCounterFloat 3s ease-in-out infinite;
}

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

.streak-counter:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15),
                0 4px 12px rgba(0, 0, 0, 0.08),
                inset 0 1px 0 rgba(255,255,255,0.6);
    animation: none;
}

.streak-counter .flame {
    font-size: 24px;
    animation: flameFlicker 1.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.4));
}

@keyframes flameFlicker {
    0%, 100% { 
        transform: scale(1) rotate(-5deg); 
        filter: brightness(1) drop-shadow(0 2px 4px rgba(245, 158, 11, 0.4)); 
    }
    50% { 
        transform: scale(1.15) rotate(5deg); 
        filter: brightness(1.3) drop-shadow(0 4px 8px rgba(245, 158, 11, 0.6)); 
    }
}

.streak-counter .count {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

body.dark-mode .streak-counter {
    background: linear-gradient(135deg, rgba(51,65,85,0.95), rgba(30,41,59,0.9));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
                0 2px 8px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255,255,255,0.1);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

/* ===== WELCOME SPLASH SCREEN ===== */
.welcome-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: splashFadeIn 0.4s ease-out;
}

.welcome-splash.hidden {
    animation: splashFadeOut 0.5s ease-out forwards;
    pointer-events: none;
}

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

@keyframes splashFadeOut {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

.splash-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.splash-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    animation: shapFloat 20s ease-in-out infinite;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.15), transparent);
    top: -150px;
    right: -150px;
    animation-delay: 0s;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.12), transparent);
    bottom: -80px;
    left: -80px;
    animation-delay: -7s;
}

.shape-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255,255,255,0.1), transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes shapeFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

.splash-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
    animation: contentSlideUp 0.8s ease-out 0.2s backwards;
}

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

.splash-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: iconFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}

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

.splash-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
    letter-spacing: -0.01em;
}

.splash-subtitle {
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 36px;
    opacity: 0.95;
    text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.splash-features {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 36px;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    transition: all 0.3s ease;
    animation: featureSlideIn 0.5s ease-out backwards;
}

.feature-item:nth-child(1) { animation-delay: 0.4s; }
.feature-item:nth-child(2) { animation-delay: 0.5s; }
.feature-item:nth-child(3) { animation-delay: 0.6s; }

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

.feature-item:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.feature-icon {
    font-size: 32px;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.15));
}

.splash-start-btn {
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
    background: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}


.splash-start-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102,126,234,0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.splash-start-btn:hover::before {
    width: 400px;
    height: 400px;
}

.splash-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.splash-start-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.btn-arrow {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.splash-start-btn:hover .btn-arrow {
    transform: translateX(8px);
}

.splash-loader {
    margin-top: 32px;
    width: 60px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin-left: auto;
    margin-right: auto;
    overflow: hidden;
    position: relative;
}

.splash-loader::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: white;
    animation: loaderSlide 1.5s ease-in-out infinite;
}

@keyframes loaderSlide {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* ===== LEVEL UP ANIMATION ===== */
.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.3) 0%, transparent 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    pointer-events: none;
    animation: levelUpFlash 1s ease-out;
}

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

.level-up-text {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #fbbf24);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: levelUpTextAnimation 1s ease-out, gradientShift 2s ease infinite;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
}

@keyframes levelUpTextAnimation {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}