:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: radial-gradient(circle at top left, #1e1b4b, #0f172a);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: #535c8b;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

.header {
    text-align: center;
    animation: fadeInDown 0.8s ease-out;
}

.title {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #818cf8, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.tutorial-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    animation: scaleIn 0.8s ease-out;
}

.device-mockup {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16 / 10;
    background: #000;
    border-radius: 24px;
    padding: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px var(--glass-border);
    overflow: hidden;
}

.screen {
    position: relative;
    width: 100%;
    height: 100%;
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

#image-container img.active {
    opacity: 1;
    z-index: 1;
}

/* Overlay for dimming effect */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    z-index: 2;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Spotlight effect */
.spotlight {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid var(--primary);
}

.spotlight.active {
    opacity: 1;
}

/* Dynamic Popup */
.popup-container {
    position: absolute;
    width: 90%;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    color: #1e293b;
    z-index: 10;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    /* Prevent popup from being cut off at edges */
    margin: 10px;
}

.popup-container.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: all;
}

.popup-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.popup-content p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: #475569;
}

.popup-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.action-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 0.85rem;
}

.action-btn.primary {
    background: var(--primary);
    color: white;
}

.action-btn.secondary {
    background: #f1f5f9;
    color: #64748b;
}

.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Cursor Animation */
.cursor {
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    transition: top 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        left 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.2s ease;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.cursor::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

.cursor.clicking::after {
    animation: clickRipple 0.4s ease-out;
}

@keyframes clickRipple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.control-btn:hover:not(:disabled) {
    background: var(--primary);
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.progress-indicator {
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
}

#current-step {
    color: var(--text-main);
}

.autoplay-control .play-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.autoplay-control .play-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.footer {
    width: 100%;
    max-width: 600px;
}

.step-description {
    background: var(--glass-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.6;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInUp 0.8s ease-out;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Mobile Responsiveness --- */

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
        gap: 1.5rem;
    }

    .device-mockup {
        border-radius: 16px;
        padding: 8px;
    }

    .popup-container {
        width: 280px;
        padding: 1.25rem;
    }

    .popup-content h3 {
        font-size: 1.1rem;
    }

    .popup-content p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .controls {
        gap: 1rem;
        padding: 0.5rem 1rem;
    }

    .control-btn {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 500px) {
    .popup-container {
        width: 85%;
        max-width: 240px;
        padding: 1rem;
    }

    .popup-content p {
        font-size: 0.85rem;
    }

    .action-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .cursor {
        width: 18px;
        height: 18px;
    }
}