:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --nav-bg: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
}

@media (max-width: 800px) {
    body {
        flex-direction: column;
        justify-content: flex-start;
    }
    .side-menu {
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .screen.active {
        padding: 20px 0;
    }
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Connection Screen Glassmorphism */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.glass-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.glass-card p {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 16px;
    font-size: 24px;
    text-align: center;
    letter-spacing: 4px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    outline: none;
    transition: border-color 0.3s;
    margin-bottom: 20px;
}

.input-group input:focus {
    border-color: var(--accent);
}

.primary-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.status-indicator {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.phone-frame {
    position: relative;
    width: 280px;
    height: 560px;
    background: #000;
    border-radius: 36px;
    border: 12px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255,255,255,0.2);
    overflow: hidden;
    margin-bottom: 20px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
}

/* --- Top Action Bar --- */
.top-action-bar {
    display: flex;
    justify-content: space-between;
    width: 280px;
    margin-bottom: 15px;
    gap: 10px;
}

.action-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.action-btn svg {
    width: 20px;
    height: 20px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.action-btn:active, .action-btn.pressed {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.action-btn.toggle-on {
    background: rgba(16, 185, 129, 0.3); /* Emerald tint */
    border-color: rgba(16, 185, 129, 0.6);
    color: #34d399;
}

.action-btn.toggle-off {
    background: rgba(239, 68, 68, 0.2); /* Red tint */
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: fill; /* ensures mapping is 1:1 with overlay */
    pointer-events: none; /* Let overlay handle clicks */
}

#input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: crosshair;
}

#stream-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    z-index: 5;
    pointer-events: none;
}

#node-tree-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    background: rgba(0, 0, 0, 0.85); /* Darken video */
    pointer-events: none;
}

#node-tree-container.hidden {
    display: none;
}

.node-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: 500;
    backdrop-filter: blur(5px);
    transition: background 0.15s, transform 0.1s, border-color 0.15s;
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px;
}

.node-btn.clickable {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
}

.node-btn.clickable:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.node-btn.clickable:active,
.node-btn.pressed {
    background: rgba(59, 130, 246, 0.5);
    transform: scale(0.95);
    border-color: rgba(59, 130, 246, 0.8);
}

/* Navigation Bar */
.android-nav-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 60px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: color 0.2s;
    pointer-events: auto;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
}

.nav-btn:hover {
    color: white;
}

.nav-btn:active {
    background: rgba(255,255,255,0.05);
}

/* Pattern Lock UI */
#pattern-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 25;
    background: rgba(0,0,0,0.4);
}
#pattern-overlay.hidden { display: none; }
.pattern-dot {
    position: absolute;
    width: 24px; height: 24px;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: background 0.1s, transform 0.1s;
    pointer-events: none; /* Let the container handle mouse events */
}
.pattern-dot.active {
    background: #3b82f6;
    border-color: #60a5fa;
    transform: translate(-50%, -50%) scale(1.3);
}
#pattern-lines {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}
.pattern-line {
    stroke: #3b82f6; stroke-width: 4; stroke-linecap: round; opacity: 0.8;
}
