* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, sans-serif;
    user-select: none;
}

body {
    background: #0b0b12;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#app {
    width: 100vw;
    height: 100vh;
    background: #0f0f1a;
    position: relative;
    overflow: hidden;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.page.active {
    display: flex;
    opacity: 1;
}

/* Camera Page */
#camera-page {
    background: #0a0a12;
    justify-content: center;
    align-items: center;
}

.camera-feed {
    position: relative;
    width: 100%;
    height: 100%;
    background: #14141f;
    overflow: hidden;
    cursor: pointer;
}

#webcam {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scaleX(-1);
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

.face-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scaleX(-1);
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 10;
}

.camera-feed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 2;
}

.camera-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 6% 6%;
}

.tv-title {
    position: absolute;
    top: 4%;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.95);
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    font-weight: 700;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.9);
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 15;
    padding: 0 30px;
}
.tv-title small {
    display: block;
    font-size: clamp(1rem, 1.6vw, 2rem);
    font-weight: 400;
    opacity: 0.8;
    margin-top: 6px;
    letter-spacing: 3px;
}

.cam-status {
    position: absolute;
    bottom: 3%;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: clamp(0.8rem, 1vw, 1.2rem);
    letter-spacing: 3px;
    pointer-events: none;
    z-index: 15;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}
.cam-status i {
    color: #00e5ff;
    margin-right: 10px;
    font-size: 10px;
}

/* Loading Page */
#loading-page {
    background: rgba(0, 0, 0, 0.92);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(16px);
    z-index: 50;
}
.spinner {
    width: 80px;
    height: 80px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00e5ff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 30px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
#loading-page p {
    color: #ccc;
    font-size: clamp(1.5rem, 2.5vw, 2.8rem);
    font-weight: 300;
}

/* Pin Page */
#pin-page {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.pin-drag-container {
    position: absolute;
    width: 300px;
    height: 340px;
    max-width: 92vw;
    max-height: 92vh;
    background: #1a1a2e;
    border-radius: 36px;
    border: 1px solid #3a3a5a;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    touch-action: none;
    flex-shrink: 0;
}

.drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 32px;
    z-index: 70;
    background: #1a1a2e;
    border-radius: 36px 36px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 13px;
    letter-spacing: 2px;
    cursor: grab;
    user-select: none;
    border-bottom: 1px solid #2a2a44;
}
.drag-handle i { margin-right: 8px; }
.drag-handle:active { cursor: grabbing; }

.resize-handle {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 40%, #00e5ff 40%, #00e5ff 60%, transparent 60%);
    opacity: 0.4;
    transition: 0.2s;
    border-radius: 0 0 28px 0;
    z-index: 71;
    pointer-events: auto;
}
.resize-handle:hover { opacity: 1; }

.pin-content-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 600px;
    height: 700px;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    padding: 40px 25px 20px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    background: #1a1a2e;
    border-radius: 36px;
    pointer-events: auto;
}

.lock-icon {
    font-size: 2.6rem;
    color: #00e5ff;
    margin-bottom: 0px;
}
.pin-content-wrapper h2 {
    color: #fff;
    font-size: 2.0rem;
    font-weight: 400;
    margin: 0;
    line-height: 1.2;
}
.pin-content-wrapper .sub {
    color: #888;
    font-size: 1.0rem;
    margin-bottom: 6px;
}
.pin-dots {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 8px;
}
.pin-dot {
    width: 38px;
    height: 38px;
    background: #0a0a14;
    border: 3px solid #333;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
}
.pin-dot.filled {
    border-color: #00e5ff;
    background: #00e5ff22;
}
.pin-dot.filled::after {
    content: "●";
    color: #00e5ff;
    font-size: 1.6rem;
}

.num-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 300px;
    width: 100%;
    margin: 0 auto 4px auto;
}
.num-key {
    background: #2a2a44;
    border: none;
    border-radius: 16px;
    padding: 10px 0;
    font-size: 1.6rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: 0.08s;
    box-shadow: 0 3px 0 #0a0a14;
    line-height: 1;
}
.num-key:active { transform: translateY(3px); box-shadow: none; }
.num-key:hover { background: #3a3a5a; }
.num-key.key-clear { background: #5a2a2a; color: #ff6b6b; }
.num-key.key-clear:hover { background: #7a3a3a; }
.num-key.key-verify { background: #00e5ff; color: #0a0a14; font-weight: 700; }
.num-key.key-verify:hover { background: #66f0ff; }

.pin-error-tv {
    color: #ff4d6d;
    font-size: 0.9rem;
    min-height: 22px;
    margin-top: 0px;
}
.pin-back-link {
    background: none;
    border: none;
    color: #666;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 2px;
}
.pin-back-link:hover { color: #aaa; }
.pin-demo-hint {
    margin-top: 0px;
    font-size: 0.8rem;
    color: #444;
}
.pin-demo-hint strong { color: #aaa; }
.forgot-password {
    color: #00e5ff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 2px;
    letter-spacing: 0.5px;
    transition: 0.2s;
}
.forgot-password:hover { color: #66f0ff; }

@media (max-width: 768px) {
    .pin-drag-container { max-width: 95vw; max-height: 95vh; }
    .tv-title { font-size: 1.8rem; top: 2%; }
    .tv-title small { font-size: 0.8rem; }
}